Cheats: Difference between revisions

From Evospace
Jump to navigation Jump to search
EvoBot (talk | contribs)
Add Category:Guides
Current quest, item and recipe names; time-of-day line removed, it has no Lua call now
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:Cheats}}
{{DISPLAYTITLE:Cheats}}
The command line in the player log runs Lua in the game's script state. This page lists the lines that skip quests, move the player, produce items and control the weather.
The command line in the player log runs Lua in the game's script state. This page lists the lines that skip quests, move the player, produce items, place and remove deposits and control the weather.


== Command line ==
== Command line ==
Line 14: Line 14:
|-
|-
| <code>/pos</code> || Prints the block cell the player stands in
| <code>/pos</code> || Prints the block cell the player stands in
|-
| <code>/weather</code> || Posts the weather card for the current conditions
|-
|-
| <code>/lua &lt;code&gt;</code> || Runs Lua. Everything below is run through it
| <code>/lua &lt;code&gt;</code> || Runs Lua. Everything below is run through it
Line 23: Line 25:
/lua 2 + 2
/lua 2 + 2
/lua for i = 1, 3 do print(i) end
/lua for i = 1, 3 do print(i) end
</syntaxhighlight>
The lines below reach the surface the player is on through <code>dim</code>. Set it once after loading a game, and again after travelling to another surface:
<syntaxhighlight lang="lua">
/lua dim = Player.get():surface()
</syntaxhighlight>
</syntaxhighlight>


Line 36: Line 44:


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
/lua quests:complete_quest(StaticQuest.get("FirstBlocks"))
/lua quests:complete_quest(StaticQuest.get("Welcome"))
/lua quests:unlock_quest(StaticQuest.get("DrillingRig"))
/lua quests:unlock_quest(StaticQuest.get("GatherCopperOre"))
/lua quests:unlock_chapter(StaticChapter.get("OreToPower"))
/lua quests:unlock_chapter(StaticChapter.get("Automation"))
/lua StaticQuest.get("FirstBlocks"):set_objective_complete_by_id("place_smelter", true)
/lua StaticQuest.get("Welcome"):set_objective_complete_by_id("open_questbook", true)
/lua StaticQuest.get("FirstBlocks"):set_objective_progress(0, 10, 10, true)
/lua StaticQuest.get("GatherCopperOre"):set_objective_progress(0, 25, 25, true)
</syntaxhighlight>
</syntaxhighlight>
<code>complete_quest</code> takes a quest that is active. <code>unlock_quest</code> takes a locked one whose chapter is open and whose required quests are done, <code>unlock_chapter</code> a chapter whose required chapters are done. Each returns false when it changed nothing. Objectives exist while their quest is active, and are counted from 0.


<code>quests:get_all_quests()</code> and <code>quests:get_all_chapters()</code> list every quest and chapter. <code>quests:is_quest_active(q)</code> and <code>quests:is_quest_completed(q)</code> test one.
<code>quests:get_all_quests()</code> and <code>quests:get_all_chapters()</code> list every quest and chapter. <code>quests:is_quest_active(q)</code> and <code>quests:is_quest_completed(q)</code> test one.
Line 48: Line 58:


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
/lua EventSystem.get():emmit(defines.events.on_player_crafted, { item = StaticItem.get("IronIngot"), count = 1 })
/lua EventSystem.get():emmit(defines.events.on_player_crafted, { item = StaticItem.get("StoneFurnace"), count = 1 })
</syntaxhighlight>
</syntaxhighlight>


Line 55: Line 65:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
/lua dim:teleport(Vec3i.new(0, 0, 80))
/lua dim:teleport(Vec3i.new(0, 0, 80))
/lua dim:teleport(dim:spawn_point())
/lua dim:teleport(Player.get():spawn_point())
/lua dim:teleport(Vec3i.new(4000, -1200, dim:sample_height(4000, -1200) + 3))
/lua dim:teleport(Vec3i.new(4000, -1200, dim:sample_height(4000, -1200) + 3))
</syntaxhighlight>
</syntaxhighlight>
<code>dim:teleport_pending()</code> is true while the target columns compile. <code>dim:streaming_ready()</code> is true when loading and meshing around the player are done.


