Disabling/Enabling Save on the fly?

Is there a quest function that I can call to temporarily disable the Save feature so the player can't save until a certain point when I re-enable it again?


The easiest way to do it on the fly (that I know of) would be to make a Boolean attribute and set up a new command with save as the command pattern.

In this example, we'll create an attribute called game.can_save in the start script, and we'll set it to true so the save function will work by default.


In the game's Start Script:
game.can_save = true


Now, we'll set up a new command.

New Command

Command Pattern:
save

Name: save2

if (game.can_save) {
  request (RequestSave, "")
}
else {
  msg ("You can't save at the moment.")
}

To use it:

Now, you can switch the ability to save off or on in any script with one line.

Can save:
game.can_save = true

Can't save:
game.can_save = false

NOTES:

  • Remember: once switched to false, saving will be disabled until you switch it back to true!

  • If you forget to set up game.can_save, you will receive an error!

    Error running script: Error compiling expression 'game.can_save': RootExpressionElement: Cannot convert type 'Object' to expression result of 'Boolean'


PUBLIC SERVICE ANNOUNCEMENT:

Disabling Save in a specific room is the safest bet because you won't have to worry with forgetting to re-enable saving after disabling it.

If you just don't want the player to be able to save in a particular room, set up a command specifically for the room with save as the command pattern and have it print "You can't do that in here!" in the script.


Great stuff! Will this override the File menu save/save as option as well? Or if not is there a way to disable access to that toolbar item?


Will this override the File menu save/save as option as well? Or if not is there a way to disable access to that toolbar item?

Excellent question!

I just checked, and this does NOT override CTRL+S or File-->Save/Save As!

Hrmm... I wish I'd have thought to check that while designing a room in which the player couldn't save...


I know how to turn off the Save Button when playing online...

JS.eval ("$('#cmdSave').css('display', 'none');")


Anyone know if this is possible?

(I would bet it's not possible from within the game's code.)


I guess its probably tied directly into the Core libraries and everyone's version of that couldn't be modified since its in the Quest install location in Program Files and not part of the published item files.


Log in to post a reply.

Support

Forums