//***************************************************************
// Copyright 2008 Centre For Advanced Spatial Analysis, UCL
//
// Author: Joel Dearden, University College London
//
// Contact: j.dearden@ucl.ac.uk
//
// Joel Dearden,
// Centre for Advanced Spatial Analysis,
// University College London,
// 1-19 Torrington Place,
// London,
// WC1E 7HB
//
//
// This file is part of SLPedEvac.
//
// SLPedEvac is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// SLPedEvac is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SLPedEvac. If not, see .
//
//***************************************************************
integer talk_to_staircase_entry = -2929221;
vector staircaseTop;
vector staircaseBottom;
integer talkToBuildingComponents = -8927211;
integer talk_to_staircase_top = -7772241;
integer processingRequest = FALSE;
integer replyToChannel = -1;
integer initialised()
{
if((staircaseTop == <0,0,0>) || (staircaseBottom == <0,0,0>))
{
return FALSE;
}
else
{
return TRUE;
}
}
default
{
state_entry()
{
//hard coded
staircaseTop = <0,0,0>;
staircaseBottom = <0,0,0>;
llSetTexture("d4bf14df-11c8-df49-d958-c8dcc2c344c6", 2);
llListen(talk_to_staircase_entry, "", NULL_KEY, "");
llListen(talkToBuildingComponents, "", NULL_KEY, "");
}
listen(integer channel, string name, key id, string message)
{
if(channel == talkToBuildingComponents)
{
if(message == "demolish")
{
llDie();
}
}
if(channel == talk_to_staircase_entry)
{
if(initialised())
{
if(processingRequest)
{
//I'm busy! - only listen for staircase top replies
if(message == "clear")
{
//reply with details of staircase so pedestrian can enter staircase
//
// FORMAT: sd:;
llSay(replyToChannel, "sd:" + (string)staircaseTop + ";" + (string)staircaseBottom);
processingRequest = FALSE;
}
if(message == "notclear")
{
//don't reply - pedestrian can't enter staircase yet
processingRequest = FALSE;
}
}
else
{
//listen for pedestrians
if(llGetSubString(message, 0, 2) == "sr:")
{
processingRequest = TRUE;
replyToChannel = (integer) llGetSubString(message, 3, -1);
llSay(talk_to_staircase_top, "query_state");
return;
}
}
}
else
{
//only listen to staircase top and bottom position messages
if(llGetSubString(message, 0, 2) == "pt:")
{
llOwnerSay("registered staircase top position");
staircaseTop = (vector) llGetSubString(message, 3, -1);
return;
}
if(llGetSubString(message, 0, 2) == "pb:")
{
llOwnerSay("registered staircase bottom position");
staircaseBottom = (vector) llGetSubString(message, 3, -1);
return;
}
}
}
}
}