Change Tree Size at MapGen V 1.5

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

Change Tree Size at MapGen V 1.5

by OdnetninI » Sun Oct 28, 2012 21:53

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/blob/stable-0.4/README.txt

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


Chage this:
Cambia esto:


Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:


Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:


Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:


Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
extern int minhtree;
extern int maxhtree;


above this at mapgen.cpp
encima de esto en el mapgen.cpp

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
treehmin = min_number
treehmax = max_number


Ejemplo:
Example:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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

by GloopMaster » Sun Oct 28, 2012 22:41

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: 449
Joined: Thu Nov 10, 2011 14:25

by xyz » Mon Oct 29, 2012 08:35

You should use
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
stoi(conf.get("treehmin"))
instead of
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
atoi(conf.get("treehmin").c_str())
 

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

by OdnetninI » Mon Oct 29, 2012 15:32

There was an error:
Habia un error:

This:
Esto:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
namespace mapgen
 

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

by Misty » Thu Sep 05, 2013 14:59

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
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Thu Sep 05, 2013 17:13

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 » Fri Oct 04, 2013 12:26

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


Return to Minetest Engine

Who is online

Users browsing this forum: No registered users and 5 guests

cron