Read input from an authored GUI
LESSON 09
Wire a text box and a button so the player can actually type the answer.
Create a GUI with ID archive_panel. Add a single-line text box answer_entry, a button check_answer
and a label feedback. Use unique element IDs. Make the panel visible during play. Leave Clear on
Enter and parser submission off for this button-driven exercise.
local Script = {}function Script.run(context)
local text = GetGUIElementProperty(
"archive_panel", "answer_entry", "text", "")
local answer = await(CallScript(
"archive_words", "normalize", Array{tostring(text)}))
local reply = "Try the direction on the label."
if answer == "" then
reply = "Type a direction first."
elseif answer == "west" then
reply = "The latch clicks."
end
SetGUIElementProperty("archive_panel", "feedback", "text", reply)
return reply
endreturn ScriptApply archive_words from the functions lesson. In the button's click action, choose the action that
runs a script and select read_answer. If using Call Script Function, expose run with no authored
parameters first. Apply the GUI, save and start Play. Type a space, WeSt, and another space. Click
the button. The label should read “The latch clicks.”
If every click produces the empty-answer response, check the GUI ID and the live text-box element ID.
The final empty string in the getter is the fallback for a missing property.
