Variable called by function for screen resolution

spolen

Villager
Member
Joined
Jan 21, 2016
Messages
12
Reaction score
1
First Language
English
Primarily Uses
I am having an issue with a script I'm working on, I am trying to call the x and y variables to set the screen resolution, and now my brain is hurting after a little while of editing and re editing, and searching online for any way to pull this off.


I am using Yanflys Core Engine with a resolution set at 1360x768, and I suspect that may be part of the issue, but I am unsure of how to do this with that script.


//Sets variables and calls those variables to functions in order to select screen resolution
var x = 1024;
var y = 768;
//
(function() {Graphics.width(x);})();
(function() {Graphics.height(y);})();
(function() {Graphics.boxWidth(x);})();
(function() {Graphics.boxHeight(y);})();


I am able to change resolution in game by adding the following to an event

Code:
Graphics.width = 1024;
Graphics.height = 768;
Graphics.boxWidth = 1024;
Graphics.boxHeight = 768;
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,696
Reaction score
3,005
First Language
Tagalog
Primarily Uses
RMVXA
//Sets variables and calls those variables to functions in order to select screen resolution
var x = 1024;
var y = 768;
//
(function() {Graphics.width(x);})();
(function() {Graphics.height(y);})();
(function() {Graphics.boxWidth(x);})();
(function() {Graphics.boxHeight(y);})();


I think it should be 


(function() {Graphics.width = x;})();


and so on


Though I don't know if those functions will be called. Basically the .width etc functions return the width object so you need to use operators to set them instead of feeding values as parameters to them.


or you might not even encapsulate them in function and just write it directly as


Graphics.width = x;


and so on


Now whether or not Yanfly's plugin intercepts your code depends on which ever code is ran first. If yanfly's get ran first, then it will be yours to remain, but if yours get ran first then yanfly's will be the effect to remain. If that code of yours isn't part of any other code block, it will probably run during setup which means it will also probably run before Yanfly's so yanfly's will overwrite the changes that it will do. If I remember right, Yanfly's plugin changes it during the loading of the very first scene which is Scene_Title. So for your code to actual have a lasting effect, you need to make sure that it is ran after Yanfly's, not before.


This is also why it worked when you did it via events, since the events are ran after Yanfly's script is already done. Aside from the fact that your events used = instead of trying to supply the values as parameters


Out of curiosity, why are you trying to do it outside of Yanfly's plugin if you have it installed anyway?
 
Last edited by a moderator:

spolen

Villager
Member
Joined
Jan 21, 2016
Messages
12
Reaction score
1
First Language
English
Primarily Uses
thanks for the info, I am trying to so it in a separate plugin because as far as I can tell there's no way of using yanflys plugin to allow the player to change the resolution, or have the game figure out the native resolution on it's own, I could've overlooked something in it though as I am not knowledgeable about javascript, using RPG Maker MV is the first real experience I've had with it.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,696
Reaction score
3,005
First Language
Tagalog
Primarily Uses
RMVXA
Then I suggest just editing Yanfly's plugin for the initial setup that you need... That way you only have one plugin modifying the game screen size rather than 2 or more.


Or well, just overwrite the same method that Yanfly uses to modify the size and put your plugin below his so that your plugin will run but Yanfly's own size modification will not. 


Anyway, I think the only problems here are:


1) You used .width(x); rather than .width = x;


2) Your code is ran during setup (if it runs at all) which might mean it will probably run before Yanfly's resulting to Yanfly's plugin overriding whatever changes you did


So once you solve those, it will most probably work.
 
Last edited by a moderator:

spolen

Villager
Member
Joined
Jan 21, 2016
Messages
12
Reaction score
1
First Language
English
Primarily Uses
well it seems I got it working for now,I noticed a difference in yanfly core engine, I ended up having to use the following, and load the script right after yanfly core engine


SceneManager._screenWidth = x;
SceneManager._screenHeight = y;
SceneManager._boxWidth = x;
SceneManager._boxHeight = y;


so the script as of now looks like this

Code:
var x = 1024;
var y = 768;

(function(){Graphics._switchFullScreen()
			SceneManager._screenWidth = x;
			SceneManager._screenHeight = y;
			SceneManager._boxWidth = x;
			SceneManager._boxHeight = y;


})();
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

The video of a psycho chasing people on the streets with a sword before getting subdued is wild. Apparent screenshots of his Twitter feed before it went private reveal a dangerous delusional mindset. I heard there was a bow person too. The crazies are really coming out of the woodworks.
Stream will be live shortly with some Witcher 3, followed by a session of the Interactive Text Adventure! Feel free to drop by!
Managed to find a way to hang a bed cover over my window. So no more being toasted alive in the afternoon!:kaoswt2:
So, uh, has anyone tried buying any resources from KokoroReflections? Because I've been looking for a 'buy' button on the site for like 10 minutes now and can't find one.
Any also thought it's too cringy to put the word "and you" in your credit as a special thanks?
Cause that's what I thought...

Forum statistics

Threads
97,993
Messages
948,402
Members
129,255
Latest member
RPGLordLight
Top