Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Advice requested from more experienced scripters

Richard Noodle
Registered User
Join date: 12 Feb 2006
Posts: 3
02-18-2006 06:16
Hi All,

I have some script for an object that kind of works and kind of doesn't. It's sending an email and recieving an xmlrpc response from a c# service on my web server.

The parts that seems to work are the email goes out with the correct data for the service on the webserver. The service does on the whole manage to get the xmlrpc through to the object. However I seem to be getting myself into some kind of endless loop, as it will only allow me to 'touch' it once. Can anyone advise me what I am doing wrong.

As you can see the LSL script is based on the one on the wiki for XMLRPC. I have just added the stuff I needed. I think I'm making a mistake with states.

LSL script:

key gChannel;
integer gCommand;

default {
state_entry() {}
touch_start(integer total_number)
{
llListen( 0, "", llGetOwner(), "";);
llSay( 0, "requests input" ); //not actual code, but gets input from user
}
listen( integer channel, string name, key id, string message )
{
list parsed = llParseString2List( message, [ " " ], [] );
integer command = llList2Integer( parsed, 0 );
gCommand = command;
llOpenRemoteDataChannel();
}
remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval) {
if (type == REMOTE_DATA_CHANNEL) {
gChannel = channel;
llEmail(sends email); //not actual code but sends out an email with the info the c# service requires, this works
state go;
}
}
}
state go {
remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval) {
if (type == REMOTE_DATA_REQUEST) {
if (sval != "";)
{
llSay(0, sval);
}
}
}

state_exit() {
llCloseRemoteDataChannel(gChannel); // clean up when you no longer want to handle requests
}
}

Also with this script my items have started to be returned to lost and found by the sim quite quickly, this wasn't happening previously.

I would be very grateful if one could advise.

Thanks

Richard.
Richard Noodle
Registered User
Join date: 12 Feb 2006
Posts: 3
Another note about the script.
02-18-2006 06:18
The actual problem is that I seem to be able to 'touch' once, the request will come back and it will display what I want, but then the object doesn't allow me to 'touch' again. I need to recompile the object before I can use it again.
Masakazu Kojima
ケロ
Join date: 23 Apr 2004
Posts: 232
02-18-2006 08:00
Your problem is that you switch to a "wait for response" state after you send the email out, but you never switch back to the state with the touch and listen events once you get the response. Here is your script in php tags so it highlights and indents properly, and fixed so that it should go back and wait for touch events after it gets a response. You should probably add a timeout in case the email gets lost or the server gets hung up.

CODE
key     gChannel;
integer gCommand;

default {
state_entry() {}
touch_start(integer total_number)
{
llListen( 0, "", llGetOwner(), "");
llSay( 0, "requests input" ); //not actual code, but gets input from user
}
listen( integer channel, string name, key id, string message )
{
list parsed = llParseString2List( message, [ " " ], [] );
integer command = llList2Integer( parsed, 0 );
gCommand = command;
llOpenRemoteDataChannel();
}
remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval) {
if (type == REMOTE_DATA_CHANNEL) {
gChannel = channel;
llEmail(sends email); //not actual code but sends out an email with the info the c# service requires, this works
state wait_for_response;
}
}
}
state wait_for_response {
remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval) {
if (type == REMOTE_DATA_REQUEST) {
if (sval != "") // response received
{
llSay(0, sval); // do whatever with it
state default; // go back and wait for touch events again.
}
}
}

state_exit() {
llCloseRemoteDataChannel(gChannel); // clean up when you no longer want to handle requests
}
}
Richard Noodle
Registered User
Join date: 12 Feb 2006
Posts: 3
Thanks
02-18-2006 11:31
Thank you Masakazu,

I thought I was missing something to do states, but I just couldn't figure it out.

Richard.