== Blocks ==
== Blocks ==


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
/lua dim:spawn_block_identity(Vec3i.new(10, 10, 60), StaticBlock.get("Chest"))
/lua dim:place(Vec3i.new(10, 10, 60), StaticBlock.get("CopperChest"))
/lua dim:set_cell(Vec3i.new(10, 10, 60), StaticBlock.get("Air"))
/lua dim:dig(Vec3i.new(10, 10, 60))
/lua dim:clear_props(Vec3i.new(10, 10, 60))
/lua dim:clear_props(Vec3i.new(10, 10, 60), 5)
/lua dim:get_cell(Vec3i.new(10, 10, 60)).name
/lua dim:get_cell(Vec3i.new(10, 10, 60)).name
</syntaxhighlight>
</syntaxhighlight>


<code>dim:get_block(bpos)</code> returns the block placed in a cell, which the sections below use to reach a chest or a machine. Positions are <code>Vec3i.new(x, y, z)</code> in block cells. <code>cs.w2bp</code> and <code>cs.bp2w</code> convert between world units and cells.
<code>place</code> and <code>dig</code> build and break the way a tool in hand does, in a column that is streamed in. <code>clear_props</code> takes every prop within a radius of the cell, at any height. <code>dim:get_block(bpos)</code> returns the block placed in a cell, which the sections below use to reach a chest or a machine. Positions are <code>Vec3i.new(x, y, z)</code> in block cells. <code>cs.w2bp</code> and <code>cs.bp2w</code> convert between world units and cells.
 
== Deposits ==
 
A deposit is two things: the source that drills mine and the map shows, and the rock that stands over it. Each has its own line, so placing a deposit takes two and removing one takes two.
 
Place a deposit under the player and stand its rock there:
 
<syntaxhighlight lang="lua">
/lua local c = Player.get():cell(); print(dim:add_deposit(StaticItem.get("ChalcopyriteOre"), Vec2i.new(c.x, c.y), 5000), dim:place_prop(StaticProp.get("ChalcopyriteCluster"), c))
</syntaxhighlight>
 
The number is the total yield. The item has to be one of the surface's deposit ores. Terrain generated before the deposit gets no ore from it, only terrain generated after it does.
 
{| class="wikitable"
! Item !! Rock
|-
| <code>ChalcopyriteOre</code> || <code>ChalcopyriteCluster</code>
|-
| <code>CoalOre</code> || <code>CoalCluster</code>
|-
| <code>PyriteOre</code> || <code>PyriteCluster</code>
|-
| <code>MagnetiteOre</code> || <code>MagnetiteCluster</code>
|-
| <code>MalachiteOre</code> || <code>MalachiteCluster</code>
|-
| <code>CinnabarOre</code> || <code>CinnabarCluster</code>
|-
| <code>BauxiteOre</code> || <code>BauxiteCluster</code>
|-
| <code>RubyOre</code> || <code>RubyCluster</code>
|-
| <code>ThorianiteOre</code> || <code>ThorianiteCluster</code>
|-
| <code>PyroplatiteOre</code> || <code>PyroplatiteCluster</code>
|-
| <code>RawOil</code> || <code>OilCluster</code>
|}
 
Remove the deposits within 20 cells of the player, then the props around them:
 
<syntaxhighlight lang="lua">
/lua local c = Player.get():cell(); print(dim:remove_deposit(c, 20), dim:clear_props(c, 20))
</syntaxhighlight>
 
<code>remove_deposit</code> takes the deposits whose centre lies within the radius and prints how many it took. The map stops showing them, and drills standing on them switch to the nearest deposit left or to the ground. <code>clear_props</code> takes every prop within the radius at any height: the rock with its shards and rubble, but also trees and grass. Nothing is dropped. The ore already in the terrain stays.


== Items ==
== Items ==
Line 77: Line 131:


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
/lua StorageBlockLogic.cast(dim:get_block(Vec3i.new(10, 10, 60))).storage_access:add(StaticItem.get("IronIngot"), 1000)
/lua StorageBlockLogic.cast(dim:get_block(Vec3i.new(10, 10, 60))).storage_access:add(StaticItem.get("IronPlate"), 1000)
</syntaxhighlight>
</syntaxhighlight>


