Formspec in mod not showing up.

Post Reply
MusaFuchs
Member
Posts: 17
Joined: Wed Feb 28, 2018 15:44

Formspec in mod not showing up.

by MusaFuchs » Post

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

  
  


})

User avatar
Pyrollo
Developer
Posts: 385
Joined: Mon Jan 08, 2018 15:14
GitHub: pyrollo
In-game: Naj
Location: Paris

Re: Formspec in mod not showing up.

by Pyrollo » Post

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(),...
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests