mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-15 23:10:31 +01:00
Improve class switch pedestals
- Related to #183 and #216 - Holographic items are now removed when you place a new pedestal, or when you destroy it - Pedestals are only diggable by admins (but punchable with a tool handling cracky 3 level)
This commit is contained in:
parent
914594e0af
commit
9ea6923dc1
|
@ -42,18 +42,22 @@ minetest.register_entity("pclasses:item", {
|
||||||
self.object:set_properties(prop)
|
self.object:set_properties(prop)
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
print(clicker:get_player_name())
|
|
||||||
print(self.class)
|
|
||||||
pclasses.api.set_player_class(clicker:get_player_name(), self.class)
|
pclasses.api.set_player_class(clicker:get_player_name(), self.class)
|
||||||
end,
|
end,
|
||||||
on_activate = function(self, staticdata)
|
on_activate = function(self, staticdata)
|
||||||
|
local tab = minetest.deserialize(staticdata)
|
||||||
|
if tab then
|
||||||
|
self.itemname = tab.itemname
|
||||||
|
self.class = tab.class
|
||||||
|
else
|
||||||
self.itemname = staticdata:split("|")[1]
|
self.itemname = staticdata:split("|")[1]
|
||||||
self.class = staticdata:split("|")[2]
|
self.class = staticdata:split("|")[2]
|
||||||
|
end
|
||||||
self.object:set_armor_groups({immortal=1})
|
self.object:set_armor_groups({immortal=1})
|
||||||
self:set_item(self.itemname)
|
self:set_item(self.itemname)
|
||||||
end,
|
end,
|
||||||
get_staticdata = function(self)
|
get_staticdata = function(self)
|
||||||
return self.itemname .. "|" .. self.class
|
return minetest.serialize({itemname = self.itemname, class = self.class})
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -69,7 +73,6 @@ function pclasses.register_class_switch(cname, params)
|
||||||
local color = params.color or { r = 255, g = 255, b = 255 }
|
local color = params.color or { r = 255, g = 255, b = 255 }
|
||||||
local txtcolor = string.format("#%02x%02x%02x", color.r, color.g, color.b)
|
local txtcolor = string.format("#%02x%02x%02x", color.r, color.g, color.b)
|
||||||
local overlay = "pclasses_class_switch_orb_overlay.png"
|
local overlay = "pclasses_class_switch_orb_overlay.png"
|
||||||
print((params.tile or overlay))
|
|
||||||
minetest.register_node(":pclasses:class_switch_" .. cname, {
|
minetest.register_node(":pclasses:class_switch_" .. cname, {
|
||||||
description = "Class switch orb (" .. cname .. ")",
|
description = "Class switch orb (" .. cname .. ")",
|
||||||
tiles = {(params.tile or overlay) .. "^[colorize:" .. txtcolor .. ":200"},
|
tiles = {(params.tile or overlay) .. "^[colorize:" .. txtcolor .. ":200"},
|
||||||
|
@ -80,20 +83,55 @@ function pclasses.register_class_switch(cname, params)
|
||||||
{-0.25, -6/16, -0.25, 0.25, 11/16, 0.25}, -- pillar
|
{-0.25, -6/16, -0.25, 0.25, 11/16, 0.25}, -- pillar
|
||||||
{-7/16, 11/16, -7/16, 7/16, 12/16, 7/16}, -- top plate
|
{-7/16, 11/16, -7/16, 7/16, 12/16, 7/16}, -- top plate
|
||||||
}},
|
}},
|
||||||
drop = "",
|
can_dig = function(pos, player) return minetest.get_player_privs(player:get_player_name()).server == true end,
|
||||||
can_dig = function() return false end,
|
|
||||||
diggable = false,
|
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
light_source = 10,
|
light_source = 10,
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
groups = {cracky = 1},
|
groups = {unbreakable = 1},
|
||||||
after_place_node = function(pos)
|
after_place_node = function(pos)
|
||||||
pos.y = pos.y + 1
|
pos.y = pos.y + 1
|
||||||
|
|
||||||
|
-- Clean remaining entities
|
||||||
|
for _,ref in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||||
|
local e = ref:get_luaentity()
|
||||||
|
if e and e.name == "pclasses:item" then
|
||||||
|
ref:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local obj = minetest.add_entity(pos, "pclasses:item")
|
local obj = minetest.add_entity(pos, "pclasses:item")
|
||||||
if obj then
|
if obj then
|
||||||
obj:get_luaentity():set_item(classes_items[cname])
|
obj:get_luaentity():set_item(classes_items[cname])
|
||||||
obj:get_luaentity():set_class(cname)
|
obj:get_luaentity():set_class(cname)
|
||||||
end
|
end
|
||||||
|
pos.y = pos.y - 1
|
||||||
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
timer:start(3)
|
||||||
|
end,
|
||||||
|
on_timer = function(pos)
|
||||||
|
pos.y = pos.y + 1
|
||||||
|
for _,ref in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||||
|
local e = ref:get_luaentity()
|
||||||
|
if e and e.name == "pclasses:item" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local obj = minetest.add_entity(pos, "pclasses:item")
|
||||||
|
if obj then
|
||||||
|
obj:get_luaentity():set_item(classes_items[cname])
|
||||||
|
obj:get_luaentity():set_class(cname)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
on_destruct = function(pos)
|
||||||
|
pos.y = pos.y + 1
|
||||||
|
for _,ref in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||||
|
local e = ref:get_luaentity()
|
||||||
|
if e and e.name == "pclasses:item" then
|
||||||
|
ref:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user