mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-29 21:57:00 +02:00
Put roboports into inventory on force toggle #75
This commit is contained in:
parent
0d85e7994a
commit
dc06a2dd0c
@ -366,12 +366,18 @@ local function toggle_tp_mode(cmd)
|
||||
end
|
||||
|
||||
global.old_force = {}
|
||||
global.force_toggle_init = true
|
||||
local function forcetoggle(cmd)
|
||||
if not game.player or not (game.player.admin or is_mod(game.player.name)) then
|
||||
cant_run(cmd.name)
|
||||
return
|
||||
end
|
||||
|
||||
if global.force_toggle_init then
|
||||
game.forces.enemy.research_all_technologies() --avoids losing logstics slot configuration
|
||||
global.force_toggle_init = false
|
||||
end
|
||||
|
||||
if game.player.force.name == "enemy" then
|
||||
local old_force = global.old_force[game.player.name]
|
||||
if not old_force then
|
||||
@ -385,6 +391,22 @@ local function forcetoggle(cmd)
|
||||
end
|
||||
end
|
||||
else
|
||||
--Put roboports into inventory
|
||||
inv = game.player.get_inventory(defines.inventory.player_armor)
|
||||
if inv[1].valid_for_read
|
||||
then
|
||||
local name = inv[1].name
|
||||
if name:match("power") or name:match("modular") then
|
||||
local equips = inv[1].grid.equipment
|
||||
for _,equip in pairs(equips) do
|
||||
if equip.name == "personal-roboport-equipment" or equip.name == "personal-roboport-mk2-equipment" then
|
||||
game.player.insert{name = equip.name}
|
||||
inv[1].grid.take(equip)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
global.old_force[game.player.name] = game.player.force.name
|
||||
game.player.force = "enemy"
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user