Skip to content

Commit

Permalink
Merge branch 'MT-CTF:master' into destructify-and-indestructify
Browse files Browse the repository at this point in the history
  • Loading branch information
src4026 authored Dec 17, 2023
2 parents 6271a2a + 266bc48 commit b17459a
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
94 changes: 94 additions & 0 deletions mods/ctf/ctf_map/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,100 @@ minetest.register_chatcommand("map", {
end
})

minetest.register_chatcommand("ctf_barrier", {
description = "Place or remove map barriers\n" ..
"place_buildtime: Within the selected area, replace certain nodes with the " ..
"corresponding build-time barrier\nremove_buildtime: Remove build-time " ..
"barriers within the selected area\nplace_outer: Surrounds the selected area " ..
"with an indestructible glass/stone barrier",
privs = {ctf_map_editor = true},
params = "[place_buildtime] | [remove_buildtime] | [place_outer]",
func = function(name, params)
if not params or params == "" then
return false, "See /help ctf_barrier for usage instructions"
end

if ctf_core.settings.server_mode ~= "mapedit" then
return false, minetest.colorize("red", "You have to be in mapedit mode to run this")
end

if params ~= "place_buildtime" and params ~= "remove_buildtime" and params ~= "place_outer" then
return false
end

if params == "place_outer" then
minetest.chat_send_player(name,
minetest.colorize("yellow", "Warning: this action can't be undone"))
end

ctf_map.get_pos_from_player(name, 2, function(p, positions)
local pos1, pos2 = vector.sort(positions[1], positions[2])

if params == "place_buildtime" and pos1.x ~= pos2.x and pos1.z ~= pos2.z then
minetest.chat_send_player(name, minetest.colorize("yellow",
"Warning: your build-time barrier is more than 1 node thick, " ..
"use /ctf_barrier remove_buildtime to remove unwanted parts"))
end

for x = pos1.x, pos2.x do
for y = pos1.y, pos2.y do
for z = pos1.z, pos2.z do
if params == "place_buildtime" then
local current_pos = {x = x, y = y, z = z}
local current_node = minetest.get_node_or_nil(current_pos)
if current_node then
if current_node.name == "air" then
minetest.set_node(current_pos, {name = "ctf_map:ind_glass_red"})
elseif current_node.name == "default:stone" then
minetest.set_node(current_pos, {name = "ctf_map:ind_stone_red"})
elseif current_node.name == "default:water_source" then
minetest.set_node(current_pos, {name = "ctf_map:ind_water"})
elseif current_node.name == "default:lava_source" then
minetest.set_node(current_pos, {name = "ctf_map:ind_lava"})
end
end
elseif params == "remove_buildtime" then
local current_pos = {x = x, y = y, z = z}
local current_node = minetest.get_node_or_nil(current_pos)
if current_node then
if current_node.name == "ctf_map:ind_glass_red" then
minetest.set_node(current_pos, {name = "air"})
elseif current_node.name == "ctf_map:ind_stone_red" then
minetest.set_node(current_pos, {name = "default:stone"})
elseif current_node.name == "ctf_map:ind_water" then
minetest.set_node(current_pos, {name = "default:water_source"})
elseif current_node.name == "ctf_map:ind_lava" then
minetest.set_node(current_pos, {name = "default:lava_source"})
end
end
elseif params == "place_outer" then
local current_pos = {x = x, y = y, z = z}
if x == pos1.x or x == pos2.x or y == pos1.y
or z == pos1.z or z == pos2.z then
local current_node = minetest.get_node_or_nil(current_pos)
if current_node then
if current_node.name == "air" or
current_node.name == "ctf_map:ignore" or
current_node.name == "ignore" then
minetest.set_node(current_pos, {name = "ctf_map:ind_glass"})
else
minetest.set_node(current_pos, {name = "ctf_map:stone"})
end
end
end
end
end
end
end
local message =
(params == "place_buildtime" and "Build-time barrier placed") or
(params == "remove_buildtime" and "Build-time barrier removed") or
(params == "place_outer" and "Outer barrier placed")
minetest.chat_send_player(name, message)
end)
end
})

-- Attempt to restore user's time speed after server close
local TIME_SPEED = minetest.settings:get("time_speed")

Expand Down
2 changes: 1 addition & 1 deletion mods/ctf/ctf_modebase/features.lua
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ return {
"5 captures, and at least 8,000 score to access the pro section."
if rank then
local captures_needed = math.max(0, 5 - (rank.flag_captures or 0))
local score_needed = math.max(math.max(0, 8000 - (rank.score or 0)))
local score_needed = math.floor(math.max(0, 8000 - (rank.score or 0)))
local current_kd = math.floor((rank.kills or 0) / (rank.deaths or 1) * 10)
current_kd = current_kd / 10
deny_pro = deny_pro .. " You still need " .. captures_needed
Expand Down

0 comments on commit b17459a

Please sign in to comment.