2019-03-21 01:36:59 +00:00
|
|
|
ctf_classes = {
|
|
|
|
__classes = {},
|
|
|
|
__classes_ordered = {},
|
|
|
|
}
|
|
|
|
|
|
|
|
dofile(minetest.get_modpath("ctf_classes") .. "/api.lua")
|
|
|
|
dofile(minetest.get_modpath("ctf_classes") .. "/gui.lua")
|
2020-05-14 17:26:28 +00:00
|
|
|
dofile(minetest.get_modpath("ctf_classes") .. "/medic.lua")
|
2019-03-22 04:01:36 +00:00
|
|
|
dofile(minetest.get_modpath("ctf_classes") .. "/ranged.lua")
|
2020-10-13 15:42:41 +00:00
|
|
|
dofile(minetest.get_modpath("ctf_classes") .. "/melee.lua")
|
2020-03-13 21:58:42 +00:00
|
|
|
dofile(minetest.get_modpath("ctf_classes") .. "/items.lua")
|
2020-03-14 19:56:40 +00:00
|
|
|
dofile(minetest.get_modpath("ctf_classes") .. "/flags.lua")
|
|
|
|
dofile(minetest.get_modpath("ctf_classes") .. "/classes.lua")
|
2020-03-14 17:22:55 +00:00
|
|
|
|
2019-03-22 04:31:57 +00:00
|
|
|
|
|
|
|
minetest.register_on_joinplayer(function(player)
|
|
|
|
ctf_classes.update(player)
|
|
|
|
|
2020-06-04 16:45:13 +00:00
|
|
|
if ctf_classes.can_change(player) and
|
|
|
|
minetest.check_player_privs(player, { interact = true }) then
|
|
|
|
ctf_classes.show_gui(player:get_player_name(), player)
|
2019-03-22 04:31:57 +00:00
|
|
|
end
|
|
|
|
end)
|
2019-03-21 01:36:59 +00:00
|
|
|
|
|
|
|
minetest.register_chatcommand("class", {
|
|
|
|
func = function(name, params)
|
|
|
|
local player = minetest.get_player_by_name(name)
|
|
|
|
if not player then
|
|
|
|
return false, "You must be online to do this!"
|
|
|
|
end
|
|
|
|
|
2020-06-04 16:45:13 +00:00
|
|
|
local can_change, reason = ctf_classes.can_change(player)
|
|
|
|
if not can_change then
|
|
|
|
return false, reason
|
2019-03-21 01:36:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local cname = params:trim()
|
|
|
|
if params == "" then
|
|
|
|
ctf_classes.show_gui(name)
|
|
|
|
else
|
|
|
|
if ctf_classes.__classes[cname] then
|
|
|
|
ctf_classes.set(player, cname)
|
|
|
|
return true, "Set class to " .. cname
|
|
|
|
else
|
|
|
|
return false, "Class '" .. cname .. "' does not exist"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
ctf_colors.set_skin = function(player, color)
|
|
|
|
ctf_classes.set_skin(player, color, ctf_classes.get(player))
|
|
|
|
end
|
|
|
|
|
2020-03-13 21:58:42 +00:00
|
|
|
ctf_classes.register_on_changed(function(player, old, new)
|
|
|
|
if not old then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
ctf.chat_send_team(ctf.player(pname).team,
|
|
|
|
minetest.colorize("#ABCDEF", pname .. " is now a " .. new.description))
|
|
|
|
end)
|