I'm working on my first Pulp project and I was wondering how you make two identical sprites in the same room have different results with interaction. For example, lets say you have two chests in one house and they each contain different items. Could you use the Sprite's position in the room on an 'on interact do' then... if statement?
I know I could just make a second, identical Sprite and name it 'chest 2' but I could see that getting cumbersome down the line if you have a lot of chests.
Adding an if statement in the interact event with the sprite's position should work. If you're planning on making multiple identical sprites with different interactions in different rooms, I suggest that you should create an event in each room. That way, you don't have to fill the interact event with different if statements.
Chest script
on interact do
tell event.room to
call "openingchest"
end
end
Room script
on openingchest do
//chest 1
if event.x==Chest1PositionX then
if event.y==Chest1PositionY then
//do action 1
end
end
//chest 2
if event.x==Chest2PositionX then
if event.y==Chest2PositionY then
//do action 2
end
end
end
Sorry if this is too technical for a beginner level, but I hope this helps.