2018-07-22 21:46:35 +02:00
|
|
|
|
|
|
|
local FORMNAME = "mission_wand_name"
|
|
|
|
|
2019-07-01 13:04:38 +02:00
|
|
|
missions.can_create_wand = function(player, pos)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2018-07-22 21:46:35 +02:00
|
|
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|
|
|
local parts = formname:split(";")
|
|
|
|
local name = parts[1]
|
|
|
|
if name ~= FORMNAME then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local pos = minetest.string_to_pos(parts[2])
|
2018-07-23 20:58:08 +02:00
|
|
|
local posStr = minetest.pos_to_string(pos)
|
|
|
|
local node = minetest.get_node(pos)
|
2018-07-22 21:46:35 +02:00
|
|
|
|
|
|
|
if not fields.name then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2019-07-01 13:04:38 +02:00
|
|
|
if not missions.can_create_wand(player, pos) then
|
|
|
|
return
|
|
|
|
end
|
2018-07-23 20:58:08 +02:00
|
|
|
|
2018-07-22 21:46:35 +02:00
|
|
|
local inv = player:get_inventory()
|
2018-08-08 08:31:28 +02:00
|
|
|
local type = "Position"
|
2018-07-22 21:46:35 +02:00
|
|
|
local stack = ItemStack("missions:wand_position")
|
|
|
|
|
2018-07-24 11:10:17 +02:00
|
|
|
if node.name == "default:chest" or node.name == "default:chest_locked" or node.name == "more_chests:dropbox" then
|
2018-07-23 20:58:08 +02:00
|
|
|
stack = ItemStack("missions:wand_chest")
|
2018-08-08 08:31:28 +02:00
|
|
|
type = "Chest"
|
|
|
|
end
|
|
|
|
|
|
|
|
if node.name == "missions:mission" then
|
|
|
|
stack = ItemStack("missions:wand_mission")
|
|
|
|
type = "Mission"
|
2018-07-23 20:58:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local meta = stack:get_meta()
|
2018-07-22 21:46:35 +02:00
|
|
|
meta:set_string("pos", posStr)
|
|
|
|
meta:set_string("name", fields.name)
|
2019-07-30 12:56:56 +02:00
|
|
|
meta:set_string("description", "Mission wand (" .. type .. "): " .. posStr ..
|
|
|
|
" with name: '" .. fields.name ..
|
2018-07-23 20:58:08 +02:00
|
|
|
"' and node '" .. node.name .. "'")
|
2018-07-22 21:46:35 +02:00
|
|
|
|
|
|
|
if inv:contains_item("main", "missions:wand") and inv:room_for_item("main", stack) then
|
|
|
|
inv:remove_item("main", "missions:wand")
|
|
|
|
inv:add_item("main", stack)
|
|
|
|
end
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
missions.form.wand = function(pos, player)
|
|
|
|
local formspec = "size[8,1;]" ..
|
|
|
|
"field[0,0.5;6,1;name;Name;]" ..
|
2018-09-07 14:59:16 +02:00
|
|
|
"button_exit[6,0.1;2,1;save;Save]" ..
|
2018-09-07 15:18:34 +02:00
|
|
|
missions.SMALLFORMBG
|
2018-07-22 21:46:35 +02:00
|
|
|
|
|
|
|
minetest.show_formspec(player:get_player_name(),
|
|
|
|
FORMNAME .. ";" .. minetest.pos_to_string(pos),
|
|
|
|
formspec
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|