Line 83: Line 137:


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
/lua AbstractCrafter.cast(dim:get_block(Vec3i.new(10, 10, 60))).crafter_input_container:get_access(0):add(StaticItem.get("IronOre"), 100)
/lua AbstractCrafter.cast(dim:get_block(Vec3i.new(10, 10, 60))).crafter_input_container:get_access(0):add(StaticItem.get("PyriteOre"), 100)
</syntaxhighlight>
</syntaxhighlight>


Line 99: Line 153:


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
/lua Recipe.get("SteelIngotRecipe").locked = false
/lua RecipeDictionary.get("ArcSmelterRecipeDictionary"):recipe("SteelPlate").locked = false
/lua Recipe.get("SteelIngotRecipe").productivity = 100
</syntaxhighlight>
</syntaxhighlight>


== Weather and time ==
A recipe is reached through the dictionary of the machines that run it, <code>:recipes()</code> lists them. Its <code>productivity</code> is set only while a mod loads, from <code>init</code>.
 
== Weather ==


{| class="wikitable"
{| class="wikitable"
Line 117: Line 172:
|-
|-
| <code>weather.wind_clear()</code> || Releases the wind
| <code>weather.wind_clear()</code> || Releases the wind
|-
| <code>shot.time_of_day(13.5)</code> || Holds the sky at a solar hour, 0..24
|}
|}


[[Category:Guides]]
=== Presets ===
 
<code>weather.set</code> and <code>weather.snap</code> take one of these names.
 
* Clear sky: <code>Clear</code>, <code>SlightlyCloudy</code>, <code>PartlyCloudy</code>, <code>Overcast</code>
* Rain: <code>LightRain</code>, <code>Rain</code>, <code>Storm</code>
* Snow: <code>Snowfall</code>, <code>Blizzard</code>
* Dust: <code>DustHaze</code>, <code>SandStorm</code>
* Fog: <code>LightLowFog</code>, <code>DenseLowFog</code>, <code>Foggy</code>, <code>ExtremeFoggy</code>
 
