控制台
控制台是游戏内置的命令行界面。关于执行游戏设置的命令行界面,请参阅页面:命令行参数。
在游戏中,控制台可用于:
- 与其他玩家聊天
- 查看状态更新
- 运行命令 / 脚本 / 作弊码
命令分为三种类型:
使用控制台
按波浪键键(`
)可切换控制台显示。此键位于1键左侧,TAB键上方。
玩家可以在 设置 → 按键→ 打开会话(及Lua控制台) 界面设置自定义快捷键。当控制台显示时,屏幕底部会显示闪烁的光标;输入聊天信息或命令,然后按回车键发送(这会同时关闭控制台)。关于聊天信息和命令前缀的内容可在本页面下文中找到。
控制台支持富文本标签。这些标签对于分享蓝图、在聊天中标记地图位置、为地图标记和车站添加图标非常有用。按住CTRL + ALT并点击地图或地面将会自动插入GPS位置标签并发送到控制台。当控制台开启时,按住SHIFT键点击大多数物品可以将其标签插入控制台。
当控制台关闭后,屏幕上只会显示最近的消息/命令,而且它们会逐渐淡出(打开控制台会立即重新显示所有最近信息)。注意,默认情况下所有已执行命令对所有用户可见。可以在 设置 → 界面 → 会话淡出延迟 界面修改信息淡出时间。
使用 /clear 命令可清除控制台显示内容。
使用↑和↓键可以滚动查看控制台历史记录。按TAB键可开启智能代码补全,包括命令、选项和玩家名称。
常规命令
命令 | 示例 | 说明 | 仅限管理员 |
---|---|---|---|
/alerts <enable/disable/mute/unmute> <alert> | /alerts disable turret_fire | 启用/禁用,静音/取消静音指定类型的警报。可用的警报类型包括:entity_destroyed, entity_under_attack, not_enough_construction_robots, no_material_for_construction, not_enough_repair_packs, platform_tile_building_blocked, turret_out_of_ammo, turret_fire, custom, no_storage, train_out_of_fuel, train_no_path, no_platform_storage, collector_path_blocked, unclaimed_cargo, no_roboport_storage, pipeline_overextended。 | 否 |
/clear | /clear | 清除控制台显示内容。 | 否 |
/color <color> | /color 20 255 255 | 改变颜色。可以是预定义的颜色之一,或者是“# # #”格式的RGB 颜色值。可用的预定义颜色:default, red, green, blue, orange, yellow, pink, purple, white, black, gray, brown, cyan, acid。 | 否 |
/evolution | /evolution | 输出当前的进化因子信息。 | 否 |
/help [command] | /help | 输出可用命令列表,可选参数可用于指定需要描述的命令。 | 否 |
/h [command] | /h | 与 /help 命令相同。 | 否 |
/mute-programmable-speaker <mute/unmute> <local/everyone> | /mute-programmable-speaker mute local | 对程控扬声器发出的全局声音执行静音/取消静音。使用“local”参数可以仅对本地客户端静音。管理员可以使用“everyone”参数来对服务器上的所有玩家静音。 | 否 |
/perf-avg-frames <number> | /perf-avg-frames 100 | 用于平均性能计数器的刻/更新次数。默认值为100。建议使用5-10的值以实现快速收敛,但此时数值波动会更快。 | 否 |
/permissions | /permissions | 开启权限设置界面。 | 是 |
/permissions <action> <parameters> | /permissions add-player DeveloperGroup kovarex | 可用选项包括:add-player <group> <player>, create-group <name>, delete-group <group>, edit-group <group> <input_action> <true/false>, get-player-group <player>, remove-player <group> <player>, rename-group <group> <new_name> 以及 reset | 是 |
/reset-tips | /reset-tips | 重置提示与技巧条目状态,使其恢复到游戏刚开始的状态。 | 否 |
/screenshot [x resolution] [y resolution] [zoom] | /screenshot | 以玩家位置为中心截取屏幕截图,并隐藏游戏界面。截图会保存在用户数据目录中。截图分辨率可以更改,默认为当前窗口大小,缩放倍率可以更改,默认值为1。 | 否 |
/seed | /seed | 输出初始地图种子。 | 否 |
/time | /time | 输出地图持续时间信息。 | 否 |
/toggle-action-logging | /toggle-action-logging | 切换记录游戏中所有输入动作的日志。此值不会在游戏重启时存留,且仅影响多人游戏中的本地线程。 | 是 |
/toggle-heavy-mode | /toggle-heavy-mode | 用于检查不同步问题。此命令会减慢游戏速度,使多人游戏无法进行。 | 是 |
/unlock-shortcut-bar | /unlock-shortcut-bar | 解锁所有快捷工具栏项目,包括导入蓝图代码、复制和粘贴、红图和绿图。 | 否 |
/unlock-tips | /unlock-tips | 解锁所有提示与技巧条目。 | 否 |
/version | /version | 输出当前游戏版本。 | 否 |
多人游戏命令
命令 | 示例 | 说明 | 仅限管理员 |
---|---|---|---|
<message> | Hello team! | 以 / 开头的控制台输入将会作为团队聊天信息显示。 | 否 |
/admin | /admin | 打开玩家管理界面。 | 是 |
/admins | /admins | 输出游戏管理员名单。 | 否 |
/ban <player> <reason> | /ban xTROLLx Throwing grenades in base | 封禁指定玩家。 | 是 |
/bans | /bans | 输出被封禁玩家名单。 | 否 |
/banlist <add/remove/get/clear> <player> | /banlist get | 将玩家移入/移出封禁名单。与 /ban 或 /unban 相同。 | 否 |
/config | /config | 打开服务器设置界面。 | 是 |
/config <get/set> <option> <value> | /config set password hunter2 | 获取或更改各种多人游戏设置。可用选项包括:afk-auto-kick, allow-commands, allow-debug-settings, autosave-interval, autosave-only-on-server, ignore-player-limit-for-returning-players, max-players, max-upload-speed, only-admins-can-pause, password, require-user-verification, visibility-lan, visibility-public。其中,afk-auto-kick 和 autosave-interval 以分钟计数。 | 是 |
/delete-blueprint-library <player> | /delete-blueprint-library everybody confirm | 从存档中删除指定离线玩家的蓝图库。输入“everybody confirm”可删除所有离线玩家的蓝图库。 | 是 |
/demote <player> | /demote AzureDiamond | 将玩家从管理员降级。 | 是 |
/ignore <player> | /ignore Cthon98 | 忽略特定玩家的聊天内容,使之不在聊天界面显示。管理员消息仍然显示。 | 否 |
/ignores | /ignores | 输出被忽略玩家名单。 | 否 |
/kick <player> <reason> | /kick xTROLLx Throwing grenades in base | 将指定玩家踢出游戏。 | 是 |
/mute <player> | /mute Cthon98 | 禁止指定玩家发送聊天信息。 | 是 |
/mutes | /mutes | 全体禁言(不能发送聊天信息) | 否 |
/open <player> | /open AzureDiamond | 打开另一个玩家的背包。 | 是 |
/o <player> | /o AzureDiamond | 与 /open 命令相同。 | 是 |
/players [online/o/count/c] | /players | 输出游戏中玩家的名单。(参数 online/o 仅输出在线玩家,参数 count/c 仅输出数量) | 否 |
/p [online/o/count/c] | /p o c | 与 /players 相同。 | 否 |
/promote <player> | /promote AzureDiamond | 将玩家晋升为管理员。 | 是 |
/purge <player> | /purge Cthon98 | 从聊天日志中清除特定玩家发送的信息。 | 是 |
/reply <message> | /reply oh, really? | 回复最后一个发送私信的玩家。 | 否 |
/r <message> | /r oh, really? | 与 /reply 相同。 | 否 |
/server-save | /server-save | 在多人游戏中将游戏保存到服务器上。 | 是 |
/shout <message> | /shout Hello world! | 向全体玩家发送信息,包括其它阵营。 | 否 |
/s <message> | /s Hello world! | 与 /shout 相同。 | 否 |
/swap-players <player> [player] | /swap-players AzureDiamond | 将自己的角色与指定玩家的角色互换,如果指定了两个玩家,则将这两个玩家的角色互换。 | 是 |
/unban <player> | /unban xTROLLx | 解封指定玩家。 | 是 |
/unignore <player> | /unignore Cthon98 | 恢复指定玩家的聊天信息显示。 | 否 |
/unmute <player> | /unmute Cthon98 | 解除玩家禁言 | 是 |
/whisper <player> <message> | /whisper AzureDiamond that's what I see | 向指定玩家发送私信。 | 否 |
/w <player> <message> | /w AzureDiamond that's what I see | 与 /whisper 相同。 | 否 |
/whitelist <add/remove/get/clear> [player] | /whitelist get | 编辑用户白名单。只有白名单中的玩家才能加入游戏。使用“get”参数输出白名单玩家列表时,需将“player”项留空。将白名单设置为空将禁用白名单功能,允许任何人加入游戏。 | 否 |
脚本和作弊命令
命令 | 说明 |
---|---|
/cheat [all/<planet-name>/<platform-name>/off] | 研究所有科技项目并启用作弊模式(允许免费制造任意物品)。
|
/command <command> | 执行 Lua 命令(如果允许)。 |
/c <command> | 与 /command 相同。 |
/editor | 切换地图编辑器。 |
/measured-command <command> | 执行 Lua 命令(如果允许)并测量耗时。 |
/mc <command> | 与 /measured-command 相同。 |
/silent-command <command> | 执行 Lua 命令(如果允许)并将结果输出到控制台。 |
/sc <command> | 与 /silent-command 相同。 |
这些功能非常强大,也允许玩家作弊。注意:一旦使用脚本命令,该存档的成就功能将被永久禁用!
基础脚本示例
计算器
/c game.player.print(1234*5678)
超常规缩放
注意过度缩放可能导致性能下降,请小心操作。
/c game.player.zoom=0.1
在标准模式中,最远缩放倍率为0.3,在地图编辑器中是0.1。更远的缩放倍率将被限制。
快速采矿
/c game.player.force.manual_mining_speed_modifier=1000
快速制造
/c game.player.force.manual_crafting_speed_modifier=1000
解锁所有科技
/c game.player.force.research_all_technologies()
使用下一节中的命令撤销此操作
注意,在地图编辑器中,可以按住SHIFT键点击科技界面上的“开始研究”按钮来研究指定的科技项目。
取消所有科技
这不会移除手动添加的加成效果。
/c for _, tech in pairs(game.player.force.technologies) do
tech.researched=false
end
注意,在地图编辑器中,可以点击科技界面上的“删除科技”按钮来取消指定的科技项目。
重置阵营
这会重置阵营的所有数据,包括击杀和生产统计数据、科技、加成和地图探测状态。
/c game.player.force.reset()
总是显示铁路区间可视化
永久显示铁路区间的可视化效果,而非只在手持铁路信号物品时显示。将 true 替换为 false 可以禁用此功能。
/c game.player.game_view_settings.show_rail_block_visualisation = true
设置所有火车自动驾驶
将所有火车设置为自动驾驶模式 - 例如,在使用蓝图建造它们之后。
/c for key,ent in pairs (game.player.surface.find_entities_filtered{name="locomotive"}) do
ent.train.manual_mode = false
end
物品栏管理脚本
作弊模式
允许无限免费制造。将 true 替换为 false 可以禁用此功能。
/c game.player.cheat_mode=true
补充资源(原油、铁矿等)
在游戏中将光标悬停在资源地格上:
/c game.player.selected.amount=7500
或者使用以下命令将地图中所有的资源重新补满。ore.amount 可以更改为需要的值。
/c surface = game.player.surface
for _, ore in pairs(surface.find_entities_filtered({type="resource"})) do
ore.amount = 10000
end
向玩家背包中添加物品
将铁板(iron-plate)替换为所需物品的内部名称。
/c game.player.insert{name="iron-plate", count=100}
例如,使用以下命令在上帝模式中生成电力接口:
/c game.player.insert{name="electric-energy-interface"}
在上帝模式中有多种物品可供选择:
infinity-chest
永续箱 - 无限生成物品infinity-pipe
永续管 - 无限生成流体electric-energy-interface
电力接口 - 提供最高500吉瓦的电力heat-interface
热力接口 - 提供最高1000℃的热能
使用以下命令为玩家添加一套强大的装备和一些建筑工具:
/c local player = game.player
player.insert{name="power-armor-mk2", count = 1}
local p_armor = player.get_inventory(5)[1].grid
p_armor.put({name = "fission-reactor-equipment"})
p_armor.put({name = "fission-reactor-equipment"})
p_armor.put({name = "fission-reactor-equipment"})
p_armor.put({name = "exoskeleton-equipment"})
p_armor.put({name = "exoskeleton-equipment"})
p_armor.put({name = "exoskeleton-equipment"})
p_armor.put({name = "exoskeleton-equipment"})
p_armor.put({name = "energy-shield-mk2-equipment"})
p_armor.put({name = "energy-shield-mk2-equipment"})
p_armor.put({name = "personal-roboport-mk2-equipment"})
p_armor.put({name = "night-vision-equipment"})
p_armor.put({name = "battery-mk2-equipment"})
p_armor.put({name = "battery-mk2-equipment"})
player.insert{name="construction-robot", count = 25}
增加玩家背包容量
为阵营中的所有玩家提供额外的100格背包容量。通过科技:工具腰带实现:
/c game.player.force.character_inventory_slots_bonus=100
世界操作脚本
显示玩家周围的地图
探测玩家周围的地图,类似于雷达的效果。
/c local radius=150
game.player.force.chart(game.player.surface, {{game.player.position.x-radius, game.player.position.y-radius}, {game.player.position.x+radius, game.player.position.y+radius}})
或者从出生点开始:
/c local radius=150
game.player.force.chart(game.player.surface, {{x = -radius, y = -radius}, {x = radius, y = radius}})
可将150更改为需要的半径,值越大所需时间越长。
隐藏已探明地图
隐藏所有已探明的区块,反转地图探测状态。
/c local surface = game.player.surface
local force = game.player.force
for chunk in surface.get_chunks() do
force.unchart_chunk({x = chunk.x, y = chunk.y}, surface)
end
显示所有已生成地图
向玩家团队显示所有已生成的地图。
/c game.player.force.chart_all()
删除区块
如果大部分地图已经探明,会增加存档文件的大小。以下命令可以取消所有正在排队等待生成的区块,并移除 0,0 点周围32个区块以外的区块。注意,此命令会移除这些区块上的玩家实体。
/c local surface = game.player.surface;
game.player.force.cancel_charting(surface);
local chunk_radius = 32;
for chunk in surface.get_chunks() do
if (chunk.x < -chunk_radius or chunk.x > chunk_radius or chunk.y < -chunk_radius or chunk.y > chunk_radius) then
surface.delete_chunk(chunk)
end
end
删除未探明区块
使用此命令删除玩家尚未探明的区块。可以在执行隐藏已探明地图的命令后使用,以删除雷达未探测的区块。
/c local surface = game.player.surface
local force = game.player.force
for chunk in surface.get_chunks() do
if not force.is_chunk_charted(surface, chunk) then
surface.delete_chunk(chunk)
end
end
关闭昼夜交替
使游戏始终处于白昼状态。
/c game.player.surface.always_day=true
改变游戏速度
0.5为一半速度,1为默认速度,2为双倍速度,等等。最小值可以取0.01。这适用于很多场合,比如正常需要等待很长时间才能完成的事情。提高游戏速度可能导致性能下降,请小心操作。
/c game.speed=X
时间停止
停止时间推移。如果将 "true" 替换为 "false",可以恢复时间推移。
/c game.player.surface.freeze_daytime=true
移除所有污染
/c game.player.surface.clear_pollution()
彻底关闭污染
/c for _, surface in pairs(game.surfaces) do
surface.clear_pollution()
end
game.map_settings.pollution.enabled = false
增加大量污染
/c game.player.surface.pollute(game.player.position, 1000000)
显示扬声器位置和放置者
/c local speakers = game.player.surface.find_entities_filtered{force = game.player.force, type="programmable-speaker"}
for key, speaker in pairs(speakers) do
game.player.print(speaker.last_user.name .. " placed a speaker at " .. speaker.gps_tag)
end
禁用友军伤害
/c game.player.force.friendly_fire = false
新增资源地格
以下命令将会以玩家角色为中心创建一片 11×11 格的资源地格,仅能在地面而非水域上创建,生成的资源地格将是完美的正方形。与自然生成过程类似,其资源数量是随机化的,但总体来说,区域边缘的资源数量较少,中心的资源数量较多。默认数值下生成的每个资源地格包含2500-3000单位的资源。
如果需要生成更大面积的资源,可以将 "local size = 5" 更改为更大的数字。更大的资源地块中的资源数量将呈指数级增加。建议不要超过30。
如果需要生成资源含量更高的地格,可以将 "local density = 10" 更改为更大的数字。输入一个大数字通常不会造成负面影响,但仍然建议不要超过100。
要改变生成资源的类型,可以将代码底部附近的 "stone" 替换为 "iron-ore", "copper-ore", "coal", 或 "uranium-ore"。
/c local surface=game.player.surface
local ore=nil
local size=5
local density=10
for y=-size, size do
for x=-size, size do
a=(size+1-math.abs(x))*10
b=(size+1-math.abs(y))*10
if a<b then
ore=math.random(a*density-a*(density-8), a*density+a*(density-8))
end
if b<a then
ore=math.random(b*density-b*(density-8), b*density+b*(density-8))
end
if surface.get_tile(game.player.position.x+x, game.player.position.y+y).collides_with("ground_tile") then
surface.create_entity({name="stone", amount=ore, position={game.player.position.x+x, game.player.position.y+y}})
end
end
end
以灵活性角度而言,地图编辑器也可以用于创建/修改/删除资源地格。
移除玩家周围的资源
移除以玩家为中心 50 x 50 格区域内的所有资源地格。
/c local surface=game.player.surface
local size=50
local pos=game.player.position
for _, e in pairs(surface.find_entities_filtered{area={{pos.x-size, pos.y-size},{pos.x+size, pos.y+size}}, type="resource"})
do e.destroy()
end
新增油田
在 3×3 格的正方形区域内创建9片油田。
/c for y=0,2 do
for x=0,2 do
game.player.surface.create_entity({name="crude-oil", amount=100000, position={game.player.position.x+x*7-7, game.player.position.y+y*7-7}})
end
end
或者随机生成,油田间不发生碰撞:
/c local position=nil
for i=1,9 do
position=game.player.surface.find_non_colliding_position("crude-oil", game.player.position, 0, i/2+1.5)
if position then
game.player.surface.create_entity({name="crude-oil", amount=100000, position=position})
end
end
新增水域
创建一个 4 x 2 格区域的小池塘。
/c
local waterTiles = {}
for y=2,4 do
for x=-2,2 do
table.insert(waterTiles, {name="water", position={game.player.position.x+x, game.player.position.y+y}})
end
game.player.surface.set_tiles(waterTiles)
end
重新生成资源
对于固体资源(如铁矿),删除所有资源实体,并按原始地图的生成方式重新创建资源实体。对于流体资源(如原油),将所有现存资源实体的产率重置为原始产率,并在整个地表上重新生成资源。
/c local surface = game.player.surface
for _, e in pairs(surface.find_entities_filtered{type="resource"}) do
if e.prototype.infinite_resource then
e.amount = e.initial_amount
else
e.destroy()
end
end
local non_infinites = {}
for resource, prototype in pairs(prototypes.get_entity_filtered{{filter="type", type="resource"}}) do
if not prototype.infinite_resource then
table.insert(non_infinites, resource)
end
end
surface.regenerate_entity(non_infinites)
for _, e in pairs(surface.find_entities_filtered{type="mining-drill"}) do
e.update_connections()
end
统计实体数量
统计所有名称中包含特定字符串的实体的数量。
/c local entity="belt"
local surface=game.player.surface
local count=0
for key, ent in pairs(surface.find_entities_filtered({force=game.player.force})) do
if string.find(ent.name,entity) then
count=count+1
end
end
game.player.print(count)
关闭悬崖生成
设置尺寸为 "none"。仅对使用此命令后生成的区块有效。使用删除所有悬崖命令可以删除已经生成的悬崖。
/c local mgs = game.player.surface.map_gen_settings
mgs.cliff_settings.cliff_elevation_0 = 1024
game.player.surface.map_gen_settings = mgs
删除所有悬崖
删除世界中存在的所有悬崖。使用关闭悬崖生成命令可以关闭新区块中悬崖的生成。
/c for _, v in pairs(game.player.surface.find_entities_filtered{type="cliff"}) do
v.destroy()
end
删除所有装饰
删除世界中所有的装饰物。
/c game.player.surface.destroy_decoratives({})
更改地图生成设置
允许更改新区块的地图生成设置;此命令不会改变已生成的区块。已删除的区块会受到设置更改的影响,因为区块会在再次探索时重新生成。
要更改资源生成设置,在以下命令中将 "iron-ore" 替换为其它资源的内部名称,并将 "very-high"替换为需要的MapGenSize值。将 "iron-ore" 替换为 "enemy-base" 可以更改敌方虫巢的生成设置。
/c local surface = game.player.surface
local resource = "iron-ore"
local mgs = surface.map_gen_settings
mgs.autoplace_controls[resource].size = "very-high"
mgs.autoplace_controls[resource].frequency = "very-high"
mgs.autoplace_controls[resource].richness = "very-high"
surface.map_gen_settings = mgs
要更改水域生成设置,可将以下命令中的 "very-high" 替换为需要的MapGenSize值。
/c local surface = game.player.surface
local mgs = surface.map_gen_settings
mgs.water = "very-high" --[[ size]]
mgs.terrain_segmentation = "very-high" --[[ frequency]]
surface.map_gen_settings = mgs
生成不可摧毁设施
这将使实体无法被破坏或杀死。将鼠标悬停在实体上,然后运行:
/c game.player.selected.destructible = false
连接关联带
如果存在至少两条关联带,其中一条的 "Entity tag"为 in
,另一条的 "Entity tag"为 out
,则可使用以下命令连接这两条关联带:
/c local i = game.get_entity_by_tag('in')
local o = game.get_entity_by_tag('out')
i.linked_belt_type = 'input'
o.linked_belt_type = 'output'
i.connect_linked_belts(o)
敌人/进化脚本
设置进化因子
取值范围从 0(新游戏)到 1。
/c game.forces["enemy"].set_evolution_factor(X, game.player.surface)
禁用随时间进化 & 增加随污染进化
/c game.map_settings.enemy_evolution.time_factor=0
/c game.map_settings.enemy_evolution.pollution_factor=game.map_settings.enemy_evolution.pollution_factor*2
后一条命令末尾的 "2" 会将默认污染系数加倍。玩家可以更改此数字以进一步增加(或减少)污染值。
杀死所有敌方阵营的虫子
注意,这只会杀死可以移动的单位,不会摧毁虫巢。
/c game.forces["enemy"].kill_all_units()
杀死所有敌人
这会杀死所有敌方单位和建筑,例如虫子、虫巢和沙虫。此命令仅对已生成世界中的敌人有效,因此地图上尚未探索且需要生成的区域中仍可能存在敌人。如有需要,可以使用命令防止在新区域中生成敌人。
/c local surface=game.player.surface
for key, entity in pairs(surface.find_entities_filtered({force="enemy"})) do
entity.destroy()
end
杀死所有附近敌人
这将在设定范围内杀死所有虫子、虫巢和沙虫。默认范围为250格,大约是全高清分辨率下两倍缩放倍率的屏幕宽度。执行命令后会显示已杀死的对象数量。
/c local surface=game.player.surface
local pp = game.player.position
local cnt = 0
for key, entity in pairs(surface.find_entities_filtered({force="enemy", radius=250, position=pp })) do
cnt = cnt+1
entity.destroy()
end
game.player.print(cnt)
启用/禁用和平模式
启用和平模式后虫群不会主动进攻,除非玩家主动进攻虫群以激怒它们。将 true 替换为 false 可禁用此模式。已经存在的虫群不受此命令影响,因此启用和平模式后,虫群的进攻可能还会持续一段时间。
/c game.player.surface.peaceful_mode = true
启用/禁用虫族扩张
虫群扩张选项允许虫群创建新的虫巢,此选项默认启用。将 true 替换为 false 可禁用此功能。
/c game.map_settings.enemy_expansion.enabled = true
防止在新区块中出现虫子
在新生成的区块中不会出现虫子,但所有当前已生成的虫子不受影响。这相当于在地图生成设置中将 emeny-base.size 设置为 none,在游戏中途可以通过更改地图生成设置命令进行设置。
/c local surface = game.player.surface
local mgs = surface.map_gen_settings
mgs.autoplace_controls["enemy-base"].size = "none"
surface.map_gen_settings = mgs
除了使用命令之外,玩家也可以使用地图编辑器界面在游戏中更改地图生成设置。通过 /editor
命令打开地图编辑器,转到“表面”选项卡然后点击“编辑地图生成设置”。
玩家角色脚本
直接涉及玩家的命令。
获取玩家位置
输出玩家当前位置的坐标。
/c game.player.print(game.player.position)
传送玩家
将玩家移动到指定位置。如果其它玩家执行上一个命令并分享坐标,玩家就可以传送到其它玩家身边。
/c game.player.teleport({X, Y})
要传送到出生点,请使用坐标 0,0。
要传送到不同的星球/表面,请使用:
/c game.player.teleport({X, Y}, 'surface_name')
启用上帝模式
上帝模式会移除玩家角色,使玩家能够飞越障碍并不受伤害。
将玩家控制与角色解绑,并删除角色:
/c game.player.character.destroy()
要撤销上一条命令,需要重新生成一个玩家角色。这将在世界的出生点生成一个新角色,此时玩家可以将控制与角色绑定。
/c game.player.create_character()
启用远距离操作
启用远距离操作,允许玩家在更远的地方建造和与实体交互。默认操作距离为10。
/c local reach = 10000
game.player.force.character_build_distance_bonus = reach
game.player.force.character_reach_distance_bonus = reach
game.player.force.character_resource_reach_distance_bonus = reach
game.player.force.character_item_drop_distance_bonus = reach
寻找玩家尸体
在地图上对玩家实体进行 ping 操作。
/c local found_corpses = game.player.surface.find_entities_filtered{type="character-corpse"}
for _,corpse in pairs(found_corpses) do
local player = game.get_player(corpse.character_corpse_player_index)
local name = player and player.name or "????"
game.player.print(name .. " --> " .. corpse.gps_tag)
end
增加奔跑速度
/c game.player.character_running_speed_modifier=3
科研脚本
开启快速研究
/c game.player.force.laboratory_speed_modifier=1
-0.5 是一半速度,0 是正常速度,1 是双倍速度,2 是三倍速度,等等。
研究指定科技
科技项目的内部名称可以在其页面右侧的信息框中找到。
/c game.player.force.technologies['electric-energy-distribution-1'].researched=true
/c game.player.force.technologies['steel-processing'].researched=true
要研究高等级的无限科技,需手动设置等级:
/c game.player.force.technologies['worker-robots-speed-6'].level = 100
/c game.player.force.technologies['mining-productivity-4'].level = 100
取消指定科技
科技项目的内部名称可以在其页面右侧的信息框中找到。
/c game.player.force.technologies['electric-energy-distribution-1'].researched=false
/c game.player.force.technologies['steel-processing'].researched=false
启用指定配方
配方/物品的内部名称可以在其页面右侧的信息框中找到。
/c game.player.force.recipes["electric-energy-interface"].enabled=true
/c game.player.force.recipes["rocket-silo"].enabled=true
/c game.player.force.recipes.loader.enabled=true
/c game.player.force.recipes["fast-loader"].enabled = true
/c game.player.force.recipes["express-loader"].enabled = true
启用所有配方
/c for name, recipe in pairs(game.player.force.recipes) do recipe.enabled = true end
重置科技效果
这将重置所有配方的启用/解锁状态,使其与当前已研究的科技匹配,同时重置其它科技效果,例如采矿速度加成等。对配方/效果的任何手动修改都将被撤销。
/c game.player.force.reset_technology_effects()
注意:当添加或更改模组后,如果解锁配方的科技已经研究完成,但配方仍然不可用时,可以使用此命令作为快速解决方案。
模组工具
基础游戏中大部分物体的内部名称都可以在 data.raw 中查找。
访问模组数据
如果命令以 __mod-name__ 开头,它将在具有相同名称的模组环境中运行。例如,以下命令将输出 Even Distribution 模组的数据内容:
/c __even-distribution__ game.player.print(serpent.dump(global))
将玩家所在的地格输出到控制台
/c game.player.print(game.player.surface.get_tile(game.player.position).name)
将所有已研究科技写入文件
/c local list = {}
for _, tech in pairs(game.player.force.technologies) do
if tech.researched then
list[#list+1] = tech.name
end
end
game.write_file("techs.lua", serpent.block(list) .. "\n", true)
将所有已解锁配方写入文件
/c local list = {}
for _, recipe in pairs(game.player.force.recipes) do
if recipe.enabled then
list[#list+1] = recipe.name
end
end
game.write_file("recipes.lua", serpent.block(list) .. "\n", true)
将模组列表写入文件
将所有当前已激活的模组及其版本号写入用户数据目录下的 script-output/mods.txt 文件中。
/c helpers.write_file("mods.txt", serpent.block(script.active_mods))
更新历史
- 1.1.92:
- 添加了科技研究完成时的通知。
- 添加了 /enable-research-queue 命令,用于启用研究队列而不禁用成就功能。