Hi everyone, I’m very new to this IF stuff and struggling to get to grips with Inform 7.
I have a scene which involves a goblin running toward the player and the game will end (with the goblin killing the player) in a few turns unless the player carries out a specific action. I have tried many ways to achieve this but failed at each attempt.
The closest I’ve got is by doing something like this…
[code][Meet The Goblin scene]
During Meet The Goblin, goblin distance is a number which varies.
When Meet The Goblin begins:
let goblin distance be 30;
say "Suddenly you hear footsteps alternating clumsily between running and stumbling through the forest; twigs cracking beneath them and accompanied by a familiar congested breathing.
'The goblin!!' you anxiously mutter under your breath."; say "Goblin distance is [goblin distance]".
Every turn during Meet The Goblin:
decrease goblin distance by 10;
say “The goblin is getting closer! [goblin distance]”;
if goblin distance is 0, end the story saying “You’re dead”.[/code]
But for some reason the “goblin distance” value seems to get reset to zero after the scene begins (you can see I’ve put in some debug code to check the distance value). So when the scene begins the line…
say "Goblin distance is [goblin distance]".
shows “Goblin distance is 30”… as it should.
But then the line…
say "The goblin is getting closer! [goblin distance]";
shows the goblin distance as -10… as if it has reset it to zero?!? I’m baffled by this, can anyone help explain to me what I am doing wrong?
Your assistance is greatly appreciated.