Merge branch 'aperx' into main
This commit is contained in:
@@ -42,7 +42,7 @@ Commands.new("set-always-day", { "exp-commands_cheat.description-always-day" })
|
||||
else
|
||||
surface.always_day = state
|
||||
end
|
||||
game.print{ "exp-commands_cheat.always-day", format_player_name(player), surface.localised_name, surface.always_day }
|
||||
game.print{ "exp-commands_cheat.always-day", format_player_name(player), surface.name, surface.always_day }
|
||||
end)
|
||||
|
||||
--- Toggles friendly fire for your force or another
|
||||
@@ -89,7 +89,7 @@ Commands.new("clear-pollution", { "exp-commands_cheat.description-clear-pollutio
|
||||
:register(function(player, surface)
|
||||
--- @cast surface LuaSurface
|
||||
surface.clear_pollution()
|
||||
game.print{ "exp-commands_cheat.clear-pollution", format_player_name(player), surface.localised_name }
|
||||
game.print{ "exp-commands_cheat.clear-pollution", format_player_name(player), surface.name }
|
||||
end)
|
||||
|
||||
--- Toggles pollution being enabled in the game
|
||||
|
||||
@@ -20,11 +20,11 @@ Commands.new("kill", { "exp-commands_kill.description" })
|
||||
if other_player == nil then
|
||||
-- Can only be nil if the target is the player and they are already dead
|
||||
return Commands.status.error{ "exp-commands_kill.already-dead" }
|
||||
elseif other_player == player then
|
||||
-- You can always kill yourself
|
||||
other_player.character.die()
|
||||
elseif highest_role(other_player).index < highest_role(player).index then
|
||||
-- Can kill lower role players
|
||||
elseif (other_player == player) or (highest_role(other_player).index < highest_role(player).index) then
|
||||
-- You can always kill yourself or can kill lower role players
|
||||
if script.active_mods["space-age"] then
|
||||
other_player.surface.create_entity{ name = "lightning", position = { other_player.position.x, other_player.position.y - 16 }, target = other_player.character }
|
||||
end
|
||||
other_player.character.die()
|
||||
else
|
||||
return Commands.status.unauthorised{ "exp-commands_kill.lower-role" }
|
||||
|
||||
@@ -10,7 +10,7 @@ Commands.new("lawnmower", { "exp-commands_lawnmower.description" })
|
||||
:register(function(player, range)
|
||||
--- @cast range number
|
||||
local surface = player.surface
|
||||
|
||||
|
||||
-- Intentionally left as player.position to allow use in remote view
|
||||
local entities = surface.find_entities_filtered{ position = player.position, radius = range, type = "corpse" }
|
||||
for _, entity in pairs(entities) do
|
||||
@@ -18,7 +18,7 @@ Commands.new("lawnmower", { "exp-commands_lawnmower.description" })
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local replace_tiles = {}
|
||||
local tiles = surface.find_tiles_filtered{ position = player.position, radius = range, name = { "nuclear-ground" } }
|
||||
for i, tile in pairs(tiles) do
|
||||
|
||||
@@ -13,11 +13,16 @@ Commands.new("waterfill", { "exp-commands_waterfill.description" })
|
||||
if Selection.is_selecting(player, SelectionName) then
|
||||
Selection.stop(player)
|
||||
return Commands.status.success{ "exp-commands_waterfill.exit" }
|
||||
elseif player.get_item_count("cliff-explosives") == 0 then
|
||||
return Commands.status.error{ "exp-commands_waterfill.requires-explosives" }
|
||||
else
|
||||
Selection.start(player, SelectionName)
|
||||
return Commands.status.success{ "exp-commands_waterfill.enter" }
|
||||
local item_count_cliff = player.get_item_count("cliff-explosives")
|
||||
local item_count_craft = math.min(math.floor(player.get_item_count("explosives") / 10), player.get_item_count("barrel"), player.get_item_count("grenade"))
|
||||
local item_count_total = item_count_cliff + item_count_craft
|
||||
if item_count_total == 0 then
|
||||
return player.print{ "exp-commands_waterfill.requires-explosives" }
|
||||
else
|
||||
Selection.start(player, SelectionName)
|
||||
return player.print{ "exp-commands_waterfill.enter" }
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -28,10 +33,12 @@ Selection.on_selection(SelectionName, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
local surface = event.surface
|
||||
|
||||
--[[
|
||||
if surface.planet and surface.planet ~= game.planets.nauvis then
|
||||
player.print({ "exp-commands_waterfill.nauvis-only" }, Commands.print_settings.error)
|
||||
return
|
||||
end
|
||||
]]
|
||||
|
||||
local area_size = (area.right_bottom.x - area.left_top.x) * (area.right_bottom.y - area.left_top.y)
|
||||
if area_size > 1000 then
|
||||
@@ -39,9 +46,12 @@ Selection.on_selection(SelectionName, function(event)
|
||||
return
|
||||
end
|
||||
|
||||
local item_count = player.get_item_count("cliff-explosives")
|
||||
if item_count < area_size then
|
||||
player.print({ "exp-commands_waterfill.too-few-explosives", area_size, item_count }, Commands.print_settings.error)
|
||||
local item_count_cliff = player.get_item_count("cliff-explosives")
|
||||
local item_count_craft = math.min(math.floor(player.get_item_count("explosives") / 10), player.get_item_count("barrel"), player.get_item_count("grenade"))
|
||||
local item_count_total = item_count_cliff + item_count_craft
|
||||
|
||||
if item_count_total < area_size then
|
||||
player.print({ "exp-commands_waterfill.too-few-explosives", area_size, item_count_total }, Commands.print_settings.error)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -59,7 +69,21 @@ Selection.on_selection(SelectionName, function(event)
|
||||
|
||||
surface.set_tiles(tiles_to_make, true, "abort_on_collision", true, false, player, 0)
|
||||
local remaining_tiles = surface.count_tiles_filtered{ area = area, name = "water-mud" }
|
||||
player.remove_item{ name = "cliff-explosives", count = tile_count - remaining_tiles }
|
||||
local t_diff = tile_count - remaining_tiles
|
||||
|
||||
if item_count_cliff >= t_diff then
|
||||
player.remove_item{ name = "cliff-explosives", count = t_diff }
|
||||
else
|
||||
if item_count_cliff > 0 then
|
||||
player.remove_item{ name = "cliff-explosives", count = item_count_cliff }
|
||||
end
|
||||
local item_count_needed = t_diff - item_count_cliff
|
||||
if item_count_needed > 0 then
|
||||
player.remove_item{ name = "explosives", count = 10 * item_count_needed }
|
||||
player.remove_item{ name = "barrel", count = item_count_needed }
|
||||
player.remove_item{ name = "grenade", count = item_count_needed }
|
||||
end
|
||||
end
|
||||
|
||||
if remaining_tiles > 0 then
|
||||
player.print({ "exp-commands_waterfill.part-complete", tile_count, remaining_tiles }, Commands.print_settings.default)
|
||||
|
||||
Reference in New Issue
Block a user