This commit is contained in:
BuckarooBanzay 2020-06-14 20:54:31 +02:00
parent 7da9603d13
commit 40ab039591
4 changed files with 19 additions and 9 deletions

@ -1,14 +1,19 @@
function digibuilder.update_formspec(meta)
local message = meta:get_string("message")
local formspec =
"size[8,9;]" ..
"size[8,9.2;]" ..
-- main inventory
"list[context;main;0,3.25;8,1;]" ..
"list[context;main;0,0.25;8,4;]" ..
-- player inventory
"list[current_player;main;0,4.5;8,4;]" ..
-- message
"label[0,8.7;" .. message .. "]" ..
-- digiline channel
"field[4.3,9;3.2,1;digiline_channel;Digiline channel;" .. (meta:get_string("channel") or "") .. "]" ..
"button_exit[7,8.7;1,1;set_digiline_channel;Set]" ..
@ -18,4 +23,5 @@ function digibuilder.update_formspec(meta)
"listring[current_player;main]"
meta:set_string("formspec", formspec)
meta:set_string("infotext", "Digibuilder: " .. message)
end

@ -5,5 +5,6 @@ local MP = minetest.get_modpath("digibuilder")
-- common functions
dofile(MP.."/common.lua")
dofile(MP.."/formspec.lua")
dofile(MP.."/digiline.lua")
dofile(MP.."/node.lua")

@ -46,8 +46,6 @@ minetest.register_node("digibuilder:digibuilder", {
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
-- default digiline channel
meta:set_string("channel", "digibuilder")
end,
on_construct = function(pos)
@ -62,6 +60,12 @@ minetest.register_node("digibuilder:digibuilder", {
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
-- default digiline channel
meta:set_string("channel", "digibuilder")
-- last message
meta:set_string("message", "Ready!")
-- formspec
digibuilder.update_formspec(meta)
end,
@ -71,9 +75,7 @@ minetest.register_node("digibuilder:digibuilder", {
local inv = meta:get_inventory()
local name = player:get_player_name()
return inv:is_empty("main") and
inv:is_empty("upgrade") and
not minetest.is_protected(pos, name)
return inv:is_empty("main") and not minetest.is_protected(pos, name)
end,
on_timer = function()--pos, elapsed)
@ -95,8 +97,9 @@ minetest.register_node("digibuilder:digibuilder", {
end
if fields.save then
print("save")
if fields.set_digiline_channel then
local meta = minetest.get_meta(pos);
meta:set_string("channel", fields.digiline_channel or "")
end
end,

BIN
textures/digibuilder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB