Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

getting a script to listen to a gesture

maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
08-17-2009 01:48
I am trying to modify a gun script that normally works from a drop down menu to resond to a gesture that uses an F key. so far no luck though :(

here is the snippet of script in particular that i am trying to get to listen to a gesture

if(llList2String(args,0) == "unholst";)
{
safe = FALSE;
//settext = TRUE;
llSetScriptState("rifle.anims",TRUE);
llWhisper(6666,"invisible " + (string)llGetOwner());
llSetLinkAlpha(LINK_SET,1.0,ALL_SIDES);
}
if(llList2String(args,0) == "holst";)
{
safe = TRUE;
settext = FALSE;
llSetScriptState("rifle.anims",FALSE);
llStopAnimation("rifle.anim.standing";);
llStopAnimation("rifle.anim.aim";);
llWhisper(6666,"visible " + (string)llGetOwner());
llSetLinkAlpha(LINK_SET,0.0,ALL_SIDES);
}

thanks in advance
Rygel Ryba
Registered User
Join date: 12 Feb 2008
Posts: 254
08-17-2009 01:58
What's the listen statement and what is the gesture saying?

You are also re-whispering in that script - if that script is in the same prim as the script that is supposed to hear those 6666 chats - it's not going to hear it.
maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
08-17-2009 02:07
i made a gesture that would say in chat /1hoster and a second for /1unhoster
the whisper part, hmm could that be changed to normal say then?
Rygel Ryba
Registered User
Join date: 12 Feb 2008
Posts: 254
08-17-2009 02:15
It's not a whisper problem so much as it is a problem with the fact that a script in a prim cannot hear another script speak within the same prim. So your script above is most likely hearing the gesture (I can't confirm that, because I can't see the listen statement), but then the script listening on 6666 isn't hearing what is being forwarded by the script you wrote.

Why doesn't your gesture just talk on 6666 in the first place?
maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
08-17-2009 02:26
From: Rygel Ryba
It's not a whisper problem so much as it is a problem with the fact that a script in a prim cannot hear another script speak within the same prim. So your script above is most likely hearing the gesture (I can't confirm that, because I can't see the listen statement), but then the script listening on 6666 isn't hearing what is being forwarded by the script you wrote.

Why doesn't your gesture just talk on 6666 in the first place?


ah, sorry i was going to amend it from 6666 to 1
would it be easier if i just posted the script in full?
maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
08-17-2009 02:37
im getting an error saying page not found when i try posting it :(
maybe i could send it to you in world to have a look at?
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
08-17-2009 05:48
Be sure that you have a space after every "< " symbol in your script, and do not use the enhanced editor option when you post to the forums. That should handle most of the problems you are having when you try to post a script here. It's a nuisance, but it's the way you have to do it.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
08-17-2009 12:52
string reload_sound="e5de9fb0-c4d5-4830-aa19-a57d864104c5";
string semiauto_sound="3db207b1-8e74-2ec2-5d04-d596985600b3";
string fullauto_sound="201ca05f-85e2-7f47-8ea1-25699541fbfb";
string firemodeswitch_sound="8532afcf-509e-113e-9b58-a81395d0c223";
string dryfire_sound="b38bdcc9-3a98-8875-da60-b4d1e6805796";
string deploy_sound="17ca1c1c-96a2-e966-1839-fd5d7abf4cdd";
//string initmessage = "M4 Carbine built by Griffin Yeats";
//string semiauto_silencedsound="7f4a1b73-7b30-b5b4-5f8c-b43162f06fe6";
//string fullauto_silencedsound="6a8368b6-e207-1ed8-8b0c-ea71289a37bd";
key owner;
string reloading_anim="Reload";
integer gotperms = FALSE;
integer dialoglistenhandle;
integer listenhandle;
integer firingmode;
string bulletname = "Training Bullet";

integer safe = TRUE;
integer reloading;
integer settext = TRUE;
list main_menu = ["bullet","firemode","safe","nosafe","reload","options","unholst","holst","help"];
list firemode_menu = ["auto","single","back..."];
list bullet_menu = ["training","damage","push","phantom", "effectson", "effectsoff", "back..."];

list option_menu = ["texton","textoff","reset","back..."];

DoSetText()
{
integer ammo = (integer)llGetObjectDesc();
string text;
string safety;
if(ammo < 0)
{
ammo = 0;
}
if(safe)
{
safety = "On";
}
else
{
safety = "Off";
}
text = llGetObjectDesc() + "\n" + "Safety:" + safety;
if(settext)
{
llSetText(text, < 1,1,1 > ,1.0);
}
else
{
llSetText("", < 0,0,0 > ,0.0);
}
}
Dialog(key id,list menu,string text)
{
llDialog(id,text,menu,25);
}
Rez(string what,integer passed)
{
llMessageLinked(LINK_SET,passed,what,(string)firingmode);
}
Init()
{
gotperms = FALSE;
if(owner != llGetOwner())
{
NewOwner();
}
else
{
GetPerms(llGetOwner());
llMessageLinked(LINK_SET,-5,"silenceroff",NULL_KEY);
// silenced = FALSE;
llWhisper(6666,"invisible " + (string)llGetOwner());
//llInstantMessage(llGetOwner(),initmessage);
llListen(0,"",llGetOwner(),"";);
llListen(25,"",llGetOwner(),"";);
DoSetText();
}
}
NewOwner()
{
owner = llGetOwner();
firingmode = 1;
//bulletname = "Training Bullet";
listenhandle = llListen(0,"",owner,"";);
llMessageLinked(LINK_SET,-5,"lookforupdate",NULL_KEY);
GetPerms(owner);
Reload();
Init();
}
GetPerms(key id)
{
llRequestPermissions(id,PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_ATTACH);

}
Reload()
{
if(settext)
{
llSetText("Reloading", < 1,0,0 > ,1.0);
}
llStopSound();
//llResetOtherScript("rifle.rez4";);
llMessageLinked(LINK_SET,-1,"reload",NULL_KEY);
llSetObjectDesc("50";);
llStartAnimation(reloading_anim);
//Rez("default clip",0);
llSleep(1);
llTriggerSound(reload_sound,0.8);
reloading = FALSE;
DoSetText();
}
Fire()
{
integer ammo = (integer)llGetObjectDesc();
if(!safe && !reloading)
{
if(ammo > 0)
{
Rez(bulletname,10000);
if(firingmode == 1)
{
llTriggerSound(semiauto_sound,1.0);
}
if(firingmode == 3)
{
llTriggerSound(fullauto_sound,1.0);
}
DoSetText();
}
else if (reloading != TRUE && ammo < = 0)
{
reloading = TRUE;
// Reload();
}
}
}
default
{
state_entry()
{
if(owner != llGetOwner())
{
NewOwner();
}
}

attach(key id)
{
if(id != NULL_KEY)
{
//llSetScriptState("rifle.perms",TRUE);
Init();
}
else
{
//llSetScriptState("rifle.perms",FALSE);
llWhisper(6666,"visible " + (string)llGetOwner());
//llStopAnimation("hold_r_rifle";);
llReleaseControls();
}
}
control(key id,integer held,integer change)
{
integer pressed = held & change;
integer down = held & ~change;
integer released = ~held & change;
integer inactive = ~held & ~change;

if(pressed & CONTROL_ML_LBUTTON)
{
if(firingmode==1 && !safe && !reloading)
{
Fire();
}
if(firingmode==3 && !safe && !reloading)
{
Fire();
}
}
if(released & CONTROL_ML_LBUTTON)
{
if(firingmode==2) Fire();
llStopSound();
llResetOtherScript("rifle.rez";);
llResetOtherScript("rifle.rez2";);
llResetOtherScript("rifle.casings";);
llResetOtherScript("rifle.casings2";);
if(reloading)
{
Reload();
}
}
if(down & CONTROL_ML_LBUTTON)
{
if(firingmode==2 & !reloading)
{
Fire();
}
if(firingmode==2 && !safe && !reloading)
{
//if(silenced)
//{
// llLoopSound(fullauto_silencedsound,1.0);
//}
//else
//{
llLoopSound(fullauto_sound,1.0);
//}
}
}
if(pressed || down & CONTROL_ML_LBUTTON)
{
if(reloading)
{
llStopSound();
llTriggerSound(dryfire_sound,1.0);
}
}
}
listen(integer channel,string name,key id,string message)
{

list args = llParseString2List(llToLower(message),[" "],[]);
if (id == llGetOwner())
{
if(llList2String(args,0) == "back...";)
{
Dialog(id,main_menu,"main menu";);
}
if(llList2String(args,0) == "help";)
{
llGiveInventory(llGetOwner(),"help";);
}
if(llList2String(args,0) == "options";)
{
Dialog(id,option_menu,"Options";);
}
if(llList2String(args,0) == "resetgun";)
{
llOwnerSay("Resetting Scripts...";);
llResetOtherScript("rifle.casings";);
llResetOtherScript("rifle.rez";);
llResetOtherScript("rifle.rez2";);
llResetScript();
}
if(llList2String(args,0) == "texton";)
{
llOwnerSay("SetText Enabled";);
settext = TRUE;
DoSetText();
}
if(llList2String(args,0) == "textoff";)
{
llOwnerSay("SetText Disabled";);
settext = FALSE;
DoSetText();
}
if(llList2String(args,0) == "bullet";)
{
Dialog(id,bullet_menu,"Bullet Menu";);
}
if(llList2String(args,0) == "effectson";)
{
llOwnerSay("Special Effects on - clipfall/bulletcasings";);
llSetScriptState("rifle.casings",TRUE);
llSetScriptState("rifle.casings2",TRUE);
llMessageLinked(LINK_SET,-5,"effectson",NULL_KEY);
}
if(llList2String(args,0) == "effectsoff";)
{
llOwnerSay("Special Effects off";);
llSetScriptState("rifle.casings",FALSE);
llSetScriptState("rifle.casings2",FALSE);
llMessageLinked(LINK_SET,-5,"effectsoff",NULL_KEY);
}
if(llList2String(args,0) == "firemode";)
{
Dialog(id,firemode_menu,"Firing Mode Menu";);
}
if(llList2String(args,0) == "reload";)
{
Reload();
}
if(llList2String(args,0) == "auto";)
{
llTriggerSound(firemodeswitch_sound,0.5);
llOwnerSay("Auto Firingmode Selected";);
firingmode = 2;
}
if(llList2String(args,0) == "single";)
{
llTriggerSound(firemodeswitch_sound,0.5);
llOwnerSay("Single Firingmode Selected";);
firingmode = 1;
}
if(llList2String(args,0) == "training";)
{
llTriggerSound(firemodeswitch_sound,0.5);
llOwnerSay("Training Bullet Selected. Causes 1 Dmg";);
bulletname = "Training Bullet";
}
if(llList2String(args,0) == "damage";)
{
llTriggerSound(firemodeswitch_sound,0.5);
llOwnerSay("Damage Bullet Selected, Causes 100 Dmg";);
bulletname = "Damage Bullet";
}
if(llList2String(args,0) == "phantom";)
{
llTriggerSound(firemodeswitch_sound,0.5);
llOwnerSay("Phantom Bullet Selected, Goes through walls and shields easily.";);
bulletname = "Phantom Bullet";
}
if(llList2String(args,0) == "push";)
{
llTriggerSound(firemodeswitch_sound,0.5);
llOwnerSay("Push Bullet Selected, Pushes av a good distance.";);
bulletname = "Push Bullet";
}
if(llList2String(args,0) == "safe";)
{
llTriggerSound(firemodeswitch_sound,0.5);
llOwnerSay("Safety On";);
safe = TRUE;
}
if(llList2String(args,0) == "nosafe";)
{
llTriggerSound(firemodeswitch_sound,0.5);
llOwnerSay("Safety Off";);
safe = FALSE;
}
if(llList2String(args,0) == "unholst";)
{
safe = FALSE;
//settext = TRUE;
llSetScriptState("rifle.anims",TRUE);

}
if(llList2String(args,0) == "holst";)
{
safe = TRUE;
settext = FALSE;
llSetScriptState("rifle.anims",FALSE);

llStopAnimation("rifle.anim.aim";);

}
}
DoSetText();
llListenControl(dialoglistenhandle,FALSE);
}
touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
Dialog(llDetectedKey(0),main_menu,"Main Menu";);
}
}
on_rez(integer start_params)
{
GetPerms(llGetOwner());
}
run_time_permissions(integer perm)
{
llAttachToAvatar(ATTACH_RHAND);
llTakeControls(CONTROL_ML_LBUTTON | CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT,TRUE,TRUE);
gotperms = TRUE;
}
}
maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
08-18-2009 16:30
can no one help a poor down and out Avatar here? :(
dont make me beg
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
08-18-2009 18:46
Well, if nothing else, your script won't compile because all of your calls to llDialog are missing the fourth parameter, the channel it's supposed to speak on. You have two of the other parameters reversed too. Take a look at syntax in the LSL wiki. That's a good place to start cleaning up. ;)
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-18-2009 21:15
It is obvious that you have spent many hours on that script. Unfortunately it is very few people that can write a script that is that involved from beginning to end and then troubleshoot it, I know I can not. BUT if you use that script as your outline then you can start building another script. Add sets of empty functions, like the llDialog calls into the script and debug as you go. Once one part works then you can add in some more and build it up slowly in layers.

If no one has pointed it out yet, I would suggest downloading LSLEditor and it's plugins. This will give you the ability to script out of world and flip easily back and forth between tabs. You will find the error checking much more verbose and it helps narrow down any problems.
_____________________
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
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
08-19-2009 00:00
From: maihem Sinister

llListen(0,"",llGetOwner(),"";);
llListen(25,"",llGetOwner(),"";);

you don't listen on channel 1 you listen on channels 0, and 25... ie you gesture needs to work on the same channel (/25message perhaps?)
_____________________
|
| . "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...
| -