Script problems
|
|
Isaiah Latrell
Registered User
Join date: 31 Mar 2006
Posts: 9
|
05-16-2006 08:43
ok i am having a bit of a delema here..i am trying to search on the wikki for a whisper on timer scripti don't even know if thats what is called but i am looking for a script that will ramdomly says things like on every 1-3 min or so ...i've been looking for it on the wikki but i don't understand anything thats in there....i know what you guys are thinking believe me im surprise i know how to count to 3 but anyways if there anyone out there that can give me a push to the right direction i really appreciated . 
|
|
Nexus Nash
Undercover Linden
Join date: 18 Dec 2002
Posts: 1,084
|
05-16-2006 10:28
From: Isaiah Latrell ok i am having a bit of a delema here..i am trying to search on the wikki for a whisper on timer scripti don't even know if thats what is called but i am looking for a script that will ramdomly says things like on every 1-3 min or so ...i've been looking for it on the wikki but i don't understand anything thats in there....i know what you guys are thinking believe me im surprise i know how to count to 3 but anyways if there anyone out there that can give me a push to the right direction i really appreciated .  Try this as start, as for saying things randomly... that's not 'easy'. But I can help you with the timer. default {
state_entry() { llSetTimerEvent(1.0); //calls the timer event every second }
timer() { llWhisper(0,"blah"); //it says 'blah every second in channel 0 (which is the main channel)) }
}
Is this what you needed to get started or did I totally miss the boat.
|
|
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
|
05-16-2006 10:50
Howdy-do, Nexus-Darlin`! From: Nexus Nash Try this as start, as for saying things randomly... that's not 'easy'. But I can help you with the timer.  T`other way `round foah me, Shugah! integer StupidVariableName = llRandInt(10); if (StupidVariableName == 1) {llwhisper(CN, "Stupid Thing Number One");}; if (StupidVariableName == 2) {llwhisper(CN, "Stupid Thing Number Two");}; if (StupidVariableName == 3) {llwhisper(CN, "Stupid Thing Number Three");}; if (StupidVariableName == 4) {llwhisper(CN, "Stupid Thing Number Four");}; if (StupidVariableName == 5) {llwhisper(CN, "Stupid Thing Number Five");}; if (StupidVariableName == 6) {llwhisper(CN, "Stupid Thing Number Six");}; if (StupidVariableName == 7) {llwhisper(CN, "Stupid Thing Number Seven");}; if (StupidVariableName == 8) {llwhisper(CN, "Stupid Thing Number Eight");}; if (StupidVariableName == 9) {llwhisper(CN, "Stupid Thing Number Nine");}; Caviat Emptor: Please note that this code is NOT TESTED and MAY CONTAIN SYNTAX ERRORS, as it was written "off the top of the head" by someone who has not even been in-world yet, much less tested a script. On the other hand, writing programs has been my hobby for a very long time. Also note that the above script will occasionaly not say anything at all. Please let me know if this helps, `k? Toodle-oo!
|
|
Lillani Lowell
Registered User
Join date: 5 Apr 2006
Posts: 171
|
05-16-2006 11:51
Taking the last guy's code and running with it..... Err, not syntax checked though.  default { state_entry() { llSetTimerEvent( llFrand( 3 ) + 1 ); } timer() { integer StupidVariableName = (integer)llFrand(10); if (StupidVariableName == 1) llWhisper(CN, "Stupid Thing Number One"  ; if (StupidVariableName == 2) llWhisper(CN, "Stupid Thing Number Two"  ; if (StupidVariableName == 3) llWhisper(CN, "Stupid Thing Number Three"  ; if (StupidVariableName == 4) llWhisper(CN, "Stupid Thing Number Four"  ; if (StupidVariableName == 5) llWhisper(CN, "Stupid Thing Number Five"  ; if (StupidVariableName == 6) llWhisper(CN, "Stupid Thing Number Six"  ; if (StupidVariableName == 7) llWhisper(CN, "Stupid Thing Number Seven"  ; if (StupidVariableName ==  llWhisper(CN, "Stupid Thing Number Eight"  ; if (StupidVariableName == 9) llWhisper(CN, "Stupid Thing Number Nine"  ; llSetTimerEvent( llFrand( 3 ) + 1 ); } }
|
|
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
|
05-16-2006 12:21
From: Lillani Lowell Taking the last guy's code and running with it.....    Well! Ah do declare! Did y`all happen ta notice ma NAME, Lillani?  Toodle-oo!
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
05-16-2006 12:41
Lists aren't necessarily the greatest things in the world, but this pretty much cries out for a list.
list thingsToSay=["One", "Two", "Three"]; (however many you like)
then in the timer event
thingsToSay=llListRandomize(thingsToSay, 0); llSay(0, llList2String(thingsToSay, 0));
It will always say something. It will be random. You can change the contents of the list and it all automatically updates and plays nicely.
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
05-16-2006 12:46
Ooh, a chance to be clever  // Edit this to change the channel the script speaks on integer channel = 0;
doRandomTimer() { llSetTimerEvent(llFrand(3) + 1); }
default { state_entry() { doRandomTimer(); }
timer() { doRandomTimer();
string notecardName = llGetInventoryName(INVENTORY_NOTECARD, 0); integer numLines = llGetNumberOfNotecardLines(notecardName); integer randomLine = llFloor(llFrand(numLines)); llGetNotecardLine(notecardName, randomLine); }
dataserver(key id, string data) { if ((data != "") && (data != EOF)) { llWhisper(channel, data); } } }
This will pick a random line from a notecard and whisper it. The notecard can be updated at any time. It works best if there's only one notecard in the prim's inventory. Uncompiled, untested, YMMV, etc.
|
|
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
|
05-16-2006 14:36
Not quite, Ziggy. llGetNumber of notecard lines is also a dataserver event. // Edit this to change the channel the script speaks on integer channel = 0; integer status; key request; string notecardName;
doRandomTimer() { llSetTimerEvent(llFrand(3) + 1); }
default { state_entry() { doRandomTimer(); }
timer() { doRandomTimer(); status = 0; notecardName = llGetInventoryName(INVENTORY_NOTECARD, 0); request = llGetNumberOfNotecardLines(notecardName); }
dataserver(key id, string data) { if ( data == request ) { if ( status == 0 ) request = llGetNotecardLine(notecardName, llFloor(llFrand(1)*((integer)data+1))); else llSay(channel,data); status = 1; } } }
I ran this through lslint, so it should at least compile.
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
05-16-2006 14:50
LOL. I always do that. Good catch 
|
|
Merlin Alphabeta
Registered User
Join date: 12 Feb 2006
Posts: 83
|
05-17-2006 09:46
From: Eloise Pasteur Lists aren't necessarily the greatest things in the world, but this pretty much cries out for a list.
list thingsToSay=["One", "Two", "Three"]; (however many you like)
then in the timer event
thingsToSay=llListRandomize(thingsToSay, 0); llSay(0, llList2String(thingsToSay, 0));
It will always say something. It will be random. You can change the contents of the list and it all automatically updates and plays nicely. You could also do it with a notecard. I'd paste the script but I developped in under contract so I don't own it. Basically, when you rez loop through the lines of the script until you get an EOF - then set a global maxlines variable - then enter a whispering state. Every time your timer event fires, just ask for a random line from the notecard, when the data_server event fires, whisper the text you get back...
|
|
Oasis Perun
Registered User
Join date: 2 Oct 2005
Posts: 128
|
05-17-2006 10:43
Shouldnt "if ( data == request ) " in the last example be "if ( id == request )" ?
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
05-17-2006 10:54
Yes, it should. This gets better and better. Now you should post a script that you haven't tested that has some subtle (or not so subtle) bug in it 
|
|
Isaiah Latrell
Registered User
Join date: 31 Mar 2006
Posts: 9
|
Thank You
05-18-2006 07:49
This scripts run awesomely awesome if thats even a word lol...thank you so much guys the scripts run smoothly....
|