|
Kator Bergson
I'm freakin out man!
Join date: 24 Nov 2005
Posts: 125
|
11-20-2006 01:41
Controllable through gestures using channels for commands. Used a popgun script and tweaked it here and there... not workin. Can somebody point out to this retarded fool just what i did wrong? o.O float SPEED = 50.0; integer LIFETIME = 7; float DELAY = 0.2; vector vel; vector pos; rotation rot; //Left this here for redundancy.... dunno why though... integer have_permissions = FALSE; integer armed = TRUE; string instruction_held_1 = "Simply Use one of the included gestures to fire a smoke grenade in the direction your facing"; string instruction_held_2 = "Choose 'Detach' from my menu to take me off."; string instruction_not_held = "Choose 'Acquire->attach->pelvis' from my menu to wear and use me."; firesmoke() { if (armed) { armed = FALSE; rot = llGetRot(); vel = llRot2Fwd(rot); pos = llGetPos(); pos = pos + vel; pos.z += 0.75; vel = vel * SPEED; llTriggerSound("shoot", 1.0); llRezObject("s.grenade", pos, vel, rot, LIFETIME); llSetTimerEvent(DELAY); } } firegrenade() { if (armed) { armed = FALSE; rot = llGetRot(); vel = llRot2Fwd(rot); pos = llGetPos(); pos = pos + vel; pos.z += 0.75; vel = vel * SPEED; llTriggerSound("shoot", 1.0); llRezObject("grenade", pos, vel, rot, LIFETIME); llSetTimerEvent(DELAY); } } default { state_entry() { if (!have_permissions) { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS); } } on_rez(integer param) { llPreloadSound("shoot"); } run_time_permissions(integer permissions) { //more redundancy... if (permissions == PERMISSION_TRIGGER_ANIMATION|PERMISSION_TAKE_CONTROLS) { if (!have_permissions) { llWhisper(0, instruction_held_1); llWhisper(0, instruction_held_2); } have_permissions = TRUE; } } attach(key attachedAgent) { if (attachedAgent != NULL_KEY) { //More sweet redundancy... llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS); } else { if (have_permissions) { llSetRot(<0,0,0,1>); have_permissions = FALSE; } } } listen(integer channel,string name,key id,string message) { list args = llParseString2List(llToLower(message),[" "],[]); if (id == llGetOwner()) { if(llList2String(args,3772) == "smoke") { firesmoke(); } if(llList2String(args,3772) == "grenade") { firegrenade(); } } } timer() { llSetTimerEvent(0.0); armed = TRUE; } }
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
11-20-2006 04:13
I dont really think you want list entry 3772 do you? should probably be a 0 if(llList2String(args,0) == "grenade")
|
|
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
|
11-20-2006 08:49
Cleaned it a little out of boredom. Changed two functions to one function (since they were the same) And I changed the repeated list args (I guess you'll add more stuff later) to a string match for sanity. float SPEED = 50.0; integer LIFETIME = 7; float DELAY = 0.2; vector vel; vector pos; rotation rot; //Left this here for redundancy.... dunno why though... integer have_permissions = FALSE; integer armed = TRUE; string instruction_held_1 = "Simply Use one of the included gestures to fire a smoke grenade in the direction your facing"; string instruction_held_2 = "Choose 'Detach' from my menu to take me off."; string instruction_not_held = "Choose 'Acquire->attach->pelvis' from my menu to wear and use me.";
fire_grenade(string grenade) // fire would be fire_grenade("smoke"); { if (armed) { armed = FALSE; rot = llGetRot(); vel = llRot2Fwd(rot); pos = llGetPos(); pos = pos + vel; pos.z += 0.75; vel = vel * SPEED; llTriggerSound("shoot", 1.0); llRezObject(grenade, pos, vel, rot, LIFETIME); llSetTimerEvent(DELAY); } }
default { state_entry() { if (!have_permissions) { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS); } } on_rez(integer param) { llPreloadSound("shoot"); } run_time_permissions(integer permissions) { //more redundancy... if (permissions == PERMISSION_TRIGGER_ANIMATION|PERMISSION_TAKE_CONTR OLS) { if (!have_permissions) { llWhisper(0, instruction_held_1); llWhisper(0, instruction_held_2); } have_permissions = TRUE; } } attach(key attachedAgent) { if (attachedAgent != NULL_KEY) { //More sweet redundancy... llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS); } else { if (have_permissions) { llSetRot(<0,0,0,1>); have_permissions = FALSE; } } } listen(integer channel,string name,key id,string message) { list args = llParseString2List(llToLower(message),[" "],[]); string arg0=llList2String(args,0); // just bust the list arg out for faster checjing if (id == llGetOwner()) { if(arg0 == "smoke") { fire_grenade("smoke"); return; } if(arg0 == "grenade") { fire_grenade("grenade); return; } } } timer() { llSetTimerEvent(0.0); armed = TRUE; } }
|
|
Kator Bergson
I'm freakin out man!
Join date: 24 Nov 2005
Posts: 125
|
11-20-2006 23:03
Well what I was attempting to do is make this work thorugh some obscure channel with a included gesture so when you pressed a F key it would either lob a grenade or a smoker... Still seems to not work on the channel i need it to or fire at all. compiles though.
|
|
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
|
11-21-2006 07:25
From: Kator Bergson Well what I was attempting to do is make this work thorugh some obscure channel with a included gesture so when you pressed a F key it would either lob a grenade or a smoker... Still seems to not work on the channel i need it to or fire at all. compiles though. I don't see a listen function in there. ie: at to globals at top integer listen_handle // this is so we can clean up the existing listen later. It's necessary unless you want to look like a jackass after a few days of wearing. somewhere in the attach, like after requestpermissions. listen_handle = llListen(channel,"",llGetOwner(),""); in there.
and somewheres in the detach or BEFORE you call the first one, for sanity. llRemoveListen(listen_handle);
|