lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


You need quotes around “solar” and “lunar” in the if statements (without them you are comparing solu to two variables called solar and lunar. They have no value (aka they are equal to nil)

 

(If you haven’t found them already, then the online “Programming in Lua” guide is a useful resource: http://www.lua.org/pil/index.html)

 

This code seems to work

 

print("Enter solar or lunar");

solu = io.read()

if solu == "solar" then

print("The next solar eclipse will be displayed here");

end

if solu == "lunar" then

print("the next lunar eclipse will show up here");

end

 


From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Trey Montgomery
Sent: 23 September 2006 14:31
To: Lua list
Subject: Solar Lua

 

Im am creating a eclipse predictor as a beginner project to get me going with Lua and I am having an issue. I have written the begining of it, I havent begun with the actual prediction function yet. I am using lua edit. And i am using the view->debug window->Lua Output
but it is not letting me type in wether or not i want to see a solar eclipse or a lunar eclipse.It just prints both solar and lunar.
Heres the code:
print("Enter solar or lunar");
solu = io.read()
if solu == solar then
print("The next solar eclipse will be displayed here");
end
if solu == lunar then
print("the next lunar eclipse will show up here");

thanx