Scripting Roadblocks
Acheron
Join Date: 2002-11-13 Member: 8489Members
<div class="IPBDescription">I am banging my head against a wall here</div> So, I've got this great script going, based in part on <a href='http://www.unknownworlds.com/forums/index.php?act=ST&f=20&t=8598' target='_blank'>Othell's script</a>.
So far, it's a script that remaps your keys if you're a Marine or a Commander. In Commander mode, ideally, you hit a key to open a menu (eg: b for "build"), and two things happen: the menu opens onscreen, and your keys are remapped for building hotkeys (eg: pressing "B, T" buys a turret; - Just like Starcraft <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html/emoticons/biggrin.gif' border='0' valign='absmiddle' alt='biggrin.gif'><!--endemo-->). However, I ran into a few problems:
- Hotkey commands cannot be combined with other commands in a single keystroke. Ie: bind "b" "hotkey86; exec buildremap.cfg" does not do both of those commands. Thus, the closest solution requires <b>two</b> keypresses to open the menu and remap the keys. Similarly, an additional keypress is required to revert your keys to their default settings after you drop buildings/equip.
- At this point, I thought, "fine, no problem". I even came up with a really sneaky solution: by altering my mouse1 bind, I could place the building <i>and</i> revert my keys. Smiling smugly, I wrote the code into my script and tested it. It didn't work. Apparently, when you are a commander, <b>you can't change what your mouse buttons do</b>. That's right, the command to place a building is hardwired into your mouse, so when I tried to alter my +attack settings, it of course did nothing. Similarly, the command to place a building does not exist, it's simply hardwired to your mouse button without your knowledge.
What does all this mean?
To implement a SC-style hotkey script, instead of hitting two buttons to get a building, you have to hit <b>four</b>. Two to open the menu, one to select the building, and one afterwards to revert your menu keys. <b>Well that's convenient</b>. <!--emo&???--><img src='http://www.unknownworlds.com/forums/html/emoticons/confused.gif' border='0' valign='absmiddle' alt='confused.gif'><!--endemo-->
So my question is: why are these two "roadblocks" in place? Is this an intentional effort of the programmers, much like this "leap-blink" effort, to prevent scripting? or is it just a coding mishap? Will it be "fixed"?
Don't get me wrong, I absolutely love NS. I just happen to love scripting as well, and I think this script, if it weren't crippled by strange extra keypresses, could turn out really well.
So far, it's a script that remaps your keys if you're a Marine or a Commander. In Commander mode, ideally, you hit a key to open a menu (eg: b for "build"), and two things happen: the menu opens onscreen, and your keys are remapped for building hotkeys (eg: pressing "B, T" buys a turret; - Just like Starcraft <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html/emoticons/biggrin.gif' border='0' valign='absmiddle' alt='biggrin.gif'><!--endemo-->). However, I ran into a few problems:
- Hotkey commands cannot be combined with other commands in a single keystroke. Ie: bind "b" "hotkey86; exec buildremap.cfg" does not do both of those commands. Thus, the closest solution requires <b>two</b> keypresses to open the menu and remap the keys. Similarly, an additional keypress is required to revert your keys to their default settings after you drop buildings/equip.
- At this point, I thought, "fine, no problem". I even came up with a really sneaky solution: by altering my mouse1 bind, I could place the building <i>and</i> revert my keys. Smiling smugly, I wrote the code into my script and tested it. It didn't work. Apparently, when you are a commander, <b>you can't change what your mouse buttons do</b>. That's right, the command to place a building is hardwired into your mouse, so when I tried to alter my +attack settings, it of course did nothing. Similarly, the command to place a building does not exist, it's simply hardwired to your mouse button without your knowledge.
What does all this mean?
To implement a SC-style hotkey script, instead of hitting two buttons to get a building, you have to hit <b>four</b>. Two to open the menu, one to select the building, and one afterwards to revert your menu keys. <b>Well that's convenient</b>. <!--emo&???--><img src='http://www.unknownworlds.com/forums/html/emoticons/confused.gif' border='0' valign='absmiddle' alt='confused.gif'><!--endemo-->
So my question is: why are these two "roadblocks" in place? Is this an intentional effort of the programmers, much like this "leap-blink" effort, to prevent scripting? or is it just a coding mishap? Will it be "fixed"?
Don't get me wrong, I absolutely love NS. I just happen to love scripting as well, and I think this script, if it weren't crippled by strange extra keypresses, could turn out really well.
Comments
I want to make a script that makes commanding more like playing starcraft. For example, pressing "B" then "T" would buy a turret.
However, the "hotkey" commands (what we use to buy buildings, open menus - basically everything we do as a commander) are very strange, and you can't make 1 press of a button do both a hotkey (for example, buy a turret) AND do another command at the same time. For those of you unfamiliar with scripting in Half-Life... <i>this is very strange and annoying</i>.
Oh, and you can only place buildings as a commander with your left mouse button. (That's also the ONLY thing you can make your left mouse button do as a commander).
Comprox is right, I want the possibility of the same keyboard key being used for dif. hotkeys, depending on which menu is open. All I'm asking here is whether the problems that prevent such a script are intentional or accidental.
Instead of "bind "b" "hotkey86; exec buildremap.cfg"" you want something like...
<!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->bind "b" buildmenu
alias buildmenu "hotkey86; exec buildremap.cfg"<!--c2--></td></tr></table><span class='postcolor'><!--ec2-->
I'm going to do some poking around to see if maybe there's a hotkey somewhere for the commander's mouseclick. I'll post back if I find anything.
Oh, wait, the research buttons I have yet to find. but those... well, you can just click those, no point in binding them.
It is kinda nice to have hotkey69 on delete, though. Click a building, hit delete, and it recycles <!--emo&:)--><img src='http://www.unknownworlds.com/forums/html/emoticons/smile.gif' border='0' valign='absmiddle' alt='smile.gif'><!--endemo-->
Right now my script *works*, and since I'm fast on the keyboard (100 wpm typing) it doesn't really matter that I have to hit buttons. But my "dream" is to distribute the script so other people can use it. So far my solutions are to:
1. Bind the menu-opening key to *only* exec the remap script, which will itself rebind the menu opening key. Ie: hit b once to rebind, hit it again to actually open the menu onscreen.
2. Bind mousewheelup to reset the keys.
These are both fairly easy to do, because you just double-tap a key to open a menu, and mwheelup is right there and not too much effort to hit.
So three <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html/emoticons/biggrin.gif' border='0' valign='absmiddle' alt='biggrin.gif'><!--endemo-->
(Here's a link to mine: <a href='http://rawr.mine.nu/commander.cfg' target='_blank'>http://rawr.mine.nu/commander.cfg</a>. Feel free to modify, or incorporate ideas, or whatever <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html/emoticons/biggrin.gif' border='0' valign='absmiddle' alt='biggrin.gif'><!--endemo-->)
<!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
Don't have anything helpful to add to the thread, but I've played under Othell's command several times; he's one of the best commanders I've seen yet. <!--emo&:)--><img src='http://www.unknownworlds.com/forums/html/emoticons/smile.gif' border='0' valign='absmiddle' alt='smile.gif'><!--endemo-->
Ie:
If my non-team talk button is t, but I *also* want that button as a hotkey for a turret, I have to somehow rebind it to t after I buy a turret. Since the command to select a turret is a hotkey, and since you can't rebind mouse1 to place the turret and rebind your keys... you have to pick another key (in my case mousewheelup) to reset your keys.
Fussy? Yes. <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html/emoticons/biggrin.gif' border='0' valign='absmiddle' alt='biggrin.gif'><!--endemo-->
heh... thanks.
I had the same thought. And you're right -- no <!--emo&:angry:--><img src='http://www.unknownworlds.com/forums/html/emoticons/mad.gif' border='0' valign='absmiddle' alt='mad.gif'><!--endemo-->
the double-tap or bind-everything-to-its-own-key methods are the only ones right now.
I think that if it's something easy to fix, it would be nice. If it would take a lot of work, the current system should work just fine. There are more pressing issues then commanders having to press a button or two more <!--emo&:)--><img src='http://www.unknownworlds.com/forums/html/emoticons/smile.gif' border='0' valign='absmiddle' alt='smile.gif'><!--endemo-->