Lua Program isn't working
So I'm trying to code a simple text fight using Lua, but I keep getting the same error even though I'm doing what it's saying.
Here's the code:
print 'A zombie appears. What do you do?'
os.execute("sleep 5")
if sleep = 0 then
print 'The zombie scratches you and you die.'
Attack = io.read()
print 'The zombie is injured.'
It should make it so if you wait five seconds then you die, but here's the error message that shows up: [string "print 'A zombie appears. What do you do?'..."]:3: 'then' expected near '='
I'm not sure what I'm doing wrong.. Can anyone help with this?
Wait, nope I got it
My general feeling is that you should explain what you found out and fixed. There's is nothing more infuriating in the world than having a problem, Googling it, finding someone asking about the same or a similar problem, then seeing a "nevermind fixed" comment with no explanation. :)
My general feeling is that you should explain what you found out and fixed.
I agree, it could help future others.
if sleep = 0 then
Problem is here. You're not checking 'sleep' for zero, you're assigning zero to it.
That's a violation of Lua syntax. 'If' expects expression, not the statement.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement