Losing Hotkeys

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

Cycrow wrote:are you sure u've set it to use the correct profile ? as the assigned keys are stored in the profile and it its not set, it'll load the defaults which wont include the added hotkeys.
All the profiles, including the default, get wiped as soon as you start a new game.

The profiles are either not being stored outside of the save game, or are being overwritten on a new game start.

Either way, each time you start a new game, you have to reassign all of the hotkeys again.

Whatever you did, you fixed some bugs in TC but created worse ones in AP.
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

DrBullwinkle wrote: Paraphrasing for clarity:

<RetVar> = register hotkey <name> to call script <Script Name>
Well, this method might be easy but it didn't work for me :) I was always getting the same number from this function no matter what I pass as <name> . I even wrote a loop with a changing name to see if I get a different number eventually - it went infinite :)

The only thing that seemingly helped was running Cycrow's code snippet followed by these two lines:

Code: Select all

$hotkeys = array alloc: size=0
set global variable: name='manager.hotkeys' value=$hotkeys
And then hacking several scripts not using the hotkey manager to re-register their hotkeys.

If somebody wishes to repeat that, keep in mind that hotkeys reappear only after a reload.
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

kurush wrote:this method might be easy but it didn't work for me :) I was always getting the same number from this function no matter what I pass as <name> .
Maybe you out-smarted the script?

I do not understand your test... you know that you are supposed to KEEP the old hotkey and ADD a new one, right? What number are you talking about? I tested by opening up the Controls / Interface menu and checking the availability of the hotkey there.

I can see how it might be necessary to do it more than once. Just keep adding hotkeys until they "stick". Obviously, save after adding a hotkey in order to save the incremented counter.

If I understand Cycrow's description of the bug, it should increment the counter each time you add a different hotkey (different name).

I did, finally, experience the bug, and adding a single extra hotkey fixed the problem completely.

YMMV, of course. :)
  • YMMV = Your Mileage May Vary. It is probably an American joke; means that your experience may not be the same as mine.
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

DrBullwinkle wrote:
I do not understand your test... you know that you are supposed to KEEP the old hotkey and ADD a new one, right?
I definitely understand that. I am talking about the handle number returned by the register hotkey script call. When this issue occurs, the number returned is the same for any number of hotkeys you are trying to register with next hotkey overwriting the one registered before it.
DrBullwinkle wrote: What number are you talking about? I tested by opening up the Controls / Interface menu and checking the availability of the hotkey there.
Not sure if there is another way to check this, we should be on the same page here :)
DrBullwinkle wrote: I can see how it might be necessary to do it more than once. Just keep adding hotkeys until they "stick". Obviously, save after adding a hotkey in order to save the incremented counter.
Unfortunately, it doesn't stick. At least not if you add hotkeys for the same script file. My test went through ~6000 attempts of registering a hotkey before I killed X3AP.exe.
DrBullwinkle wrote: If I understand Cycrow's description of the bug, it should increment the counter each time you add a different hotkey (different name).
I did, finally, experience the bug, and adding a single extra hotkey fixed the problem completely.
It might work in some special case, i.e. when only one hotkey was unregistered. It didn't work in my situation. Fortunately, the nuclear option seems to work. I am actually not sure why can renaming work based on Cycrow's explanation.
As I understand it, they have a collection there where some elements can get marked as "unregistered", but when adding a hotkey they actually use the # of registered hotkeys as a new index instead of either searching for one those "unregistered" elements or adding a new one at the end.
Last edited by kurush on Thu, 5. Jul 12, 07:53, edited 1 time in total.
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

kurush wrote:My test went through ~6000 attempts
That's what I mean about outsmarting the script. I would expect it to NOT work that way.

But it is good to know that you got it to work by removing all of the hotkeys.

Question: Does that repair your damaged save file? Does it now work correctly?
.
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

DrBullwinkle wrote: Question: Does that repair your damaged save file? Does it now work correctly?
.
It seems to, at least until I hit that unknown code that unregistered a hotkey for me. I wonder if it could be a result of moving my save file from one PC to another.
I would expect it to NOT work that way.
Care to elaborate why? I started from just renaming them of course.

Here is the script that I ended up running:

Code: Select all

$id = 1536
while $id < 3000
unregister hotkey $id
inc $id =
end

$hotkeys = array alloc: size=0
set global variable: name='manager.hotkeys' value=$hotkeys
set global variable: name='com.agent.hotkey1' value=[FALSE]
set global variable: name='com.logistics.hotkey1' value=[FALSE]
set global variable: name='com.logistics.hotkey2' value=[FALSE]
set global variable: name='missile.defense.mosquito.hotkey1' value=[FALSE]
This covers CLS, CAG, and MDM hotkeys plus whatever is registered in the hotkey manager (i.e. turbo boost). After running this script I saved and reloaded.
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

kurush wrote:that unknown code that unregistered a hotkey for me.
My guess is that the Plugin Manager runs an uninstall script, if available. So you might be safe if you never uninstall anything. Maybe.
kurush wrote:
I would expect it to NOT work that way.
Care to elaborate why?
The problem is in the saved game, not in the "register hotkey" command. So I would expect that repeating the command in a loop would have no effect.

You have to create a new hotkey, then SAVE. Test. Repeat, if necessary.

Also, I specifically changed the setup script for the missing hotkey (not just any arbitrary hotkey). That is another reason why making a loop does not make sense to me, because you may have to fix whichever hotkey is broken. At least, that is what I did.

But I am mostly guessing. I only had one bad hotkey, so maybe my case was simpler than yours.

Thanks for posting your code. Why do you loop from 1536 to 3000? If that has been mentioned before, I must have missed it.
.
Last edited by DrBullwinkle on Thu, 5. Jul 12, 08:42, edited 1 time in total.
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

