Modding question

User avatar
tomlukeywood
Member
 
Posts: 85
Joined: Sat Oct 10, 2015 13:13
IRC: tomlukeywood
In-game: tomlukeywood

Modding question

by tomlukeywood » Thu Oct 22, 2015 22:17

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?
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Modding question

by Don » Thu Oct 22, 2015 23:32

Minetest uses formspec for in game gui.

http://dev.minetest.net/formspec
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Modding question

by rubenwardy » Fri Oct 23, 2015 06:44

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.
 

User avatar
tomlukeywood
Member
 
Posts: 85
Joined: Sat Oct 10, 2015 13:13
IRC: tomlukeywood
In-game: tomlukeywood

Re: Modding question

by tomlukeywood » Sat Oct 24, 2015 19:56

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
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Modding question

by Don » Sat Oct 24, 2015 20:06

You could put your output in a new formspec.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
tomlukeywood
Member
 
Posts: 85
Joined: Sat Oct 10, 2015 13:13
IRC: tomlukeywood
In-game: tomlukeywood

Re: Modding question

by tomlukeywood » Sun Oct 25, 2015 10:21

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)
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Modding question

by Don » Sun Oct 25, 2015 11:37

Change your form name to mymod_form
You can not use a : in the name
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Modding question

by rubenwardy » Sun Oct 25, 2015 12:58

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
Attachments
worksforme.png
worksforme.png (192.79 KiB) Viewed 1457 times
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Modding question

by Don » Sun Oct 25, 2015 13:49

Sorry my mistake!
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
tomlukeywood
Member
 
Posts: 85
Joined: Sat Oct 10, 2015 13:13
IRC: tomlukeywood
In-game: tomlukeywood

Re: Modding question

by tomlukeywood » Sun Oct 25, 2015 14:05

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
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Modding question

by rubenwardy » Sun Oct 25, 2015 15:55

Are you using exactly the same code as posted? What Minetest version?
 

User avatar
tomlukeywood
Member
 
Posts: 85
Joined: Sat Oct 10, 2015 13:13
IRC: tomlukeywood
In-game: tomlukeywood

Re: Modding question

by tomlukeywood » Sun Oct 25, 2015 19:52

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
 


Return to Minetest General

Who is online

Users browsing this forum: Google [Bot] and 12 guests

cron