another string based problam
|
|
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
|
05-11-2008 18:48
ok this should be the last string related one i hope, what im trying to do this time is create a type of pay system ex "!pay mrc 20 result mrc homewood 20 i got the beginig working but im lost on how to work it into having it say the message after it, here is what i got string name;
default { state_entry() { llListen(0,"",llGetOwner(),""); } listen( integer channel, string name, key id, string message ) { list command = llParseString2List(message, [" "], []); string pay = llList2String(command, 1); if(llList2String(command, 0) == "!pay") { name = llToLower(pay); llSensor("", NULL_KEY, AGENT, 96, PI); } } sensor(integer num) { integer x; for(x=0;x<num;x++) { string detectname = llToLower(llDetectedName(x)); if(llSubStringIndex(detectname, name) == 0) { llWhisper(0,detectname); } } } }
|
|
Kidd Krasner
Registered User
Join date: 1 Jan 2007
Posts: 1,938
|
05-12-2008 08:02
In order to make the amount of the payment available in the sensor event handler, you need to save it in a global, the same way you're saving the name. Then you can build the message with something like llOwnerSay(detectname + " " + amount);
(Aside: I'm assuming you don't really need llWhisper. llOwnerSay is likely to be the better choice.)
|
|
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
|
05-12-2008 13:14
ok i was messing around with it and not sure what i did or didnt do (?) = error location in sensor string name; list mess;
default { state_entry() { llListen(0,"",llGetOwner(),""); } listen( integer channel, string name, key id, string message ) { list command = llParseString2List(message, [" "], []); string pay = llList2String(command, 1); mess = llParseString2List(message, [], [" "]); if(llList2String(command, 0) == "!pay") { name = llToLower(pay); llSensor("", NULL_KEY, AGENT, 96, PI); } } sensor(integer num) { integer x; for(x=0;x<num;x++) { string amount = llListFindList(mess,(?)); string detectname = llToLower(llDetectedName(x)); if(llSubStringIndex(detectname, name) == 0) { llOwnerSay(detectname + " " + amount); } } } }
|
|
MCM Villiers
Registered User
Join date: 7 Oct 2007
Posts: 39
|
05-12-2008 15:56
llListFindList returns only TRUE or FALSE and its an integer so it wont work for what you want. I would suggest using the following instead. string amount = llList2String(mess, <location in list>);
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
05-12-2008 16:04
No, it doesn't; llListFindList returns the position of the target list within the source list, or -1 if not found.
<edit - actually I misread the main question as regards the rest of this>
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
|
05-12-2008 16:12
i think i killed asomething, it is only doing my name i can go !pay someone 10 it will say mrc homewood 10, but it should say no agents in area with that name >.> string name; list mess;
default { state_entry() { llListen(0,"",llGetOwner(),""); } listen( integer channel, string name, key id, string message ) { list command = llParseString2List(message, [" "], []); string pay = llList2String(command, 1); mess = llParseString2List(message, [], [" "]); if(llList2String(command, 0) == "!pay") { name = llToLower(pay); llSensor("", NULL_KEY, AGENT, 96, PI); } } sensor(integer num) { integer x; for(x=0;x<num;x++) { string amount = llList2String(mess,-1); string detectname = llToLower(llDetectedName(x)); if(llSubStringIndex(detectname, name) == 0) { llOwnerSay(detectname + " " + amount); } } } no_sensor() { llOwnerSay("No Agent in Area With That Name"); } }
|
|
MCM Villiers
Registered User
Join date: 7 Oct 2007
Posts: 39
|
05-13-2008 06:11
From: Mrc Homewood i think i killed asomething, it is only doing my name i can go !pay someone 10 it will say mrc homewood 10, but it should say no agents in area with that name >.> string name; list mess;
default { state_entry() { llListen(0,"",llGetOwner(),""); } listen( integer channel, string name, key id, string message ) { list command = llParseString2List(message, [" "], []); string pay = llList2String(command, 1); mess = llParseString2List(message, [], [" "]); if(llList2String(command, 0) == "!pay") { name = llToLower(pay); llSensor("", NULL_KEY, AGENT, 96, PI); } } sensor(integer num) { integer x; for(x=0;x<num;x++) { string amount = llList2String(mess,-1); string detectname = llToLower(llDetectedName(x)); if(llSubStringIndex(detectname, name) == 0) { llOwnerSay(detectname + " " + amount); } } } no_sensor() { llOwnerSay("No Agent in Area With That Name"); } }
Yea you did...use a Name2Key database and it will look it up and use that for a sensor unless you want it to not work. Also I realized that you are using spaces to convert the string to a list, one problem....you need to use 2 parts of the list instead of one. One for the first and one for the last. Hope that helps. Also, you will always have a sensor reply if you have your self in range of it.....so use something other then no_sensor() Edit: You can use the name instead of doing the name2key lookup, I just looked at the syntax for llSensor(). I'll post back with an example in a few minutes after I test. //Mrc's Sensor script modified by MCM Villiers //use !pay <amount> <avatars full name> to trigger it list mess; string last = ""; string first = ""; default { state_entry() { llListen(0,"",llGetOwner(),""); } listen( integer channel, string name, key id, string message ) { list command = llParseString2List(message, [" "], []); mess = llParseString2List(message, [], [" "]); if(llList2String(command, 0) == "!pay") { last = llList2String(mess,-1); first = llList2String(mess,-3); llSensor(first + " " + last, NULL_KEY, AGENT, 96, PI); } } sensor(integer num) { string pay = llList2String(mess, 2); llOwnerSay(first + " " + last + " " + pay); } no_sensor() { llOwnerSay("No agent in the area with that name"); } }
|