Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Swords not working anymore

Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
12-23-2004 17:11
This is a strange bug that started showing in previous update (fortunately I found a fix for my own scripts by moving all the permission stuff into the state_entry() function instead of putting them in the attach() event) but which has become nastier in the current version of SL: many swords, staves, and other wearable objects that use llTakeControls() don't reset when they're detached then reattached later. It means many objects only work once, then don't anymore after they've been detached.

I could "revive" some of my swords by manually resetting the script from the edit dialog, but Astary Pendragon had less luck with some expensive items of his (couldn't edit the script, so he couldn't reset them manually).
Adam Zaius
Deus
Join date: 9 Jan 2004
Posts: 1,483
12-23-2004 17:47
This is a problem with scripts written pre 1.4 - LL changed the permissions mechanism. Any modern script should be fine. :)

-Adam
_____________________
Co-Founder / Lead Developer
GigasSecondServer
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
12-23-2004 18:10
Ah, thanks, but I'd appreciate to know what exactly changed and how to fix those scripts, if I may ask :)
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
12-24-2004 03:38
(this thread should be moved to the script tips forum)

some programers were lazy and didn't build proper permission checking.

here is what i use...


i wrote this template to be used with weapons and other attachments.
CODE

integer PermNeeded;
integer ControlsNeeded;

perm()
{
integer a=llGetPermissions();
if((a&PermNeeded)==PermNeeded && llGetPermissionsKey()==llGetOwner())
{
if(!llGetAttached() && (a&PERMISSION_ATTACH))
llAttachToAvatar(G_DEFAULTATTACH);
else
{
if(ControlsNeeded a&PERMISSION_TAKE_CONTROLS)
{
llTakeControls(ControlsNeeded,TRUE,FALSE);
}
//insert other stuff that needs to happen here when it is succesful
}
}
else
llRequestPermissions(llGetOwner(),PermNeeded);
}

default
{
control(key id, integer level, integer edge)
{
//your control code.
}
state_entry()
{
PermNeeded = PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS;
ControlsNeeded = //CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_UP |
//CONTROL_DOWN | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT | CONTROL_LBUTTON |
CONTROL_ML_LBUTTON;
perm();
}
run_time_permissions(integer a)
{
perm();
}
on_rez(integer a)
{
perm();
}
attach(key a)
{
if(a==NULL_KEY)
{
if(llGetPermissions() & PERMISSION_TAKE_CONTROLS);
llReleaseControls();
}
else
perm();
}
}
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey