The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Shirakami on July 17, 2017, 11:46:09 AM

Title: [command_x] The designated building can not be built
Post by: Shirakami on July 17, 2017, 11:46:09 AM
Hello!

I wanted to create a script that uses AI scripts to simulate the building of multiple tile city buildings.

Specifically, it is a script that divides the building of two tiles into two, building one building when building one building, and building the other building next to it.

But with the current function, you can not specify the name of the building.

Will you be able to specify the name of the building in the future?

Place a script to build the specified building at the specified location.

function step()
{
local pos = square_x(80, 80).get_ground_tile()
local w = command_x(tool_build_house)

local buildingName = "myHouse"

local err = w.work(pl, pos, buildingName)
}
Title: Re: [command_x] The designated building can not be built
Post by: An_dz on July 17, 2017, 12:27:27 PM
If the building allows renaming you can call set_name.

http://dwachs.github.io/simutrans-sqapi-doc/group__rename__func.html
Title: Re: [command_x] The designated building can not be built
Post by: Shirakami on July 17, 2017, 02:18:01 PM
Thanks for the advice!
However, I could not build a commercial building.
Title: Re: [command_x] The designated building can not be built
Post by: Shirakami on July 17, 2017, 03:17:56 PM
As a result of searching, I found out that by changing the code below.


simtool.cc / line 5265

- const char *c = default_param+2;
+ const char *c = default_param;


With this I can build the building I want.
Title: Re: [command_x] The designated building can not be built
Post by: Dwachs on July 17, 2017, 04:22:43 PM
Thanks for posting! Would be interesting to see your script in action :)

The default parameter for the build_house tool is

I + R + "name"

where

I = one character: '1' to ignore climate requirements, all other chars: respect climate requirements
R = one character indicating rotation of building: '0'-'3' specific rotation, '#' random rotation, 'A' automatic alignment to roads for city buildings
name = name of building
   
If you replace the call to work by

local err = w.work(pl, pos, "0#" + buildingName)

you should be on the safe side.
Title: Re: [command_x] The designated building can not be built
Post by: Shirakami on July 17, 2017, 06:44:16 PM
I did not know how to write the correct parameters.
Thank you!  :)