add naming tweaks to items

This commit is contained in:
wsor 2021-06-05 19:44:13 -04:00
parent d07b12ea9f
commit 404f3caefb
3 changed files with 36 additions and 5 deletions

View File

@ -6,5 +6,11 @@ minetest.register_on_joinplayer(function(player)
if pinfo.formspec_version < 4 then
minetest.kick_player(player:get_player_name(), "please use a formspec v4 client (5.4) client")
end
end
)
end)
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
if itemstack:get_meta():get_string("description") ~= "" then
local meta = minetest.get_meta(pos)
meta:set_string("description", itemstack:get_meta():get_string("description"))
end
end)

View File

@ -29,6 +29,11 @@ minetest.register_node("fl_storage:wood_chest", {
elseif rLength == 10 then slotSize, formSize = 0.89, "10.4,9.97"
else slotSize, formSize = 1, "10.4,10.3" end
if minetest.get_meta(pos):get_string("description") ~= "" then
chName = minetest.get_meta(pos):get_string("description")
minetest.get_meta(pos):set_string("infotext", minetest.get_meta(pos):get_string("description"))
end
--header of formspec
local formspec = {
"formspec_version[4]",
@ -79,7 +84,7 @@ minetest.register_node("fl_storage:wood_chest", {
--show formspec
local chest_formspec = table.concat(formspec, "")
minetest.show_formspec(clicker:get_player_name(), "fl_wildlife:trader_formspec", chest_formspec)
minetest.show_formspec(clicker:get_player_name(), "fl_storage:chest_formspec", chest_formspec)
end,
on_dig = function(pos, node, digger)
local inv = minetest.get_inventory({type="node", pos=pos})
@ -93,6 +98,11 @@ minetest.register_node("fl_storage:wood_chest", {
end
minetest.node_dig(pos, node, digger)
end,
preserve_metadata = function(pos, oldnode, oldmeta, drops)
if minetest.get_meta(pos):get_string("description") ~= "" then
drops[1]:get_meta():set_string("description", minetest.get_meta(pos):get_string("description"))
end
end,
})
local function shelf_nodes(name)
@ -131,6 +141,11 @@ local function shelf_nodes(name)
elseif rLength == 10 then slotSize, formSize = 0.89, "10.4,7.77"
else slotSize, formSize = 1, "10.4,8.1" end
if minetest.get_meta(pos):get_string("description") ~= "" then
cname = minetest.get_meta(pos):get_string("description")
minetest.get_meta(pos):set_string("infotext", minetest.get_meta(pos):get_string("description"))
end
--header of formspec
local formspec = {
"formspec_version[4]",
@ -182,7 +197,7 @@ local function shelf_nodes(name)
table.insert(formspec, "listring[current_player;main]")
local shelf_formspec = table.concat(formspec, "")
minetest.show_formspec(clicker:get_player_name(), "fl_wildlife:trader_formspec", shelf_formspec)
minetest.show_formspec(clicker:get_player_name(), "fl_storage:shelf_formspec", shelf_formspec)
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if overlay == "vessel" or overlay == "book" then
@ -205,6 +220,11 @@ local function shelf_nodes(name)
end
minetest.node_dig(pos, node, digger)
end,
preserve_metadata = function(pos, oldnode, oldmeta, drops)
if minetest.get_meta(pos):get_string("description") ~= "" then
drops[1]:get_meta():set_string("description", minetest.get_meta(pos):get_string("description"))
end
end,
on_place = minetest.rotate_node,
groups = group,
})

View File

@ -24,7 +24,12 @@ function fl_wildlife.egg_it(t_name, d_name, color)
inventory_image = "farlands_egg.png^(farlands_egg_overlay.png^[colorize:" .. color .. ")", --"404.png",
stack_max = 99,
on_place = function(itemstack, placer, pointed_thing)
minetest.add_entity(pointed_thing.above, t_name)
local ent = minetest.add_entity(pointed_thing.above, t_name)
if itemstack:get_meta():get_string("description") ~= "" then
local self = ent:get_luaentity()
self.object:set_properties({nametag = itemstack:get_meta():get_string("description"),})
mobkit.remember(self,"nametag",itemstack:get_meta():get_string("description"))
end
end,
})
end