mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-12 11:00:25 +01:00
[pclasses & mff_pclasses] Use implicit on_update
- After executing on_unassigned and on_assigned, implicitly call on_update (or add a dummy on_update for assigning if there is none)
This commit is contained in:
parent
126ce0d7e4
commit
b0ba6a7956
@ -11,12 +11,9 @@ pclasses.api.register_class("admin", {
|
||||
if inform then
|
||||
minetest.chat_send_player(pname, "Hello admin.")
|
||||
end
|
||||
pclasses.api.util.on_update(pname)
|
||||
end,
|
||||
on_unassigned = function(pname)
|
||||
end,
|
||||
on_update = function(pname)
|
||||
end,
|
||||
switch_params = {
|
||||
color = {r = 255, g = 00, b = 224},
|
||||
holo_item = "maptools:pick_admin"
|
||||
|
@ -12,7 +12,6 @@ pclasses.api.register_class("hunter", {
|
||||
minetest.chat_send_player(pname, "You are now a hunter")
|
||||
minetest.sound_play("pclasses_full_hunter", {to_player=pname, gain=1})
|
||||
end
|
||||
pclasses.api.util.on_update(pname)
|
||||
minetest.log("action", "[PClasses] Player " .. pname .. " become a hunter")
|
||||
end,
|
||||
on_unassigned = function(pname)
|
||||
|
@ -12,7 +12,6 @@ pclasses.api.register_class("warrior", {
|
||||
minetest.sound_play("pclasses_full_warrior", {to_player=pname, gain=1})
|
||||
minetest.chat_send_player(pname, "You are now a warrior")
|
||||
end
|
||||
pclasses.api.util.on_update(pname)
|
||||
minetest.log("action", "[PClasses] Player " .. pname .. " becomes a warrior")
|
||||
end,
|
||||
on_unassigned = function(pname)
|
||||
|
@ -13,7 +13,6 @@ pclasses.api.register_class("wizard", {
|
||||
minetest.chat_send_player(pname, "You are now a wizard.")
|
||||
end
|
||||
-- Add specs here
|
||||
pclasses.api.util.on_update(pname)
|
||||
minetest.log("action", "[PClasses] Player " .. pname .. " becomes a wizard")
|
||||
end,
|
||||
on_unassigned = function(pname)
|
||||
|
@ -56,9 +56,17 @@ function pclasses.api.set_player_class(pname, cname, inform)
|
||||
if pclasses.api.get_class_by_name(cname) then
|
||||
if pclasses.api.get_player_class(pname) then
|
||||
pclasses.api.get_class_by_name(pclasses.api.get_player_class(pname)).on_unassigned(pname)
|
||||
pclasses.api.get_class_by_name(pclasses.api.get_player_class(pname)).on_update(pname)
|
||||
end
|
||||
pclasses.data.players[pname] = cname
|
||||
pclasses.api.get_class_by_name(cname).on_assigned(pname, inform)
|
||||
local newclass = pclasses.api.get_class_by_name(cname)
|
||||
newclass.on_assigned(pname, inform)
|
||||
-- Implicit call to on_update because we don't wanna repeat it
|
||||
if newclass.on_update then
|
||||
newclass.on_update(pname)
|
||||
else
|
||||
newclass.on_update = function(pname) end -- So that it won't annoy us later
|
||||
end
|
||||
|
||||
local ref = minetest.get_player_by_name(pname)
|
||||
local armor_inv = minetest.get_inventory({type = "detached", name = pname .. "_armor"})
|
||||
|
Loading…
Reference in New Issue
Block a user