News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Scenario feedback

Started by iGi, December 07, 2021, 08:24:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

iGi

First of all, thanks for the very good scripting documentation, it helped a lot!

Small things:
Currently it seems, it's not possible to iterate the available factories at all. (not factory_list_x, but generally available in the pak.)
The documentation mentions this:
building_desc_x.get_building_list()
- It seems the building_type enum is missing, I couldn't get it working.
- When using integer values instead of the enum, it was working, but factories are not implemented, it always returns null.
It would be nice to get the size of the factory, and maybe it's default base production value and input/output wares.


It would be nice if the magic string for the command_x.work() function would be explained (at least for some tools)
http://dwachs.github.io/simutrans-sqapi-doc/classcommand__x.html#a9f4c7c16b89f4737e21e9223491817e7
The comment from the c++ source helps alot:

/* builds a (if param=NULL random) industry chain starting here *
* the parameter string is a follow:
* 1#34,oelfeld
* first letter: ignore climates
* second letter: rotation (0,1,2,3,#=random)
* next number is production value (-1 to use default of building)
* finally industry name
*/


Some minor documentation errors:
The add_message and add_message_at parameters are incorrect. (player_x text, string position)
http://dwachs.github.io/simutrans-sqapi-doc/group__scen__only.html#ga15e0556b540bba833e1b1d8fd66fe2c1

Maybe one or two lines, how include(..) works. I think the files must be in a subfolder.


Bigger thing:
It would be nice if the script has access to the internal placefinder for factories. Currently the problem is, when you want to place a factory by script, you first have to find a suitable place, and this is time consuming and not easy.
And then, when you finally found a place, the actual position you give, is not even used, which means you have to first get all factories, remember them, and then see after the command where it was actually built. (this is when you use the city_chain tool)
Especially for city chains, I think it would be nice if i just have to provide the coords of the city (city_x) and it will build it there.


Dwachs

Thanks for the feedback!

Building list (with the exception of factories) can be accessed like this

local list = building_desc_x.get_building_list(building_desc_x.headquarter)


I can create wrapper functions for these command_x.work calls. Which commands are you using in your scenario?

The documentation creation gets confused with two methods add_message_at with different parameters for ai or scenario scripts.

There is documentation of include: http://dwachs.github.io/simutrans-sqapi-doc/api__include_8cc.html#a3f75a4a361860c91884223aafc12b943 (maybe harder to find?)
Parsley, sage, rosemary, and maggikraut.

makie

Quote from: iGi on December 07, 2021, 08:24:14 PMIt would be nice to get the size of the factory, and maybe it's default base production value and input/output wares.
And may be the intro_year=
:)
Extracting information out of the pak ist better then hard coded scripting.
Because the pak can change. And the the hard coded things outdated. 

iGi

Quote from: Dwachs on December 07, 2021, 08:52:45 PMI can create wrapper functions for these command_x.work calls. Which commands are you using in your scenario?
I only use tool_land_chain and tool_city_chain.

Never checked the File List, only ever the Class List in the documentation...

I just found this sleep function:
http://dwachs.github.io/simutrans-sqapi-doc/api__control_8cc.html#a14a11029699a982ceb1e798082d611d6
Does this mean it just continues on the next tick, where i've left it? So I don't have to litter the code with these "generators" that yield inbetween?

Dwachs

Script execution is suspended all the time, and in the next step scripts are woken up again. So one does not need to program around the op-code limitation. The idea behind this is (a) scripts caught in an infinite loop do not stop the main program and (b) script programmer do not need to worry too much about op-code management.

There are some restrictions though:
-- if one wants to be sure that something is done without these kind of interruptions then calling sleep() will ensure full amount of op-codes
-- if there is a call chain squirrel-function A -> c++ function B -> squirrel function C, and script runs out of op-codes during execution of C then script suspension does not work, and an error is thrown. This is most likely the source of the error during calls to sort()
Parsley, sage, rosemary, and maggikraut.

Dwachs

So there is now (r10275) the class factory_desc_x to query information about factories. To get the size, access the building desc of the factory: factorydesc.get_building_desc().get_size()
Parsley, sage, rosemary, and maggikraut.

iGi

Quote from: Dwachs on December 10, 2021, 05:52:14 PMSo there is now (r10275) the class factory_desc_x to query information about factories. To get the size, access the building desc of the factory: factorydesc.get_building_desc().get_size()
Thanks for the quick implementation, it works.

About documentation: Without checking your commit and seeing the tests, I would not have known how to get an instance of factory_desc_x.
for example: local desc = factory_desc_x("FactoryName")

I think a factory_desc_list_x or some other way to iterate all possible factories, would be nice.

Dwachs

There is now factory_desc_x::get_list in r10296
Parsley, sage, rosemary, and maggikraut.