News:

Congratulations!
 You've won the News Item Lottery! Your prize? Reading this news item! :)

"Automated" object placing when building a map

Started by PLinden, January 10, 2025, 05:08:34 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PLinden

Hi

I'm currently building a map based on a real metropolitan area to simulate and hopefully improve traffic flows. Trying to be as accurate as possible, I take the coordinates of the object (town, station, stop...) from a real world map image with the same dimensions as the in-game map and then place the object manually in game as public player.

Since the map is quite large (3000x2500) and I already manually placed 100 towns, I wonder if there is a smarter way to place objects. Especially manually moving to the right location is very time-consuming.

I was thinking of manually editing the save game and inserting a list of text markers with labels and coordinates from my excel file. However, since the map is so big, I think the xml file would crash my computer.

Then I was thinking of a script that processes a list of entries and places a text marker with a label at the given coordinate.

Given my lack of experience with Simutrans, I'd appreciate any advise on how to do this properly.

Thanks a lot

prissi

There is a script interface in the newest version in some pak sets. Which are you playing?

Switch to public player and then mark a area with the new tool. the second to last in the special toolbar in pak64 and pak128. Mark a reagion. It will generate a script in your simutrans folder under addons/pakset/tool and then a folder with the tool you just wrote. If you open the folder, you will find a file tool.nut
// automated rebuild scrip with size (6,3)

include("hm_toolkit_v3")

function hm_build() {
if(this.player.nr != 1) {
return "Must be run as public player!"
}

hm_ground_tl(0,[0,0,0])
...
hm_ground_tl(0,[0,1,0])
hm_city_tl(0,"01_CITYrmax",[1,1,0],0)
hm_way_tl("Road_040",[5,0,0],[0,0,0],1,0)
hm_way_tl("Road_040",[4,2,0],[0,2,0],1,0)
hm_way_tl("Road_040",[3,2,0],[3,0,0],1,0)
hm_way_tl("Road_040",[0,2,0],[0,0,0],1,0)
hm_house_tl("RES_15_14",[2,1,0],0)
hm_house_tl("RES_15_14",[4,1,0],0)
hm_set_owner_tl(15,[5,0,0])
}
The coordinates are relative to the mouse click when calling the macro and building it.
hm_gorund_tl flattens the ground. You will not need this for your scripts
hm_city_tl builds a townhall (and gives the population in the first parameter. Using 0 avoids building any houses automatically; otherwise the town will grow to that population. However, if you have laid down roads first, then the chances are very good that the growth will be along those predefined roads.
hm_house_tl build a house and obviously must be called after the creation of the townhall or else the house will belong to whatever townhall is next.
hm_way_tl builds a road
hm_set_owner_tl sets this road as unowned (15)

There is one strong limitation right now: The ground needs to be in the right height. So currently, you need to have either the height at each position or have a flat world. However, changing the build skript to take only coordinates in x,y is quite straight fordward. I will change them for the next nightly that these also accepts coord with only two paramter.

PLinden

Thanks for your reply! This seems like a good solution. I would just select the entire map and have it place text markers at the defined coordinates.

I play pak128.german v2.3 beta. Do I have problems finding it or is this not included in this pak set?


prissi

As far as I know, it is not included in the pakset. But you can edit the config/menuconf.tab file in the pakset. In general tools section you need to add

general_tool[42]=,,,F2
general_tool[47]=,,,F3

So that would put the recording at F3 and the script execution at F2. You can choose any other key too.