Hello!!
I think this is my first actual post in this forums so.....that's fun ^^:
Anyway, I have a problem with some javascript that I've been working on. I'm still a bit of a newbie when it comes to this language so please bear with me.
So I'm trying to find a way to make it so that when the player presses a certain button, they can 'reverse' the text and go back to previous text boxes. It's kinda like in Phoenix Wright where in the testimonies you can go either backwards and forwards in text. Anyway, the code I wrote for trying to do this is here:
Basically what I'm trying to do with this is make a list of text inside the text window and adding it using AddToMessageArray to simulate text. You can see it here:
That part is working fine. The part that's really tripping me up is the trying to go backwards part. According to the code, it should go back whenever I press 'shift'. The problem that I'm having is that it's not really going back correctly.
Here's what happens when I press enter for the first time:
Here's the text when I do it the second time:
It goes back one and displays the text. However, when I press shift again, nothing happens. I have to press enter again and then press shift afterwards in order to go fully back to 'hi'. Is there anyway I can just press shift and it'll go straight to the previous text? Thank you in advance for anyone and if I wasn't clear on anything, please tell me. Again, first time. Probably missed something ^^;
I think this is my first actual post in this forums so.....that's fun ^^:
Anyway, I have a problem with some javascript that I've been working on. I'm still a bit of a newbie when it comes to this language so please bear with me.
So I'm trying to find a way to make it so that when the player presses a certain button, they can 'reverse' the text and go back to previous text boxes. It's kinda like in Phoenix Wright where in the testimonies you can go either backwards and forwards in text. Anyway, the code I wrote for trying to do this is here:
var Text = new Array;
var Recycling = new Array;
var part;
function showText() {
var textObject;
for(i = 0; i < Text.length; i++){
if(!$gameMessage.isBusy()){
textObject = Text;
$gameMessage.setFaceImage(textObject.faceImage, textObject.faceImageNumber);
$gameMessage.setBackground(textObject.background);
$gameMessage.setPositionType(textObject.position);
$gameMessage.add(textObject._text);
$gameMessage.newPage();
Text.splice(i,1);
}
}
}
function addToMessegeArray(index,contents){
if(Text.length < index + 1){
Text.push(contents);
Recycling.push(contents);
part = index;
}
}
function Backwards() {
if (part != 0)
part--;
Text.push(Recycling[part]);
showText();
}
var DV_Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
DV_Scene_Map_update.call(this);
if (Text.length>0) {
showText();
}
};
var Nik_Message_Update = Window_Message.prototype.update;
Window_Message.prototype.update = function() {
Nik_Message_Update.call(this);
if (Input.isTriggered('shift')){
Backwards();
}
}
var Recycling = new Array;
var part;
function showText() {
var textObject;
for(i = 0; i < Text.length; i++){
if(!$gameMessage.isBusy()){
textObject = Text;
$gameMessage.setFaceImage(textObject.faceImage, textObject.faceImageNumber);
$gameMessage.setBackground(textObject.background);
$gameMessage.setPositionType(textObject.position);
$gameMessage.add(textObject._text);
$gameMessage.newPage();
Text.splice(i,1);
}
}
}
function addToMessegeArray(index,contents){
if(Text.length < index + 1){
Text.push(contents);
Recycling.push(contents);
part = index;
}
}
function Backwards() {
if (part != 0)
part--;
Text.push(Recycling[part]);
showText();
}
var DV_Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
DV_Scene_Map_update.call(this);
if (Text.length>0) {
showText();
}
};
var Nik_Message_Update = Window_Message.prototype.update;
Window_Message.prototype.update = function() {
Nik_Message_Update.call(this);
if (Input.isTriggered('shift')){
Backwards();
}
}
Basically what I'm trying to do with this is make a list of text inside the text window and adding it using AddToMessageArray to simulate text. You can see it here:
That part is working fine. The part that's really tripping me up is the trying to go backwards part. According to the code, it should go back whenever I press 'shift'. The problem that I'm having is that it's not really going back correctly.
Here's what happens when I press enter for the first time:
Here's the text when I do it the second time:
Third time pressing enter:
Here's what happens when I press "Shift" at this moment:
Here's what happens when I press "Shift" at this moment:
It goes back one and displays the text. However, when I press shift again, nothing happens. I have to press enter again and then press shift afterwards in order to go fully back to 'hi'. Is there anyway I can just press shift and it'll go straight to the previous text? Thank you in advance for anyone and if I wasn't clear on anything, please tell me. Again, first time. Probably missed something ^^;