AP - hotkeys are broken

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

kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

AP - hotkeys are broken

Post by kurush »

Help! Evil monster from Würselen is eating our hotkeys. Cycrow is on the run and can'd do anything about it. :lol:
Last edited by kurush on Fri, 25. May 12, 06:58, edited 2 times in total.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

I'm avoiding using hotkeys for AP.

The whole hotkey system in AP is right royally bugged, and so far, zero is being done about it.

Is there any reason why you would want to turn it off in a hurry after turning it on ? If not, then better in AP to use a command.
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

apricotslice wrote: The whole hotkey system in AP is right royally bugged, and so far, zero is being done about it.
I won't argue here - I spent half of the time working on my script figuring out why my hotkey replaces Plugin Configuration. For some reason it was getting the same hotkey handler as *one of handlers* for Plugin Configuration and the other one doesn't seem to show up. Why Plugin Configuration shows twice in that hotkey collection is anybody's guess.
I ended up with a hotkey because initially it was envisioned as a one time operation to clear the sector of all your missiles. Only after I got it working, I realized that it is actually better for performance if I destroy only the missiles that are not far from stations and ended up repeating that action every 5 sec.
Last edited by kurush on Fri, 25. May 12, 05:04, edited 1 time in total.
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

kurush wrote:I spent half of the time for this script figuring out why my hotkey replaces Plugin Configuration.
Does switching to a different profile (then switch back) help?

Does restarting X3 help?

Does rebooting the computer help?

There is something funny about hotkeys, but I have yet to see a *permanent* problem. One of the above has worked each time I have seen an issue. That is not a guarantee that they will work for you, but it is worth a try.

It seems as though part of the profile gets stuck in memory.

Use 2 custom equipment wares
There are several good scripts on this forum that do not work because of something wrong with their custom wares. That includes scripts by some of the best known and most experienced scripters. In a couple of cases, I have tracked problems to what appears to be a change in EMP that occurred a couple of years ago. In another case, there appears to be a bug in EMP itself.

I have looked everywhere that I can think of for authoritative documentation about custom wares. My questions on the forum have gone unanswered. The *only* decent documentation that I could find was the readme that comes with the EMPx package. And that doc presumes that the reader is familiar with language files and the way that they can replace values in the vanilla files. In my case, that was not a valid assumption the first time that I tried to read the doc.

MARS works reliably because the MARS ware is built in to the vanilla TWareT. Full replacement mods work because they replace TWareT. But trying to add custom wares, reliably, seems to be sketchy, at best.

Maybe the problems have been worked out, and maybe the current EMP that is built into the Plugin Manager is stable now. Maybe the Plugin Manager tab for Wares works properly -- it appears to add rows to types\TwareT.pck that the PM generates when you close the PM. I don't know -- I only know, for sure, that you should test wares on more than one installation of the game. Preferably with multiple users playing different games.

At least be aware that there are common issues. That may be the reason why several scripters appear to have stopped using custom wares.

PS: Modding TWareT for your own game is easy enough. The hard part is trying to distribute custom wares to others.
Last edited by DrBullwinkle on Wed, 23. May 12, 02:08, edited 2 times in total.
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

DrBullwinkle wrote: Does switching to a different profile (then switch back) help?

Does restarting X3 help?

Does rebooting the computer help?
I did a couple of reboots yesterday and it didn't help. I tried switching profiles and it didn't help either. Basically, my plugin configuration hotkey is gone after I run my setup script because my hotkey gets the same handle number. The only useful thing I used there was Turbo Booster configuration not to use EC before laser and shield gen, but still. I wonder if I can write a script to unregister all hotkeys found in Cycrow's collection, clear that collection and see whether it registers them back properly after that.

