In lots of my builds I use the CONTROL_LEFT and CONTROL_RIGHT to activate special functions - toggle camera modes, switch TCS on and off, activate particle effects or raise and lower landing gear, and so on. Until this week I've not had any difficulty. At the moment I'm working on an airship which has harpoon cannons - one on the bow and one on either side of the hull. The idea is that I use CONTROL_LEFT to rotate through the cannons to activate them, and CONTROL_LMOUSE to fire whichever cannon it active.
The difficulty is that the script is somehow interpreting CONTROL_LEFT as alternating between the shift + left cursor and the left mouse button. I've placed a llOwnerSay in the child script to parrot the link messages it's receiving and another in the main script which should only get executed when the mouse is clicked, then I start hitting shift + left cursor and nothing else. Here's what I get:
--------Shift + Left Cursor--------
[7:13] 9: CANNONINACTIVE
[7:13] 9: CANNONACTIVE-9
--------Shift + Left Cursor--------
[7:13] Narwhal: MOUSE CLICK
[7:13] 9: FIRE-9
[7:13] 9: CANNONINACTIVE
[7:13] 9: CANNONACTIVE-12
--------Shift + Left Cursor--------
9 is the name of the cannon at the nine o'clock position, it's the first one to be activated. Narwhal is the name of the object.
Each time shift + left cursor is pressed I send "CANNONINACTIVE" to to deactivate all of the cannons, followed by CANNONACTIVE- followed by the name of the cannon to be activated.
So the first time I press shift + left cursor cannon 9 goes active. That's working perfectly as seen above. I wait a moment to ensure that there's nothing lingering to be processed and press shift + left cursor a second time and the main script somehow registers a mouse click which it's passing to the cannon - that's the FIRE-9 line. Then after an intentional three second delay (to keep people from being able to fire constantly) it actually does the shift + left action.
Here's the code from the main script:
if (( level && CONTROL_LBUTTON) && (cannon != 0))
{
if((llGetTime() - reloadTime) > 3)
{
llOwnerSay("MOUSE CLICK"
;reloadTime = llGetTime();
llMessageLinked(LINK_SET, 8008, "FIRE-" + (string)cc, NULL_KEY);
}
}
if(level && CONTROL_LEFT)
{
if((llGetTime() - nullTime) > 1)
{
nullTime = llGetTime();
cannon +=1;
if(cannon == 4) {cannon = 0;}
if(cannon == 1) {cc = 9;}
if(cannon == 2) {cc = 12;}
if(cannon == 3) {cc = 3;}
llMessageLinked(LINK_SET, 8008, "CANNONINACTIVE", NULL_KEY);
if(cannon != 0)
{
llMessageLinked(LINK_SET, 8008, "CANNONACTIVE-" + (string)cc, NULL_KEY);
llSleep(.1);
}
}
}
Clearly something is hokey but for the life of me I can't figure out what. The only place in the entire object that the words "MOUSE CLICK" occur are in the section which in my mind can only get executed when the mouse is - y'know, clicked. Oh and clicking the mouse butting does function exactly as intended.
Can anyone see something that I'm clearly doing wrong and will feel dreadfully stupid about missing? Or has anyone encountered and solved this issue already?
Thanks...
