HornsterLG

Veteran
Veteran
Joined
Dec 19, 2021
Messages
32
Reaction score
9
First Language
german
Primarily Uses
RMMV
I am using Yanfly Options Core and I want the player to be able to turn the following canvas render option on/off (I have a plugin that can change the fullscreen render option. I can manually change the render option by replacing "pixelated" with "auto" or disabling the plugin/ removing the line of code):

Graphics.TDDP_updateCanvasImageRenderingMode = function() {
this._canvas.style.imageRendering = usePixelPerfectMode() ? 'pixelated' : '';
}

// I tried:
if ($gameVariables.value(28) === 1) {
Graphics.TDDP_updateCanvasImageRenderingMode = function() {
this._canvas.style.imageRendering = usePixelPerfectMode() ? 'pixelated' : '';
}
};
// i tried this too
Graphics.TDDP_updateCanvasImageRenderingMode = function() {
if ($gameVariables.value(28) === 1) {
this._canvas.style.imageRendering = usePixelPerfectMode() ? 'pixelated' : '';
}
};
// this gave me the "null" error, because the variable was not declared when launching the game.

// i tried this too:
var render = 1;
if (var render === 1) {
Graphics.TDDP_updateCanvasImageRenderingMode = function() {
this._canvas.style.imageRendering = usePixelPerfectMode() ? 'pixelated' : '';
}
};
// That condition is wrong for some reason. Any help is appreciated. :)

link to the plugin: https://forums.rpgmakerweb.com/index.php?threads/pixel-perfect-scaling-mode.141354/
 
Last edited:

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
730
Reaction score
701
First Language
german
Primarily Uses
RMMZ
Can you maybe flip the order?

Code:
Graphics.TDDP_updateCanvasImageRenderingMode = function() {
  if ($gameVariables.value(28) === 1) {
    this._canvas.style.imageRendering = usePixelPerfectMode() ? 'pixelated' : '';
  } else {
    ...
  }
}
 

Zeireth

Veteran
Veteran
Joined
Nov 2, 2013
Messages
81
Reaction score
64
First Language
English
Primarily Uses
N/A
Lol. Please learn javascript first before you start editing code. The examples where you place functions inside if statements is completely wrong. var render = 1; if (var render === 1) { }; does nothing to help.

// An if statement
if (condition) {
// block of code to be executed if the condition is true
}

In your example if (var render === 1) { }; var render === 1 is a boolean. That condition is true if var render is equal to 1, which it is so the boolean is true therefore the block of code in the if statement can be executed.

Learn the basics of javascript. It should take up to 4 to 6 weeks to learn. Start by learning variables, strings, statements, arrays, and functions. Eventually you will be able to read code. That's assuming the person wrote good readable code.

https://www.javascript.com/ This site has a nice introductory course. Code Academy is also a nice place to learn javascript. I believe Code Academy has more free courses. There is also many videos on Youtube that can teach you the basics.

I do not know the plugin. Also please do not post the whole plugin to get help from others. I know you are only showing a portion of it.

If you are able to contact the author, then I would ask them for help.
 

Zeireth

Veteran
Veteran
Joined
Nov 2, 2013
Messages
81
Reaction score
64
First Language
English
Primarily Uses
N/A
Can you maybe flip the order?

Code:
Graphics.TDDP_updateCanvasImageRenderingMode = function() {
  if ($gameVariables.value(28) === 1) {
    this._canvas.style.imageRendering = usePixelPerfectMode() ? 'pixelated' : '';
  } else {
    ...
  }
}
Yeah that might work. A switch would look nicer inside that function.

Graphics.TDDP_updateCanvasImageRenderingMode = function() {
if ($gameVariables.value(28) === 1) {
this._canvas.style.imageRendering = usePixelPerfectMode() ? 'pixelated' : '';
} else {
this._canvas.style.imageRendering = usePixelPerfectMode() ? '' : 'pixelated';
}
}
 

HornsterLG

Veteran
Veteran
Joined
Dec 19, 2021
Messages
32
Reaction score
9
First Language
german
Primarily Uses
RMMV
Yeah that might work. A switch would look nicer inside that function.

