2019-08-12 19:35:56 -04:00
|
|
|
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") .. ")")
|
2019-08-12 20:58:47 -04:00
|
|
|
meta:set_string("formspec", "size[11,5.5]real_coordinates[true]\
|
|
|
|
field[1,2.5;9,0.5;name;Home name;${maggems_landmark:name}]")
|
2019-08-12 19:35:56 -04:00
|
|
|
end,
|
2019-08-12 20:58:47 -04:00
|
|
|
on_receive_fields = function(pos, formname, fields, sender)
|
|
|
|
local meta = minetest.get_meta(pos)
|
2019-08-13 21:32:22 -04:00
|
|
|
if (sender:get_player_name() ~= meta:get_string("owner")) then return false end
|
2019-08-12 20:58:47 -04:00
|
|
|
meta:set_string("maggems_landmark:name", fields.name)
|
|
|
|
meta:set_string("infotext", meta:get_string("maggems_landmark:name") ..
|
|
|
|
" (" .. meta:get_string("owner") .. ")")
|
|
|
|
return true
|
2019-08-12 19:35:56 -04:00
|
|
|
end,
|
2019-08-12 20:58:47 -04:00
|
|
|
on_blast = function() end,
|
2019-08-12 19:35:56 -04:00
|
|
|
--[[
|
|
|
|
-- 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'},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|