Hint discovery by looktips
No touching necessary anymore
This commit is contained in:
parent
f7461414d2
commit
3c41155550
@ -55,13 +55,15 @@ minetest.register_entity(":__builtin:falling_node", {
|
|||||||
|
|
||||||
on_activate = function(self, data)
|
on_activate = function(self, data)
|
||||||
self.object:set_armor_groups({immortal = 1})
|
self.object:set_armor_groups({immortal = 1})
|
||||||
return data_load(self, data)
|
data_load(self, data)
|
||||||
|
self.represents_item = self.node and self.node.name
|
||||||
end,
|
end,
|
||||||
|
|
||||||
set_node = function(self, node, meta)
|
set_node = function(self, node, meta)
|
||||||
if not node then return self.object:remove() end
|
if not node then return self.object:remove() end
|
||||||
|
|
||||||
self.node = node
|
self.node = node
|
||||||
|
self.represents_item = self.node and self.node.name
|
||||||
local def = minetest.registered_items[node.name]
|
local def = minetest.registered_items[node.name]
|
||||||
if def.falling_replacement then
|
if def.falling_replacement then
|
||||||
self.node.name = def.falling_replacement
|
self.node.name = def.falling_replacement
|
||||||
|
@ -31,7 +31,9 @@ minetest.register_entity(":__builtin:item", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
set_item = function(self, item)
|
set_item = function(self, item)
|
||||||
item = item and ItemStack(item):to_string()
|
local stack = ItemStack(item)
|
||||||
|
item = item and stack:to_string()
|
||||||
|
self.represents_item = stack:get_name()
|
||||||
if item and item ~= self.itemstring then
|
if item and item ~= self.itemstring then
|
||||||
self.itemstring = item
|
self.itemstring = item
|
||||||
self.object:set_yaw(math_random() * math_pi * 2)
|
self.object:set_yaw(math_random() * math_pi * 2)
|
||||||
|
@ -114,11 +114,12 @@ nodecore.register_on_chat_message("chat message stats", function(name, msg)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
-- PLAYER INVENTORY SCAN
|
-- PLAYER SCAN
|
||||||
|
|
||||||
nodecore.register_playerstep({
|
nodecore.register_playerstep({
|
||||||
label = "inv",
|
label = "inv",
|
||||||
action = function(player)
|
action = function(player, data)
|
||||||
|
-- inventory
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
local t = {}
|
local t = {}
|
||||||
for i = 1, inv:get_size("main") do
|
for i = 1, inv:get_size("main") do
|
||||||
@ -130,5 +131,23 @@ nodecore.register_playerstep({
|
|||||||
for k in pairs(t) do
|
for k in pairs(t) do
|
||||||
discover(player, "inv:" .. k)
|
discover(player, "inv:" .. k)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- looking at
|
||||||
|
local pt = data.raycast()
|
||||||
|
if pt then
|
||||||
|
if pt.type == "node" then
|
||||||
|
local nn = minetest.get_node(pt.under).name
|
||||||
|
discover(player, "look:" .. nn)
|
||||||
|
local stack = nodecore.stack_get(pt.under)
|
||||||
|
if stack and not stack:is_empty() then
|
||||||
|
discover(player, "look:" .. stack:get_name())
|
||||||
|
end
|
||||||
|
elseif pt.type == "object" then
|
||||||
|
local luaent = pt.ref:get_luaentity()
|
||||||
|
if luaent and luaent.represents_item then
|
||||||
|
discover(player, "look:" .. luaent.represents_item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user