[I'm useing Vanilla DF 34.11 with Ironhand's Graphics pack. Results may vary, but should not]
So I have been trying to force trees to grow in specific tiles.
Tiletypes lets me force saplings/trees where ever I want, but these plants lack any sort of plant association.
Useing lua, I can open the tile and find the following information:
printall(tile.plants) gives me a list of typically 0-5 plant entries for each tile.
printall(tile.plants[ x]) gives me the individual plant information.
printall(tile.plants[ x]) shows me a list of information, the ones that seem to be relevant are:
tile.plants[ x].material=
tile.plants[ x].grow_counter=
tile.plants[ x].update_order=
tile.plants[ x].hitpoints=
tile.plants[ x].flags.is_shrub=
"material" is definitely needed, that tells you what type of plant it is.
"grow_counter" is fairly optional, but it may result in dead bushes if left too high for bushes; or saplings if left too low for trees.
"update_order" is a complete mystery as to whether it is needed or not, any advice should be useful. So far I am assuming I can safely ignore this.
"hitpoints" is a little relevant, bushes/grasses seem to have 100000; while trees/saplings seem to have 400000. I have not tested this extensively, values may vary (although fiddling with it hasn't really caused any issues so far)
"flags.is_shrub" is important. It needs to be [false] if you want a tree, and [true] in all other circumstances.
Fiddling with these settings however, I find that instead of turning my [Tiletypes] fake plant into a real one, plants in other tiles instead turn into impossible configurations (usually resulting in a dead bush with no image data).
Further investigation turns up that for each "tile.plants[ x]" entry there is also a ".pos" entry. These entries contain the actual coordinates for each plant the tile stores. To get the correct result, "tile.plants[ x].pos" needs to be altered to reflect the tile of the fake plant as well.
However, when we mess with the ".pos" entries we find that the tile it used to point to now displays a problem plant.
Further investigation of the ".pos" scatter shows that the referenced plant tile can have a maximum x/y variance of +/-12 from the target tile (so say your starting tile was x=275 and y=465, you could have x values from 263 to 287, and y values from 453 to 477). This means that there are 625 possible squares for you to search to find the correct one to edit without breaking any other tile. This gives 3750 "tile.plants[ x].pos" entries to check at most.
Because each tile has multiple entries and they are restricted to areas within 12 of the source tile, it should be possible to determine some sort of pattern with further testing.
Sadly I do not have significant data as yet, only having looked at two tiles. Any further data is welcome.
Tile 1 Variances
0=x-2, y+12
1=x+6, y
2=x+10, y-3
3=x+12, y+5
4=x+11, y+12
5=x+9, y+9
Tile 2 Variances
0=x+12, y+8
1=x+6, y+5
2=x+12, y+6
3=x, y
4=x+4, y-2
5=x+8, y+4
Ignoring problems with altering ".pos" for now, I have examined the data further and determined the following:
Setting "tile.plants[ x].flags.is_shrub=" does not prevent you from creating shrubs or trees if you use the wrong settings. It determines what the game calls the tile, as well as possibly what rate it decays over time (more experimentation is need to see if shrubs with is_shrub=false will remain intact forever, or die as normal)
The only information that must be in place to create a plant is:
tile.plants[ x].material=
tile.plants[ x].pos.x=
tile.plants[ x].pos.y=
tile.plants[ x].pos.z=
"tile.plants[ x].pos.z" has always turned up correctly for me so far, although I have not looked near slopes (I do expect it to always be correct).
Thoughts/contributions/contradictions? I am hoping we can gather enough data to see proper plant growth added to the tiletypes plugin.