Triggers could be implemented in sprites, so that if a trigger was on, it would trigger an ending elsewhere or cause a different room to appear from an exit. Or if an item was interacted with once, it would show different dialogue afterwards.
0 In room 1, talk to a character sprite (dialogue: Please get milk.)
1 In room 2, interact with sprite of fridge, triggers A (dialogue: You take milk from the fridge.)
2 Interact with fridge again, but because A is triggered, there is different dialogue (dialogue: You already took the milk!)
3 Because A is triggered, talking to the character sprite again triggers an ending (ending: Thank you for the milk!) Without trigger A, the character sprite would repeat the original dialogue.