[[Category:Guides{{#translation:}}]]

Latest revision as of 23:42, 28 November 2026

The command line in the player log runs Lua in the game's script state. This page lists the lines that skip quests, move the player, produce items, place and remove deposits and control the weather.

Command line

Two input slots open the same field. Console opens it in command mode, where the leading / is implied. Chat opens it as chat, and a line starting with / is still run as a command. Both slots are rebindable. Arrow keys recall previous lines.

Command Effect
/help [command] Lists the commands, or prints the usage of one
/time Prints the day and the world clock, with (frozen) while the day phase is held
/pos Prints the block cell the player stands in
/weather Posts the weather card for the current conditions
/lua <code> Runs Lua. Everything below is run through it

The line is compiled as return <code> first, so an expression prints its value. A line that does not compile that way is run as a chunk, so statements and loops work. print writes to the console, the first 20 lines of it.

/lua 2 + 2
/lua for i = 1, 3 do print(i) end

The lines below reach the surface the player is on through dim. Set it once after loading a game, and again after travelling to another surface:

/lua dim = Player.get():surface()

Quests

Complete every quest that is active:

/lua for _, q in ipairs(quests:get_active_quests()) do quests:complete_quest(q) end

Single quests, chapters and objectives:

/lua quests:complete_quest(StaticQuest.get("Welcome"))
/lua quests:unlock_quest(StaticQuest.get("GatherCopperOre"))
/lua quests:unlock_chapter(StaticChapter.get("Automation"))
/lua StaticQuest.get("Welcome"):set_objective_complete_by_id("open_questbook", true)
/lua StaticQuest.get("GatherCopperOre"):set_objective_progress(0, 25, 25, true)

complete_quest takes a quest that is active. unlock_quest takes a locked one whose chapter is open and whose required quests are done, unlock_chapter a chapter whose required chapters are done. Each returns false when it changed nothing. Objectives exist while their quest is active, and are counted from 0.

quests:get_all_quests() and quests:get_all_chapters() list every quest and chapter. quests:is_quest_active(q) and quests:is_quest_completed(q) test one.

A quest that waits for a gameplay event completes when the event is emitted:

/lua EventSystem.get():emmit(defines.events.on_player_crafted, { item = StaticItem.get("StoneFurnace"), count = 1 })

Teleport

/lua dim:teleport(Vec3i.new(0, 0, 80))
/lua dim:teleport(Player.get():spawn_point())
/lua dim:teleport(Vec3i.new(4000, -1200, dim:sample_height(4000, -1200) + 3))

Blocks

/lua dim:place(Vec3i.new(10, 10, 60), StaticBlock.get("CopperChest"))
/lua dim:dig(Vec3i.new(10, 10, 60))
/lua dim:clear_props(Vec3i.new(10, 10, 60), 5)
/lua dim:get_cell(Vec3i.new(10, 10, 60)).name

place and dig build and break the way a tool in hand does, in a column that is streamed in. clear_props takes every prop within a radius of the cell, at any height. dim:get_block(bpos) returns the block placed in a cell, which the sections below use to reach a chest or a machine. Positions are Vec3i.new(x, y, z) in block cells. cs.w2bp and cs.bp2w convert between world units and cells.

Deposits

A deposit is two things: the source that drills mine and the map shows, and the rock that stands over it. Each has its own line, so placing a deposit takes two and removing one takes two.

Place a deposit under the player and stand its rock there:

/lua local c = Player.get():cell(); print(dim:add_deposit(StaticItem.get("ChalcopyriteOre"), Vec2i.new(c.x, c.y), 5000), dim:place_prop(StaticProp.get("ChalcopyriteCluster"), c))

The number is the total yield. The item has to be one of the surface's deposit ores. Terrain generated before the deposit gets no ore from it, only terrain generated after it does.

Item Rock
ChalcopyriteOre ChalcopyriteCluster
CoalOre CoalCluster
PyriteOre PyriteCluster
MagnetiteOre MagnetiteCluster
MalachiteOre MalachiteCluster
CinnabarOre CinnabarCluster
BauxiteOre BauxiteCluster
RubyOre RubyCluster
ThorianiteOre ThorianiteCluster
PyroplatiteOre PyroplatiteCluster
RawOil OilCluster

Remove the deposits within 20 cells of the player, then the props around them:

/lua local c = Player.get():cell(); print(dim:remove_deposit(c, 20), dim:clear_props(c, 20))

remove_deposit takes the deposits whose centre lies within the radius and prints how many it took. The map stops showing them, and drills standing on them switch to the nearest deposit left or to the ground. clear_props takes every prop within the radius at any height: the rock with its shards and rubble, but also trees and grass. Nothing is dropped. The ore already in the terrain stays.

Items

Items are added to a container. Place a chest, read its cell with /pos, then fill it:

/lua StorageBlockLogic.cast(dim:get_block(Vec3i.new(10, 10, 60))).storage_access:add(StaticItem.get("IronPlate"), 1000)

:sub(item, count) removes them again. Machine inventories take items the same way:

/lua AbstractCrafter.cast(dim:get_block(Vec3i.new(10, 10, 60))).crafter_input_container:get_access(0):add(StaticItem.get("PyriteOre"), 100)

Machines

/lua AbstractCrafter.cast(dim:get_block(Vec3i.new(10, 10, 60))).energy_input_inventory:add_resource(100000)
/lua AbstractCrafter.cast(dim:get_block(Vec3i.new(10, 10, 60))).productivity = 500
/lua AbstractCrafter.cast(dim:get_block(Vec3i.new(10, 10, 60))).speed = 10

add_resource fills an energy, heat or fluid slot directly. The Admin Electric Generator block produces unlimited power and can be placed like any other block.

Recipes

/lua RecipeDictionary.get("ArcSmelterRecipeDictionary"):recipe("SteelPlate").locked = false

A recipe is reached through the dictionary of the machines that run it, :recipes() lists them. Its productivity is set only while a mod loads, from init.

Weather

Line Effect
weather.set("Rain") Transitions to a weather preset
weather.snap("Rain") Switches to it at once
weather.clear() Returns weather control to the biome
weather.wind(20) Holds the wind speed, up to the planet maximum of 20 m/s
weather.wind_clear() Releases the wind

Presets

weather.set and weather.snap take one of these names.

  • Clear sky: Clear, SlightlyCloudy, PartlyCloudy, Overcast
  • Rain: LightRain, Rain, Storm
  • Snow: Snowfall, Blizzard
  • Dust: DustHaze, SandStorm
  • Fog: LightLowFog, DenseLowFog, Foggy, ExtremeFoggy