Log In  

I keep getting the same syntax error when trying to run my game. I don't know if I'm missing something or not.
the code is:
if btn(x button) and p1.landed=true then
p1.y-p1.boost
p1.landed=false
p1.jumping=true
end

It kept giving me the error 'then' expected near '='

P#74171 2020-03-24 20:53

:: dredds

You need to use "==" (two equals signs) for comparisons. One equals sign is only used for assigning a value to a variable.

So your code needs to be:

if btn(x button) and p1.landed == true then
  p1.y-p1.boost
  p1.landed=false
  p1.jumping=true
end

Also "p1.y-p1.boost" should probably be "p1.y -= p1.boost" (subtract p1.boost from p1.y, updating p1.y)

P#74172 2020-03-24 22:34 ( Edited 2020-03-24 22:34)
:: beluga

ok got it, thanks!

P#74175 2020-03-25 00:26

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-04-03 18:00 | 0.009s | 2097k | Q:13