maggems_landmark/init.lua
codefairy a2c34f1223 Allow players to change the name of their home nodes
This is a quick prototype; expect this to be expanded on in a later
update.
2019-08-12 20:58:47 -04:00

72 lines
2.2 KiB
Lua

minetest.register_node("maggems_landmark:home", {
description = "Misi Home",
tiles = {"maggems_landmark_home_side.png"},
is_ground_content = false,
paramtype = "light",
light_source = 3,
groups = {cracky = 1, level = 1},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Locked Chest")
meta:set_string("owner", "")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("maggems_landmark:name", "Home")
meta:set_string("infotext", meta:get_string("maggems_landmark:name") ..
" (" .. meta:get_string("owner") .. ")")
meta:set_string("formspec", "size[11,5.5]real_coordinates[true]\
field[1,2.5;9,0.5;name;Home name;${maggems_landmark:name}]")
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
if (sender ~= meta:get_string("owner")) then return false end
meta:set_string("maggems_landmark:name", fields.name)
meta:set_string("infotext", meta:get_string("maggems_landmark:name") ..
" (" .. meta:get_string("owner") .. ")")
return true
end,
on_blast = function() end,
--[[
-- TODO: proper home features
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main") and
default.can_interact_with_node(player, pos)
end,
allow_metadata_inventory_move = function(pos, from_list, from_index,
to_list, to_index, count, player)
if not default.can_interact_with_node(player, pos) then
return 0
end
return count
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if not default.can_interact_with_node(player, pos) then
return 0
end
return stack:get_count()
end
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if not default.can_interact_with_node(player, pos) then
return 0
end
return stack:get_count()
end
--]]
})
minetest.register_craft({
output = 'maggems_landmark:home',
recipe = {
{'maggems:misi'},
{'default:mese_crystal_fragment'},
}
})