Help with formspecs?
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?
FOSS gamedev and creative worlds
https://forums.minetest.org/
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)
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