Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

This one partially works

Random Torok
Registered User
Join date: 19 Mar 2007
Posts: 33
10-05-2007 12:40
Here is the complete script

vector openpos;//XYZ coordinates of the door when closed
vector closedpos ;//XYZ coordinates of the door when closed
float offset;
integer channel;
key Offsetkey;
key Channelkey;
string gName = "Configuration";
float time = 5.0;//time before the door close itself

default
{
state_entry()
{
Offsetkey = llGetNotecardLine(gName, 0);
Channelkey = llGetNotecardLine(gName, 1);
}

dataserver(key query_id, string data)
{
if(query_id == Offsetkey)//Filtering the call
{
if (data != EOF) // not at the end of the notecard
{
offset = (float)data;
}
}

if(query_id == Channelkey)//Filtering the call
{
if (data != EOF) // not at the end of the notecard
{
channel = (integer)data;
}
}
state closed;
}
}

state closed
{
state_entry()
{
llListen(channel, "", "", "";);
llOwnerSay("Offset is " + (string)offset + " channel is " + (string)channel);
}

listen( integer channel, string name, key id, string message )
{
if (message == "Slide";)
{
closedpos = llGetPos();
openpos = closedpos + <offset, 0.0, 0.0>;
llSay(0, (string)closedpos);
llSay(0, (string)openpos);
llSetPos(openpos);
llSleep(time);
llSetPos(closedpos);
}
}
}

I'm having a problem with the notecard reading. It's getting the keys for both lines of the notecard. But it doesn't seem to be processing the second key. It sets offset just fine but doesn't set channel. I've used multiple llOwnerSay functions and the script doesn't seem to be entering the second if(query_id == Channelkey).

The goofy thing is, this notecard reading stuff comes from a script that is working fine.

All and any comments greatly appreciated.

Someday I'll be good enough to give back to the forums.

RT
Flennan Roffo
Scripter
Join date: 29 Sep 2007
Posts: 26
10-05-2007 12:53
Do it like this:

CODE

string notecard_name="Config";

default
{
state_entry()
{
Line=0;
request=llGetNotecardLine(notecard_name, 0);
}

///////////////////// dataserver() ////////////////////

dataserver(key id, string data)
{
if (id == request)
{
request = NULL_KEY;

if (data != EOF)
{
if (Line==0)
offset=(float)data;
else if (Line==1)
channel=(integer)data;
request=llGetNotecardLine(notecard_name, ++Line);
}
else
{
// We're done!
}
}
}
}
_____________________
Logic Scripted Products and Script Services
Peacock Park (187,228,69)

*** Get your free copy of SL Mail today! ***