Recommended Posts

Very cool. I tried to do a twist on this and replace the "Rewind" button with an "Undo" button but I can't seem to get it to work. In the game, when I clicked on the button it did nothing. I exited the game, tweaked the code again, and then my save wouldn't load.

Then I gave up :-) I'm not what you'd call a seasoned modder.

Link to comment
Share on other sites

Very cool. I tried to do a twist on this and replace the "Rewind" button with an "Undo" button but I can't seem to get it to work. In the game, when I clicked on the button it did nothing. I exited the game, tweaked the code again, and then my save wouldn't load.

Then I gave up :-) I'm not what you'd call a seasoned modder.

 

Well, there was a hotfix today, so maybe your changes got overwritten, sins both files where updated.

 

Also the second part of the code (function) is already in there, editing a single line (well word, actually) would have been enough.

 

Since the mod does not update the savegame (which needs to be in sync for most events) your savegame most likely will be crewed every time you use this mod. I suggest you not use this.

 

If you want to test a correctly working mod, just PM me.

Link to comment
Share on other sites

Very cool. I tried to do a twist on this and replace the "Rewind" button with an "Undo" button but I can't seem to get it to work. In the game, when I clicked on the button it did nothing. I exited the game, tweaked the code again, and then my save wouldn't load.

Then I gave up :-) I'm not what you'd call a seasoned modder.

 

Yeah, if/when I find how to create objects on the HUD, I'll add a button for it. But I avoided rewind button, because it doesn't show up in ironman, and making it show up on all instances requires too many stuff to be changed. As the game doesn't have any official mod support, where I can mount my own files (easily) and overwrite what game has, I just avoided it.

 

But in any case, if you want to do that, you need to add a different code piece to "hud.lua", and the code you add would look like

 

onClickRewindGame = function ( hud )

       hud._game:undoAction( )

end

 

The other file changes are still the same. Now, when you click on rewind, you will undo your last action. But this button will not be seen in ironman, and its tooltip will be unmodded so it'll still call it rewind. If you cannot do it on your own, just give me a poke and I'll pack a file for you.

 

Also the second part of the code is already (mostly) a part of that script (9xx), so it's sort of a hit or miss. (also, the engine can be very picky, sometimes in which order script-stuff happens.)

 

Since the mod does not update the savegame (which needs to be in sync for some events) your savegame most likely will be crewed every time you use this mod.

 

What are you talking about? Part of what script? Hit or miss what? And what is script-stuff exactly?

 

And this mod will not screw your save because I'm using what is already there. Not adding new content, but adding new functionality which is way different from the former, and usually does not require to alter save files or whatsoever.

Link to comment
Share on other sites

 

What are you talking about? Part of what script? Hit or miss what? And what is script-stuff exactly?

 

And this mod will not screw your save because I'm using what is already there. Not adding new content, but adding new functionality which is way different from the former, and usually does not require to alter save files or whatsoever.

 

If you used "what is already in there" you would have simply changed a single word, instead of adding a function which already basically exists and keep full functionality and in-game registration.

 

The savegame file is also used as a debug file (every single move, action, whatever is registered and saved). Whenever it finds that something is amiss upon loading, like missing an action or something, it will either reset to the last turn made (or up to  running in sync) or completely reset to the start of the mission and/or create a new level. Worst case scenario your save will never load again.

 

Your savegame will most likely get corrupted when you quit in the middle of a mission and having used the undoAction, because you do not register your undoAction.

 

You also do not have any checks on your function, like: can it actually be used? The loading screen is actually you first action (Action 0), you start the game at action 1, if for some reason, hé, there are those people, use this function on you very first turn it will try (or do) get back to the loading screen. I wonder what will happen :indecisiveness:

Link to comment
Share on other sites

Yeah, if/when I find how to create objects on the HUD, I'll add a button for it. But I avoided rewind button, because it doesn't show up in ironman, and making it show up on all instances requires too many stuff to be changed. As the game doesn't have any official mod support, where I can mount my own files (easily) and overwrite what game has, I just avoided it.

First, thanks for the help! But that's exactly what I want. I think Rewind rewinds a full turn too much at LEAST, and want it to rewind one action only. And then not be available anymore. And I want Ironman to not allow rewind/undo/anything like that. Allowing any sort of taking back moves in Ironman seems wrong to me; it's what that mode is FOR.

 

But in any case, if you want to do that, you need to add a different code piece to "hud.lua", and the code you add would look like...

 

That's close to what I had, but I put it inside the remove the ability to use this button again" part of the script so I could only undo once per mission. 

 

Well, there was a hotfix today, so maybe your changes got overwritten, sins both files where updated.

And for you as well, thanks for the help! But that's not the issue. I did this all within a few minutes and after the game crashed I checked the file to make sure it was the same one I had. More likely is...

 

Since the mod does not update the savegame (which needs to be in sync for most events) your savegame most likely will be crewed every time you use this mod. I suggest you not use this.

