1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-12-13 23:35:55 +02:00

command update and player_modifier removed from global

This commit is contained in:
Gerkiz
2019-11-10 22:02:45 +01:00
parent fe0c6d6e47
commit ae94ef6dae
6 changed files with 129 additions and 68 deletions

View File

@@ -1,10 +1,15 @@
local Session = require 'utils.session_data'
local Modifiers = require 'player_modifiers'
local Server = require 'utils.server'
local Color = require 'utils.color_presets'
commands.add_command(
'spaghetti',
'Does spaghett.',
function(cmd)
local p_modifer = Modifiers.get_table()
local player = game.player
local _a = p_modifer
local param = tostring(cmd.parameter)
local force = game.forces["player"]
local p
@@ -13,16 +18,23 @@ commands.add_command(
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})
p("[ERROR] You're not admin!", Color.fail)
return
end
else
p = log
end
end
if param == nil then player.print("Arguments are true/false", {r=0.22, g=0.99, b=0.99}) return end
if param == nil then player.print("[ERROR] Arguments are true/false", Color.yellow) return end
if param == "true" then
game.print("The world has been spaghettified!", {r = 1, g = 0.5, b = 0.1})
if not _a.spaghetti_are_you_sure then
_a.spaghetti_are_you_sure = true
player.print("Spaghetti is not enabled, run this command again to enable spaghett", Color.yellow)
return
end
if _a.spaghetti_enabled == true then player.print("Spaghetti is already enabled.", Color.yellow) return end
game.print("The world has been spaghettified!", Color.success)
force.technologies["logistic-system"].enabled = false
force.technologies["construction-robotics"].enabled = false
force.technologies["logistic-robotics"].enabled = false
@@ -47,8 +59,10 @@ commands.add_command(
force.technologies["worker-robots-speed-4"].enabled = false
force.technologies["worker-robots-speed-5"].enabled = false
force.technologies["worker-robots-speed-6"].enabled = false
_a.spaghetti_enabled = true
elseif param == "false" then
game.print("The world is no longer spaghett!", {r = 1, g = 0.5, b = 0.1})
if _a.spaghetti_enabled == false or _a.spaghetti_enabled == nil then player.print("Spaghetti is already disabled.", Color.yellow) return end
game.print("The world is no longer spaghett!", Color.yellow)
force.technologies["logistic-system"].enabled = true
force.technologies["construction-robotics"].enabled = true
force.technologies["logistic-robotics"].enabled = true
@@ -73,6 +87,7 @@ commands.add_command(
force.technologies["worker-robots-speed-4"].enabled = true
force.technologies["worker-robots-speed-5"].enabled = true
force.technologies["worker-robots-speed-6"].enabled = true
_a.spaghetti_enabled = false
end
end)
@@ -80,6 +95,8 @@ commands.add_command(
'generate_map',
'Pregenerates map.',
function(cmd)
local p_modifer = Modifiers.get_table()
local _a = p_modifer
local player = game.player
local param = tonumber(cmd.parameter)
local p
@@ -88,18 +105,26 @@ commands.add_command(
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})
p("[ERROR] You're not admin!", Color.fail)
return
end
else
p = log
end
end
if param == nil then player.print("Must specify radius!", {r=0.22, g=0.99, b=0.99}) return end
if param > 50 then player.print("[ERROR] Value is too big.", Color.fail) return end
if param == nil then player.print("[ERROR] Must specify radius!", Color.fail) return end
if not _a.generate_map then
_a.generate_map = true
player.print("[WARNING] This command will make the server LAG, run this command again if you really want to do this!", Color.yellow)
return
end
local radius = param
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})
game.print("Map generation done!", Color.success)
_a.generate_map = nil
return
end
surface.request_to_generate_chunks({0,0}, radius)
@@ -107,13 +132,16 @@ commands.add_command(
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})
game.print("Map generation done!", Color.success)
_a.generate_map = nil
end)
commands.add_command(
'dump_layout',
'Dump the current map-layout.',
function()
local p_modifer = Modifiers.get_table()
local _a = p_modifer
local player = game.player
local p
@@ -121,12 +149,17 @@ commands.add_command(
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})
p("[ERROR] You're not admin!", Color.warning)
return
end
else
p = log
end
end
if not _a.dump_layout then
_a.dump_layout = true
player.print("[WARNING] This command will make the server LAG, run this command again if you really want to do this!", Color.yellow)
return
end
local surface = game.players[1].surface
game.write_file("layout.lua", "" , false)
@@ -167,14 +200,17 @@ commands.add_command(
str = str .. t.name
str = str .. '"},'
game.write_file("layout.lua", str .. '\n' , true)
player.print("Dumped layout as file: layout.lua")
player.print("Dumped layout as file: layout.lua", Color.success)
end
_a.dump_layout = false
end)
commands.add_command(
'creative',
'Enables creative_mode.',
function()
local p_modifer = Modifiers.get_table()
local _a = p_modifer
local player = game.player
local p
@@ -182,40 +218,54 @@ commands.add_command(
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})
p("[ERROR] You're not admin!", Color.fail)
return
end
else
p = log
end
end
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"})
local item = game.item_prototypes
local i = 0
for k, v in pairs(item) do
i = i + 1
if k and v.type ~= "mining-tool" then
player.force.character_inventory_slots_bonus = tonumber(i)
player.insert{name=k, count=v.stack_size}
player.print("Inserted all items")
if not _a.creative_are_you_sure then
_a.creative_are_you_sure = true
player.print("[WARNING] This command will enable creative/cheat-mode for all connected players, run this command again if you really want to do this!", Color.yellow)
return
end
if _a.creative_enabled == true then player.print("[ERROR] Creative/cheat-mode is already active!", Color.fail) return end
game.print(player.name .. " has activated creative-mode!", Color.warning)
Server.to_discord_bold(table.concat{'[Creative] ' .. player.name .. ' has activated creative-mode!'})
for k, v in pairs(game.connected_players) do
v.cheat_mode = true
v.insert{name="power-armor-mk2", count = 1}
if v.character ~= nil then
local p_armor = v.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"})
local item = game.item_prototypes
local i = 0
for _k, _v in pairs(item) do
i = i + 1
if _k and _v.type ~= "mining-tool" then
_a[k].character_inventory_slots_bonus["creative"] = tonumber(i)
v.character_inventory_slots_bonus = _a[k].character_inventory_slots_bonus["creative"]
v.insert{name=_k, count=_v.stack_size}
v.print("Inserted all base items.", Color.success)
_a.creative_enabled = true
end
end
end
end
end)
@@ -234,7 +284,7 @@ commands.add_command(
p = player.print
if not trusted[player.name] then
if not player.admin then
p("Only admins and trusted weebs are allowed to run this command!", {r = 1, g = 0.5, b = 0.1})
p("[ERROR] Only admins and trusted weebs are allowed to run this command!", Color.fail)
return
end
end
@@ -242,10 +292,11 @@ commands.add_command(
p = log
end
end
if param == nil then player.print("Must specify radius!", {r=0.22, g=0.99, b=0.99}) return end
if param > 500 then player.print("[ERROR] Value is too big.", Color.warning) return end
if param == nil then player.print("[ERROR] Must specify radius!", Color.warning) return end
local radius = {{x = -param, y = -param}, {x = param, y = param}} or {{x = -1, y = -1}, {x = 1, y = 1}}
for _, entity in pairs(player.surface.find_entities_filtered{area = radius, type = "corpse"}) do
player.print("Cleared biter-corpses.")
player.print("Cleared biter-corpses.", Color.success)
entity.destroy()
end
end)