DrBullwinkle wrote: Thanks for posting your code. Why do you loop from 1536 to 3000? If that has been mentioned before, I must have missed it.
.
This is the Cycrow's code that I just copy/pasted. It was his suggestion to run it. Now I realized that I am still missing one hotkey *sigh*. Now it is Plugin Configurations, I wonder where does it get registered.
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

Oh, right... now I remember the 1536-3000.
kurush wrote:Plugin Configurations, I wonder where does it get registered.
init.community.config.xml?
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22409
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

1536 is the id of the first custom hotkey, 3000 is just a random number to cover all hotkeys.

if i get chance tonite ill create a script that will remove all the registered hotkeys using regex
User avatar
Charon_A
Posts: 105
Joined: Wed, 6. Nov 02, 20:31

Post by Charon_A »

I banged against this some time ago.
The problems started after I tried to start a new game to test my script and then loaded old save and unregistered/registered some hotkeys. To be on the safe side - do not start new game until you're really done with the one you're playing :)

As for regex, I tried this, but not every script follows naming convention.
$global.keys = get global variables: regular expression='.*key.*'

I even went to the length of analyzing all the scripts I had and manually unregistered all their hotkeys. That didn't help either.

So after all I tried a brute-force 1500-2000 loop and unregistered all I could - still got missing/overlapping hotkeys on consecutive registration attempts.

I finally gave up and decided to roll back to the last save before I started uninstalling hotkeys and stating new games. That save has most of the hotkeys I need and works for now. I try very hard not to add any more hotkeys in my current game.
Be careful about reading health books. You may die of a misprint.
---Mark Twain---
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

DrBullwinkle wrote:I only had one bad hotkey, so maybe my case was simpler than yours.
Yes, yours is the most simplest case, hence the difference in emphasis.

I have over a dozen that go missing as soon as you add 1 new hotkey, and as soon as you start a new game.

Its too many for hit and miss fixes.
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

Charon_A wrote:I try very hard not to add any more hotkeys in my current game.
Adding hotkeys is not a problem.

The only issue is with *removing* hotkeys.
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

Cycrow wrote:1536 is the id of the first custom hotkey, 3000 is just a random number to cover all hotkeys.

if i get chance tonite ill create a script that will remove all the registered hotkeys using regex
I just realized that the script actually didn't help. It still allows me to register up to 10 hotkeys and then starts reusing the indexes. How would the regex version differ from just trying to unregister them all?
DrBullwinkle wrote: init.community.config.xml?
At least I think I know what had hit me :) This script apparently has some code to unregister its hotkey when the hotkey manager is either installed or removed.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

DrBullwinkle wrote: The only issue is with *removing* hotkeys.
The hotkey manager has code to remove them, but I cant determine why it would be used. Not knowing the logic, I'm not game to simply remove the call.

This is why I want Cycrow to fix it. He knows the logic structure for the group of scripts.

And btw, I've NOT removed any hotkeys. I get the problem when I ADD a hotkey and start a new game. There is no reason at all why the scripts should be trying to delete hotkeys at all ! Hence my not understanding the logic of it.
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

apricotslice wrote: The hotkey manager has code to remove them, but I cant determine why it would be used. Not knowing the logic, I'm not game to simply remove the call.
Hotkey manager unregister logic does not kick in, so there is no need to remove anything from there. There are other script that can use the unregister function.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

kurush wrote:
apricotslice wrote: The hotkey manager has code to remove them, but I cant determine why it would be used. Not knowing the logic, I'm not game to simply remove the call.
Hotkey manager unregister logic does not kick in, so there is no need to remove anything from there. There are other script that can use the unregister function.
If thats the case, then the problem is NOT in the unregister code, because I've never removed any hotkeys.

The only way the unregister code can be the problem is if the logic uses that function generally. eg. in order to add a new hotkey, it first deletes all of them, and then adds them all back in. That kind of thing is the sort of logic I was refering to, as its the only way I can see the unregister code being used in my game. If that isnt the case, then unregistering hotkeys has nothing at all to do with the problem !
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

apricotslice wrote: If thats the case, then the problem is NOT in the unregister code, because I've never removed any hotkeys.
You have to read all setup and init scripts to be able to say that. For example, I figured that my hotkey likely got unregistered by init.community.plugin.xml that can unregister the hotkey for Plugin Configurations under certain circumstances. You don't have to uninstall anything to trigger that. Ironically, all you have to do is install the hotkey manager when plugin manager is already there and has its hotkey registered.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

kurush wrote:
apricotslice wrote: If thats the case, then the problem is NOT in the unregister code, because I've never removed any hotkeys.
You have to read all setup and init scripts to be able to say that. For example, I figured that my hotkey likely got unregistered by init.community.plugin.xml that can unregister the hotkey for Plugin Configurations under certain circumstances. You don't have to uninstall anything to trigger that. Ironically, all you have to do is install the hotkey manager when plugin manager is already there and has its hotkey registered.
Well then, that would appear to be the problem. Why cant that circumstance be fixed by Cycrow and released as a hotkey manager update ?

However, if it was that, why hasnt it already been fixed and released as a script update ?
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22409
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

apricotslice wrote: Well then, that would appear to be the problem. Why cant that circumstance be fixed by Cycrow and released as a hotkey manager update ?
because its not actually a problem with the hotkey manager
the scripts were designed to work with or without the hotkey manager.
without it, it manages its own hotkey.

but when you start using the hotkey manager, the script will remove its own version and use the hotkey manager.

so no changes to the hotkey manager will help with this.

the scripts that do this will need to be altered. And it isn't just the Config plugin that does this, there are many others

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”