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

Commit

Permalink
Fix nil team in ctf:settings callback
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Mar 29, 2016
1 parent cddcf97 commit 8c073e1
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions ctf_colors/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,28 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- 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 .. ", "

local pdata = ctf.player(name)
local team = ctf.team(pdata.team)
if team and ctf.can_mod(name, pdata.team) then
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
colors = colors .. color
minetest.chat_send_player(name, "Color " .. fields.color ..
" does not exist! Available: " .. colors)
end
minetest.chat_send_player(name, "Color " .. fields.color ..
" does not exist! Available: " .. colors)
elseif team then
minetest.chat_send_player(name, "You don't have the rights to change settings.")
else
minetest.chat_send_player(name, "You don't appear to be in a team")
end

return true
Expand Down

0 comments on commit 8c073e1

Please sign in to comment.