Basic movement can be facilitated through:
if btn(0) then x-=1 end
But when I add sfx:
if btn(0) then x-=1 and sfx(0) end
It always generates an error as soon as that button 0 is pressed. Why is that? If x then y and z end. Is there something wrong with that syntax? Or is it related to sfx not working in this way?
And why is it when I clarify with brackets it doesn't even run!? Am I clarifying that my syntax is wrong before teh game starts? That's funny.
i.e.
if btn(0) then (x-=1 and sfx(0)) end
You are misusing the keyword 'and'. Each statement will execute without using the word 'and', you just have to put them on their own line.
if btn(0) then x-=1 sfx(0) end |
The keyword 'and' is what is called a logical operator. It is an operation on boolean values, true and false.
For example:
true and true == true
true and false == false
false and false == false
false and true == false
Statements such as comparisons eg. (x > 1) result in boolean values that can be used with the 'and' operator.
[Please log in to post a comment]