Types/SimulationDefinition: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (fixed link)
m (expand game.move_cursor with comment)
Line 81: Line 81:
game.activate_rail_planner{position=position,ghost_mode=bool}
game.activate_rail_planner{position=position,ghost_mode=bool}
game.deactivate_rail_planner()
game.deactivate_rail_planner()
game.move_cursor{position=position,speed=number}
game.move_cursor{position=position,speed=number} --[[should be called every tick. Returns true when target is reached]]
game.activate_selection()
game.activate_selection()
game.finish_selection()
game.finish_selection()

Revision as of 14:18, 19 October 2022

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 generate_map 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. require is not available[1].

init

Type: Types/string

Default: ""

Only loaded if init_file 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. require is not available[2].

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. require is not available[3].

update

Type: Types/string

Default: ""

Only loaded if update_file 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. require is not available[4].

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 save 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:

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}