On custom wares - I didn't know it is that complicated :) I wonder whether I can just rename that Camouflage Device thingie somehow and be done with it then. One thing that I don't like is that it stays equipped if you switch ships, I wonder if I can find something that works as UFJD instead.
Edit: easily to rename it in the t file.
Edit2: I tried to remove both Plugin Configuration entries from the collection via a script to make Cycrow's script it re-register them and sure as hell it got re-registered with the same ID as my hotkey :) Do we have 12 hotkeys max or something? I got these two entries in that hotkey array:

Code: Select all

Hotkey config Plugin Configurations 1551 plugin.config.hotkey
Hotkey destroymymissiles Missile monitor 1551 kr.killmissiles.hotkey
The second entry for Plugin Configuration is gone after running that script, it had the same key of "config" but plugin.config.menu as script.
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

kurush wrote:I did a couple of reboots yesterday and it didn't help.
OK, good. You have a reproducible instance of the bug; AND you know your computer well. You may be in a good position to solve this. :)

Does it matter whether the keys are registered with "register hotkey" or with Cycrow's Hotkey Manager? As you may know, the Hotkey Manager stores key definitions in memory, so that they can be removed. Removing hotkeys, once registered via "register hotkey", requires knowing the exact name used to register it.
On custom wares ... easily to rename it in the t file.
Yes. I forgot to mention that wares are easy if you are only modifying your own game. Just edit TWareT.

The issues come when you try to distribute the custom ware.

The Plugin Manager uses a technique of merging the ware definition with EMP, then smooshing them together into a PM-generated TWareT.pck. That might, actually, be the most elegant way of distributing custom wares. Unfortunately, it seems to be undocumented, so you have to know that the PM deletes the .pck when it opens, and re-creates the .pcks when the PM closes.
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

DrBullwinkle wrote: Does it matter whether the keys are registered with "register hotkey" or with Cycrow's Hotkey Manager? As you may know, the Hotkey Manager stores key definitions in memory, so that they can be removed. Removing hotkeys, once registered via "register hotkey", requires knowing the exact name used to register it.
Both problematic hotkeys are registered with Hotkey Manager and I was playing with its internal collection to resolve it. It looks like out of my hotkey and Plugin Configuration I can get either one or another, but not both.
The issues come when you try to distribute the custom ware.
Sorry, I should have said "Easy to change it in the translation file", meaning that I can rename Camouflage Device to Missile Monitor by adding the page number where I found its original name to my text file.
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

You said it correctly (changing the name in the t file). I just read it... "sideways, sort of". :) Good solution, by the way.

The Hotkey Manager is just a script. Perhaps you can fix it?
One thing that I don't like is that the [Camouflage Device] stays equipped [on the ship] if you switch ships, I wonder if I can find something that works as UFJD instead.


There are some items that travel with the player rather than with the ship. UFJD and Licenses come to mind.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

There is a thread for this hotkey issue, and basically it got handballed to Cycrow, who hasnt responded on it at all.

Edit : http://forum.egosoft.com/viewtopic.php?p=3845746

The only thing I've found that works is a cold start. If you restart, the problem remains. If you power off, the bug gets reset and a game will start up ok. Usually.

But the only really sure way of getting hotkeys to work, is every time you add a hotkey, you immediately start a new game. Which of course, is rediculous.

Needless to say, this is "modding", so egosoft themselves are not interested in fixing their own problem.

If someone decides to take it on, the appropriate place to discuss and test is in that thread.

If anyone wants to have a go at fixing this, I'd say go for it !

Ironically, what they did fixed a big issue for some mods in TC, but in the process, created a worse issue in AP. The only person with any knowledge on it appears to be Cycrow, and yet, it obviously has no priority with him at all, as last I heard, he wasnt even responding to other moderators PM's about this.

Anyway, not sure how far the thread on this has dropped down the abyss, but its worth finding and keeping current. Or at least, keep it noticible as an ongoing problem.http://forum.egosoft.com/viewtopic.php?p=3845746
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

