I've stripped this script down to focus on the element I'm having issues with...
The order of things:
1) XML-RPC string received
2) string mapped to float
3) animation() sends float to Spur()
4) Spur() shouts float to object BASE
5) BASE shouts the same float back to this object
6) float sent to Pulse()
7) Pulse() sends float to Spur()
steps 4 - 7 loop so that Pulse() continues
The problem is that when I send a new message via XML-RPC, and a new float (let's say 6) is sent to Spur(), I get multiple threads! This means that the old float (let's say 1) is still hanging around and we get Pulse() looping on float 1 then 6. If I send another message (let's say
it gets added to this queue: 1,6,8I only want the latest thread to loop! In this example: 8. I want to kill the previous thread/s: 1,6 whenever a new thread is received.
How can I do that!!!!! Really struggling to find the cause/solution.
Huge thanks in advance to you all
Mark.
CODE
key gChannel;
DEBUG(list out)
{
llSay(0, llList2CSV(out));
}
Pulse(float anima)
{
integer i;
list original = llGetPrimitiveParams([PRIM_POINT_LIGHT]);
float c_lev = llList2Float(original, 2);
float dim = c_lev / anima;
for(i=0;i< anima;++i)
{
list original = llGetPrimitiveParams([PRIM_POINT_LIGHT]);
float intense = llList2Float(original, 2);
vector c_c = llList2Vector(original, 1);
float take = intense - dim;
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, c_c, take, 10, 0.75]);
}
for(i=0;i< anima;++i)
{
list original = llGetPrimitiveParams([PRIM_POINT_LIGHT]);
float intense = llList2Float(original, 2);
vector c_c = llList2Vector(original, 1);
float add = intense + dim;
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, c_c, add, 10, 0.75]);
}
Spur(anima);
}
Spur(float an)
{
llShout(-150,(string)an);
}
animation(string ani){
if (ani == "very slow"){ Spur(6); }
if (ani == "slower"){ Spur(5); }
if (ani == "slow"){ Spur(4); }
if (ani == "pulse"){ Spur(3); }
if (ani == "medium"){ Spur(2.75); }
if (ani == "fast"){ Spur(2.5); }
if (ani == "faster"){ Spur(2); }
if (ani == "very fast"){ Spur(1.75); }
if (ani == "crescendo"){ Spur(1.5); }
if (ani == "heartbeat"){ Spur(1);}
}
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;
state waiting;
} else DEBUG(["Unexpected event type", type, channel, message_id, sender, ival, sval]);
}
}
state waiting
{
state_entry()
{
llListen(-160, "base", NULL_KEY, "" );
}
remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
{
if (type == REMOTE_DATA_REQUEST)
{
string stringPortionOfReply = "Default Reply";
integer intPortionOfReply = 0;
if (sval){
animation(sval);
}
llRemoteDataReply(channel, message_id, stringPortionOfReply, intPortionOfReply);
} else DEBUG(["Unexpected event type:", type, channel, message_id, sender, ival, sval]);
}
listen(integer channel, string name, key id, string message)
{
Pulse((float)message);
}
}