1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00

Merge pull request #75 from Gerkiz/commands

added commands
This commit is contained in:
Gerkiz 2019-10-27 23:23:29 +01:00 committed by GitHub
commit dac4719269
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,98 @@
function generate_map(radius)
commands.add_command(
'spaghetti',
'Does spaghett.',
function(cmd)
local player = game.player
local force = game.forces["player"]
local p
if player then
if player ~= nil then
p = player.print
if not player.admin then
p("You're not admin!", {r = 1, g = 0.5, b = 0.1})
return
end
else
p = log
end
end
if cmd.parameter == nil then player.print("Arguments are enable/disable", {r=0.22, g=0.99, b=0.99}) return end
if cmd.parameter == "enable" then
game.print("The world has been spaghettified!", {r = 1, g = 0.5, b = 0.1})
force.technologies["logistic-system"].enabled = true
force.technologies["construction-robotics"].enabled = true
force.technologies["logistic-robotics"].enabled = true
force.technologies["robotics"].enabled = true
force.technologies["personal-roboport-equipment"].enabled = true
force.technologies["personal-roboport-mk2-equipment"].enabled = true
force.technologies["character-logistic-trash-slots-1"].enabled = true
force.technologies["character-logistic-trash-slots-2"].enabled = true
force.technologies["auto-character-logistic-trash-slots"].enabled = true
force.technologies["worker-robots-storage-1"].enabled = true
force.technologies["worker-robots-storage-2"].enabled = true
force.technologies["worker-robots-storage-3"].enabled = true
force.technologies["character-logistic-slots-1"].enabled = true
force.technologies["character-logistic-slots-2"].enabled = true
force.technologies["character-logistic-slots-3"].enabled = true
force.technologies["character-logistic-slots-4"].enabled = true
force.technologies["character-logistic-slots-5"].enabled = true
force.technologies["character-logistic-slots-6"].enabled = true
force.technologies["worker-robots-speed-1"].enabled = true
force.technologies["worker-robots-speed-2"].enabled = true
force.technologies["worker-robots-speed-3"].enabled = true
force.technologies["worker-robots-speed-4"].enabled = true
force.technologies["worker-robots-speed-5"].enabled = true
force.technologies["worker-robots-speed-6"].enabled = true
elseif cmd.parameter == "disable" then
game.print("The world is no longer spaghett!", {r = 1, g = 0.5, b = 0.1})
force.technologies["logistic-system"].enabled = false
force.technologies["construction-robotics"].enabled = false
force.technologies["logistic-robotics"].enabled = false
force.technologies["robotics"].enabled = false
force.technologies["personal-roboport-equipment"].enabled = false
force.technologies["personal-roboport-mk2-equipment"].enabled = false
force.technologies["character-logistic-trash-slots-1"].enabled = false
force.technologies["character-logistic-trash-slots-2"].enabled = false
force.technologies["auto-character-logistic-trash-slots"].enabled = false
force.technologies["worker-robots-storage-1"].enabled = false
force.technologies["worker-robots-storage-2"].enabled = false
force.technologies["worker-robots-storage-3"].enabled = false
force.technologies["character-logistic-slots-1"].enabled = false
force.technologies["character-logistic-slots-2"].enabled = false
force.technologies["character-logistic-slots-3"].enabled = false
force.technologies["character-logistic-slots-4"].enabled = false
force.technologies["character-logistic-slots-5"].enabled = false
force.technologies["character-logistic-slots-6"].enabled = false
force.technologies["worker-robots-speed-1"].enabled = false
force.technologies["worker-robots-speed-2"].enabled = false
force.technologies["worker-robots-speed-3"].enabled = false
force.technologies["worker-robots-speed-4"].enabled = false
force.technologies["worker-robots-speed-5"].enabled = false
force.technologies["worker-robots-speed-6"].enabled = false
end
end)
commands.add_command(
'generate_map',
'Pregenerates map.',
function(cmd)
local player = game.player
local p
if player then
if player ~= nil then
p = player.print
if not player.admin then
p("You're not admin!", {r = 1, g = 0.5, b = 0.1})
return
end
else
p = log
end
end
if cmd.parameter == nil then player.print("Must specify radius!", {r=0.22, g=0.99, b=0.99}) return end
local radius = cmd.parameter
local surface = game.players[1].surface
if surface.is_chunk_generated({radius, radius}) then
game.print("Map generation done!", {r=0.22, g=0.99, b=0.99})
@ -6,41 +100,31 @@ function generate_map(radius)
end
surface.request_to_generate_chunks({0,0}, radius)
surface.force_generate_chunk_requests()
for _, player in pairs(game.connected_players) do
player.play_sound{path="utility/new_objective", volume_modifier=1}
for _, pl in pairs(game.connected_players) do
pl.play_sound{path="utility/new_objective", volume_modifier=1}
end
game.print("Map generation done!", {r=0.22, g=0.99, b=0.99})
end
end)
function spaghetti()
game.forces["player"].technologies["logistic-system"].enabled = false
game.forces["player"].technologies["construction-robotics"].enabled = false
game.forces["player"].technologies["logistic-robotics"].enabled = false
game.forces["player"].technologies["robotics"].enabled = false
game.forces["player"].technologies["personal-roboport-equipment"].enabled = false
game.forces["player"].technologies["personal-roboport-mk2-equipment"].enabled = false
game.forces["player"].technologies["character-logistic-trash-slots-1"].enabled = false
game.forces["player"].technologies["character-logistic-trash-slots-2"].enabled = false
game.forces["player"].technologies["auto-character-logistic-trash-slots"].enabled = false
game.forces["player"].technologies["worker-robots-storage-1"].enabled = false
game.forces["player"].technologies["worker-robots-storage-2"].enabled = false
game.forces["player"].technologies["worker-robots-storage-3"].enabled = false
game.forces["player"].technologies["character-logistic-slots-1"].enabled = false
game.forces["player"].technologies["character-logistic-slots-2"].enabled = false
game.forces["player"].technologies["character-logistic-slots-3"].enabled = false
game.forces["player"].technologies["character-logistic-slots-4"].enabled = false
game.forces["player"].technologies["character-logistic-slots-5"].enabled = false
game.forces["player"].technologies["character-logistic-slots-6"].enabled = false
game.forces["player"].technologies["worker-robots-speed-1"].enabled = false
game.forces["player"].technologies["worker-robots-speed-2"].enabled = false
game.forces["player"].technologies["worker-robots-speed-3"].enabled = false
game.forces["player"].technologies["worker-robots-speed-4"].enabled = false
game.forces["player"].technologies["worker-robots-speed-5"].enabled = false
game.forces["player"].technologies["worker-robots-speed-6"].enabled = false
end
commands.add_command(
'dump_layout',
'Dump the current map-layout.',
function()
local player = game.player
local p
function dump_layout()
local surface = game.surfaces["labyrinth"]
if player then
if player ~= nil then
p = player.print
if not player.admin then
p("You're not admin!", {r = 1, g = 0.5, b = 0.1})
return
end
else
p = log
end
end
local surface = game.players[1].surface
game.write_file("layout.lua", "" , false)
local area = {
@ -80,4 +164,60 @@ function dump_layout()
str = str .. '"},'
game.write_file("layout.lua", str .. '\n' , true)
end
end)
commands.add_command(
'creative',
'Enables creative_mode.',
function()
local player = game.player
local p
if player then
if player ~= nil then
p = player.print
if not player.admin then
p("You're not admin!", {r = 1, g = 0.5, b = 0.1})
return
end
else
p = log
end
end
local starting_items = {
{name = 'submachine-gun', count = 1},
{name = 'uranium-rounds-magazine', count = 200},
{name = 'construction-robot', count = 250},
{name = 'logistic-robot', count = 250},
{name = 'electric-energy-interface', count = 50},
{name = 'substation', count = 50},
{name = 'roboport', count = 10},
{name = 'infinity-chest', count = 10},
{name = 'raw-fish', count = 200},
{name = 'infinity-pipe', count = 10},
{name = 'heat-interface', count = 10},
{name = 'selection-tool', count = 1}
}
game.print(player.name .. " has activated creative-mode!", {r=0.22, g=0.99, b=0.99})
log(player.name .. " has activated creative-mode!")
player.cheat_mode = true
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 = "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 = "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"})
for _, item in pairs(starting_items) do
player.insert(item)
end
end)