custom hotbuild hotkey

Everything about mods can be found here.

Moderator: Morax

custom hotbuild hotkey

Postby PhilipJFry » 19 May 2017, 16:39

I'm trying to make a custom hotbuild hotkey that does the same thing as the existing hotbuild hotkey for pgens without the power storage.
I have basically 0 coding experience and just took hotbuildex as a template mod and managed to create the key but i have two issues:
1) the key isn't bound at the start of the game and i have to open the keybinding menu to make the game map the key
2) the hotkey label isn't showing for the key

if someone who knows stuff would be so kind to tell me what i have to do to fix these two issues that would be amazing
edit: deleted the file cause it didn't work and keyblue made a working mod
Last edited by PhilipJFry on 21 May 2017, 09:19, edited 1 time in total.
cats>dogs
post logs
User avatar
PhilipJFry
Supreme Commander
 
Posts: 2635
Joined: 23 Mar 2016, 21:16
Location: Austria
Has liked: 232 times
Been liked: 348 times
FAF User Name: PhilipJFry

Re: custom hotbuild hotkey

Postby KeyBlue » 19 May 2017, 17:31

1) this does seem to be the case
Apparantly you need to have new keybinds set in your game.prefs since keybinds gets loaded before any mods come into play.
So the game gives an error that it doesn't know what action "Specialkey" is. But it knows what it is when you go into keybinding menu since the mod is loaded then.
To add the key to game.prefs you need to have something like this somewhere in your mod (i've seen it put in gamemain.lua ):
Code: Select all
KeyMapper.SetUserKeyAction('SpecialKey', {action = "UI_Lua import('/lua/keymap/hotbuild.lua').buildAction('PgenNoStorage')", category = 'hotbuilding', order = 1101})

This will add it to your game.prefs and in the next game it'll be work.

2) Looks like hotkey labels can't handle multiple groups containing the same unit. So it just takes whichever comes last in the code.
And tries to get a hotkey for that. But i assume you unbound it and used that key for your new hotbuild group.
So now it tries to show it for the original one but because its not bound it stays empty.

Since you'll probably not want to use the original one anyway, you could try to remove "Pgen" unitkeygroup by setting it to nil.
User avatar
KeyBlue
Priest
 
Posts: 403
Joined: 28 Jan 2016, 01:06
Has liked: 140 times
Been liked: 93 times
FAF User Name: KeyBlue

Re: custom hotbuild hotkey

Postby PhilipJFry » 20 May 2017, 15:11

thank you for the tip
i just put the entire keymapper.lua file into the mod.
edit: deleted the attachement cause keyblue made a working mod
Last edited by PhilipJFry on 21 May 2017, 09:20, edited 1 time in total.
cats>dogs
post logs
User avatar
PhilipJFry
Supreme Commander
 
Posts: 2635
Joined: 23 Mar 2016, 21:16
Location: Austria
Has liked: 232 times
Been liked: 348 times
FAF User Name: PhilipJFry

Re: custom hotbuild hotkey

Postby KeyBlue » 20 May 2017, 15:18

why did you put the keymapper.lua file in the mod?
and what did it accomplish?
User avatar
KeyBlue
Priest
 
Posts: 403
Joined: 28 Jan 2016, 01:06
Has liked: 140 times
Been liked: 93 times
FAF User Name: KeyBlue

Re: custom hotbuild hotkey

Postby PhilipJFry » 20 May 2017, 15:34

it did map the key when starting the game
unfortunately it also causes a crash in combination with some other mod (probably notify) so i need to fix that

edit: ok now it just crashes... not sure why it worked the first few times when it tested it
edit2: i did use that file cause it was the only file with the SetUserKeyAction function in it that i could find
cats>dogs
post logs
User avatar
PhilipJFry
Supreme Commander
 
Posts: 2635
Joined: 23 Mar 2016, 21:16
Location: Austria
Has liked: 232 times
Been liked: 348 times
FAF User Name: PhilipJFry


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest