local createNodeFormspec(value)
return "size[5,5]"..
"label[1,1;This is shown on right click]"..
"field[1,2;2,1;x;x;" .. value .. "]"
end
-- in the node definition:
after_place_node = function(pos, placer)
-- This function is run when the chest node is placed.
-- The following code sets the formspec for chest.
-- Meta is a way of storing data onto a node.
local meta = minetest.get_meta(pos)
if not meta then
return
end
meta:set_string("value", default_value)
meta:set_string("formspec", createNodeFormspec( meta:get_string("value") ))
end,
on_receive_fields = function(pos, formname, fields, player)
if(fields.quit) then
return
end
local meta = minetest.get_meta(pos)
if not meta then
return
end
meta:set_string("value", fields.x)
meta:set_string("formspec", createNodeFormspec( meta:get_string("value") ))
end
meta:set_string("value", "")local default_value= ""
meta:set_string("value", default_value)Users browsing this forum: No registered users and 15 guests