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.
MapPositionMapPositiontrueMapPositionMapPositiontrueuint32uint32trueunknownbooleanfalseunknowndoublefalseunknownPlayerIdentificationfalseunknowndefines.directionfalseunknownbooleanfalseunknownbooleantrueunknowndoublefalseunknownuint8falsebooleanunknownfalseIs 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.
stringunknownfalseThe 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.
LuaSimulation.create_test_player{ name: string } -> LuaPlayer
simulation.create_test_player{ name=name }
takes_table: truetable_optional: falsename: string — The name of the new player.LuaPlayer — The created player.LuaSimulation.get_slot_position{ inventory_index: InventoryIndex, slot_index: ItemStackIndex, inventory?: "character" | "entity" } -> MapPosition?
simulation.get_slot_position{ inventory_index=inventory_index, slot_index=slot_index }
takes_table: truetable_optional: falseinventory_index: InventoryIndexslot_index: ItemStackIndex — This index is 0-based, unlike other inventory indices.inventory?: "character" | "entity" — Defaults to "character".MapPosition? — Position of the GUI slot on the screen, if successfully found.LuaSimulation.get_widget_position{ type: SimulationWidgetType, data?: string, data2?: string } -> MapPosition?
simulation.get_widget_position{ type=type }
takes_table: truetable_optional: falsetype: SimulationWidgetTypedata?: stringdata2?: stringMapPosition? — Center of the GUI widget on the screen, if successfully found.LuaSimulation.activate_rail_planner{ position?: MapPosition, ghost_mode?: boolean, build_mode?: defines.build_mode }
simulation.activate_rail_planner{ position=position }
takes_table: truetable_optional: trueActivate the rail planner at the given position.
position?: MapPositionghost_mode?: boolean — Defaults to false.build_mode?: defines.build_mode — Defaults to normal.LuaSimulation.deactivate_rail_planner()
simulation.deactivate_rail_planner()
takes_table: falsetable_optional: falseDeactivate the rail planner.
LuaSimulation.move_cursor{ position: MapPosition, speed?: double } -> boolean
simulation.move_cursor{ position=position }
takes_table: truetable_optional: falseMove the cursor towards the given position at the given speed.
position: MapPositionspeed?: double — Defaults to 0.2.boolean — Whether the cursor will reach the target position with this move.LuaSimulation.mouse_down()
simulation.mouse_down()
takes_table: falsetable_optional: falseSend a left mouse button-down event at its current position.
LuaSimulation.mouse_up()
simulation.mouse_up()
takes_table: falsetable_optional: falseSend a left mouse button-up event at its current position.
LuaSimulation.mouse_click()
simulation.mouse_click()
takes_table: falsetable_optional: falseSend a left mouse button click event at its current position. This is equivalent to calling LuaSimulation::mouse_down, then LuaSimulation::mouse_up.
LuaSimulation.control_down{ control: string, notify: boolean }
simulation.control_down{ control=control, notify=true }
takes_table: truetable_optional: falseSend a control press event at the current cursor position.
control: string — The name of the control input to press.notify: boolean — Whether to show flying text of the activated control.LuaSimulation.control_up{ control: string }
simulation.control_up{ control=control }
takes_table: truetable_optional: falseSend a control release event at the current cursor position.
control: string — The name of the control input to release.LuaSimulation.control_press{ control: string, notify: boolean }
simulation.control_press{ control=control, notify=true }
takes_table: truetable_optional: falseSend a control down and up event at the current cursor position. This is equivalent to calling LuaSimulation::control_down, then LuaSimulation::control_up.
control: string — The name of the control input to press and release.notify: boolean — Whether to show flying text of the activated control.LuaSimulation.write{ text?: string }
simulation.write{ text=text }
takes_table: truetable_optional: falseWrite text as if it was typed by a player. Overwrites existing text by selecting it first.
text?: string — The text to write. Does nothing if no text is provided.LuaSimulation.scroll_clipboard_forwards()
simulation.scroll_clipboard_forwards()
takes_table: falsetable_optional: falseScroll the clipboard forwards by one entry.
LuaSimulation.scroll_clipboard_backwards()
simulation.scroll_clipboard_backwards()
takes_table: falsetable_optional: falseScroll the clipboard backwards by one entry.