I got an urge to play Hangman, a classic word-guessing game from my youth. So I banged out the following. It doesn't have any pretty graphics, but it has the core of the game, and I can't stop playing! 😁
import "listUtil"
// Select a word.
word = ""
words = file.readLines("/sys/data/englishWords.txt")
while word.len < 5
word = words.any
end while
shown = ["_"] * word.len
// Main loop
tries = 10
while tries > 0
print shown.join("")
if shown.indexOf("_") == null then
print "YOU WIN with " + tries + " guesses left!"
exit
end if
prompt = "You have " + tries + " guesses left. Your guess? "
guess = input(prompt).lower
if guess.len != 1 then continue
gotAny = false
for i in word.indexes
if shown[i] == "_" and word[i].lower == guess then
shown[i] = word[i]
gotAny = true
end if
end for
if not gotAny then tries = tries - 1
end while
print "Sorry, you're out of guesses!"
print "The word was: " + word