As to whether this is a bug or bad code, I couldn't say. BUT, I did find a method that is able to do what you want, albeit messy. First, check if the player is in the same room as the item (Field1Furrow in your case). Inside the on collect do
event, event.room will always be whatever it was when it was called, even if the player changes rooms during that wait timer. So, in the player script:
on enter do
currentRoom = event.room
end
Now we can compare currentRoom
with event.room
. What I had hoped would work is:
on collect do
Field1--
money += 2
swap "BlankTileSwap"
wait 30 then
while currentRoom!=event.room do
wait 0.1 then // doesn't work :(
end
end
swap "Field1Furrow"
end
end
Unfortunately, it looks like pulp pays no mind to wait functions inside of while loops, and the console immediately throws an error after the while loop goes through 400 times which I guess is just a safety against infinite loops. So with no loops, and no iterators, this is what I got:
First, in the game script:
on load do
queue_1_room = 999 //dummy value
queue_2_room = 999
// and so on for as big of a queue you want
end
on enter do
call "drawItems"
end
on drawItems do
log "Drawing all queued items for {event.room}..."
if queue_1_room==event.room then
tell queue_1_x,queue_1_y to
swap queue_1_tile
end
queue_1_room = 999
elseif queue_2_room==event.room then
tell queue_2_x,queue_2_y to
swap queue_2_tile
end
queue_2_room = 999
// and so on for as big as you want your queue...
end
end
Then, in Field1Furrow script:
on collect do
Field1--
money += 2
swap "BlankTileSwap"
wait 30 then
if currentRoom!=event.room then
swap "Field1Furrow"
else
if queue_1_room==999 then
queue_1_room = event.room
queue_1_x = event.x
queue_1_y = event.y
queue_1_tile = event.tile
elseif queue_2_room==999 then
queue_2_room = event.room
queue_2_x = event.x
queue_2_y = event.y
queue_2_tile = event.tile
end
// and so on....
end
end
If anyone was any more elegant ways to do this I'd love to see! One thing to note is that while "drawItems" can be its own function, the if tree in Field1Furrow cannot, because event.room will be different then. Also, maybe the devs can add waits inside while loops as a potential feature to simplify this down a ton : )