Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Book Script

Status
Not open for further replies.
Hello,

I'm currently working on porting a book and scroll script, which I wrote in RGSS3, to MV.

It works like this:
You create an event and activate a switch which prevents player movement.
Then you add a script content and write the text for both pages to be displayed into variables.
Next you display a picture of a book and create instances of two classes, left page and right page. These classes write the text of the two variables into windows with clear background and display those, so it looks like the text written in the book. X and Y offset variables allow for adjusting the position of the text.
For each time a page is to be turned, you create a new event page, change the text in the variables and reload the classes.
The last page disposes of the classes and the background picture.

Now the thing is, in MV I can apparently no longer display windows outside of a menu scene. At least I didn't find out how. The problem is that the Scene_Menu not only blurs out the background (and thus the book), it also pauses the entire game, meaning I can no longer activate the event and turn pages. I know I can set the books as background for the scene (even though it ignores the PNG's alpha channel), but how can I work around the pause?
 

LTN Games

Master Mind
Resource Team
Xy$
0.01
You can add windows to the map by adding your window as a child to Scene_Map, this should keep the game running and events readable.
JavaScript:
// Alias Scene_Map create function
var alias_SceneMap_create = Scene_Map.prototype.create;
Scene_Map.prototype.create = function() {
  alias_SceneMap_create.call(this);
  this.addNewWindow();
};
// New function to add new window to scene map .
Scene_Map.prototype.addNewWindow = function(){
  this._newWindow = new Your_Window();
  this.addChild(this._newWindow);
};
 
You can add windows to the map by adding your window as a child to Scene_Map, this should keep the game running and events readable.
JavaScript:
// Alias Scene_Map create function
var alias_SceneMap_create = Scene_Map.prototype.create;
Scene_Map.prototype.create = function() {
  alias_SceneMap_create.call(this);
  this.addNewWindow();
};
// New function to add new window to scene map .
Scene_Map.prototype.addNewWindow = function(){
  this._newWindow = new Your_Window();
  this.addChild(this._newWindow);
};
Ok, I'll check it out, thanks. How would I call this from the event? Calling functions from a plugin via event is something I haven't quite figured out yet.
 

LTN Games

Master Mind
Resource Team
Xy$
0.01
The previous code I gave you I said call the method in the Scene_Map.prototype.create function, that should actually be in the Scene_Map.prototype.start function, otherwise you won't see the window unless moving your character. Anyway....
How would I call this from the event? Calling functions from a plugin via event is something I haven't quite figured out yet.
There are a few different ways to accomplish this, but you can quickly tap into Game_System or some other global class and create a new method which will create the window on the map. You can put this code in a plugin and test it out.

JavaScript:
Game_System.prototype.createNewWindow = function(){
  this._newWindow = new Window_Gold();
  this._newWindow.x = 0;
  this._newWindow.y = 0;
// The next line will create the window on whatever scene is active
// since we will be using this method on the map, it will create on the map.
  SceneManager._scene.addChild(this._newWindow);
};
// To call in event, use script call $gameSystem.createNewWindow();
Alternatively, you can always have the window created on the map, and have script calls or plugin commands which change the opacity of the window but depending on how much calculation your window will be making every frame it may be wise to avoid this method in case it causes a performance hit.
 
There are a few different ways to accomplish this, but you can quickly tap into Game_System or some other global class and create a new method which will create the window on the map. You can put this code in a plugin and test it out.
First of all, thanks, that works like a charm.
But now I ran into a different problem.

In the original VX Ace version, I had several event pages per book. Each event page represented one page in the book. They were set to Trigger: Action Button. I had a page counter that was increased every new page.
Event page 1: condition none, sets counter to 1
Event page 2: condition variable counter>=1, sets counter to 2
Event page 3: condition variable counter>=2, sets counter to 3
and so on.
That worked well, as the next page was started immediately after the previous page was finished and the action button was pressed.

Now, MV apparently no longer automatically switches to the next page when Action Button is selected as trigger. Instead, the event closes and I need to trigger it again for it to continue with the next page. There does not seem to be a content that calls the next page. Labels don't seem to work between pages as well. Putting everything in one page does not work as I would need a "wait for input" content between the pages, which apparently doesn't exist.
Been sitting here for some time, trying various ideas to work around this (such as trying to start the next event page via script content), but none worked... any ideas?
 

LTN Games

Master Mind
Resource Team
Xy$
0.01
Hmm, It can be hard to see your problem without looking at how your code is trying to do this but you could do a search through the events pages and extract the information you need from them. So instead of using a window you can make a new scene with your window in it and handle all the information you received from the event in your scene. Are you using comments for the books text?
 
Hmm, It can be hard to see your problem without looking at how your code is trying to do this but you could do a search through the events pages and extract the information you need from them. So instead of using a window you can make a new scene with your window in it and handle all the information you received from the event in your scene. Are you using comments for the books text?
I'm sorry, it looks like I misinterpreted what happens. I'm not using modified message boxes anymore, so of course the event closes once it's done and the windows are displayed. I need to activate the event again in order to change the content of the windows.
That means the event works just fine, the problem is a different one. I apologize for the confusion.
One of the problems of my method is that the player can still move around while the book is displayed. Since the player needs to remain in front of the event and activate it to change pages, I use a switch to halt player movement.

Here I used Game_Player.prototype.canMove.
However, apparently if this function returns false, the player also can no longer interact with the event. Not sure if that actually makes sense. Activating an event does not count as movement to me. Apparently "canMove" checks if the player can do anything at all.
I need to edit the Game_Player.prototype.moveByInput function instead. Then it works as intended.

However, I encountered yet another problem. Once I opened a book, I can no longer save the game. It works fine before, but afterwards it refuses to do so.
I'm as stumped as stumped can be here. I'll upload a text project and link it below. The plugin in question is called BooksAndScrolls.js, the event is in the top room, the book next to the door.

Project: https://onedrive.live.com/redir?resid=EC2F88A8E2D0F7D7!2016&authkey=!AFD0X0lLFIwSLcg&ithint=file,zip

UPDATE:
This is getting weirder and weirder...
I have two classes, Window_BookPageLeft and Window_BookPageRight, both derrived from Window_Base.
I noticed that as soon as I create an instance of one of those classes in a function
this._windowBookPageLeft = new Window_BookPageLeft(0,0);
saving is disabled. I don't even need to addChild() or something. Creating the instance is enough. What is this? Window_Base doesn't seem to have a function or parameter that enables/disables saving.
This also happens when I create a new Window_Base, btw.

UPDATE:
I know the problem now. The error was creating the windows in Game_System. That makes the whole thing unsavable. Putting it in Game_Temp instead works, however.
 
Last edited:
Status
Not open for further replies.
Top