-- Show form when the /formspec command is used.
minetest.register_chatcommand("formspec", {
func = function(name, param)
minetest.show_formspec(name, "mymod:form",
"size[5,6]" .. "textarea[1,0;2,3;name;Input;default]" ..
"textarea[1,3;2,3;name;Output;default]" ..
"button_exit[1,5.5;2,1;exit;Compute!]"
)
end
})
Don wrote:You could put your output in a new formspec.
-- Show form when the /formspec command is used.
minetest.register_chatcommand("formspec", {
func = function(name, param)
minetest.show_formspec(name, "mymod:form",
"size[5,6]" .. "textarea[1,0;2,3;input;Input;default]" ..
"textarea[1,3;2,3;output;Output;default]" ..
"button_exit[1,5.5;2,1;exit;Compute!]"
)
end
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "mymod:form" then return false end
minetest.chat_send_all("Input: " .. fields.input)
return true
end)Don wrote:Change your form name to mymod_form
You can not use a : in the name
tomlukeywood wrote:Don wrote:You could put your output in a new formspec.
ok so i am trying to get the input from the formspec stored in a variable
and i so far have this:
but when i run the command:
minetest.chat_send_all("Input: " .. fields.input)
nothing is shown in the chat not even the "Input:" part of the string
am i doing anything wrong?Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
-- Show form when the /formspec command is used.
minetest.register_chatcommand("formspec", {
func = function(name, param)
minetest.show_formspec(name, "mymod:form",
"size[5,6]" .. "textarea[1,0;2,3;input;Input;default]" ..
"textarea[1,3;2,3;output;Output;default]" ..
"button_exit[1,5.5;2,1;exit;Compute!]"
)
end
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "mymod:form" then return false end
minetest.chat_send_all("Input: " .. fields.input)
return true
end)
Are you clicking the button? If you press enter it sometimes just closes it.

rubenwardy wrote:Are you using exactly the same code as posted? What Minetest version?
Users browsing this forum: Google [Bot] and 12 guests