Trying to get Sprites to move randomly in plup, Like npc villagers, etc

Hello, Im new to coding and have been using pulp. Im about 75% done building a basic rpg. Ive coded a fishing mini game, dialogue trees with multiple options, a few other mini games, and even a working shop that buys and sells items (its still got a bit of work on that though). But for some reason I cannot figure out how to code a simple sprite to wander around. I have tried some basic tutorials and they have not worked at all for what I want. I tried Squidgods "spikeball"tutorial and it didnt seem to work for a sprite, and i do need it to work for sprites. If anyone has a sample pulp code for making a sprite wander around it would be greatly appreciated. I think after this game Im going to try SDK, seems like a lot more support there. Btw I cant wait to show you all what Im working on, I dont wanna give any hints yet, as no one seems to have done something like it on playdate, Ill post some pics soon.
game picture

1 Like

I have wondered this as well

this would be very helpful

Randomly moving NPC.json.zip (3.2 KB)

The above should work for you! It's very simple though, so you won't be able to do more than one of these guys in a room unless you rename each of the variables of each copy of the NPC in the room. If you are actually considering this, something like chatGPT could do it for you quickly.

If you want an explanation of how this works, here's a quick rundown.

The bit where I'm adding to a variable named timer is creating a looping timer that calls an event named timer when the variable gets to ten.

In the NPC script, it's checking the name of the tiles around it, and generating a random number between one and four. Depending on the number it chooses a direction, swaps itself to the floor tile, and tells the target tile to swap to an NPC.

I could probably create a better working one where you DONT have to repeat the variables if given a little more time.

Hope it helps!