I saw a bit of a need for this in a recent thread so here it is:
// NPC made by tricxta
if (playerenters){
timereverywhere;
setstring this.tileset,pics1.png;//tileset used to show the animations
this.speed=.25;//speed at which the tiles cycle
this.sequence={0x64F,0x65F,0x66F,0x64F};//store cycle tiles
this.sequencestep={2,2,2};//store sequence lengths
this.sequencepos={0,1,2};//store tile positions
this.sequences=3;//number of different sequences
setarray this.ts,4096;//store all level tile data
this.count=0;
for (this.i=0;this.i<4096;this.i++){
for (this.a=0;this.a<this.sequences;this.a++){//remember to change the count
if (tiles[this.i%64,int(this.i/64)]==this.sequence[this.sequencepos[this.a]]){
this.ts[this.count]=this.i%64;
this.ts[this.count+1]=int(this.i/64);
this.ts[this.count+2]=this.sequencepos[this.a];
this.ts[this.count+3]=this.sequencestep[this.a];
this.count+=4;
}
if (this.i%(64*32)==0)sleep .05;//takes a quick break halfway through to fix a glitch
}
}
timeout=0.05;
}
if (timeout){
this.step++;
for (this.i=0;this.i<this.count;this.i+=4){
this.tile=this.sequence[this.ts[this.i+2]+(this.step%this.ts[this.i+3])];
showimg 300+(this.ts[this.i+1]*64)+this.ts[this.i],#s(this.tileset),this.ts[this.i],this.ts[this.i+1];
changeimgpart 300+(this.ts[this.i+1]*64)+this.ts[this.i],256*int(this.tile/512)+16*(this.tile%16),int((this.tile%512)/16)*16,16,16;
changeimgvis 300+(this.ts[this.i+1]*64)+this.ts[this.i],0;
}
timeout=this.speed;
}
Setting it up is a bit of a process however:
say I wanted to animate a given tile:
1)place the starting tile
2)select it
3)press this button:
4)copy and paste the value into the correct array, the code is well commented for that section so it’s straight forward
5)do the same for the tiles you want it to proceed to
6)Change the other array elements to the appropriate values,once again this is all well commented with an example for those who are confused
Currently I have the code set up to animate the following tiles demonstrating the flexibility of how the code is constructed:
Enjoy, I don’t mind if you don’t credit me for this in your server acknowledgements but if you claim this code as your own then… you won’t be on my good side lol
Note:This will not animate tiles in adjacent levels!