I use an idea I got from a shareware RPG maker that I played a demo of (Blades of Exile?) in that, there were variables called 'stuff done flags'. And they would be at 0 if nothings happened, but when you defeat the boss, or save the princess, or open treasure chestA a different 'stuff done flag' (or sdf as I dub em for short) would be set to 1. Then you can have a lot of variables... better than having just one variable to define all of your story.
if sdf(0)=0 then text 0,0,"You must kill Trogdor!"
if sdf(0)=1 then text 0,0,"You have already killed Trogdor!"
if sdf(1)=0 then text 0,10,"The princess is held captive in the castle!"
if sdf(1)=1 then text 0,10,"The princess was in another castle >=("
Of course, that's stupid cos Trogdor cannot be killed