Page 1 of 1

Modding question

PostPosted: Thu Oct 22, 2015 22:17
by tomlukeywood
i am seeing if its possible to make a computer craft mod for Minetest (there is a lua interpreter written in lua so should not be too hard once i can get a GUI )

are there any introductions to making GUI's with the minetest modding api?

Re: Modding question

PostPosted: Thu Oct 22, 2015 23:32
by Don
Minetest uses formspec for in game gui.

http://dev.minetest.net/formspec

Re: Modding question

PostPosted: Fri Oct 23, 2015 06:44
by rubenwardy
Tutorial from the Minetest Modding Book.

However, the system is quite limited. Other people have tried to make computer craft mods, but been stopped by the limitations of formspecs.

Re: Modding question

PostPosted: Sat Oct 24, 2015 19:56
by tomlukeywood
this is the best i have so far
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;name;Input;default]" ..
             "textarea[1,3;2,3;name;Output;default]" ..
            "button_exit[1,5.5;2,1;exit;Compute!]"

)
   end
})


dose the minetest api have anything that could be used to display output?

also are there any good tutorials on how to receive and manipulate the input from input boxes in minetest?

as in this image i just used a input box for both

Image

Re: Modding question

PostPosted: Sat Oct 24, 2015 20:06
by Don
You could put your output in a new formspec.

Re: Modding question

PostPosted: Sun Oct 25, 2015 10:21
by tomlukeywood
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)

Re: Modding question

PostPosted: Sun Oct 25, 2015 11:37
by Don
Change your form name to mymod_form
You can not use a : in the name

Re: Modding question

PostPosted: Sun Oct 25, 2015 12:58
by rubenwardy
Don wrote:Change your form name to mymod_form
You can not use a : in the name


Wrong. You can use a :

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)


works for me.
Are you clicking the button? If you press enter it sometimes just closes it.

Image

Re: Modding question

PostPosted: Sun Oct 25, 2015 13:49
by Don
Sorry my mistake!

Re: Modding question

PostPosted: Sun Oct 25, 2015 14:05
by tomlukeywood
Are you clicking the button? If you press enter it sometimes just closes it.

yes i am clicking the button

i do get this output though when pressing the button though:
Image

Re: Modding question

PostPosted: Sun Oct 25, 2015 15:55
by rubenwardy
Are you using exactly the same code as posted? What Minetest version?

Re: Modding question

PostPosted: Sun Oct 25, 2015 19:52
by tomlukeywood
rubenwardy wrote:Are you using exactly the same code as posted? What Minetest version?

exact same output when i copy and paste the code above

my minetest version is:
Minetest 0.4.13-dev

compiled from source with no changes except some lua mods in the mods folder