Auto place tree help

Place to get help with not working mods / modding interface.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1456
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Auto place tree help

Post by TheSAguy »

Hi,

In my Bio Industries mod, I have the ability for one to plant a seedling that will grow into a tree.


Depending on the terrain type, the seedling has a chance to turn into a tree. This part I have working.

The part I need help with, is what type of tree should grow there - Art of the tree, since certain trees only grow on certain terrain types.
I don't know how to select the tree art/type based on the terrain type. I know it's depending on the terrain temperature and water, but still have no idea how to implement this.

Currently, I have crude code where I've hard coded the tree type based on terrain, but would like to make this dynamic and match the actual Vanilla (and other mods like Alien Biomes)

Can someone please help me convert the code I have below and attached to make my hard coded tree selection dynamic to auto select to correct tree please.

I've attached my full mod and also just the code in question.
Tree Code


Thanks.[/quote]
Attachments
control.lua
Just the Code in question
(3.87 KiB) Downloaded 75 times
Bio_Industries_1.6.7.zip
Full Mod
(25.74 MiB) Downloaded 51 times
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Auto place tree help

Post by darkfrei »

How about make a parser for it? On chunck generated, find all decorative entities and add them to the table with tiles near them.
Export this table to the file.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1456
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Auto place tree help

Post by TheSAguy »

darkfrei wrote:How about make a parser for it? On chunck generated, find all decorative entities and add them to the table with tiles near them.
Export this table to the file.
I'm not sure if we're talking about the same thing here darkfrei.

Using my mod, when you plant a seedling it turns into a tree.
The game know what trees to spawn at the beginning of the game, depending on the terrain type. I just need to replicate that...
I know it's got something to do with the temperature and moisture of the tile. The combination of that two gives a range of possible tree entities it can use.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Auto place tree help

Post by darkfrei »

TheSAguy wrote: The game know what trees to spawn at the beginning of the game, depending on the terrain type. I just need to replicate that...
I know it's got something to do with the temperature and moisture of the tile. The combination of that two gives a range of possible tree entities it can use.
I think you don't need to plant trees at the beginning of the game. Just collecting information where is which plant and make the same on spawning.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1456
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Auto place tree help

Post by TheSAguy »

Darkfrei,

How would I go about reading in the terrain type and tree names into a table that I can output?
This is not something I've done before.

Thanks.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Auto place tree help

Post by darkfrei »

On chunck generated iterate x and y coordinate. Now we are making table: if this pair is not in table, then save tile.name and tree.name to the table.

If you want to place new tree, then find this tile in our table and we have all (or not all, but some) trees for this terrain.
For vanilla this table can be exported to the file and added as required file.
Post Reply

Return to “Modding help”