Change Tree Size at MapGen V 1.5

For people working on the C++ code.
Post Reply
User avatar
OdnetninI
Member
Posts: 38
Joined: Sun Oct 21, 2012 08:20

Change Tree Size at MapGen V 1.5

by OdnetninI » Post

EDIT V 1.5:
  • change atoi for stoi. Thanks XYZ
  • Put a minime of tree (1).
  • If max is smaller than min, invert variables.
Hola:
He estado desarrollando una modificación en el engine para hacer una cierta modificación. Cambiar el tamaño de los arboles. Solo necesitas modificar dos .cpp del codigo fuente y compilarlo.

Hi:
I was developping a mod for engine ore to make a good thing. Change tree heihgt. You only need to modificate 2 source files, and compile Minetest.

Como Compilar: How to Compile: https://github.com/celeron55/minetest/b ... README.txt

First Open src/subgame.cpp
Primero Abre src/subgame.cpp


Chage this:
Cambia esto:

Code: Select all

std::string getGameName(const std::string &game_path)
{
    std::string conf_path = game_path + DIR_DELIM + "game.conf";
    Settings conf;
    bool succeeded = conf.readConfigFile(conf_path.c_str());
    if(!succeeded)
        return "";
    if(!conf.exists("name"))
        return "";
    return conf.get("name");
}
For this:
Por esto:

Code: Select all

int minhtree = 0;
int maxhtree = 0;

std::string getGameName(const std::string &game_path)
{
    std::string conf_path = game_path + DIR_DELIM + "game.conf";
    Settings conf;
    bool succeeded = conf.readConfigFile(conf_path.c_str());
    if(!succeeded)
        return "";
    if(!conf.exists("name"))
        return "";
    /*
        Get Tree size
    */
    if(!conf.exists("treehmin"))
        minhtree = 4;
    else
        minhtree = stoi(conf.get("treehmin"));

    if(!conf.exists("treehmax"))
        maxhtree = 5;
    else
        maxhtree = stoi(conf.get("treehmin"));

    /*
          Prevent user Error
    */
    if(minhtree > maxhtree)
    {
           int j = minhtree;
           minhtree = maxhtree;
           maxhtree = j;
    }
    if(minhtree < 1) minhtree = 1;
    if(maxhtree < 1) maxhtree = 1;

    return conf.get("name");
}
Now open src/mapgen.cpp
Ahora abre src/mapgen.cpp


Change this:
Cambia esto:

Code: Select all

void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
        bool is_apple_tree, INodeDefManager *ndef)
{
    MapNode treenode(ndef->getId("mapgen_tree"));
    MapNode leavesnode(ndef->getId("mapgen_leaves"));
    MapNode applenode(ndef->getId("mapgen_apple"));

    s16 trunk_h = myrand_range(4, 5);
    v3s16 p1 = p0;
    for(s16 ii=0; ii<trunk_h; ii++)
    {
        if(vmanip.m_area.contains(p1))
            vmanip.m_data[vmanip.m_area.index(p1)] = treenode;
        p1.Y++;
    }

    // p1 is now the last piece of the trunk
    p1.Y -= 1;
For This
Por Esto:

Code: Select all

void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
        bool is_apple_tree, INodeDefManager *ndef)
{
    MapNode treenode(ndef->getId("mapgen_tree"));
    MapNode leavesnode(ndef->getId("mapgen_leaves"));
    MapNode applenode(ndef->getId("mapgen_apple"));

    s16 trunk_h = myrand_range(minhtree, maxhtree);
    v3s16 p1 = p0;
    for(s16 ii=0; ii<trunk_h; ii++)
    {
        if(vmanip.m_area.contains(p1))
            vmanip.m_data[vmanip.m_area.index(p1)] = treenode;
        p1.Y++;
    }

    // p1 is now the last piece of the trunk
    p1.Y -= 1;
Add This:
Añade Esto:

Code: Select all

extern int minhtree;
extern int maxhtree;
above this at mapgen.cpp
encima de esto en el mapgen.cpp

Code: Select all

namespace mapgen
Now Compile It.
Ahora Compila

Ahora si quieres cambiar el tamaño sigue adelante.
Sino no sigas, no se alterará el tamaño actual.

Atención: Afecta a todos los arboles nuevos creados en cualquier mapa. Recomendado usar un minetest_game para cada tamaño.

Now Continue if you want change size.
If not, don't continue, height doesn't change.

Warring: it made that all new generated trees at any map chages. I recomed use a diferent minetest_game for every size do you want.

Y solo necesitas ir a games/minetest (o games/nombre_de_tu_juego) y añadir al game.conf:
And you only need to go to games/minetest (or games/name_of_your_game) and adds to game.conf:

Code: Select all

treehmin = min_number
treehmax = max_number
Ejemplo:
Example:

Code: Select all

name = MinetestCreative
treehmin = 5
treehmax = 8
Divierte
Have fun with this.
:)
Bye
Last edited by OdnetninI on Mon Oct 29, 2012 15:32, edited 1 time in total.

User avatar
GloopMaster
Member
Posts: 213
Joined: Wed Aug 01, 2012 18:03
Location: http://minetest.net/forum/

by GloopMaster » Post

belongs in unofficial engine development.

anyway, nice idea, i just lack the want or ability to compile anything. X3
Meow.

That is all.

User avatar
xyz
Member
Posts: 450
Joined: Thu Nov 10, 2011 14:25

by xyz » Post

You should use

Code: Select all

stoi(conf.get("treehmin"))
instead of

Code: Select all

atoi(conf.get("treehmin").c_str())

User avatar
OdnetninI
Member
Posts: 38
Joined: Sun Oct 21, 2012 08:20

by OdnetninI » Post

There was an error:
Habia un error:

This:
Esto:

Code: Select all

extern int minhtree;
extern int maxhtree;
Must be go above this at mapgen.cpp
Debe ir encima de esto en el mapgen.cpp

Code: Select all

namespace mapgen

User avatar
Misty
Member
Posts: 51
Joined: Sun Jun 16, 2013 02:09

by Misty » Post

You seem to be saying that all the trees generated with the new code will be the same size. Is there a way to randomize the size of the generated trees so that some are min size, some are max size, and some are in between the two?
Certified 100% signature Virus free.

User avatar
sfan5
Moderator
Posts: 3933
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

You should not check for configuration errors in getGameName
Misty wrote:You seem to be saying that all the trees generated with the new code will be the same size. Is there a way to randomize the size of the generated trees so that some are min size, some are max size, and some are in between the two?
s16 trunk_h = myrand_range(minhtree, maxhtree);
assigns a random number between minhtree and maxhtree to the variable trunk_h(Height of the tree trunk).
It does randomize the tree height
Last edited by sfan5 on Thu Sep 05, 2013 17:15, edited 1 time in total.
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
Misty
Member
Posts: 51
Joined: Sun Jun 16, 2013 02:09

by Misty » Post

Thank you,
that answers my question very well.
: )
Certified 100% signature Virus free.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest