异星工厂常用命令介绍

本文主要介绍异星工厂常用的Lua命令,以及异星工厂服务器的搭建

服务器搭建

首先,我们最好创建一个单独的账户gamemaster

1
adduser gamemaster

然后我们从这个连接下载对应版本的factorio服务端(headless),它是一个压缩包。

1
tar -xvJf factorio_headless_x64_xxx.tar.xz

解压之后的文件夹主要有binconfigdatamodssavestemp这几个目录。bin下面就是一个factorio的可执行文件。config里面是一些服务器的配置信息,这些信息大多与游戏性能相关,我们一般不在这里进行修改。data文件夹比较重要,里面server-settings.example.json中包含了服务器的一些设置信息,比如是否允许作弊,是否开启房间密码,游戏自动保存的时间间隔等,这里面必须要设置的是usernamepassword字段,这个是在factorio游戏里面你自己创建的账户。map-gen-settings.example.json则用来描述生成地图的配置,例如是否是和平模式,各种资源的多少等。
通过下面的命令创建新的世界

1
/home/gamemaster/factorio/bin/x64/factorio --create /home/gamemaster/factorio/saves/initial.zip --map-gen-settings /home/gamemaster/factorio/data/map-gen-settings.json --map-settings /home/gamemaster/factorio/data/map-settings.json

通过下面的命令启动服务器

1
nohup /home/gamemaster/factorio/bin/x64/factorio --server-settings /home/gamemaster/factorio/data/server-settings.example.json --start-server-load-latest --console-log /home/gamemaster/Factorio.log &

命令相关

通过下面脚本可以获得当前所有可以insert的物品

1
for name, _ in pairs(game.item_prototypes) do; game.write_file("item_names.txt", name.."\n", true); end

通过下面的脚本可以集齐一套神装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 = "fusion-reactor-equipment"})
p_armor.put({name = "fusion-reactor-equipment"})
p_armor.put({name = "fusion-reactor-equipment"})
p_armor.put({name = "energy-shield-mk2-equipment"})
p_armor.put({name = "energy-shield-mk2-equipment"})
p_armor.put({name = "energy-shield-mk2-equipment"})
p_armor.put({name = "energy-shield-mk2-equipment"})
p_armor.put({name = "energy-shield-mk2-equipment"})
p_armor.put({name = "energy-shield-mk2-equipment"})
-- 外骨骼,可选配 p_armor.put({name = "exoskeleton-equipment"})
-- 夜视模块,可选配 p_armor.put({name = "night-vision-equipment"})
p_armor.put({name = "personal-laser-defense-equipment"})
p_armor.put({name = "personal-laser-defense-equipment"})
p_armor.put({name = "personal-roboport-mk2-equipment"})
p_armor.put({name = "battery-mk2-equipment"})
p_armor.put({name = "battery-mk2-equipment"})

下面列出了一些物品的获取命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
game.player.insert{name="construction-robot", count = 100}
game.player.insert{name="pipe", count = 100000}
game.player.insert{name="pipe-to-ground", count = 100000}
game.player.insert{name="coal", count = 100000}
game.player.insert{name="iron-plate", count = 100000}
game.player.insert{name="rail", count = 10000}
game.player.insert{name="long-handed-inserter", count = 100000}
game.player.insert{name="stack-filter-inserter", count = 100000}
game.player.insert{name="rail-chain-signal", count = 1000}
game.player.insert{name="substation", count = 1000}
game.player.insert{name="big-electric-pole", count = 1000}
game.player.insert{name="logistic-chest-storage", count = 100}
game.player.insert{name="grenade", count = 100}
game.player.insert{name="cliff-explosives", count = 100}
game.player.insert{name="locomotive", count = 2}
game.player.insert{name="train-stop", count = 100}
game.player.insert{name="laser-turret", count = 1000}
game.player.insert{name="express-transport-belt", count = 100000}
game.player.insert{name="express-underground-belt", count = 100000}
game.player.insert{name="express-splitter", count = 100000}
game.player.insert{name="electric-mining-drill", count = 100}
game.player.insert{name="stone-brick", count = 10000}
game.player.insert{name="copper-plate", count = 10000}
game.player.insert{name="stone", count = 10000}
game.player.insert{name="rocket-launcher", count = 2}
game.player.insert{name="roboport", count = 100}
game.player.insert{name="explosive-rocket", count = 100}

修改人物奔跑速度

1
/c game.player.character.character_running_speed_modifier = 3

修改和平模式

1
/c game.player.surface.peaceful_mode = true

开启作弊

1
/c game.player.cheat_mode=true