diff --git a/formspec.lua b/formspec.lua index 8041ab9..bf1d920 100644 --- a/formspec.lua +++ b/formspec.lua @@ -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 diff --git a/init.lua b/init.lua index f4d83f8..7ebcfc5 100644 --- a/init.lua +++ b/init.lua @@ -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") diff --git a/node.lua b/node.lua index 6d1ddfa..fca1c85 100644 --- a/node.lua +++ b/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, diff --git a/textures/digibuilder.png b/textures/digibuilder.png new file mode 100644 index 0000000..dcd0d3c Binary files /dev/null and b/textures/digibuilder.png differ