News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

It's time to update the script API documentation

Started by Yona-TYT, December 16, 2024, 09:17:04 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Yona-TYT


As you may know, there have been some major changes to the scripts lately and some things in the documentation have become obsolete, so it needs to be updated as soon as possible.


Quote from: Dwachs on October 07, 2016, 03:40:47 PMThe online documentation can be found at:

http://dwachs.github.io/simutrans-sqapi-doc/
Does anyone know or have access to this?.

Andarix

The documentation is probably created from the code with Doxygen.

And as far as I know, only Dwachs has access to it.

Yona-TYT

Quote from: Andarix on December 16, 2024, 09:52:54 PMAnd as far as I know, only Dwachs has access to it.
I think he's been inactive for a while, so we're going to have problems. :o

prissi

In principle, this documentation is made automatically by adding proper comments when adding new functions. I can send him an email and ask him for the script to generate the documentations. Probably some comments have to be corrected again to include the new functions.


Andarix

The current version 1.12.0 of Doxygen gives the following error.

Quote...
Parsing files
Preprocessing D:/simutrans_entwicklung/svn/simutrans_svn/trunk/src/simutrans/script/api/api_base.h...
Der Befehl "." ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Parsing file D:/simutrans_entwicklung/svn/simutrans_svn/trunk/src/simutrans/script/api/api_base.h...
Preprocessing D:/simutrans_entwicklung/svn/simutrans_svn/trunk/src/simutrans/script/api/api_doc.h...
Der Befehl "." ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
...

Dwachs used Linux. I use Windows. I have no idea if that is the cause.

The list of api files itself is created.



prissi

It runs a shell script for parsing. Hence, it runs on the mingw command line after tweaking the directories.

Andarix

#7
Simutrans-Squirrel-API_r11496.zip

[edit]

The documentation was incorrect.


Andarix


prissi

I think we should rather integrate into the build an update the documentation directly from the simutrans build. No need to fork this.


Yona-TYT

#12
is_work_allowed_here() should be fixed,

It should be something like:

string is_work_allowed_here     (
        integer      pl,
        integer      tool_id,
        String        name or default_paramte
        coord3d      pos,
        table      tool
    )    

Also the rules:
static void forbid_way_tool (integer player_nr, integer tool_id, way_types wt, string default_paramter)
 
static void forbid_way_tool_rect (integer player_nr, integer tool_id, way_types wt, string default_paramter, coord pos_nw, coord pos_se, string err)
 
static void forbid_way_tool_cube (integer player_nr, integer tool_id, way_types wt, string default_paramter, coord3d pos_nw, coord3d pos_se, string err)
 

 
static void clear_forbid_way_tool (integer player_nr, integer tool_id, integer wt, string default_paramter)
 
static void clear_way_tool_rect (integer player_nr, integer tool_id, integer wt, string default_paramter, coord pos_nw, coord pos_se, bool allow)
 
static void clear_way_tool_cube (integer player_nr, integer tool_id, integer wt, string default_paramter, coord3d pos_nw, coord3d pos_se, bool allow)
 

 
static void clear_player (integer player_nr)
 
static void allow_way_tool_rect (integer player_nr, integer tool_id, way_types wt, string default_paramter, coord pos_nw, coord pos_se)
 
static void allow_way_tool_cube (integer player_nr, integer tool_id, way_types wt, string default_paramter, coord3d pos_nw, coord3d pos_se)

Andarix


ceeac

Quote from: prissi on December 22, 2024, 08:36:16 AMI think we should rather integrate into the build an update the documentation directly from the simutrans build. No need to fork this.
Implemented auto-generation of docs using CMake in r11540. The documentation is not built by default, but can be built using cmake --build <build dir> --target docs. The generated docs will be put in <build dir>/documentation/simutrans for the main program and <build dir>/documentation/sqapi for the script API.

Yona-TYT

QuoteClass to access tiles on the map.

There is the possibility to iterate through all objects on the tile:
local tile = tile_x( ... )
foreach(thing in tile) {
    ... // thing is an instance of the map_object_x (or a derived) class
}

This doesn't work currently, this patch fixes it: 0001-ADD-support-for-iterate-tile_x.patch

prissi


Yona-TYT

Quote from: Yona-TYT on January 02, 2025, 01:21:00 AMThis doesn't work currently, this patch fixes it: 0001-ADD-support-for-iterate-tile_x.patch
Unfortunately we need to revert this as it is affecting tile.get_objects()

          foreach(obj in t.get_objects()){
            local type = obj.get_type()
            t.find_object(type).unmark()
          }


This generates an error in the API, it seems that if it is used with get_objects() then you cannot directly use tile_x to iterate the objects.

And I don't know how to make both of them work without crashing.

Isaac Eiland-Hall



prissi