Skip to content
This repository has been archived by the owner on Aug 29, 2019. It is now read-only.

Commit

Permalink
Clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Nov 22, 2015
1 parent 85d0eda commit b72072c
Show file tree
Hide file tree
Showing 10 changed files with 456 additions and 458 deletions.
1 change: 0 additions & 1 deletion ctf/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ function ctf.init()
ctf._set("maximum_in_team", -1)
ctf._set("default_diplo_state", "war")
ctf._set("hud", true)
ctf._set("remove_player_on_leave", false)
ctf._set("autoalloc_on_joinplayer", true)
ctf._set("friendly_fire", true)

Expand Down
6 changes: 0 additions & 6 deletions ctf/teams.lua
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,6 @@ minetest.register_on_joinplayer(function(player)
end
end)

minetest.register_on_leaveplayer(function(player)
if ctf.setting("remove_player_on_leave") then
ctf.remove_player(player:get_player_name())
end
end)

-- Disable friendly fire.
minetest.register_on_punchplayer(function(player, hitter)
if player and hitter then
Expand Down
4 changes: 2 additions & 2 deletions ctf_chat/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ minetest.register_chatcommand("t", {
})

-- Chat plus stuff
if chatplus then
if minetest.global_exists("chatplus") then
chatplus.register_handler(function(from, to, msg)
if not ctf.setting("chat.team_channel") then
-- Send to global
return nil
end

if ctf.setting("chat.default") ~= "team" then
if ctf.player(from).team then
minetest.chat_send_player(to, ctf.player(from).team ..
Expand Down
49 changes: 49 additions & 0 deletions ctf_colors/gui.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

ctf.gui.register_tab("settings", "Settings", function(name, team)
local color = ""
if ctf.team(team).data.color then
color = ctf.team(team).data.color
end

local result = "field[3,2;4,1;color;Team Color;" .. color .. "]" ..
"button[4,6;2,1;save;Save]"


if not ctf.can_mod(name,team) then
result = "label[0.5,1;You do not own this team!"
end

minetest.show_formspec(name, "ctf:settings",
"size[10,7]" ..
ctf.gui.get_tabs(name, team) ..
result
)
end)

minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "ctf:settings" then
return false
end

-- Settings page
if fields.save then
ctf.gui.show(name, "settings")

if ctf.flag_colors[fields.color] then
team.data.color = fields.color
ctf.needs_save = true
else
local colors = ""
for color, code in pairs(ctf.flag_colors) do
if colors ~= "" then
colors = colors .. ", "
end
colors = colors .. color
end
minetest.chat_send_player(name, "Color " .. fields.color ..
" does not exist! Available: " .. colors)
end

return true
end
end)
32 changes: 32 additions & 0 deletions ctf_colors/hud.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ctf.hud.register_part(function(player, name, tplayer)
local text_color = ctf.team(tplayer.team).data.color
local color = ctf.flag_colors[text_color]
if not color then
color = "0x000000"
end

if ctf.setting("colors.nametag") then
player:set_nametag_attributes({ color = "0xFF" .. string.sub(color, 3) })
end

if ctf.setting("colors.skins") and text_color and color then
player:set_properties({
textures = {"ctf_colors_skin_" .. text_color .. ".png"},
})
end

if not ctf.hud:exists(player, "ctf:hud_team") then
ctf.hud:add(player, "ctf:hud_team", {
hud_elem_type = "text",
position = {x = 1, y = 0},
scale = {x = 100, y = 100},
text = "Team " .. tplayer.team,
number = color,
offset = {x = -20, y = 20},
alignment = {x = -1, y = 0}
})
else
ctf.hud:change(player, "ctf:hud_team", "text", "Team " .. tplayer.team)
ctf.hud:change(player, "ctf:hud_team", "number", color)
end
end)
83 changes: 2 additions & 81 deletions ctf_colors/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,84 +19,5 @@ ctf.register_on_init(function()
ctf._set("colors.nametag", true)
end)

ctf.hud.register_part(function(player, name, tplayer)
local text_color = ctf.team(tplayer.team).data.color
local color = ctf.flag_colors[text_color]
if not color then
color = "0x000000"
end

if ctf.setting("colors.nametag") then
player:set_nametag_attributes({ color = "0xFF" .. string.sub(color, 3) })
end

if ctf.setting("colors.skins") and text_color and color then
player:set_properties({
textures = {"ctf_colors_skin_" .. text_color .. ".png"},
})
end

if not ctf.hud:exists(player, "ctf:hud_team") then
ctf.hud:add(player, "ctf:hud_team", {
hud_elem_type = "text",
position = {x = 1, y = 0},
scale = {x = 100, y = 100},
text = "Team " .. tplayer.team,
number = color,
offset = {x = -20, y = 20},
alignment = {x = -1, y = 0}
})
else
ctf.hud:change(player, "ctf:hud_team", "text", "Team " .. tplayer.team)
ctf.hud:change(player, "ctf:hud_team", "number", color)
end
end)

ctf.gui.register_tab("settings", "Settings", function(name, team)
local color = ""
if ctf.team(team).data.color then
color = ctf.team(team).data.color
end

local result = "field[3,2;4,1;color;Team Color;" .. color .. "]" ..
"button[4,6;2,1;save;Save]"


if not ctf.can_mod(name,team) then
result = "label[0.5,1;You do not own this team!"
end

minetest.show_formspec(name, "ctf:settings",
"size[10,7]" ..
ctf.gui.get_tabs(name, team) ..
result
)
end)

minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "ctf:settings" then
return false
end

-- Settings page
if fields.save then
ctf.gui.show(name, "settings")

if ctf.flag_colors[fields.color] then
team.data.color = fields.color
ctf.needs_save = true
else
local colors = ""
for color, code in pairs(ctf.flag_colors) do
if colors ~= "" then
colors = colors .. ", "
end
colors = colors .. color
end
minetest.chat_send_player(name, "Color " .. fields.color ..
" does not exist! Available: " .. colors)
end

return true
end
end)
dofile(minetest.get_modpath("ctf_colors") .. "/hud.lua")
dofile(minetest.get_modpath("ctf_colors") .. "/gui.lua")

0 comments on commit b72072c

Please sign in to comment.