Carbon Philter Posted July 15, 2011 Share Posted July 15, 2011 Hi all. Need some more help,please.I'm setting up controls for a boat and can't seem to trigger actions associated with the forward/back control correctly. In the main script - modded from Cubey Terra's submarine script - I have the bit which activates the movement by incremental speed steps working ok and the boat moves as I want.I have a second script which takes a link message to provide data for an on-screen 'dashboard' reporting engine, speed, depth, etc, and to test I added in an OwnerSay to see if it was functioning correctly. Although the sender script is only sending the trigger once I would appear to be getting the recieving script triggering twice - once on key press and once on key release instead of just firing once for the key being pressed so I'm getting double rports although as I said, the motor moves the boat as intended.Is there something I'm missing in the controls event to stop the duplication or is it something set up wrong in the receiving script?Thanks for any advice/suggestions. The main script portion is as follows: if ((change & CONTROL_FWD) || (change & CONTROL_BACK)) { if (held & CONTROL_FWD) { if (throttle < THROTTLE_MAX) { throttle++; llOwnerSay ((string)throttle); } } else if (held & CONTROL_BACK) { if (throttle > THROTTLE_MIN) { throttle--; llOwnerSay ((string)throttle); } } llMessageLinked(LINK_SET,throttle*10,"throttle",""); // pass throttle setting to child prims }and the receiving script is this:// script for Dashboardfloat TIMER_INT = 0.25;integer throttle;integer number;string engine_telegraph;default{ state_entry() { llSetText("",ZERO_VECTOR,1); llSoundPreload("telegraph"); } on_rez(integer num) { llResetScript(); } link_message(integer sender_number, integer number, string message, key id) { if (message == "throttle") { throttle = number; llOwnerSay ((string)throttle); llPlaySound("telegraph", 1); } if (throttle == 0) { engine_telegraph = "Stop"; llOwnerSay ("Stop sent"); llPlaySound("telegraph", 1); } if ( throttle == 10) { engine_telegraph = "Dead Slow Ahead"; llOwnerSay ("Dead Slow Ahead sent"); llPlaySound("telegraph", 1); } else if ( throttle == 20) { engine_telegraph = "Slow Ahead"; llOwnerSay ("Slow Ahead sent"); llPlaySound("telegraph", 1); } else if ( throttle == 30) { engine_telegraph = "Half Ahead"; llOwnerSay ("Half Ahead sent"); llPlaySound("telegraph", 1); } else if ( throttle == 40) { engine_telegraph = "Full Ahead"; llOwnerSay ("Full Ahead sent"); llPlaySound("telegraph", 1); } else if ( number == -10) { engine_telegraph = "Dead Slow Astern"; llOwnerSay ("Dead Slow Astern"); llPlaySound("telegraph", 1); } else if ( number == -20) { engine_telegraph = "Slow Astern"; llOwnerSay ("Slow Astern sent"); llPlaySound("telegraph", 1); } else if ( number == -30) { engine_telegraph = "Half Astern"; llOwnerSay ("Half Astern sent"); llPlaySound("telegraph", 1); } else if ( number == -40) { engine_telegraph = "Full Astern"; llOwnerSay ("Full Astern sent"); llPlaySound("telegraph", 1); } else if (message == "unseated") { llSleep(0.7); llSetTimerEvent(0); llSetText("",ZERO_VECTOR,0); throttle = 0; } else if (message == "seated") { llSetTimerEvent(TIMER_INT); } } timer() { vector pos = llGetPos(); float waterlevel = llWater(<0.0,0.0,0.0>); float seabed = llGround(<0.0,0.0,0.0>); float fdepth = (waterlevel - seabed)*100; integer i10depth = (integer)fdepth; float depthF = (float)i10depth/100; integer speed = (integer)llRound((llVecMag(llGetVel())) * 1.9438444); llSetText("Engine: "+ engine_telegraph +"\nSpeed = "+(string)speed+" knots \nSeabed at "+ (string)llGround(<0.0,0.0,0.0>) + "m \nWater level: " + (string)llWater(<0.0,0.0,0.0>) + "m \nDepth = "+(string)depthF+"m \nKeel clearance: " + (string)((llWater(<0.0,0.0,0.0>)-1.87399) - llGround(<0.0,0.0,0.0>))+ "m \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ",<1,1,1>,1); }} Link to comment Share on other sites More sharing options...
Ron Khondji Posted July 15, 2011 Share Posted July 15, 2011 Your messagelinked is in the wrong place. The message gets send every time CONTROL_FWD or _BACK is pressed or released. Put the messagelinked where your ownersays are and it should work. Link to comment Share on other sites More sharing options...
Carbon Philter Posted July 15, 2011 Author Share Posted July 15, 2011 Thanks Ron - cracked it instantly. Why can't I see these things?? Much appreciated. Link to comment Share on other sites More sharing options...
Void Singer Posted July 15, 2011 Share Posted July 15, 2011 that would be one solution, the alternative is to test both change AND level keydown = change and level keyheld = level keyup =change as you can see for each sequence of key press both change an level are true twice... once together, and once each alone (although held will repeat as long as it's held) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now