Undoonetransaction - stop it showing text Undo:... in the UI!

It's very very long and complicated, but essentially I have a function which will be triggered in a very specific scenario which will undo the last turn.

The problem is, I don't want it to be obvious to the player that the "undo transaction" has been run. Unfortunately, because it's an editor script, I can't even look at what it's doing to rebuild the whole script myself (and exclude that Undo:... text).

So can someone tell me how to set up my own "undoonetransaction" which is effectively the same as the editorscript (EditorScriptsGameStateUndoonetransaction) but without that text? Because I can muddle along when I can see the script (I appreciate I can't edit an editorscript but I can't even see what it's doing which is super-frustrating.

Cheers!


I don't think you can access the internal undo buffer directly. If you want to do an undo without the output, I'd suggest suppressing the output. Off the top of my head, you could do something like this:

JS.eval ("$(function () {var r = window.addText; window.addText = function(){}; window.resumeText = function() {window.addText = r;}});")
undo
JS.resumeText ()

The (rather awkward) eval line basically removes the javascript function addText, which is used for all Quest functions which display text to the screen. This prevents any text being output at all until the corresponding JS.resumeText() is reached.

Alternatively, you could do it the same way menus are handled:

section = StartNewOutputSection()
undo
EndOutputSection (section)
HideOutputSection (section)

this looks a bit simpler; it just starts a new output section, and then hides that section using the same code that is used to hide menu options after one has been selected.


ooooh these are some great ideas... I don't know enough javascript unfortunately, but I'm learning, slowly! I'll give this a try and let you know what I think!


So, it works! The message does flash up for a split second, but then gets cleared. So I can live with that! (I used the second option just because of my unfamiliarity with javascript... but might come back to that (if it has any differences in behaviour).

Thanks again for the quick response. This has saved me a really long (and convoluted) workaround, so I hugely appreciate it.


If you're doing this a lot, it might be more efficient to set up some functions. You could put something like this in the UI Initialisation script (On the game's "Advanced Scripts" tab):

JS.eval ("$(function () {var r = addText; var d; window.addText = function(t) {d || r(t)}; window.disableOutput = function() {d = 1}; window.enableOutput = function() {d = 0};});")

Once that's set up, you could just use the JS functions it creates:

JS.disableOutput()

and

JS.enableOutput()

These will let you suppress any output whenever you want.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums