Hello there! Apologies if this isn't where I'm supposed to put problems like this, it was the only place that made sense in my head.
To get on topic though, I was messing around with SRDude's Undertale Battle System plugin and I decided that I wanted to try and add my own "soul mode" to the plugin, inspired by Megaman Battle network. It'd essentially be a reworked purple/trap soul mode made to work in a 3x3 grid area with both left/right and up/down movement, however what I instead got was this strange movement where pressing up/left or down/right would essentially have me press both at the same time.
And here is the code that produces this movement
I've tried doing the only things that made sense to me, which was to try and move around where the last four if statements are in in this segment of code. I've tried placing them individually at the end, as a pair of two if/else statements, I tried placing the X and Y statements in their own separate areas thinking they would be executed differently somehow?
If it isn't already clear I'm novice when it comes to any kind of programming, and it's only more confusing when I'm working with someone else's code.
If anyone would be willing to offer me any advice or solutions to this that would be amazing
To get on topic though, I was messing around with SRDude's Undertale Battle System plugin and I decided that I wanted to try and add my own "soul mode" to the plugin, inspired by Megaman Battle network. It'd essentially be a reworked purple/trap soul mode made to work in a 3x3 grid area with both left/right and up/down movement, however what I instead got was this strange movement where pressing up/left or down/right would essentially have me press both at the same time.
And here is the code that produces this movement
JavaScript:
if(this.mode === 6) {
var upT = Input.isTriggered('up');
var downT = Input.isTriggered('down');
var leftT = Input.isTriggered('left');
var rightT = Input.isTriggered('right');
if(!this.targetY) this.targetY = _.trapPositions[this.trapIndex] + uSide;
if(this.y === this.targetY) {
if(upT && this.trapIndex > 0) {
this.trapIndex--;
this.isTrapMoving = true;
}
if(downT && this.trapIndex < _.trapPositions.length - 1) {
this.trapIndex++;
this.isTrapMoving = true;
}
}
this.targetY = _.trapPositions[this.trapIndex] + uSide;
if(!this.targetX) this.targetX = _.trapPositions[this.trapIndex] + lSide;
if(this.x === this.targetX) {
if(leftT && this.trapIndex > 0) {
this.trapIndex--;
this.isTrapMoving2 = true;
}
if(rightT && this.trapIndex < _.trapPositions.length - 1) {
this.trapIndex++;
this.isTrapMoving2 = true;
}
}
this.targetX = _.trapPositions[this.trapIndex] + lSide;
if(this.y < this.targetY) {
this.y += 15;
if(this.y > this.targetY) {
this.y = this.targetY;
}
if(this.y === this.targetY) this.isTrapMoving = false;
} else if(this.y > this.targetY) {
this.y -= 15;
if(this.y < this.targetY) {
this.y = this.targetY;
}
if(this.y === this.targetY) this.isTrapMoving = false;
} else if(this.x > this.targetX) {
this.x -= 15;
if(this.x < this.targetX) {
this.x = this.targetX;
}
if(this.x === this.targetX) this.isTrapMoving2 = false;
} else if(this.x < this.targetX) {
this.x += 15;
if(this.x > this.targetX) {
this.x = this.targetX;
}
if(this.x === this.targetX) this.isTrapMoving2 = false;
}
}
I've tried doing the only things that made sense to me, which was to try and move around where the last four if statements are in in this segment of code. I've tried placing them individually at the end, as a pair of two if/else statements, I tried placing the X and Y statements in their own separate areas thinking they would be executed differently somehow?
If it isn't already clear I'm novice when it comes to any kind of programming, and it's only more confusing when I'm working with someone else's code.
If anyone would be willing to offer me any advice or solutions to this that would be amazing