Code: Select all
--HOMEWORK: Make a functioning sticky-note node that stores user-written
--text. Requires Formspec and Meta knowledge
minetest.register_node("tutorial:formspecSN", {
description = "wriiiitteee oooonnn meeeeeee(write on me)",
drawtype = "mesh",
mesh = "stickyNote.obj",
tiles = {"stickyNote.png"},
groups = {cracky=3},
selection_box = {
type = "fixed",
fixed = {-4/16,-1,-4/16,4/16,-5/16,4/16},
},
collision_box = {
type = "fixed",
fixed = {-4/16,-1,-4/16,4/16,-5/16,4/16},
},
on_construct = function(pos)
meta = minetest.get_meta(pos)
meta:set_string("scribbles", "Blah")
meta:set_int("written", 0)
end,
on_punch = (function(pos, node, player, pointed_thing)
meta = minetest.get_meta(pos)
minetest.show_formspec("Tacos", "tutorial:form",
"size[4 ,3]" ..
"label[0,0;Hello, " .. "Tacos" .. "]" ..
"field[1,1.5;3,1;name;Name;]" ..
"button_exit[1,2;2,1;exit;Save]")
if meta:get_int("written") == 0 then
minetest.chat_send_all("W=0")
else
minetest.chat_send_all("W!=0")
end
--~ minetest.chat_send_all("Notepad Was Punched")
--~ local value = meta:get_string("scribbles")
--~ minetest.chat_send_all(value)
end),
})