DrBullwinkle wrote: The Hotkey Manager is just a script. Perhaps you can fix it?
Actually, I remembered now that I started from directly registering a hotkey and ran into exactly the same issue. I only switched to the hotkey manager once I ran into this funky behavior thinking that it can do a better job than myself. That tells me that Cycrow probably has nothing to do with the bug and it is somewhere in the game engine. Not cool - I was thinking about one more hotkey-based script.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

The trouble is, Cycrow is the only only one who really understands this part of the game.

So if the devs dont understand what they did and why its going wrong, Cycrow is the only one who has a chance of debugging it. And it appears he is unavailable.
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

Well, I guess I found several bugs in the hotkey manager :)

1) Cycrow tried to use a boolean global variable for synchronization of his "purge" method. Problem is setting a global variable to [FALSE] apparently results in this variable being null and any condition where it is involved evaluates to false. As a result, the purge script wasn't getting called at all and some garbage hotkeys were accumulating in that collection. In my case it included 3 keys for boarding hotkeys and two keys for plugin manager.
2) Even when called, the purge method did not purge from its collection the hotkeys that no longer have a handle, meaning they are not in fact registered.

After I fixed 1 and 2, I was able to get both Plugin Configuration and my hotkey visible. But now the Hepastos hotkey disappeared :) It looks like there is more to research.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

I'll cross post that onto the tech support thread.

Keep going. :)

Yes, definitely look wider at anything connected. Like why does changing one profile wipe out all of them ? Why when you start a new game are all profiles wiped clean ?
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

Actually, Hepastos is gone because I replaced bonus pack version with the unsigned version and apparently X2I switched from using the hotkey manager to manual hotkey registration at some point. So, it no longer even tries to register its hotkey because it has some key remembered that is already invalid.
Now my biggest question is why nobody actually tries to check whether their hotkey is active in the setup script? What is wrong with this:

$hk = get hotkey index, script name 'my.script'
if $hk == 0
$hk = register hotkey 'My Label' to call script 'my.script'
end

?

But in any case, I am still getting duplicate handles even after all these changes. I changed my setup to try registering two different scripts for two hotkeys and got the same handle for both plus the same handle for the building service. If I start a new game, everything seems to be in order.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

kurush wrote: $hk = get hotkey index, script name 'my.script'
if $hk == 0
$hk = register hotkey 'My Label' to call script 'my.script'
end

?

But in any case, I am still getting duplicate handles even after all these changes. I changed my setup to try registering two different scripts for two hotkeys and got the same handle for both plus the same handle for the building service. If I start a new game, everything seems to be in order.
No answer to your question, other than I've never seen it done before. My first hotkey was a direct copy of one of Cycrows scripts, and all since then were a copy of that. :)

The reason it was all rewritten was because TC was accumulating them every time the setup script ran. Oddly now, the checks put in for TC to setup hotkeys and stuff on the second load, dont actually work in AP properly.

Oddball thought - are you working on the AP game files, or on Cycrows 3rd party addon ? I would expect them to be different, with AP being the later. Just checking. :)
User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 25128
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus »

kurush wrote:Actually, Hepastos is gone because I replaced bonus pack version with the unsigned version and apparently X2I switched from using the hotkey manager to manual hotkey registration at some point.
Bonus package scripts generally use the Hotkey manager. That way removing the setup-scripts of the BP scripts (that's what the BP uninstaller does) will also remove the hotkeys without the need for an uninstall script. The original (unsigned) version has never been using the Hotkey manager in the first place.

As for replacing the Hephaistos Corp versions, it's also important to note that BP scripts are distributed as .pck-files (the unsigned version comes as .xml) and that the setup-scripts are different (including different names). So you should uninstall the BP version, before installing the unsigned version.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

Better would be to unpack the BP scripts, work on them, then repack them.
User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 25128
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus »

Better in what sense?
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

The Bonus Pack scripts should be the latest version of the hotkey scripts.
User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 25128
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus »

Hotkey scripts? Please explain a bit more detailed what you're talking about, becauce I really have no idea what you mean.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

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