Author Topic: [command_x] The designated building can not be built  (Read 444 times)

0 Members and 1 Guest are viewing this topic.

Offline Shirakami

[command_x] The designated building can not be built
« 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.

Code: [Select]
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)
}

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2594
  • Total likes: 290
  • Helpful: 89
  • D'oh
    • by An_dz
  • Languages: PT, EN, (it, de)
Re: [command_x] The designated building can not be built
« Reply #1 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

Offline Shirakami

Re: [command_x] The designated building can not be built
« Reply #2 on: July 17, 2017, 02:18:01 PM »
Thanks for the advice!
However, I could not build a commercial building.

Offline Shirakami

Re: [command_x] The designated building can not be built
« Reply #3 on: July 17, 2017, 03:17:56 PM »
As a result of searching, I found out that by changing the code below.

Code: [Select]
simtool.cc / line 5265

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

With this I can build the building I want.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4251
  • Total likes: 177
  • Helpful: 149
  • Languages: EN, DE, AT
Re: [command_x] The designated building can not be built
« Reply #4 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
Code: [Select]
I + R + "name"
where
Code: [Select]
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
Code: [Select]
local err = w.work(pl, pos, "0#" + buildingName)
you should be on the safe side.
Parsley, sage, rosemary, and maggikraut.

Offline Shirakami

Re: [command_x] The designated building can not be built
« Reply #5 on: July 17, 2017, 06:44:16 PM »
I did not know how to write the correct parameters.
Thank you!  :)