Random Room, is it possible?

I’m making a game where I want the player to end up in a random room after they collect an item. How do I do that?

The key to doing anything randomly in Pulp is the random function. This returns a random number in a given range.

An easy way of randomly choosing a destination room would be to name your rooms like room1, room2, room3, etc. and to use string formatting to use the result of a random call as your goto destination.

For example, if you have 5 rooms named room1 to room5 your collect event handler could look like this:

on collect do
  room_number = random 1,5
  goto 12,7 in "room{room_number}"

In practice you might want to specify different coordinates for each room. There are a few ways you could do that - you could add another goto in the enter event handler on each room script, you could add some conditional if logic inside the collect event for each room, or you could define custom events for each room and call the correct event using string formatting.