The script below works (open and close a door via an external server)
What I'd like to do is set a variable like "integer Touched" to say "1" when the door is touched i.e.:
CODE
touch_start(integer N)
{
integer Touched = 1;
and then change this:
CODE
if(sval == "on")
{
llSay(0, "Door Opened!");
state open;
}
to something like this:
CODE
if(sval == "on")
{
if(touched =="1"){ llSay(0, "Door Opened!");
} else
state open;
}
I don't know how to get the variable in scope however...
The full code atm:
CODE
vector OpenRot = <0.00, 0.00, 192.25>;
vector ClosedRot = <0.00, 0.00, 281.25>;
key gChannel;
DEBUG(list out)
{
llSay(0, llList2CSV(out));
}
default
{
state_entry()
{
llOpenRemoteDataChannel();
}
remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
{
if (type == REMOTE_DATA_CHANNEL)
{
gChannel = channel;
llSay(0, "Channel: " + (string)channel +"");
state closed;
} else DEBUG(["Unexpected event type", type, channel, message_id, sender, ival, sval]);
}
}
state closed
{
touch_start(integer N)
{
llHTTPRequest("http://...msg=door%20on",[HTTP_METHOD,"GET"],"");
}
state_entry()
{
llSetRot(llEuler2Rot(ClosedRot * DEG_TO_RAD));
}
remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
{
if (type == REMOTE_DATA_REQUEST)
{
// DEBUG(["Received", ival, sval]);
string stringPortionOfReply = "Default Reply";
integer intPortionOfReply = 0;
if(sval == "on")
{
llSay(0, "Door Opened!");
state open;
}
llRemoteDataReply(channel, message_id, stringPortionOfReply, intPortionOfReply);
} else DEBUG(["Unexpected event type:", type, channel, message_id, sender, ival, sval]);
}
}
state open
{
touch_start(integer N)
{
llHTTPRequest("http://......msg=door%20off",[HTTP_METHOD,"GET"],"");
}
state_entry()
{
llSetRot(llEuler2Rot(OpenRot * DEG_TO_RAD));
}
remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
{
if (type == REMOTE_DATA_REQUEST)
{
// DEBUG(["Received", ival, sval]);
string stringPortionOfReply = "Default Reply";
integer intPortionOfReply = 0;
if(sval == "off")
{
llSay(0, "Door Closed!");
state closed;
}
llRemoteDataReply(channel, message_id, stringPortionOfReply, intPortionOfReply);
} else DEBUG(["Unexpected event type:", type, channel, message_id, sender, ival, sval]);
}
}