Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float Size_Point = 0.1;
- vector Color_Point = <1,0,0>;
- list Particle_Parameters = [
- PSYS_SRC_TEXTURE, "",
- PSYS_PART_START_SCALE, < Size_Point, Size_Point, FALSE >,
- PSYS_PART_END_SCALE, < Size_Point, Size_Point, FALSE >,
- PSYS_PART_START_COLOR, Color_Point,
- PSYS_PART_END_COLOR, Color_Point,
- PSYS_SRC_BURST_PART_COUNT, 1,
- PSYS_SRC_BURST_RATE, 0.0,
- PSYS_PART_MAX_AGE, 9.0,
- PSYS_SRC_PATTERN, 1,
- PSYS_PART_FLAGS,
- PSYS_PART_EMISSIVE_MASK
- ];
- vector BoardSize = <2,2,0.1>;
- integer GridSize = 12;
- vector Origin;
- float Step;
- list Grid;
- list makeArray ( integer rows, integer cols ) {
- integer i;
- list array = [];
- array += < rows, cols, 0 >;
- for (i=0; i < rows * cols; ++i) {
- array += (llFrand(1) < 0.25);
- }
- return array;
- }
- integer getElement( list array, integer row, integer col ) {
- vector metadata = llList2Vector( array, 0);
- integer cols = (integer)metadata.y;
- integer index = row * cols + col + 1;
- return llList2Integer( array, index);
- }
- list setElement( list array, integer row, integer col, integer value ) {
- vector metadata = llList2Vector( array, 0);
- integer cols = (integer)metadata.y;
- integer index = row * cols + col + 1;
- return llListReplaceList(array, [value], index, index);
- }
- integer Lookup(integer row, integer col) {
- return getElement(Grid, row % GridSize, col % GridSize);
- }
- integer Neighbors(integer row, integer col) {
- return Lookup(row, col+1)+
- Lookup(row+1, col+1)+
- Lookup(row+1, col)+
- Lookup(row+1, col-1)+
- Lookup(row, col-1)+
- Lookup(row-1, col-1)+
- Lookup(row-1, col)+
- Lookup(row-1, col+1);
- }
- RunGrid() {
- list NewGrid = Grid;
- llSetAlpha(1, ALL_SIDES);
- integer x; integer y; integer n;
- for(x=0;x<GridSize;x++) {
- for(y=0;y<GridSize;y++) {
- n = Neighbors(x, y);
- if(getElement(Grid, x,y)) {
- llSetLinkPrimitiveParamsFast( LINK_THIS, [PRIM_POSITION, Origin + <((float)x)*Step, ((float)y)*Step, 0>]);
- llParticleSystem( Particle_Parameters );
- llSleep(0.12);
- llParticleSystem( [] );
- if(n < 2 || n > 3) {
- NewGrid = setElement(NewGrid, x, y, 0);
- }
- } else if(n == 3){
- NewGrid = setElement(NewGrid, x, y, 1);
- }
- }
- }
- llSetAlpha(0, ALL_SIDES);
- Grid = NewGrid;
- }
- default
- {
- state_entry()
- {
- vector CSize = llGetScale();
- Step = BoardSize.x / GridSize;
- Origin = <-1, -1, 0.1> + <CSize.x, CSize.y, 0>;
- Grid = makeArray(GridSize, GridSize);
- }
- link_message(integer sender_num, integer num, string msg, key id)
- {
- llSetTimerEvent(10);
- RunGrid();
- }
- timer() {
- RunGrid();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement