We did the same thing on delteria but I like your method you did with the array regarding setShape2 I did that aswell. Also use [PHP] tags instead of code tags looks much cleaner.
PHP Code:
//#CLIENTSIDE
function onCreated() {
with (findimg(200)) {
this.image = thiso.bridgeImage;
this.layer = 1;
this.x = thiso.x;
this.y = thiso.y;
this.mode = 1;
this.alpha = 0.75;
if (thiso.direction == "vertical")
this.y += 2;
else
this.x += 2;
}
this.bridgeWidth = getImgWidth(this.bridgeImage) / 16;
this.bridgeHeight = getImgHeight(this.bridgeImage) / 16;
this.w = this.bridgeWidth + (this.direction == "horizontal" ? 4 : 0);
this.h = this.bridgeHeight + (this.direction == "vertical" ? 5 : 0);
// 10 16
// 10 21
this.dontBlock();
onTimeOut();
}
function onBridge(temp.py) {
if (player.x in |this.x, this.x + this.w|) {
if (temp.py in |this.y, this.y + this.h|)
return true;
}
return false;
}
function isPlayerEntering(temp.py) {
if (player.x in |this.x, this.x + this.w|) {
if (temp.py in |this.y, this.y + 2|)
return true;
if (temp.py in |this.y + this.h - 2, this.y + this.h|)
return true;
}
return false;
}
function onTimeOut() {
temp.py = player.y + 2 + vecy(player.dir) * 1.05;
temp.entered = isPlayerEntering(temp.py);
if (temp.entered) {
if (player.attached == false) {
attachPlayerToObj(0, this.id);
setshape2(this.w, this.h, this.shape);
}
} else if (player.attached == true && player.attachid == this.id) {
if (onBridge(temp.py)) {
} else {
detachplayer();
}
this.chat = "attached";
} else {
this.chat = "na";
}
setTimer(0.05);
}