Log In  


I'm new to pico-8 and when trying to check if a boolean is false with

if is_point_in_rect(coin.x,coin.y,left,top,right,bottom) and not coin.is_collected() then

it returns an error
(I tried removing the "and not coin.is_collected" to see if the error was with the is_point_in_rect() function, and it didn't bring up an error)

Cart #hagomiyewa-0 | 2022-02-15 | Code ▽ | Embed ▽ | No License



Get rid of those parentheses. It should just be:
if coin.is_collected then...
not if coin.is_collected() then...

The parentheses are for calling a function.

Hmmm... looking more closely, that section should be changed to:

  if is_point_in_rect(coin.x,coin.y,left,top,right,bottom) and not coin.is_collected then
     coin.is_collected = true
     score+=1
  end

Here's the cart with the code fixed. It works!

Cart #hagomiyewa1-0 | 2022-02-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA



[Please log in to post a comment]