News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

"run script" option

Started by ojii, December 16, 2013, 10:06:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ojii

Seeing how powerful the scripting interface seems to be (see [1]), I was wondering if it wouldn't make sense to add a way to just run a script (not a scenario) on a game. There would be a menu somewhere to run arbitrary scripts on the current map (eg all .nut files in scripts/ would be listed there or something like that). Could allow for some really cool tools to be built.


[1] http://forum.simutrans.com/index.php?topic=12971.0

isidoro

Next logical option could be to be able to tie some scripts to interface buttons (pakset or user).


Dwachs

Is certainly possible.

What would you like to do with scripts?

Currently the scripting is limited to retrieve data from the game. Only a few commands are available to alter the game. The main difficulty is that the code to execute commands (building removing etc) does not allow to check whether a command would be successful and the execute it, it rather does both things simultaneously.

(ojii: did you want to link to this thread: http://forum.simutrans.com/index.php?topic=12956.0 ?)
Parsley, sage, rosemary, and maggikraut.

ojii

dwachs, yes, my apologise. no idea where my link came from.

in my case, i'm mostly interested in extracting information from games and dumping them to a file. since (as previous discussions showed) it's unlikely that the savegame format will change to something that will be reasonably readable by 3rd party tools (and I understand the reasoning, especially time constraints, for not doing so), a nice work around could be to just write squirrel scripts to export data to some format.

looking through the current api docs I agree that it won't be as useful yet, but looking at the source code it doesn't look like it's that hard for you developers to add more (purely informational) APIs. Something I personally would love to see is something to get all stations and lines (stop_list_x? and line_list_x?).

Modding of games is what got me into programming and I'm always fascinated by the creative things people come up with for games that provide some sort of modability (arguably through paksets simutrans already has a lot covered here) and I would love to see what would happen if simutrans had a reasonably easy way to extend it (even if for now it's just a "read-only" API).

Dwachs

Quote from: ojii on December 17, 2013, 08:19:37 AM
looking through the current api docs I agree that it won't be as useful yet, but looking at the source code it doesn't look like it's that hard for you developers to add more (purely informational) APIs. Something I personally would love to see is something to get all stations and lines (stop_list_x? and line_list_x?).
This is an easy addition.

Hard stuff is to make the constructing tools available in the API together with checks that a certain tool can be used at a certain position.
Parsley, sage, rosemary, and maggikraut.

prissi

Why is there a need to test. It could just do construction and either get 0 or an error string, just like a real player would get.

Dwachs

Quote from: prissi on December 17, 2013, 10:59:04 AM
Why is there a need to test. It could just do construction and either get 0 or an error string, just like a real player would get.
If the script wants to do only one single action, then a test is not needed.

If the scripts wants to do a sequence of actions, then a test is needed to ensure that all actions are valid before even spending money on the first action (think of script-controlled AI). Any script-side planning of actions needs some kind of checks whether certain actions are possible.
Parsley, sage, rosemary, and maggikraut.

prissi

The non-scripting AI does not do not get any special tests e.g. they transform land for the stations. Then even if way building fails then money is lost.

All testing is done beforehand by the AI. That could be done as well with a script. So in this regards it is not needed to have precognition (which may fail anyway, when just at this moment somebody else builds something.)