mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
Detect math error in hangman & use consistent/clear error messaging
This commit is contained in:
parent
db2c6ed4d9
commit
0fa7dda2cb
@ -1,10 +1,18 @@
|
|||||||
-- Hangman in eLua using the 'term' module
|
-- Hangman in eLua using the 'term' module
|
||||||
-- Inspired by the original 'hangman' from the bsdgames package
|
-- Inspired by the original 'hangman' from the bsdgames package
|
||||||
|
|
||||||
|
-- we need a random function
|
||||||
|
-- using math.random for now, which implies target=lua, not lualong
|
||||||
|
if not math then
|
||||||
|
print "\nError: Hangman needs the math module (disabled when target=lualong) !\n"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local h, w = term.lines(), term.cols()
|
local h, w = term.lines(), term.cols()
|
||||||
local tries = 0
|
local tries = 0
|
||||||
|
|
||||||
-- "Databse" with our words
|
-- "Database" with our words
|
||||||
local words = { "simple", "hangman", "guess", "elua", "inane", "serial",
|
local words = { "simple", "hangman", "guess", "elua", "inane", "serial",
|
||||||
"stupenduous", "software" }
|
"stupenduous", "software" }
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ elseif pd.platform() == "LM3S" then
|
|||||||
elseif pd.platform() == "STR9" then
|
elseif pd.platform() == "STR9" then
|
||||||
ledpin = pio.P9_0
|
ledpin = pio.P9_0
|
||||||
else
|
else
|
||||||
print( "Unknown platform " .. pd.platform() )
|
print( "\nError: Unknown platform " .. pd.platform() .. " !\n" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user