Skip to reading
BASIC Scripting

Read exactly what the player typed

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView illustrations

BASIC IN YOUR GAME

Three answers are enough to tell whether the whole connection works. Try an empty box, a wrong word, and a correct word typed in mixed case.

Code example
FUNCTION Run()
    DIM raw = GetGUIElementProperty("station", "entry", "text", "")
    DIM answer = Lower(Trim(raw))
    DIM reply = "Read the sign again."
    IF answer = "" THEN
        reply = "Type a direction."
    ELSEIF answer = "west" THEN
        reply = "The latch clicks."
    END IF
    SetGUIElementProperty("station", "reply", "text", reply)
    RETURN reply
END FUNCTION

The running preview after the player entered WeSt and selected Check direction.

Source table from Read exactly what the player typed, page 19
Empty box or spacesTrim leaves an empty string. The label reads “Type a direction.”
eastThe starting reply stays in place, so the label reads “Read the sign again.”
WeStLower turns it into west. The label reads “The latch clicks.”

The last empty string in GetGUIElementProperty is the fallback. If every entry acts blank, check the GUI ID, element ID and property name. RETURN also gives the calling script the answer.

Page 19 of 86Permalink
Go to page