|
Nectere Niven
Gadget Junky
Join date: 12 Jan 2007
Posts: 211
|
07-03-2007 19:25
I am trying to create a sequence of events (texture change) on several prims in a specific order, looped - can someone point me in the right direction? I am not sure what to use or how to use it. Right now I have them all on a staggered timer (not talking to each other) and when I first reset all the scripts it works fabulous, but after about 3 loops it gets out of order again and they are all (seemingly) randomly changing.
ex. Texture changes firing on the following prims starting at 1 and ending at 9 in sequential order and looped (think of a spiral or clock perhaps) and preferrably capable of being linked to a animated texture prim or other prims (which dont change texture)
Fire prims in order 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 1 -> 2 ...etc
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
07-03-2007 20:14
Are the prims linked together? If so, it should be much simpler to coordinate from a single script, using llSetLinkTexture(). If not, it will still be easier to coordinate the timing from a single script, but it'll have to send chat messages to listeners in the individual objects, telling them when to change texture.
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
07-03-2007 20:33
I agree with Qie. One script that uses a timer to cycle thru the textures, sending a message for each change. Then, another script in each prim that listens for its message and reacts to it. llLinkMessage if the prims are all linked, and llSay(<someprivatechannel>  otherwise Take a stab at this, and we can help you debug. Another apporach is to just put a timer in each script that syncs to the Wall clock, like this one... /15/4c/180313/1.html Each prim would have it's own special time to do whatever the action is.
|
|
Nectere Niven
Gadget Junky
Join date: 12 Jan 2007
Posts: 211
|
07-03-2007 21:32
Well this isnt accomplishing much more than the simple staggered timer I was using on each prim. Ideally yes I would like the whole object to be linked, but not all prims will have scripts in them. This is what I am trying to fiddle with at the moment. I have really no idea what I am doing, I hammer stuff together and hope it works... // Regular clock ticker. // Set interval to some number of seconds // // Put a call to perfomr some actions in action(). // // Object will perform action() every interval seconds. If there are more than // one, they will work in synch. // // Lee Ponzu, no rights reserved
float interval = 2.0; //seconds between actions float inv; float acc = .01;
action() { integer number = llGetInventoryNumber(INVENTORY_TEXTURE); float rand = llFrand(number); integer choice = (integer)rand; string name = llGetInventoryName(INVENTORY_TEXTURE,choice); if (name != "") llSetTexture(name, ALL_SIDES); llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, ALL_SIDES,1,1,1.0, 1,0.25); // put the action that should be performed here
}
// Gets the number of milliseconds since midnight UTC. // GetGMTmsclock() is by ...damn, can't find it. Thanks though.
integer GetGMTmsclock() { string stamp = llGetTimestamp(); return (integer) llGetSubString(stamp, 11, 12) * 3600000 + (integer) llGetSubString(stamp, 14, 15) * 60000 + llRound((float) llGetSubString(stamp, 17, -2) * 1000.0); }
float GetTime() { return GetGMTmsclock()*.001; }
default { state_entry() { llOwnerSay( "Ready."); llSetTimerEvent(interval); inv=1.0/interval; } on_rez(integer n) { llOwnerSay("rezzing"); //tick = llGetTime(); }
touch_start(integer total_number) { llSay(0, "Spiral."); llSleep(10); }
timer() { float now = GetTime(); float count = now*inv; // invariant is for count to be close to an integer, and // delta to be zero
float delta = interval*(count - llRound(count)); if(llFabs(delta) > acc) llSetTimerEvent( interval-delta );
// this is where the action would go...
action();
} }
|