Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Why won't this work?!

woofbag Fudo
Registered User
Join date: 3 Aug 2006
Posts: 31
12-23-2007 21:01
I'm trying to make it so whenever one of my turrets is rezzed in a non-combat sim the script is turned off and is essentially turned into a lawn ornament, but it just doesn't work....kinda. When you rez one of the turrets, it acts like it's in a battle sim (The script doesn't turn off), but if you rez a second one, THAT one works properly (The script turns off). I just don't get it... can anyone help? Pretty sure here's where the problem is...

(Dots represent parts of script I left out)

...
default
{
state_entry()
{
llSetRot(<0.50002, -0.50000, -0.49998, -0.50000>;);
llSensorRepeat(llGetObjectName(),"",SCRIPTED,100,TWO_PI,1);
llSetTimerEvent(2);
}
sensor(integer num)
{
if(llGetParcelFlags(llGetPos()) & PARCEL_FLAG_ALLOW_DAMAGE)
{
if(num > 3)
{
llSay(0,"More than four turrets in the area! Deleting!";);
llDie();
}
else
{
state norm;
}
}
else
{
llSay(DEBUG_CHANNEL,"Turret rezzed in a safe area! Turret will not operate!";);
llInstantMessage(llGetOwner(),"Turret rezzed in a safe area! It will not fire! If it isn't a safe area make sure the land has the safe button off!";);
llMessageLinked(LINK_SET,1,"safez",NULL_KEY);
llSetScriptState(llGetScriptName(),FALSE);
}
}
no_sensor()
{
state norm;
}
timer()
{
state norm;
}
}
...
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-23-2007 21:30
From: woofbag Fudo
I'm trying to make it so whenever one of my turrets is rezzed in a non-combat sim the script is turned off and is essentially turned into a lawn ornament, but it just doesn't work....kinda. When you rez one of the turrets, it acts like it's in a battle sim (The script doesn't turn off), but if you rez a second one, THAT one works properly (The script turns off). I just don't get it... can anyone help? Pretty sure here's where the problem is...


you problem is in the sensor repeat call... it'll never trigger if it doesn't first detect an object with the same name that has an active script.... because you only test the parcel flags in the sensor event.

llSensorRepeat(llGetObjectName(),"",SCRIPTED,100,TWO_PI,1);

instead test the parcel flags in the on_rez event and turn it off there. or move the test to a function and call it from both sensor and no-sensor
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
woofbag Fudo
Registered User
Join date: 3 Aug 2006
Posts: 31
12-23-2007 22:02
Thanks for your response, around 2 minutes after I posted I realized that xD Wouldn't really know how to fix it by myself though, so you helped! ^^ But while we're on the subject of things that won't work, I also made it so when my turrets receive a command, they re-shout the command on a different chat channel that the turrets also listen on so other turrets farther away will also receive the command, thing is, it just won't work...Here's an example command...

...
if(m == "fire mode";)
{
MODE = TRUE;
llSay(0,"Fire Mode activated!";);
llShout(#, "fire mode";);
}
...
And here's where it listens on the chat channel
...
state norm
{
state_entry()
{
llSensorRepeat("","",AGENT,100,TWO_PI,.1);
llListen(0,"",llGetOwner(),"";);
llListen(#,"","","";);
list listfund = llParseString2List(llToLower(llKey2Name(llGetOwner())),[" "],[]);
donotshoot += llList2String(listfund,0);
listento += llList2String(listfund,0);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y,FALSE);
llInstantMessage(llGetOwner(),"Turret ready!";);
}
...