Retrofiting a game to provide a way back from bad ends

Got a little question here, I'm trying to retrofit a game I made to allow people to back up(Well not techicnally) when they have reached a game over.. Now with hunderes of various game overs spread out through the game I'd like to do this en mass through a program such as notepad++

The basic logic I want is to replaced
finish with

Ask ("Do you want to go back?") {
  if (result) {
    MoveObject (player, The Main Hall)
  else {

its the code i've tried has pretty much broken the game, it think some of it is in the formating when trying the mass replace..i'd rather not have to do it for each of the hundreds of instances


I think the problem here is you don't have a 'result'. So you ask the player if they want to go back, and if the result is... the result is what?

That's what I imagine would cause the trouble. Also, I'd use 'get input' rather than 'ask'.

Plus, if you're trying to do it for hundreds of bad ends, then maybe just stick the code in a function called BadEnd and replace the 'finish' with 'call function BadEnd'. Functionally it's the same, but if you ever need to change the bad-end-reversal-code, now you only need to change it in one place.

The first part i don't think is the problem, since i've done it on a test and didn't have the game fail to load, thinks the result is honestly just ignored,

The working it into a function on the other hand might just work perfectly, will have to relearn how to make simple functions of course, but still, its a solid idea


I don't think it would make the game fail to load at all. If you have an 'if (something=condition)' without the condition, then if memory serves, the game will chug along fine until it tries to call that, at which point it freezes.

What exactly IS the error you're getting? Can you paste it here?

That looks like it should work.

However… if you're doing a mass search-and-replace on "finish", my first worry would be whether you ever use the word "finish" within a longer line; maybe as part of an object name, a variable name, or even in a message. Replacing in those cases would cause the game to break whenever it reaches that place, or might even prevent the game from loading at all.

If your editor supports regular expressions, I'd try replacing ^\s*finish\s*(\(\))?\s*$, to replace either finish or finish() on a line on its own.

That looks okay to me - assuming you have a room called "The Main Hall", and the player object is called "player".

As Io says, it would be good if you could tel us the error. Also, what is the surrounding code?

@Io, result is a local variable set by the Ask function, and will be true if the player replies "yes" and false otherwise.


@The Pixie Ah, good to know. I've never actually used Ask myself. But even then, shouldn't it be 'if (result=true)'?

No. The if statement already tests whether the expression evaluates to true. You could use if (result = true) as a condition. But you could also use if ( (result = true) = true), and (I hope) you wouldn't say that's any easier to read.

(Still suspecting my first guess is the most likely)

Edit- Io's idea of making a function was brilliant, after I went through the game and fixed all the text finishes, made a simple function to copypaste and it works functionally, the details of changing it to look better/make more sense will be easy. Thank you so much to everyone who's helping me understanding coding as i get deeper in.

Will get to testing this afternoon was late last night, but will try to dig up the error code, looking back, I probably missed a key "Finish" in the coding somewhere, something that wasn't supposed to change. Thank you for all your help though.
Had already thought of having rogue "finishes" in places that weren't supposed to be changed, ie finishing a cup of tea, but when going through all those lines by hand missing something is fairly easy, I use a real primitive method of keeping in text finishes out, I adjust the in text spellings to finishh then when i'm done just plan a mass replace of those back to the proper language

Did you disable or change the undo command? Because that works.

Or just use vanilla "undo".

Also, teleporting the player to an empty room with no exits, and turning off all the window panes, works as an alternative to the
"finish" function.

Ignore me. (I posted without reading everything first.)

Log in to post a reply.