Help! Making object vanish after collecting key

Hello, this is my very first time using pulp. I created this game with the playdate pulp site. But, I ran into a problem, I have this item and if I collect all 6 I am able to break something blocking the exit to another scene, This is sorta like a key to get through a door type of thing. I really have no clue how to script it, so a little help would be neat.

Sounds like you need a variable to check how many you have collected.
On your item, try something like:

on collect do
keyNum++
end

this will increment a variable “keyNum” by 1 when the item is collected then something like:

on draw do
if keyNum==6 then
swap "TileNameToSwapTo"
end
end

on a sprite tile for you “blocked exit”, which will swap the tile to something else once “keyNum” reaches 6.

1 Like

This is probably the simplest way to achieve this: Let’s say you have an Item tile named “key”. If you don’t add any custom PulpScript behavior, when the player walks over the Item tile it will be swapped with the “white” tile (or “black” if you’ve chose that as your background color”) and an automatically created variable named keys (the tile’s name plus “s”) will have 1 added to it. Then you would have a Sprite tile named “door” and for its behavior have the following PulpScript:

on interact do
    if keys==6 then
        swap “white”
    end
end

The “door” tile will be solid (because all Sprite tiles are solid) and prevent the player from walking though it. Unless they’ve collected 6 keys. If that condition is met, the next time the player walks into the door it will be replaced with a non-solid tile allowing the player to pass through.

2 Likes