this, which matches what I saw in-game (the level wouldn't load after running that function).

Link to comment
Share on other sites

If you used "what is already in there" you would have simply changed a single word, instead of adding a function which already basically exists and keep full functionality and in-game registration.

 

The savegame file is also used as a debug file (every single move, action, whatever is registered and saved). Whenever it finds that something is amiss upon loading, like missing an action or something, it will either reset to the last turn made (or up to  running in sync) or completely reset to the start of the mission and/or create a new level. Worst case scenario your save will never load again.

 

Your savegame will most likely get corrupted when you quit in the middle of a mission and having used the undoAction, because you do not register your undoAction.

 

You also do not have any checks on your function, like: can it actually be used? The loading screen is actually you first action (Action 0), you start the game at action 1, if for some reason, hé, there are those people, use this function on you very first turn it will try (or do) get back to the loading screen. I wonder what will happen :indecisiveness:

 

I added a new function because the structure allows it. Instead of messing with existing stuff, if I'm allowed to create new things, I'll go with the latter always. I created a new function, and linked that to an existing stuff, because I don't know how to create new UI buttons (yet).

 

I'm not registering the undo action, because I'm removing the last action you've made, and going to the "new" last action. As far as the game is concerned (and as far as I can tell), that move you undid do not exist. I paid extra attention to how other things work in the game, especially the existing rewind to avoid weird stuff happening.

 

Here is what I can tell about rewind: It keeps removing the last actions you've made, till it finds "endTurnAction". Then it decrements a local value (initially 2), and keeps removing the actions till the said local value is equal to or less than zero. When this condition is met (local value <= 0), it inserts the removed last action (which is "endTurnAction") back to the action history, and goes to the last action; as far as the gamer concerned, what happens is, a turn is rewinded completely, and you continue from the beginning of the previous turn.

 

And if you undo at the very first move, it shows you the initialization screen again. Because as you said, it is considered as an action as well, and undoing at the very first move just lets you watch it again (I tried :p) I know I can add some simple stuff, but not before I learn how to implement more complex stuff.

 

Anyway, I hope this clears some of your concerns.

 

That's close to what I had, but I put it inside the remove the ability to use this button again" part of the script so I could only undo once per mission.

 

...

 

this, which matches what I saw in-game (the level wouldn't load after running that function).

 

If you make a syntax error, it will not load. And game doesn't tell you that there is a syntax error in the code.

 

Also, if you want 1 undo per turn, you need to use something else :) I tried it but every action (opening doors, peeking, etc...) are logged separately, and 1 undo wasn't ideal.

Link to comment
Share on other sites

I added a new function because the structure allows it. Instead of messing with existing stuff, if I'm allowed to create new things, I'll go with the latter always.

 

Again, simply changing one word would have done the job. See the mod I send you. It will simply change the Rewind function into an undo function (while keeping in mind that you miss-clicked. Eventually what this discussion was all about.) You have now effectively created an infinite extra undo feature capable of completely rewinding the game. Very exploitable and could have been prevented.

 

I created a new function, and linked that to an existing stuff, because I don't know how to create new UI buttons (yet).

 

You did not link it to anything, you just executed stuff. Also, good luck with creating and placing a new button. It’s rather tedious without an editing tool, but not impossible.

 

I'm not registering the undo action, because I'm removing the last action you've made, and going to the "new" last action. As far as the game is concerned (and as far as I can tell), that move you undid do not exist. I paid extra attention to how other things work in the game, especially the existing rewind to avoid weird stuff happening.

 

I'm sure you did. BUT! Upon the start of the game the savegame get loaded into memory. That [mem-savegame] will be use for the remainder of your game session to load it's data, it will only write to savegame.lua. Your action does not get saved. Also not not registering makes bug tracking harder ;)

 

With you mod the following can happen:

mem-save will go: a53 > a54 > a55 > [undo] > a54 > a55 ...

savegame.lua will go: a53 > a54 > a55 > a54 [error]

 

The above is just an example to give you an idea (data is stored differently), also some other stuff gets updated, unless you use the undoAction, then nothing gets updated. As long as you finish your mission all will most likely be fine. Quiting in between will be a risk.

 

I believe the latest hotfix is able to handle savegame corruption better and/or maintaining it better upon exiting. So it’s convenient time on your part, though this is pure speculation.

 

Here is what I can tell about rewind: It keeps removing the last actions you've made, till it finds "endTurnAction". Then it decrements a local value (initially 2), and keeps removing the actions till the said local value is equal to or less than zero. When this condition is met (local value <= 0), it inserts the removed last action (which is "endTurnAction") back to the action history, and goes to the last action; as far as the gamer concerned, what happens is, a turn is rewinded completely, and you continue from the beginning of the previous turn.

 

Something like that. It does not insert the removed last action, it prevents the endTurnAction from being removed and puts the player at the turn-start after the endTurnAction. It’s kind of hard to insert something that doesn’t exit, but maybe you rephrased it wrong.

 

And if you undo at the very first move, it shows you the initialization screen again. Because as you said, it is considered as an action as well, and undoing at the very first move just lets you watch it again (I tried  :razz: ) I know I can add some simple stuff, but not before I learn how to implement more complex stuff.

 

Well I’m not entirely sure. I currently do not know what other stuff happens during initialization screen. Maybe it’s just for show, but sins you actions does not exit (for the game) who knows what unforeseen things can happen further in the mission,.

 

