chests can now be named

This commit is contained in:
kaadmy 2015-10-18 15:24:47 -07:00
parent 55dea76d3c
commit 9c314e0549
4 changed files with 64 additions and 31 deletions

View File

@ -23,6 +23,9 @@ default_privs = interact, shout, spawn, fast, player_skin
# if you're given the inital stuff; a stone pick and 10 torches
give_initial_stuff = false
# if you can name chests when the sign is below the chest; may cause problems
signs_allow_name_above = false
# possible player skins; make sure they exist in the form "player_skins_[skin].png"!
player_skins_names = male,female

View File

@ -2,6 +2,31 @@
-- Functions/ABMs
--
-- Chest naming via signs
function default.write_name(pos, text)
-- check above, if allowed
if minetest.setting_getbool("signs_allow_name_above") then
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
local abovedef = nil
if minetest.registered_nodes[minetest.get_node(above).name] then
abovedef = minetest.registered_nodes[minetest.get_node(above).name]
end
if abovedef and abovedef.write_name ~= nil then
abovedef.write_name(above, text)
end
end
-- then below
local below = {x = pos.x, y = pos.y - 1, z = pos.z}
local belowdef = nil
if minetest.registered_nodes[minetest.get_node(below).name] then
belowdef = minetest.registered_nodes[minetest.get_node(below).name]
end
if belowdef and belowdef.write_name ~= nil then
belowdef.write_name(below, text)
end
end
-- Saplings growing
function default.grow_tree(pos, variety)
@ -270,26 +295,25 @@ minetest.register_abm( -- cactus grows
minetest.register_abm( -- papyrus grows
{
nodenames = {"default:papyrus"},
neighbors = {"group:plantable_sandy"},
neighbors = {"group:plantable_sandy", "group:plantable_soil"},
interval = 20,
chance = 10,
action = function(pos, node)
pos.y = pos.y-1
local name = minetest.get_node(pos).name
if name == "default:sand" or name == "default:dirt" or name == "default:dirt_with_grass" then
if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
return
end
if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
return
end
pos.y = pos.y+1
local height = 0
while minetest.get_node(pos).name == "default:papyrus" and height < 3 do
height = height+1
pos.y = pos.y+1
local height = 0
while minetest.get_node(pos).name == "default:papyrus" and height < 3 do
height = height+1
pos.y = pos.y+1
end
if height < 3 then
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="default:papyrus"})
end
end
if height < 3 then
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="default:papyrus"})
end
end
end,
@ -332,21 +356,4 @@ minetest.register_abm( -- weak torchs burn out and die after ~3 minutes
end
})
-- if minetest.setting_getbool("flowing_water_sounds") then
-- minetest.register_abm( -- river water makes gurgling noises
-- {
-- nodenames = {"group:flowing_water"},
-- interval = 1,
-- chance = 16,
-- action = function(pos, node)
-- minetest.sound_play(
-- "default_water",
-- {
-- pos = pos,
-- gain = 0.2,
-- })
-- end
-- })
-- end
default.log("functions", "loaded")

View File

@ -1210,7 +1210,12 @@ minetest.register_node(
minetest.pos_to_string(pos))
meta:set_string("text", fields.text)
meta:set_string("infotext", '"'..fields.text..'"')
default.write_name(pos, meta:get_string("text"))
end,
on_destruct = function(pos)
default.write_name(pos, "")
end
})
minetest.register_node(
@ -1422,6 +1427,15 @@ minetest.register_node(
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
write_name = function(pos, text)
local meta = minetest.get_meta(pos)
if text ~= "" then
meta:set_string("infotext", text)
else
meta:set_string("infotext", "Chest")
end
end,
})
local form_chest = default.ui.get_page("core_2part")

View File

@ -173,6 +173,15 @@ minetest.register_node(
local inv = meta:get_inventory()
return inv:is_empty("main") and locks.is_owner(meta, player)
end,
write_name = function(pos, text)
local meta = minetest.get_meta(pos)
if text ~= "" then
meta:set_string("infotext", text .. " (Owned by " .. meta:get_string("lock_owner") .. ")")
else
meta:set_string("infotext", "Locked Chest (Owned by " .. meta:get_string("lock_owner") .. ")")
end
end,
on_blast = function() end,
})