Help with formspecs?

User avatar
Tmanyo
Member
 
Posts: 151
Joined: Mon Sep 29, 2014 01:20
GitHub: Tmanyo
IRC: Tmanyo
In-game: tmanyo

Help with formspecs?

by Tmanyo » Sun Jun 05, 2016 20:21

I am new to modding so go easy on me. Is there a way for a player to input a string of words in the field box and index key-words in the string they submitted to supply the player an answer through a list of possible answers?
Tmanyo
http://rrhmsservers.weebly.com/
Servers I Host:
Xtremetest
Vault-81
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Help with formspecs?

by Krock » Mon Jun 06, 2016 17:22

First of all, there are basically two questions:
1) How do I use text input fields?
2) Searching a text element in a list

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
Formspec element for your text input:
field[x pos,y pos;width,height;field_name;label text;]

Getting the formspec callback (when pressing a button)
minetest.register_on_player_receive_fields(function(sender, formname, fields)
   if formname ~= "formspec_name" then
      return
   end
   if not fields["field_name"] then
      return
   end
   
   -- String lookup code
end)


And now the text value search part:
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
local mytable = {
   "stuff1 things",
   "foobar attack",
   "string operation",
   "iamstupid.com"
}
-- Looking through the whole table
for i,v in ipairs(mytable) do
   if string.match(string.lower(v), "text to search") then
      -- Found something!
   end
end
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Tmanyo
Member
 
Posts: 151
Joined: Mon Sep 29, 2014 01:20
GitHub: Tmanyo
IRC: Tmanyo
In-game: tmanyo

Re: Help with formspecs?

by Tmanyo » Mon Jun 06, 2016 21:37

Thank you, Krock. You answered my question.
Tmanyo
http://rrhmsservers.weebly.com/
Servers I Host:
Xtremetest
Vault-81
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron