Types/SimulationDefinition: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(Updated styling of prototype doc migration note)
(Removed old prototype docs)
 
Line 2: Line 2:


</p><p>This wiki page is no longer updated and '''will be removed at some point in the future''', so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback [https://forums.factorio.com/viewforum.php?f=233 on the forums].</p></div>
</p><p>This wiki page is no longer updated and '''will be removed at some point in the future''', so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback [https://forums.factorio.com/viewforum.php?f=233 on the forums].</p></div>
Used by [[Prototype/TipsAndTricksItem]] and by main menu simulations ([[Prototype/UtilityConstants#main_menu_simulations]]).
== Optional properties ==
=== save ===
'''Type''': [[Types/FileName]]
The save file that is used for this simulation. If not given and <code>generate_map</code> is true, a map gets generated by the game.
=== init_file ===
'''Type''': [[Types/FileName]]
This code is run as a (silent) console command inside the simulation when it is first initialized. Since this is run as a console command, the restrictions of console commands apply, e.g. <code>require</code> is not available<sup>[https://lua-api.factorio.com/latest/Libraries.html]</sup>.
=== init ===
'''Type''': [[Types/string]]
'''Default''': ""
Only loaded if <code>init_file</code> is not present.
This code is run as a (silent) console command inside the simulation when it is first initialized. Since this is run as a console command, the restrictions of console commands apply, e.g. <code>require</code> is not available<sup>[https://lua-api.factorio.com/latest/Libraries.html]</sup>.
=== update_file ===
'''Type''': [[Types/FileName]]
This code is run as a (silent) console command inside the simulation every time the simulation is updated. Since this is run as a console command, the restrictions of console commands apply, e.g. <code>require</code> is not available<sup>[https://lua-api.factorio.com/latest/Libraries.html]</sup>.
=== update ===
'''Type''': [[Types/string]]
'''Default''': ""
Only loaded if <code>update_file</code> is not present.
This code is run as a (silent) console command inside the simulation every time the simulation is updated. Since this is run as a console command, the restrictions of console commands apply, e.g. <code>require</code> is not available<sup>[https://lua-api.factorio.com/latest/Libraries.html]</sup>.
=== init_update_count ===
'''Type''': [[Types/uint32]]
'''Default''': 0
Amount of ticks that this simulation should run for before the simulation is shown to the player. These updates happen after init/init_file has been run and at the highest possible rate (> 60 UPS).
=== length ===
'''Type''': [[Types/uint32]]
'''Default''': 0
How long this simulation takes. In the main menu simulations, another simulation will start after this simulation ends.
=== generate_map ===
'''Type''': [[Types/bool]]
'''Default''': false
If <code>save</code> is not given and this is true, a map gets generated by the game for use in the simulation.
=== checkboard ===
'''Type''': [[Types/bool]]
'''Default''': true
If this is true, the map of the simulation is set to be a lab-tile checkerboard in the area of {{-20, -15},{20, 15}} when the scenario is first initialized (before init/init_file run).
=== volume_modifier ===
'''Type''': [[Types/float]]
Multiplier for the simulation volume set by the player in the sound settings.
=== override_volume ===
'''Type''': [[Types/bool]]
If true, overrides the simulation volume set by the player in the sound settings, simply setting the volume modifier to 1.
== Addition API ==
Simulation-only APIs:
<syntaxhighlight lang="lua">
game.create_test_player{name=string}
game.activate_rail_planner{position=position,ghost_mode=bool}
game.deactivate_rail_planner()
game.move_cursor{position=position,speed=number}  --[[should be called every tick. Returns true when target is reached]]
game.activate_selection()
game.finish_selection()
game.deactivate_selection()
game.scroll_clipboard_forwards()
game.scroll_clipboard_backwards()
game.camera_player_cursor_position [RW]
game.camera_position [RW]
game.camera_zoom [W]
game.camera_player [W]
game.camera_player_cursor_direction [W]
game.camera_alt_info [W]
game.smart_belt_building [W]
player.drag_start_position [W]
player.raw_build_from_cursor{ghost_mode=bool,created_by_moving=bool,position=position}
surface.create_entities_from_blueprint_string{string=string,position=position,force=force,direction=defines.direction,flip_horizonal=bool,flip_vertical=bool,by_player=player}
</syntaxhighlight>

Latest revision as of 14:32, 25 October 2024

The prototype docs have moved to a new website with an improved format. This documentation page can now be found here: https://lua-api.factorio.com/latest/types/SimulationDefinition.html

This wiki page is no longer updated and will be removed at some point in the future, so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback on the forums.