Page 1 of 1

Formspec in mod not showing up.

Posted: Tue Jun 26, 2018 14:12
by MusaFuchs
I'm attempting to write a simple sticky-note mod where the user clicks on a block and a formspec pops up. Right now the I can't for the life of me get the formspec to actually show up.

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),
	

  
  


})

Re: Formspec in mod not showing up.

Posted: Tue Jun 26, 2018 14:35
by Pyrollo
You should pass the player name as first argument to show_formspec.

Player name is got from player:

Code: Select all

if player:is_player() then
  minetest.show_formspec(player:get_player_name(),...