Custom tile animation

I saw a bit of a need for this in a recent thread so here it is:

// NPC made by tricxta
if (playerenters){
  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
  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]]){
      if (this.i%(64*32)==0)sleep .05;//takes a quick break halfway through to fix a glitch

if (timeout){
  for (this.i=0;this.i<this.count;this.i+=4){
    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;

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!

well… technically you can’t animated it as a grouped object but you can achieve the same thing and just animate each tile of the object for example a waterfall.
As I’ve shown with the example you can use a tile thats alreadt included in another tile animation so recycling of tile values is allowed. The possibilities are only limited to your imagination pretty much :slight_smile:

It’ll break with more than one player.

whys that?

I looked over the !isleader part. My bad.

Well, it’ll look like shit and be unreliable with more than one player. You should animate them locally with showimg’s instead.

I thought that at first but wasn’t sure if there would be any issues with lag since I haven’t worked with showimg enough to know much about how it could cause lag.

Thats a nice idea actually, the only problem for me is converting the hex value into a tileset location so I could use changeimgpart. If you could provide some kinda method to achieve this I’d update the code and everyone could run the code clientside, as for being unreliable with more then one player, I don’t see how tbh.

It’s sending a lot of data to each client each from for no reason. If the leader starts to lag out, other players won’t see the tiles continue to animate. You can use this thread for some useful formulas and other things.

thanks for that, I didn’t know graal automatically converted the hex to an integer.
Edit:updated the original post so the code now runs off showimg and is handled individually by each client :slight_smile:

For a moment, when going over this post, I almost believed I was reading something from that one really popular site.

TVTropes o_o So many hours wasted…