How to "kill player"?

I need help. I'm trying to "kill" my character by running into a sprite.

When player interacts, I want the player to "pop". How do I do that? Do I put a call "eventName" in the behavior of the sprite, then put the actual events in the player script? Kind of confused how to link behaviors...?

Thanks!

There are a couple of ways you could do this. One way is to create a custom “die” handler on the player. Then call that in the deadly sprite’s “interact” handler. It might look something like this:

In the Sprite’s PulpScript:

on interact do
    tell event.player to
        call "die"
    end
end

And in the Player’s:

on die do
    ignore
    play "player die" then
        goto x,y in "room name"
        swap "player"
        listen
    end
end

ignore ignores user input until the death animation has completed and the room has reloaded, then we swap back to the player’s normal animation and start listening again with listen.

(Sorry, I’m typing on my phone which insists on smart quotes even in code blocks...hrm, it happens on the desktop too, must be the forum software :man_facepalming:)

3 Likes

Oh man! Thank you!

What's the difference between this and just emit "die" in the sprite's script?

emit will send the “die” event to any onscreen tile that implements a handler for it. A tell+call will have less runtime overhead. Plus tell event.player makes your intent more explicit.

1 Like

Ah! Perfect! Thank you!