Factorio Runtime DocsVersion 2.0.33

ClassLuaSimulationnew

Functions for use during simulations. This object cannot be saved, and cannot be used outside of a simulation.

The simulation object instance can be obtained from LuaGameScript::simulation.

Members

create_test_player{name=…} LuaPlayer
get_slot_position{inventory_index=…, slot_index=…, inventory?=…} MapPosition?
get_widget_position{type=…, data?=…, data2?=…} MapPosition?
activate_rail_planner{position?=…, ghost_mode?=…, build_mode?=…}

Activate the rail planner at the given position.

Activate the rail planner at the given position.

deactivate_rail_planner()

Deactivate the rail planner.

Deactivate the rail planner.

move_cursor{position=…, speed?=…} boolean

Move the cursor towards the given position at the given speed.

Move the cursor towards the given position at the given speed.

mouse_down()

Send a left mouse button-down event at its current position.

Send a left mouse button-down event at its current position.

mouse_up()

Send a left mouse button-up event at its current position.

Send a left mouse button-up event at its current position.

mouse_click()

Send a left mouse button click event at its current position. [...]

Send a left mouse button click event at its current position. [...]

control_down{control=…, notify=…}

Send a control press event at the current cursor position.

Send a control press event at the current cursor position.

control_up{control=…}

Send a control release event at the current cursor position.

Send a control release event at the current cursor position.

control_press{control=…, notify=…}

Send a control down and up event at the current cursor position. [...]

Send a control down and up event at the current cursor position. [...]

write{text?=…}

Write text as if it was typed by a player. [...]

Write text as if it was typed by a player. [...]

scroll_clipboard_forwards()

Scroll the clipboard forwards by one entry.

Scroll the clipboard forwards by one entry.

scroll_clipboard_backwards()

Scroll the clipboard backwards by one entry.

Scroll the clipboard backwards by one entry.

camera_player_cursor_position :: RW MapPosition?
camera_position :: RW MapPosition?
camera_surface_index :: RW uint?
hide_cursor :: W boolean
camera_zoom :: W double
camera_player :: W PlayerIdentification
camera_player_cursor_direction :: W defines.direction
camera_alt_info :: W boolean
smart_belt_building :: W boolean?
gui_tooltip_interval :: W double
active_quickbars :: W uint8
valid :: R boolean

Is this object valid? [...]

Is this object valid? [...]

object_name :: R string

The class name of this object. [...]

The class name of this object. [...]

Methods

create_test_player{name=…} → LuaPlayer

Parameters

Table with the following fields:
name :: string

The name of the new player.

The name of the new player.

Return values

→ LuaPlayer

The created player.


get_slot_position{inventory_index=…, slot_index=…, inventory?=…} → MapPosition?

Parameters

Table with the following fields:
inventory_index :: InventoryIndex
slot_index :: ItemStackIndex
inventory :: "character" or "entity"?

Defaults to "character".

Defaults to "character".

Return values

→ MapPosition?

Position of the GUI slot on the screen, if successfully found.


get_widget_position{type=…, data?=…, data2?=…} → MapPosition?

Parameters

Table with the following fields:
type :: SimulationWidgetType
data :: string?
data2 :: string?

Return values

→ MapPosition?

Center of the GUI widget on the screen, if successfully found.


activate_rail_planner{position?=…, ghost_mode?=…, build_mode?=…}

Activate the rail planner at the given position.

Parameters

Table (optional) with the following fields:
position :: MapPosition?
ghost_mode :: boolean?

Defaults to false.

Defaults to false.

build_mode :: defines.build_mode?

Defaults to normal.

Defaults to normal.


deactivate_rail_planner()

Deactivate the rail planner.


move_cursor{position=…, speed?=…} → boolean

Move the cursor towards the given position at the given speed.

Parameters

Table with the following fields:
position :: MapPosition
speed :: double?

Defaults to 0.2.

Defaults to 0.2.

Return values

→ boolean

Whether the cursor will reach the target position with this move.


mouse_down()

Send a left mouse button-down event at its current position.


mouse_up()

Send a left mouse button-up event at its current position.


mouse_click()

Send a left mouse button click event at its current position. This is equivalent to calling LuaSimulation::mouse_down, then LuaSimulation::mouse_up.


control_down{control=…, notify=…}

Send a control press event at the current cursor position.

Parameters

Table with the following fields:
control :: string

The name of the control input to press.

The name of the control input to press.

notify :: boolean

Whether to show flying text of the activated control.

Whether to show flying text of the activated control.


control_up{control=…}

Send a control release event at the current cursor position.

Parameters

Table with the following fields:
control :: string

The name of the control input to release.

The name of the control input to release.


control_press{control=…, notify=…}

Send a control down and up event at the current cursor position. This is equivalent to calling LuaSimulation::control_down, then LuaSimulation::control_up.

Parameters

Table with the following fields:
control :: string

The name of the control input to press and release.

The name of the control input to press and release.

notify :: boolean

Whether to show flying text of the activated control.

Whether to show flying text of the activated control.


write{text?=…}

Write text as if it was typed by a player. Overwrites existing text by selecting it first.

Parameters

Table with the following fields:
text :: string?

The text to write. Does nothing if no text is provided.

The text to write. Does nothing if no text is provided.


scroll_clipboard_forwards()

Scroll the clipboard forwards by one entry.


scroll_clipboard_backwards()

Scroll the clipboard backwards by one entry.

Attributes

camera_player_cursor_position :: Read|Write MapPosition  ?


camera_position :: Read|Write MapPosition  ?


camera_surface_index :: Read|Write uint  ?


hide_cursor :: Write boolean  


camera_zoom :: Write double  


camera_player :: Write PlayerIdentification  


camera_player_cursor_direction :: Write defines.direction  


camera_alt_info :: Write boolean  


smart_belt_building :: Write boolean  ?


gui_tooltip_interval :: Write double  


active_quickbars :: Write uint8  


valid :: Read boolean  

Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be false. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access.


object_name :: Read string  

The class name of this object. Available even when valid is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct.

Classes

Concepts

Events

Defines