Skip to reading
BASIC Scripting

Clean and combine player text

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 PDF page

THE BASIC LANGUAGE

A player who types a direction with spaces or mixed capitalization probably means the same thing. Normalize the input before comparing it.

Code example
FUNCTION Run()
    DIM raw = "  WeSt  "
    DIM word = Lower(Trim(raw))
    DIM report = Replace("Dial: ?", "?", word)
    RETURN report
END FUNCTION

What you should see The result is Dial: west. Trim removes whitespace at the ends, Lower changes WeSt to west, and Replace fills the question mark.

Source table from Clean and combine player text, page 15
Upper / LowerConvert the letter case for display or comparison.
Contains / StartsWith / EndsWithTest a piece of text. An optional third Boolean chooses case sensitivity.
Split / JoinSplit("red,blue", ",") produces two entries. Join(["red","blue"], " / ") produces the text red / blue.
StringLengthCount the length of a string. A zero-length answer can be given its own feedback before any other comparisons.
Page 15 of 86Permalink
Go to page