I believe it can prevent the executive from being brain-scanned (sub mission does not start) or at retest prevent the executive from dropping the pass code. At least this is what I encountered.

 

Anyway, I hope this clears some of your concerns.

 

Well I personally would not post a mod like this publicly (as I explained in previous posts) and keep it private for a small group. This prevents unaware users, not knowing what they’re doing, to effectively ruin their game and/or prevent the game from starting at all. And before you know it they are gonna bug Klei or Steam. I’ve seen this happen on other games. Eventhough the game does check for modded content, they should not be bothered by bugs caused by mods.

 

If you make a syntax error, it will not load. And game doesn't tell you that there is a syntax error in the code.

 

Well, actually it does. But it would also cause the game not to load at all. At least from what I know. So this is not what happened.

 

Also, if you want 1 undo per turn, you need to use something else :-)I tried it but every action (opening doors, peeking, etc...) are logged separately, and 1 undo wasn't ideal.

 

Well, again, my mod takes care of all of that. It’s not actually a mod… really.

Link to comment
Share on other sites

Again, simply changing one word would have done the job. See the mod I send you. It will simply change the Rewind function into an undo function (while keeping in mind that you miss-clicked. Eventually what this discussion was all about.) You have now effectively created an infinite extra undo feature capable of completely rewinding the game. Very exploitable and could have been prevented.

Not my idea. My idea is to keep rewind separate. Not to overwrite it. Also, I want undo to be usable in ironman as well. I can get rewind button to show on ironman, but it involves more overwriting, hence the reason I avoided it.

 

And again, as I've said several times by now, it doesn't even have simple checks, because I don't want to develop something complex before the game matures and possibly gets released first. 

 

You did not link it to anything, you just executed stuff. Also, good luck with creating and placing a new button. It’s rather tedious without an editing tool, but not impossible.

 

Do you even read (or comprehend) what I write? The function is new, and it is linked to an existing element on the UI. If you don't understand what I just wrote, don't bother replying.

 

I'm sure you did. BUT! Upon the start of the game the savegame get loaded into memory. That [mem-savegame] will be use for the remainder of your game session to load it's data, it will only write to savegame.lua. Your action does not get saved. Also not not registering makes bug tracking harder ;)

 

With you mod the following can happen:

mem-save will go: a53 > a54 > a55 > [undo] > a54 > a55 ...

savegame.lua will go: a53 > a54 > a55 > a54 [error]

 

The above is just an example to give you an idea (data is stored differently), also some other stuff gets updated, unless you use the undoAction, then nothing gets updated. As long as you finish your mission all will most likely be fine. Quiting in between will be a risk.

 

I believe the latest hotfix is able to handle savegame corruption better and/or maintaining it better upon exiting. So it’s convenient time on your part, though this is pure speculation.

 

Again, as I've said several times by now, I do not register undoAction, because the actions that you undo do NOT exist. Similar to your example (so you maybe understand this time)

 

game (what you see & play):

a53 - a54 - a55 - undo - undo - a54

 

save:

a53 - a54

 

Now I cannot stress the importance of this: I've TESTED everything as much as I can. I played several games, to see if this mod is leaving any loose bits around, which may corrupt the save at some point, or have different effects.

 

Here is one of my tests: one of my agents is next to a door. I save the game, copy the save file, run the game again. This save point is referenced as "original". I open the door, run and hide behind a cover, then save the game again. This save point is referenced as "after". Now when I compare original to after, obviously after contains these actions I've done just now. Now, here is the real test: I undo the last actions, till the point I started playing the game; where my agent is next to the door. I save the game, take the file, and compare it to the original.

 

Guess what? 100% identical. Which is/was what I expected, and what I got from the results of the "experiments". This is ONLY ONE test I've done over a dozen save tests at least.

 

Do you think I'd put out something that'd destroy people's progress? I am not a rookie wannabe modder who makes mods just for the sake of making mods. I make mods because it is my hobby. And I pay attention to every bit of detail. I pay attention to performance. I pay attention to usability, and I pay attention to stability & compatibility. Of course I am just one human being, and I don't know everything about the game, but I always try and check for any possible problems that can arise, and save file corruption due to undo action is NOT one of them, my friend.

 

Something like that. It does not insert the removed last action, it prevents the endTurnAction from being removed and puts the player at the turn-start after the endTurnAction. It’s kind of hard to insert something that doesn’t exit, but maybe you rephrased it wrong.

 

Reading this part alone tells me that you don't know a jack about how LUA or coding in general works.

 

It works EXACTLY like how I described it. The last action is already removed by the time the if-check is done. If the if-check passes, it is reinserted back to the history. Sure, in essence it prevents last endTurnAction from being removed, but I'm not talking about its essence / meaning, I'm talking about literally what it is doing.

 

As I've said above, I'm not a rookie modder, and I wouldn't post something that'd ruin anyone's progress. I can't check every variable, but I make damn sure to do my best and eliminate any problems that I find.

 

This is the last time I'm replying to you. I'm sorry but, this is like talking to a brick wall.

 

Good day to you, sir.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.