The International Simutrans Forum

Development => Technical Documentation => Topic started by: zhaop on June 26, 2015, 01:36:53 PM

Title: Squirrel API docs on one page
Post by: zhaop on June 26, 2015, 01:36:53 PM
Hi all,

I've been thinking of scripts that help you calculate stuff while you're playing (e.g. predicting profits on certain planned routes, etc). The squirrel API seems like a good way to go. The documentation (http://dwachs.github.io/simutrans-sqapi-doc/annotated.html) is great, but I didn't like clicking through pages of docs to find what I wanted, especially as a newcomer to the API. So I've started to put together a single page that contains (for now) every class, along with their inheritance chain, and their own methods and properties.

* attraction_list_x
   next_i () : void
   _get (integer) : building_x
* building_x --> map_object_x --> coord3d, extend_get
   get_factory () : factory_x
   get_city () : city_x
   is_townhall () : bool
   is_headquarter () : bool
   is_monument () : bool
   get_passenger_level () : integer
   get_mail_level () : integer
   get_desc () : building_desc_x
   is_same_building (building_x) : bool
* building_desc_x --> obj_desc_time_x --> obj_desc_x --> extend_get
   building_type : enum
    attraction_city
    attraction_land
    monument
    factory
    townhall
    headquarter
    harbour
    depot
    station
    station_extension
   is_attraction () : bool
   get_size (integer rotation) : coord
   get_maintenance () : integer
   get_cost () : integer
   get_capacity () : integer
   can_be_built_underground () : bool
   can_be_built_aboveground () : bool
   enables_pax () : bool
   enables_mail () : bool
   enables_freight () : bool
   get_type () : building_desc_x::building_type
   get_waytype () : way_types
   get_headquarter_level () : integer
   static get_building_list (building_desc_x::building_type) : array<building_desc_x>
* city_x --> coord, extend_get
   city_x (integer x, integer y)
   get_name () : string
   get_citizens () : array<integer>
   get_growth () : array<integer>
   get_buildings () : array<integer>
   get_citycars () : array<integer>
   get_transported_pax () : array<integer>
   get_generated_pax () : array<integer>
   get_transported_mail () : array<integer>
   get_generated_mail () : array<integer>
   get_year_citizens () : array<integer>
   get_year_growth () : array<integer>
   get_year_buildings () : array<integer>
   get_year_citycars () : array<integer>
   get_year_transported_pax () : array<integer>
   get_year_generated_pax () : array<integer>
   get_year_transported_mail () : array<integer>
   get_year_generated_mail () : array<integer>
   get_citygrowth_enabled () : bool
   get_pos () : coord
   get_pos_nw () : coord
   get_pos_se () : coord
   change_size (integer delta) : void
   set_citygrowth_enabled (bool) : void
   set_name (string) : void
* city_list_x
   _nexti () : void
   _get () : void
* convoy_x --> extend_get
   needs_electrification () : bool
   get_name () : string
   get_pos () : coord3d
   get_owner () : player_x
   get_goods_catg_index () : array<integer>
   get_waytype () : way_types
   get_schedule () : schedule_x
   get_capacity () : array<integer>
   get_transported_goods () : array<integer>
   get_revenue () : array<integer>
   get_cost () : array<integer>
   get_profit () : array<integer>
   get_traveled_distance () : array<integer>
   get_way_tolls () : array<integer>
   get_distance_traveled_total () : integer
* convoy_list_x
   _nexti () : void
   _get () : convoy_x
* coord
   operator+ (coord other) : coord
   operator- (coord other) : coord
   operator- () : coord
   operator* (integer fac) : coord
   operator/ (integer fac) : coord
   _tostring () : string
   x : integer
   y : integer
* coord3d --> coord
   operator+ (coord3d other) : coord3d
   operator- (coord other) : coord3d
   operator+ (coord3d other) : coord3d
   operator- (coord other) : coord3d
   operator- () : coord3d
   operator* (integer fac) : coord3d
   operator/ (integer fac) : coord3d
   _tostring () : string
   x : integer
   y : integer
   z : integer
* debug
   static get_forbidden_text () : string
* dir
   static is_single (dir d) : bool
   static is_twoway (dir d) : bool
   static is_threeway (dir d) : bool
   static is_curve (dir d) : bool
   static is_straight (dir d) : bool
   static double (dir d) : dir
   static backward (dir d) : dir
* extend_get
* factory_x --> coord, extend_get
   factory_x (integer x, integer y)
   get_consumers () : array<coord>
   get_suppliers () : array<coord>
   get_name () : string
   set_name (string) : void
   get_production () : array<integer>
   get_power () : array<integer>
   get_boost_electric () : array<integer>
   get_boost_pax () : array<integer>
   get_boost_mail () : array<integer>
   get_pax_generated () : array<integer>
   get_pax_departed () : array<integer>
   get_pax_arrived () : array<integer>
   get_mail_generated () : array<integer>
   get_mail_departed () : array<integer>
   get_mail_arrived () : array<integer>
   input : table<factory_production_x>
   output : table<factory_production_x>
* factory_list_x
   _nexti () : void
   _get () : void
* factory_production_x --> extend_get
   get_storage () : array<integer>
   get_received () : array<integer>
   get_consumed () : array<integer>
   get_in_transit () : array<integer>
   get_delivered () : array<integer>
   get_produced () : array<integer>
   max_storage : integer
* good_desc_x --> obj_desc_x --> extend_get
   good_desc_x (string name)
   get_catg_index () : integer
* good_desc_list_x
   _nexti () : void
   _get () : void
* gui
   static open_info_win () : bool
   static add_message_at (string text, coord position) : void
   static add_message (string text) : void
* halt_x --> extend_get
   get_name () : string
   get_owner () : player_x
   is_connected (halt_x halt, good_desc_x freight_type) : integer
   accepts_good (good_desc_x freight_type) : bool
   get_arrived () : array<integer>
   get_departed () : array<integer>
   get_waiting () : array<integer>
   get_happy () : array<integer>
   get_unhappy () : array<integer>
   get_noroute () : array<integer>
   get_convoys () : array<integer>
   get_walked () : array<integer>
   get_convoy_list () : convoy_list_x
   get_line_list () : line_list_x
   _cmp (halt_x halt) : integer
* halt_list_x
   _nexti () : void
   _get () : halt_x
* label_x --> map_object_x --> coord3d, extend_get
   set_text (string text) : void
   static create (coord pos, player_x pl, string text) : label_x
* line_x --> extend_get
   get_name () : string
   get_owner () : player_x
   get_schedule () : schedule_x
   get_goods_catg_index () : array<integer>
   get_capacity () : array<integer>
   get_transported_goods () : array<integer>
   get_convoy_count () : array<integer>
   get_revenue () : array<integer>
   get_cost () : array<integer>
   get_profit () : array<integer>
   get_traveled_distance () : array<integer>
   get_way_tolls () : array<integer>
   get_convoy_list () : convoy_list_x
* line_list_x
   _nexti () : void
   _get () : line_x
* map_object_x --> coord3d, extend_get
   map_object_x (integer x, integer y, integer z)
   get_owner () : player_x
   get_name () : string
   get_waytype () : way_types
   get_pos () : coord3d
   is_removable (player_x) : string
   get_type () : map_objects
* obj_desc_x --> extend_get
   get_name () : string
   is_equal (obj_desc_x other) : bool
* obj_desc_time_x --> obj_desc_x --> extend_get
   get_intro_date () : time_x
   get_retire_date () : time_x
   is_future (time_x time) : bool
   is_retired (time_x time) : bool
   is_available (time_x time) : bool
* obj_desc_transport_x --> obj_desc_time_x --> obj_desc_x --> extend_get
   get_maintenance () : integer
   get_cost () : integer
   get_waytype () : way_types
   get_topspeed () : integer
* player_x --> extend_get
   player_x (integer nr)
   get_headquarter_level () : integer
   get_headquarter_pos () : coord
   get_name () : string
   get_construction () : array<integer>
   get_vehicle_maint () : array<integer>
   get_new_vehicles () : array<integer>
   get_income () : array<integer>
   get_maintenance () : array<integer>
   get_assets () : array<integer>
   get_cash () : array<integer>
   get_net_wealth () : array<integer>
   get_profit () : array<integer>
   get_operating_profit () : array<integer>
   get_margin () : array<integer>
   get_transported () : array<integer>
   get_powerline () : array<integer>
   get_transported_pax () : array<integer>
   get_transported_mail () : array<integer>
   get_transported_goods () : array<integer>
   get_convoys () : array<integer>
   get_way_tolls () : array<integer>
   book_cash (integer delta) : void
   is_active () : bool
   get_line_list () : line_list_x
* rules
   static forbid_tool (integer player_nr, integer tool_id) : void
   static allow_tool (integer player_nr, integer tool_id) : void
   static forbid_way_tool (integer player_nr, integer tool_id, way_types wt) : void
   static allow_way_tool (integer player_nr, integer tool_id, way_types wt) : void
   static forbid_way_tool_rect (integer player_nr, integer tool_id, way_types wt, coord pos_nw, coord pos_se, string err) : void
   static allow_way_tool_rect (integer player_nr, integer tool_id, way_types wt, coord pos_nw, coord pos_se, string err) : void
   static forbid_way_tool_cube (integer player_nr, integer tool_id, way_types wt, coord3d pos_nw, coord3d pos_se, string err) : void
   static allow_way_tool_cube (integer player_nr, integer tool_id, way_types wt, coord3d pos_nw, coord3d pos_se, string err) : void
   static clear () : void
* schedule_x
   entries : array<schedule_entry_x>
   waytype : way_types
* schedule_entry_x --> coord3d --> coord
   get_halt (player_x pl) : halt_x
   load : integer
   wait : integer
* settings
   get_industry_increase_every () : integer
   set_industry_increase_every (integer count) : void
   get_traffic_level () : integer
   set_traffic_level (integer rate) : void
   get_start_time () : time_x
   get_station_coverage () : integer
   get_passenger_factor () : integer
   get_factory_worker_radius () : integer
   get_factory_worker_minimum_towns () : integer
   get_factory_worker_maximum_towns () : integer
   avoid_overcrowding () : bool
   no_routing_over_overcrowding () : bool
   separate_halt_capacities () : bool
* square_x --> coord, extend_get
   square_x (integer x, integer y)
   get_halt () : halt_x
   get_player_halt (player_x pl) : halt_x
   get_tile_at_height (integer z) : tile_x
   get_ground_tile () : tile_x
* tile_x --> coord3d, extend_get
   tile_x (integer x, integer y, integer z)
   find_object (map_objects) : map_object_x
   remove_object (player_x pl, map_objects type) : string
   get_halt () : halt_x
   is_water () : bool
   is_bridge () : bool
   is_tunnel () : bool
   is_empty () : bool
   is_ground () : bool
   has_way (way_types wt) : bool
   has_ways () : bool
   has_two_ways () : bool
   get_way_dirs (way_types wt) : dir
   get_way_dirs_masked (way_types wt) : dir
   get_neighbour (way_types wt, dir d) : tile_x
   get_objects () : tile_object_list_x
* tile_object_list_x --> coord3d --> coord
   _nexti () : void
   _get () : void
* time_x
   raw : integer
   year : integer
   month : integer
* time_ticks_x --> time_x
   ticks : integer
   ticks_per_month : integer
   next_month_ticks : integer
* tree_x --> map_object_x --> coord3d, extend_get
   get_age () : integer
   get_desc () : tree_desc_x
* tree_desc_x --> obj_desc_x --> extend_get
* ttext
   ttext (string text)
   to_string () : string
* ttextfile --> ttext
   ttextfile (string file)
* way_x --> map_object_x --> coord3d, extend_get
   has_sidewalk () : bool
   is_electrified () : bool
   has_sign () : bool
   has_signal () : bool
   has_wayobj () : bool
   is_crossing () : bool
   get_dirs () : dir
   get_dirs_masked () : dir
   get_desc () : way_desc_x
* way_desc_x --> obj_desc_transport_x --> obj_desc_time_x --> obj_desc_x --> extend_get
   has_double_slopes () : bool
   get_system_type () : integer
* world --> extend_get
   static is_coord_valid (coord k) : bool
   static find_nearest_city (coord k) : city_x
   static get_season () : integer
   static remove_player (player_x pl) : bool
   static get_time () : time_ticks_x
   static get_citizens () : array<integer>
   static get_growth () : array<integer>
   static get_towns () : array<integer>
   static get_factories () : array<integer>
   static get_convoys () : array<integer>
   static get_citycars () : array<integer>
   static get_ratio_pax () : array<integer>
   static get_generated_pax () : array<integer>
   static get_ratio_mail () : array<integer>
   static get_generated_mail () : array<integer>
   static get_ratio_goods () : array<integer>
   static get_transported_goods () : array<integer>
   static get_year_citizens () : array<integer>
   static get_year_growth () : array<integer>
   static get_year_towns () : array<integer>
   static get_year_factories () : array<integer>
   static get_year_convoys () : array<integer>
   static get_year_citycars () : array<integer>
   static get_year_ratio_pax () : array<integer>
   static get_year_generated_pax () : array<integer>
   static get_year_ratio_mail () : array<integer>
   static get_year_generated_mail () : array<integer>
   static get_year_ratio_goods () : array<integer>
   static get_year_transported_goods () : array<integer>
   static get_attraction_list () : attraction_list_x
   static get_convoy_list () : convoy_list_x


Skeleton
  start () : void
  resume_game () : void
  new_month () : void
  new_year () : void
  get_map_file () : string
  get_about_text () : string
  get_rule_text () : string
  get_goal_text () : string
  get_info_text () : string
  get_result_text () : string
  get_debug_text () : string
  is_scenario_completed (integer pl) : integer
  is_tool_allowed (integer pl, integer tool_id, way_types wt) : bool
  is_work_allowed_here (integer pl, integer tool_id, coord3d pos) : string
  is_schedule_allowed (integer pl, schedule_x schedule) : string
* scenario : struct
   short_description : string
   author : string
   version : string
   api : string
* map : struct
   file : string
* persistent : table


Constants
* (anonymous) : enum
   player_all
* map_objects : enum
   mo_tree
   mo_pointer
   mo_cloud
   mo_building
   mo_signal
   mo_bridge
   mo_tunnel
   mo_depot_rail
   mo_depot_road
   mo_depot_water
   mo_powerline
   mo_transformer_s
   mo_transformer_c
   mo_roadsign
   mo_pillar
   mo_depot_air
   mo_depot_monorail
   mo_depot_tram
   mo_depot_maglev
   mo_wayobj
   mo_way
   mo_label
   mo_field
   mo_crossing
   mo_groundobj
   mo_depot_narrowgauge
   mo_pedestrian
   mo_city_car
   mo_car
   mo_train
   mo_monorail
   mo_maglev
   mo_narrowgauge
   mo_ship
   mo_airplane
   mo_moving_object
* tool_ids : enum
   tool_remover
   tool_raise_land
   tool_lower_land
   tool_setslope
   tool_restoreslope
   tool_set_marker
   tool_clear_reservation
   tool_build_transformer
   tool_add_city
   tool_change_city_size
   tool_plant_tree
   tool_build_way
   tool_build_bridge
   tool_build_tunnel
   tool_remove_way
   tool_build_wayobj
   tool_build_station
   tool_build_roadsign
   tool_build_depot
   tool_build_house
   tool_land_chain
   tool_city_chain
   tool_build_factory
   tool_link_factory
   tool_headquarter
   tool_lock_game
   tool_add_citycar
   tool_forest
   tool_stop_mover
   tool_make_stop_public
   tool_remove_wayobj
   tool_buy_house
   tool_build_cityroad
   tool_increase_industry
   tool_switch_player
   tool_step_year
   tool_fill_trees
   tool_set_traffic_level
   dialog_edit_factory
   dialog_edit_attraction
   dialog_edit_house
   dialog_edit_tree
   dialog_enlarge_map
* way_system_types : enum
   st_flat
   st_elevated
   st_tram
* way_types : enum
   wt_all
   wt_road
   wt_rail
   wt_water
   wt_monorail
   wt_maglev
   wt_tram
   wt_narrowgauge
   wt_air
   wt_power
   wt_invalid


I don't know if this is the right place to post this. Would this help anyone? How should I improve it? :)