Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sign a Guestbook?

Jeshu Fluno
...ZZzz d-_-b zzZZ...
Join date: 24 Jun 2006
Posts: 8
07-21-2006 14:07
Hi all! Im kinda noob on scripting, and was looking for something that could allow a visitor to sign a guestbook and to write something (maybe a phrase) on that guestbook. Is that possible?
Of course whatever is written there, will go to my email :D
Kaklick Martin
Singer/Songwriter
Join date: 3 Oct 2005
Posts: 175
07-21-2006 14:45
have them touch the object - that will allow you to use llKey2Name() to get the AVs name, (or you could use a sensor, but touch would be more like signing) you could also set up a listen event triggered by the touch (which would only listen to that AVs chat) to grab the phrase - then kill the listen after it gets the quote. Look up llKey2Name() on the wiki and it should give you enough to get going on this.

<obi-wan voice>Use the wiki Jeshu</obi-wan voice>
Jesse Malthus
OMG HAX!
Join date: 21 Apr 2006
Posts: 649
07-21-2006 14:54
You could use a list in coordination with a listen and llEmail.
Check the wiki, it is your friend.
_____________________
Ruby loves me like Japanese Jesus.
Did Jesus ever go back and clean up those footprints he left? Beach Authority had to spend precious manpower.
Japanese Jesus, where are you?
Pragmatic!
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
Here's a quickly written script
07-21-2006 15:12
This might get you started.

I needed a break from my regular work so I quickly wrote this. I have not tested in-world, but it will compile and it *looks* like it will work ;)

What this does (is supposed to do) is sense people around and then asks somone if they want to sign the guest book. The script uses llDialog to ask the first person it senses.

If the sensed person answers Yes, then they are invited to sign the guest book by saying a message on a configured channel. The script tells the user what channel it uses and gives an example of how to say the message.

Once the user says the message, the script emails the person's name and message to a configured address.

The script, by default, listens for 30 seconds and scans for people every 10 seconds.

It sould not ask someone again if they just signed the guest book, but it rembers only the last person who signed - so if the person who signed first is still in the area after another person signs, then the first person will be asked again. Easy enough to change.

You can configure:

* the channel the script uses
* How long the script listens for a message
* The sensor's range (in meters)
* Seconds between each sensor sweep

Note: The sensor scans in a circle, with the object the script is in at the center of the circle.

This script can contribute to lag due to the sensor - changing it to respond to a touch event is simple and is left as an excercise for you :)

CODE

// Configured values:
integer listenChannel=222;
float listenTimeout=30.0;
float scanRange=10.0;
float scanDelay=10.0;

string ownerAddress="someone@example.com";
string guestBookSubject="Guest Book Message From";

// Cross this line at your own risk
integer listenHandle=0;
key personWhoJustSigned=NULL_KEY;

setListen(integer onOff)
{
if(listenHandle)
{
llListenRemove(listenHandle);
listenHandle=0;
}
if(onOff)
listenHandle=llListen(listenChannel,"",NULL_KEY,"");
}

default
{
state_entry()
{
llSensorRepeat("",NULL_KEY,AGENT,scanRange,PI,scanDelay);
llSetTimerEvent(listenTimeout);
}

sensor(integer numDetected)
{
if(numDetected>1)
{
llSay(0,"Cannot deal with more than one person at a time. I am picking the first person I detected.");
}
if(llDetectedKey(0)==personWhoJustSigned)
return;
setListen(TRUE);
llDialog(llDetectedKey(0),"Would you like to sign the Guest Book?",["Yes","No"],listenChannel);
}

timer()
{
setListen(FALSE);
}

listen(integer channel,string name, key id,string message)
{
if(message=="Yes")
{
llSay(0,"Say / " + (string)listenChannel + " <your message>...");
llSay(0,"Replace <your message> with a message you want to appear in the Guest Book");
return;
}
else if(message=="No")
{
setListen(FALSE);
return;
}
personWhoJustSigned=id;
string guestName=llKey2Name(id);
llSay(0,"Thank you! " + llKey2Name(llGetOwner()) + " is glad that you took time to sign the guest book!");
llEmail(ownerAddress,guestBookSubject + ":" + guestName,message);
guestName="";
}
}


-2fast
Jeshu Fluno
...ZZzz d-_-b zzZZ...
Join date: 24 Jun 2006
Posts: 8
07-21-2006 15:37
Hey thanks a LOT for your fast replys!!
I've been surfing through the wiki for about an hour, its hard when you don't know what to look for! But now that i know what commands to use, i can work on the guestbook :)

Thanks 2fast for the example script, i cant wait to go home to try it!
Thanks obi-wan <voice>, you've been helpfull too :D


-Jeshu
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
07-21-2006 17:09
you should jsut use the name attribute instead of using llKey2Name, (or llDetectedName)
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
07-23-2006 11:10
From: Strife Onizuka
you should jsut use the name attribute instead of using llKey2Name, (or llDetectedName)


Ahh yes....that is a left over from when I was writing this as a touch based guest book. :)

Thanks -2fast