Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

I found something, but it doesnt work...

azkay Itamae
Doctor Azkay.
Join date: 7 Aug 2006
Posts: 3
08-08-2006 18:17
Ok, I finnaly found exactly what I wanted, A katana. It was in a newbie pack for 1$. Bargain ^^, Anyway, I go to equip it and BAM
CODE

Katana Sword: Script trying to take controls from owner but PERMISSION_TAKE_CONTROLS permission not set!
Katana Sword: Script trying to take controls from owner but PERMISSION_TAKE_CONTROLS permission not set!

I know nothing about SL scripting, so can you guys help me out?
SCRIPT:
CODE

integer SWORD = 1;
integer PUNCH12 = 2;
integer PUNCHL = 3;
integer KICK = 4;
integer FLIP = 5;

integer strike_type;

default
{
state_entry()
{
llSetStatus(STATUS_BLOCK_GRAB, TRUE);
}
run_time_permissions(integer perm)
{
if (perm)
{
llTakeControls(CONTROL_ML_LBUTTON | CONTROL_LBUTTON | CONTROL_UP | CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ROT_RIGHT | CONTROL_DOWN, TRUE, TRUE);
}
}

attach(key on)
{
if (on != NULL_KEY)
{
integer perm = llGetPermissions();

if (perm != (PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION))
{
llRequestPermissions(on, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
}
else
{
llTakeControls(CONTROL_ML_LBUTTON | CONTROL_LBUTTON | CONTROL_UP | CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ROT_RIGHT, TRUE, TRUE);
}

}
else
{
llSay(0, "releasing controls");
llTakeControls(FALSE, TRUE, TRUE);
}
}

timer()
{
if ( (strike_type == FLIP)
|| (strike_type == SWORD))
{
llSensor("", "", ACTIVE | AGENT, 4.0, PI_BY_TWO*0.5);
}
else
{
llSensor("", "", ACTIVE | AGENT, 3.0, PI_BY_TWO*0.5);
}
llSetTimerEvent(0.0);
}

control(key owner, integer level, integer edge)
{
if (level & (CONTROL_ML_LBUTTON | CONTROL_LBUTTON))
{
if (edge & CONTROL_UP)
{
llApplyImpulse(<0,0,3.5>,FALSE);
llStartAnimation("backflip");
// llTriggerSound("swing3", 0.5);
llSetTimerEvent(0.25);
strike_type = FLIP;
}
if (edge & CONTROL_FWD)
{
llStartAnimation("sword_strike_R");
llSleep(0.5);
// llTriggerSound("swordswing", 0.5);
llSetTimerEvent(0.25);
strike_type = SWORD;
}
if (edge & (CONTROL_LEFT | CONTROL_ROT_LEFT))
{
llStartAnimation("sword_strike_R");
// llTriggerSound("swing1", 0.5);
llSetTimerEvent(0.25);
strike_type = PUNCHL;
}
if (edge & (CONTROL_RIGHT | CONTROL_ROT_RIGHT))
{
llStartAnimation("sword_strike_R");
// llTriggerSound("swing2", 0.5);
llSetTimerEvent(0.25);
strike_type = PUNCH12;
}
if (edge & CONTROL_BACK)
{
llStartAnimation("sword_strike_R");
// llTriggerSound("swing3", 0.5);
llSetTimerEvent(0.25);
strike_type = KICK;
}
if (edge & CONTROL_DOWN)
{
llMoveToTarget(llGetPos(), 0.25);
llSleep(1.0);
llStopMoveToTarget();
}
}
}

sensor(integer tnum)
{
vector dir = llDetectedPos(0) - llGetPos();
dir.z = 0.0;
dir = llVecNorm(dir);
rotation rot = llGetRot();
if (strike_type == SWORD)
{
// llTriggerSound("swordhit", 0.5);
dir += llRot2Up(rot);
dir *= 200.0;
llPushObject(llDetectedKey(0), dir, ZERO_VECTOR, FALSE);
}
else if (strike_type == PUNCH12)
{
// llTriggerSound("righthand", 0.2);
dir += dir;
dir *= 100.0;
llPushObject(llDetectedKey(0), dir, ZERO_VECTOR, FALSE);
}
else if (strike_type == PUNCHL)
{
// llTriggerSound("lefthand", 0.2);
dir -= llRot2Left(rot);
dir *= 100.0;
llPushObject(llDetectedKey(0), dir, ZERO_VECTOR, FALSE);
}
else if (strike_type == KICK)
{
// llTriggerSound("kick", 0.2);
dir += dir;
dir *= 100.0;
llPushObject(llDetectedKey(0), dir, ZERO_VECTOR, FALSE);
}
else if (strike_type == FLIP)
{
// llTriggerSound("kick", 0.5);
llPushObject(llDetectedKey(0), <0,0,150>, ZERO_VECTOR, FALSE);
}
strike_type= 0;
}
}


Thanks.

Azkay.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-08-2006 20:32
It's possible the problem is with this line:
From: someone
llTakeControls(FALSE, TRUE, TRUE);

To release controls it should be using 'llReleaseControls()' or possibly:
llRequestPermissions(llGetPermissionsKey(), 0)

I usually do both (in a place I know permissions have in fact been granted), one after the other (though technically I guess only the first is necessary).
azkay Itamae
Doctor Azkay.
Join date: 7 Aug 2006
Posts: 3
08-09-2006 13:03
Ok, now im not getting that problem, but now, how do I actually "use" the sword? how do I swing it and the other stuff?
Azurei Ash
The Sticky!
Join date: 12 Jan 2006
Posts: 38
08-09-2006 13:35
It's probably the fairly common freebie katana which has been around a while and the script can be buggy sometimes, thought it should work for the most part.

To use it, just hold down the left mouse button and move around or jump and you will do varous attacks. Ok, so maybe not various, there is really only one built-in sword swinging animation. XD

~Az
Grazel Cosmo
Registered User
Join date: 12 Mar 2005
Posts: 28
08-09-2006 15:48
Part of the problem and this seems common with a lot of the freebie scripts. It only requests permissions from the original owner and so if its passed on to someone else they can't use it and get an error message like that. The quick and dirty fix for any item where the permissions doesn't seem to work (or it won't listen to you like some titlers that set a listen for only their owner) is to put this code in:

CODE
on_rez(integer start_param)
{
llResetScript();
}


If there's already an on_rez event just add the llResetScript(); call at the end of it. This isn't alway the ideal solution but is the quick and dirty one.