Moving Tentacle Script
|
|
Charissa Korvin
Registered User
Join date: 15 May 2005
Posts: 138
|
08-09-2006 17:50
I was given a script for tentacle movement and I'm hoping someone can help me with a problem I'm having. I have a set of tentacles, 18 prims, worn on the back, 12 of which are flexi-prims. I had to drop this script into each one in order for them to obtain movement. default { state_entry() { llSensorRepeat("",NULL_KEY,AGENT,10,PI,1.0); } sensor(integer num) { key target = llDetectedKey(0); vector mypos = llGetPos(); vector targetpos = llDetectedPos(0); vector test = llVecNorm(targetpos-mypos); llSetPrimitiveParams([PRIM_FLEXIBLE, TRUE, 3,0.55,0.0,0.0,5.0,test]); //llOwnerSay("Test: " + (string)test); } no_sensor() { key target = llDetectedKey(0); vector mypos = llGetPos(); vector targetpos = llDetectedPos(0); vector test = llVecNorm(targetpos-mypos); llSetPrimitiveParams([PRIM_FLEXIBLE, FALSE, 3,0.5,0.0,0.0,1.0,test]); } link_message(integer sn, integer num, string str, key id) { if(str == "OFF") { state off; } } } state off { state_entry() { key target = llDetectedKey(0); vector mypos = llGetPos(); vector targetpos = llDetectedPos(0); vector test = llVecNorm(targetpos-mypos); llSensorRemove(); llSetPrimitiveParams([PRIM_FLEXIBLE, FALSE, 3,0.5,0.0,0.0,1.0,test]); } link_message(integer sn, integer num, string str, key id) { if(str == "ON") { state default; } } }
The strangeness is; after teleporting or after a while the script seems to either time out or something causing the flexability of the prims this script is in to "turn off". Any assistance would be greatly appreciated!
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
08-09-2006 18:49
First off, that's a lot of unnecessary computation to be doing every time you are turning flexibility OFF. O.o
Also, after a teleport I'm sure sensors may have a problem for a while. Do they STAY off, or just take a while to come on again? You could use the 'changed' event to stop the sensor for a while just after you teleport (the tentacles should then stay in their previous state until the period is over, unless something else--outside the script that is--is messing with the flexible state).
|
|
Charissa Korvin
Registered User
Join date: 15 May 2005
Posts: 138
|
08-09-2006 19:03
From: Hewee Zetkin First off, that's a lot of unnecessary computation to be doing every time you are turning flexibility OFF. O.o Also, after a teleport I'm sure sensors may have a problem for a while. Do they STAY off, or just take a while to come on again? You could use the 'changed' event to stop the sensor for a while just after you teleport (the tentacles should then stay in their previous state until the period is over, unless something else--outside the script that is--is messing with the flexible state). First, thank you for your attention to this. I did not write the script my self nor am I a good scripter. I am trying to learn and therefore rather ignorant as to what is creating the problem or how to properly fix it. The tentacles seem to revert to their previous-flexable state after a while. But I have not tested it to see if they revert while I continue wearing them. When the problem occurs I've been taking them off and putting them back on a while later. I will try and make sense of what you're saying but I'm not sure. Perhaps there is a more streamlined script out there that is more efficient?
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
08-09-2006 19:26
From: Charissa Korvin Perhaps there is a more streamlined script out there that is more efficient? If nothing else, i'd suggest removing this: state_entry() { llSensorRepeat("",NULL_KEY,AGENT,10,PI,1.0); }
into a separate script, and have it just notify the individual tentacles with link message about position of detected target, if any. I mean, dozen or more scanners firing up every second... eeek >.< also, the script goes into off state when it receives link message with command "OFF" ... perhaps this is what causes the thing to go rigid every now and then? (it also goes rigid when thre's no avatar for tentacles to follow within 10 m but i presume you know it ^^; ) finally, the no_sensor() event means nothing was detected, so it's quite pointless to do the whole llDetected... part in that event handler. just replace it with PRIM_FLEXIBLE, FALSE ... line. Any parameters supplied with it will be ignored anyway due to FALSE switch which disables flex effect.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
08-09-2006 19:47
From: Joannah Cramer If nothing else, i'd suggest removing this: state_entry() { llSensorRepeat("",NULL_KEY,AGENT,10,PI,1.0); }
into a separate script, and have it just notify the individual tentacles with link message about position of detected target, if any. I mean, dozen or more scanners firing up every second... eeek >.< Oh. LOL. Excellent point. I missed the first time around that this same script was going into so many prims. Yeah. Lag city. Use as few sensors as possible.
|
|
Charissa Korvin
Registered User
Join date: 15 May 2005
Posts: 138
|
08-09-2006 20:12
*reads replies many times* Thank you for your responses. I will attempt to follow your directions and see what happens! ^_^
|
|
Charissa Korvin
Registered User
Join date: 15 May 2005
Posts: 138
|
08-09-2006 20:17
From: Joannah Cramer If nothing else, i'd suggest removing this: state_entry() { llSensorRepeat("",NULL_KEY,AGENT,10,PI,1.0); }
into a separate script, and have it just notify the individual tentacles with link message about position of detected target, if any. I mean, dozen or more scanners firing up every second... eeek >.< Totally lost on what ya mean by Link Message
|
|
Charissa Korvin
Registered User
Join date: 15 May 2005
Posts: 138
|
08-09-2006 20:22
Ok, Ideally, I'd like this script to just make the tentacles move. I don't really care about detecting other AVs near them and all that. So....Any help there?
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
08-09-2006 21:00
From: Charissa Korvin Ok, Ideally, I'd like this script to just make the tentacles move. I don't really care about detecting other AVs near them and all that. So....Any help there? OK, taking complete stab in the dark here since i don't know what the whole thing is built like... but the script you have basically just scans for presence of nearby avatar, and after detecting them turns flex on and sets a force parameter so tentacle moves in direction of that person. So if you just want it to move around no matter where and what, something like this might work: default {
state_entry() { llSetTimerEvent( llFrand( 4.0 ) + 1.0 ); }
timer() {
vector direction = < llFrand(1.0) - llFrand(1.0), llFrand(1.0) - llFrand(1.0), llFrand(1.0) - llFrand(1.0) >; llSetPrimitiveParams( [ PRIM_FLEXIBLE, TRUE, 3, 0.55, 0.0, 0.0, 5.0, direction ] ); llSetTimerEvent( llFrand( 4.0 ) + 1.0 ); } }
this will make your tentacle whip around in random directions and with varying force. Gave it a try and it seems rather tentacle-like... i may plant a few in my pool i guess o.O;
|
|
Charissa Korvin
Registered User
Join date: 15 May 2005
Posts: 138
|
08-09-2006 21:29
TYVM Joannah Seems to work great so far! 
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-27-2008 06:52
thread bump. i would refrain from using multiple timers,(a timer in each prim) as they are lag intensive. maybe one of these? this one works on the entire link set, unfortunetly it makes them all face the same direction From: someone default {
state_entry() { llSetTimerEvent( llFrand( 4.0 ) + 1.0 ); }
timer() {
vector direction = < llFrand(1.0) - llFrand(1.0), llFrand(1.0) - llFrand(1.0), llFrand(1.0) - llFrand(1.0) >; llSetPrimitiveParams( LINK_SET,[ PRIM_FLEXIBLE, TRUE, 3, 0.55, 0.0, 0.0, 5.0, direction ] ); llSetTimerEvent( llFrand( 4.0 ) + 1.0 ); } }
or this one so you can list the link numbers to change, and use 2 or 3 timers (rather than 12)just use multiple scripts and change the link numbers in each list From: someone list primnums = [2,4,6,8,10,12,14,16,18,20,22,24]; integer links; default {
state_entry() { llSetTimerEvent( llFrand( 4.0 ) + 1.0 ); integer i = ~llGetListLength(primnums); while (++i)//grab all the list entrys { links = llList2Integer(primnums,i);//turn those list entries into one integer for the next function } }
timer() {
vector direction = < llFrand(1.0) - llFrand(1.0), llFrand(1.0) - llFrand(1.0), llFrand(1.0) - llFrand(1.0) >; llSetLinkPrimitiveParams( links,[ PRIM_FLEXIBLE, TRUE, 3, 0.55, 0.0, 0.0, 5.0, direction ] ); llSetTimerEvent( llFrand( 4.0 ) + 1.0 ); } }
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
09-27-2008 07:22
/me wonders what devious creation Ruthven is working on for Halloween that involves a 2 year old tentacle script?
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|