From 0fa7dda2cbfc73cc25688ff6125921337a8914ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Thomas?= Date: Sat, 9 Aug 2008 15:36:11 +0000 Subject: [PATCH] Detect math error in hangman & use consistent/clear error messaging --- examples/hangman.lua | 10 +++++++++- examples/led.lua | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/hangman.lua b/examples/hangman.lua index 49eaa447..09e68ed0 100644 --- a/examples/hangman.lua +++ b/examples/hangman.lua @@ -1,10 +1,18 @@ -- Hangman in eLua using the 'term' module -- 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 tries = 0 --- "Databse" with our words +-- "Database" with our words local words = { "simple", "hangman", "guess", "elua", "inane", "serial", "stupenduous", "software" } diff --git a/examples/led.lua b/examples/led.lua index 15b546ef..48284c78 100644 --- a/examples/led.lua +++ b/examples/led.lua @@ -7,7 +7,7 @@ elseif pd.platform() == "LM3S" then elseif pd.platform() == "STR9" then ledpin = pio.P9_0 else - print( "Unknown platform " .. pd.platform() ) + print( "\nError: Unknown platform " .. pd.platform() .. " !\n" ) return end