Skip to content
This repository was archived by the owner on Aug 20, 2020. It is now read-only.

Commit 6d63e41

Browse files
committed
Added holographic entity and pedestals as switch 'orbs'
- Modified class orb to be pedestals with floating entity above
1 parent 1e76bd1 commit 6d63e41

File tree

1 file changed

+83
-6
lines changed

1 file changed

+83
-6
lines changed

mods/pclasses/nodes.lua

+83-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,97 @@
1+
minetest.register_entity("pclasses:item", {
2+
initial_properties = {
3+
hp_max = 1,
4+
physical = false,
5+
collisionbox = {-0.17,-0.17,-0.17, 0.17,0.17,0.17},
6+
visual = "sprite",
7+
visual_size = {x=0.5, y=0.5},
8+
textures = {""},
9+
spritediv = {x=1, y=1},
10+
initial_sprite_basepos = {x=0, y=0},
11+
is_visible = false,
12+
},
13+
itemname = '',
14+
class = '',
15+
set_class = function(self, class)
16+
self.class = class
17+
end,
18+
set_item = function(self, itemstring)
19+
self.itemname = itemstring
20+
local itemname = itemstring
21+
local item_texture = nil
22+
local item_type = ""
23+
if minetest.registered_items[itemname] then
24+
item_texture = minetest.registered_items[itemname].inventory_image
25+
item_type = minetest.registered_items[itemname].type
26+
end
27+
local prop = {
28+
is_visible = true,
29+
visual = "sprite",
30+
textures = {"unknown_item.png"}
31+
}
32+
if item_texture and item_texture ~= "" then
33+
prop.visual = "sprite"
34+
prop.textures = {item_texture}
35+
prop.visual_size = {x=0.50, y=0.50}
36+
else
37+
prop.visual = "wielditem"
38+
prop.textures = {itemname}
39+
prop.visual_size = {x=0.25, y=0.25}
40+
prop.automatic_rotate = math.pi * 0.10
41+
end
42+
self.object:set_properties(prop)
43+
end,
44+
on_rightclick = function(self, clicker)
45+
print(clicker:get_player_name())
46+
print(self.class)
47+
pclasses.api.set_player_class(clicker:get_player_name(), self.class)
48+
end,
49+
on_activate = function(self, staticdata)
50+
self.itemname = staticdata:split("|")[1]
51+
self.class = staticdata:split("|")[2]
52+
-- self.object:set_armor_groups({immortal=1})
53+
self:set_item(self.itemname)
54+
end,
55+
get_staticdata = function(self)
56+
return self.itemname .. "|" .. self.class
57+
end,
58+
})
59+
60+
local classes_items = {
61+
["hunter"] = "throwing:bow_minotaur_horn_improved",
62+
["warrior"] = "default:dungeon_master_s_blood_sword",
63+
["admin"] = "maptools:pick_admin",
64+
["adventurer"] = "unified_inventory:bag_large"
65+
}
66+
167
function pclasses.register_class_switch_orb(cname, color)
268
color = color or { r = 255, g = 255, b = 255 }
369
local txtcolor = string.format("#%02x%02x%02x", color.r, color.g, color.b)
470
local overlay = "pclasses_class_switch_orb_overlay.png"
5-
minetest.register_node(":pclasses:class_switch_orb_" .. cname, {
71+
minetest.register_node(":pclasses:class_switch_" .. cname, {
672
description = "Class switch orb (" .. cname .. ")",
773
tiles = {overlay .. "^[colorize:" .. txtcolor .. "^" .. overlay},
74+
drawtype = "nodebox",
75+
node_box = { type = "fixed", fixed = {
76+
{-7/16, -8/16, -7/16, 7/16, -7/16, 7/16}, -- bottom plate
77+
{-6/16, -7/16, -6/16, 6/16, -6/16, 6/16}, -- bottom plate (upper)
78+
{-0.25, -6/16, -0.25, 0.25, 11/16, 0.25}, -- pillar
79+
{-7/16, 11/16, -7/16, 7/16, 12/16, 7/16}, -- top plate
80+
}},
881
drop = "",
982
can_dig = function() return false end,
1083
diggable = false,
1184
sunlight_propagates = true,
1285
light_source = 10,
1386
sounds = default.node_sound_glass_defaults(),
14-
groups = {not_in_creative_inventory=1},
15-
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
16-
-- TODO implement timeout logic
17-
pclasses.api.set_player_class(player:get_player_name(), cname)
18-
end
87+
groups = {not_in_creative_inventory=1, cracky = 1},
88+
after_place_node = function(pos)
89+
pos.y = pos.y + 1
90+
local obj = minetest.add_entity(pos, "pclasses:item")
91+
if obj then
92+
obj:get_luaentity():set_item(classes_items[cname])
93+
obj:get_luaentity():set_class(cname)
94+
end
95+
end,
1996
})
2097
end

0 commit comments

Comments
 (0)