Read what the player typed
On this page
TEXT AND INPUT
A player may enter “west”, “WEST” or a word surrounded by spaces. Decide which differences matter before comparing their answer.
Read the live text#
local raw = GetGUIElementProperty(
"archive_panel", "answer_entry", "text", "")The first two arguments identify the GUI and its text box. The third requests its current text. The empty string at the end is a fallback if the lookup fails. Substitute the IDs used by your own GUI.
Clean it before comparing#
local text = tostring(raw)
local trimmed = text:match("^%s*(.-)%s*$")
local answer = string.lower(trimmed)The pattern removes spaces from the two ends. It keeps spaces inside the answer. Lowercasing then turns WeSt into west. The comparison now accepts both.
Give a helpful reply#
local reply = "Look for wear on one of the dials."
if answer == "" then
reply = "Type a direction first."
elseif answer == "west" then
reply = "The lock releases."
end
SetGUIElementProperty("archive_panel", "feedback", "text", reply)These three fragments belong inside the same function. The final line puts the chosen reply in a label. An empty answer gets its own message so the player knows what to do next.
Lua scripting / Illustrated guide W11
