I should have been clear that what I posted was the formula I based the water movement on. This is my original script.
//#CLIENTSIDE function onCreated() { this.setimg("block.png"); } function onActionPulled() { if (this.waterlevel == 0) { this.final = {9,39,47,39,47,27,55,27,55,47,9,47}; // x, y values of where the water starts filling this.current = {11,41,49,41,49,29,53,29,53,45,11,45}; // x, y values where the water is finished filling } else if (this.waterlevel == 1) { this.final = {11,41,49,41,49,29,53,29,53,45,11,45}; this.current ={9,39,47,39,47,27,55,27,55,47,9,47};
} this.time = 0; this.waterlevel = !this.waterlevel; setTimer(0.05); } function onTimeout() { for (this.a=0;this.a<=this.final.size();this.a++;) { this.distx = this.final[0+this.a] - this.current[0+this.a]; // finds the difference between the coordinates in both arrays this.disty = this.final[1+this.a] - this.current[1+this.a]; this.movelength = (this.distx * this.distx + this.disty * this.disty) ^ 0.5; // finds out how many tiles away this.distx = this.distx / this.movelength; this.disty = this.disty / this.movelength; this.current[0+this.a] = this.current[0+this.a] + this.distx * 0.05; // move a step towards the final target this.current[1+this.a] = this.current[1+this.a] + this.disty * 0.05; showpoly(200,this.current); changeimgcolors 200,0,0,1,0.75; this.a++; } setTimer(0.05); } }
|