Graphics.TDDP_updateCanvasImageRenderingMode = function() {
if ($gameVariables.value(28) === 1) {
this._canvas.style.imageRendering = usePixelPerfectMode() ? 'pixelated' : '';
} else {
this._canvas.style.imageRendering = usePixelPerfectMode() ? '' : 'pixelated';
}
}
it does not work with $gameVariables or $gameSwitches, because the plugins are loaded before $gameVariables or $gameSwitches are loaded.
 

HornsterLG

Veteran
Veteran
Joined
Dec 19, 2021
Messages
32
Reaction score
9
First Language
german
Primarily Uses
RMMV
I found the solution. I Added the rendering code right into an option inside "yanfly options core" plugin.
The code is:

Graphics._canvas.style.imageRendering = 'pixelated' ;
//for cursor move right and for cursor move left it is:
Graphics._canvas.style.imageRendering = 'auto' ;

ty everyone for trying to help! :)
 

Zeireth

Veteran
Veteran
Joined
Nov 2, 2013
Messages
81
Reaction score
64
First Language
English
Primarily Uses
N/A
it does not work with $gameVariables or $gameSwitches, because the plugins are loaded before $gameVariables or $gameSwitches are loaded.
That is not true. Please do not spread misinformation.

I made a plugin for myself that uses $gameVariables in my code. Many of Yanfly's plugins use $gameVariables.

$gameVariables are part of the data manager. Data manager is a static class. You can look it up in rpg_managers.js in your project's js folder.

Two Jscript script files in the js folder use $gameVariables. rpg_objects.js uses $gameVariables 31 times in the file. rpg_windows.js uses $gameVariables 10 times in the file.
 

HornsterLG

Veteran
Veteran
Joined
Dec 19, 2021
Messages
32
Reaction score
9
First Language
german
Primarily Uses
RMMV
That is not true. Please do not spread misinformation.

I made a plugin for myself that uses $gameVariables in my code. Many of Yanfly's plugins use $gameVariables.

$gameVariables are part of the data manager. Data manager is a static class. You can look it up in rpg_managers.js in your project's js folder.

Two Jscript script files in the js folder use $gameVariables. rpg_objects.js uses $gameVariables 31 times in the file. rpg_windows.js uses $gameVariables 10 times in the file.
That's weird, because I definitely got this error message when trying:
"can not read property value of null"
researching that error gave me this:
"all error messages with "of undefined" or "of null" basically tell you that the game tried to access a data object that does not exist."
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,841
Reaction score
6,257
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,789
Reaction score
15,917
First Language
English
Primarily Uses
RMMV

Reopening to address new issue

 

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
730
Reaction score
701
First Language
german
Primarily Uses
RMMZ
it does not work with $gameVariables or $gameSwitches, because the plugins are loaded before $gameVariables or $gameSwitches are loaded.
This is a common beginner's mistake that I want to correct. It's true that Game objects starting with $ are not loaded yet when a Plugin is read in (which is a common beginner's mistake, too); however, we can still point to them inside a function.

Example:

Code:
var doSomething() = function() {
  // do something with $gamePlayer.x
}

The function "doSomething" is like a blueprint that points to objects, that are initialized right now. The question is, when is "doSomething" actually called? Right after you defined it? Before or after the Title Screen? ... When this function is called after the Game objects are loaded, everything is fine.

I can't transfer my example 1:1 to your scenario, but I hope things are getting clearer for you.
 

Latest Threads

Latest Posts

Latest Profile Posts

Coin Locker title screen:
Still in progress...

Screenshot_134.png
the girls.png
So, these are all the girls of the party =3 (beside the protagonist if you play as a female.)
Now, I just have one more character sheet of the guys left and I'm done with their presentations =3
Can you recognize where this area is from? :kaocry:
Mq9QM3h.png
For those with up to 9 elements of magic; how do you structure your database. By element? Or by what is offensive vs supportive spells?
would anyone here be interested in rough concept art for the main protagonist of my game that might get changed later? :kaoswt2:

Forum statistics

Threads
124,442
Messages
1,163,680
Members
163,256
Latest member
onbetltd
Top