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

P#106976 2022-02-15 15:46

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
P#106977 2022-02-15 15:56 ( Edited 2022-02-15 16:18)

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

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

P#107091 2022-02-17 05:08

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 08:25:11 | 0.009s | Q:18