Parameter-string does not equal string?

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV


SE.Params.Minimap.Menu_ResetScrollKey according to the console has a value of "end".
So I write SE.Params.Minimap.Menu_ResetScrollKey === "end" // returns false????
I tried "end" === "end" // returns true... Erm... I'm confused.

What am I doing wrong? I tried different quote styles and whatnot but nothing works.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,118
First Language
English
Primarily Uses
RMMV
Hmmm so in JS the single quotes are exactly the same as double quotes, you can do either and it doesn't matter, hopefully that makes your troubleshooting easier (you don't have to try everything twice).

The only thing I could think of is the fromStringParam is somehow mutating (changing) the value itself. Do you feel comfortable sharing more code?
 

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
Entire script SE_Keys.js.

The other script (Minimap) that calls the fromStringParam from SE_Keys is erm... rather big with ~3200 lines so I just highlite this:

Code:
* @param Menu_ZoominKey
 * @text Menu Zoomin-key
 * @desc Key for zooming in. You can find more values in SE_keys.
 * @parent Menu
 * @type select
 * @option none
 * @option pageup
 * @option pagedown
 * @option +
 * @option -
 * @default pageup
 *
 * @param Menu_ZoomoutKey
 * @text Menu Zoomout Key
 * @desc Key for zooming out. You can find more values in SE_keys.
 * @parent Menu
 * @type select
 * @option none
 * @option pageup
 * @option pagedown
 * @option +
 * @option -
 * @default pagedown
 *
 * @param Menu_ResetZoomKey
 * @text Menu Reset Zoom Key
 * @desc Key for resetting the zoom. You can find more values in SE_keys.
 * @parent Menu
 * @type select
 * @option none
 * @option home
 * @option end
 * @option insert
 * @option delete
 * @default home
 *
 * @param Menu_ResetScrollKey
 * @text Menu Reset Scroll Key
 * @desc Key to reset the mapscroll. You can find more values in SE_keys.
 * @parent Menu
 * @type select
 * @option none
 * @option home
 * @option end
 * @option insert
 * @option delete
 * @default end
Code:
    SE.Minimap.Menu.ManualZoomKey_In        = SE.Keys.fromStringParam(Params.Menu_ZoominKey); // <<< works
    SE.Minimap.Menu.ManualZoomKey_Out       = SE.Keys.fromStringParam(Params.Menu_ZoomoutKey); // <<< works
    SE.Minimap.Menu.ManualZoomKey_Reset     = SE.Keys.fromStringParam(Params.Menu_ResetZoomKey); // <<< works
    SE.Minimap.Menu.ManualScrollKey_Reset   = SE.Keys.fromStringParam(Params.Menu_ResetScrollKey); // <<< Error? Why?
Also there is no whitespace or anything after or before 'end'.
I don't think the problem is in my Minimap script because it also bugs in the RMMV console itself (see screenshot in OP).

Could it be an RMMV bug? Because it prints "end" and it says that it is typeof string. So how can this not be equal to "end"? Also the other parameters do work. It's just this one that bugs.

Note that using == instead of === results in the same error.
 
Last edited:

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
Ah yes I think that this is an old RMMV bug... I vaguely remember posting about this ~4 years ago.
When I change the code to this:
Code:
 * @param Menu_ResetScrollKey
 * @text Menu Reset Scroll Key
 * @desc Key to reset the mapscroll. You can find more values in SE_keys.
 * @parent Menu
 * @type select
 * @option none
 * @option home
 * @option end
 * @option insert
 * @option delete
 * @default end
 *
 * @param PLACE_HOLDER_BECAUSE_STUPID_RMMV_BUG
 * @text blablabla
 * @desc Key to reset the mapscroll. You can find more values in SE_keys.
 * @parent Menu
 * @type select
 * @option none
 * @option home
 * @option end
 * @option insert
 * @option delete
 * @default end
it works... Because it seems that the LAST parameter always bugs so I need a dummy-parameter? Is this serious or am I doing something wrong? Also if I type this in the console now:
Code:
SE.Keys.fromStringParam(SE.Params.Minimap.Menu_ResetScrollKey) // works now
SE.Keys.fromStringParam(SE.Params.Minimap.PLACE_HOLDER_BECAUSE_STUPID_RMMV_BUG) // << bugs
Can someone explain please? Do I do something wrong or is this bug still there?


Update:
Found it:
https://forums.rpgmakerweb.com/index.php?threads/mv-sometimes-has-bugged-parameters.56041/

I did a .length check and indeed, RMMV still adds a hidden character to the "end" string because Javascript says that "end" is 4 characters long (but ONLY for the last parameter). My good god, why is this still not fixed?
Sadly the workarround that Victor Sant gave no longer works in the latest version of RMMV.

Help... How do I fix this now? It even appears to occur for the last parameter for each group of variables so I have this happen many times it seems..

Proof:
https://i.imgur.com/Ce2ieBk.png
 
Last edited:

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,118
First Language
English
Primarily Uses
RMMV
Appreciate the advice from Victor, but it doesn't really help to say "it's a bit bugged". Let's find out what's really happening here.

Please do this in your console and show the results:
Code:
console.log(SE.Params.Minimap.Menu_ResetScrollKey);
console.log(SE.Params.Minimap.Menu_ResetScrollKey === "end");
console.log(SE.Params.Minimap.Menu_ResetScrollKey.length);
for (var i = 0; i < SE.Params.Minimap.Menu_ResetScrollKey.length; i++) {console.log(SE.Params.Minimap.Menu_ResetScrollKey.charCodeAt(i))}
 

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
I am on a roll today, I actually found a solution. In fromStringParam() I add this code:

Code:
key_str = key_str.replace(/[\x00-\x1F\x7F-\x9F]/g, ""); // Remove hidden control characters... Because... RMMV bug... Again...
It is caused by a control character. Where can I report this bug?
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,118
First Language
English
Primarily Uses
RMMV
Can you run the code I requested above to determine precisely what "control character" it is?
 

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
Sure:


13 = carriage return. So that's the problematic character. It's also the one that makes the most sense and is likely caused by Javascript not using the semi-colon like proper programming languages. It also explains why it always happens to the last one (or in a group).

But I'm a bit disappointed though. No keymapper in 2019 in RMMV and a bug on top of it. Writing a proper key-mapped-parameter means we have to add every possible key to the parameter, for each parameter, which is holy hell (over 100 lines of code for each parameter).
 

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
So now I'm wondering why my minimap is not visible. Guess:



Code:
 * @param IsVisibleByDefault
 * @text Visible By Default?
 * @desc Will the minimap be visible by default? This applies to each map. If set to false, it will also overrides any plugin commands upon entering a new map.
 * @parent General
 * @type boolean
 * @default true
 *

Good lord... Even my 'true-booleans' are turning into false ones. From now on I sanitize everything:
Code:
    // Get Plugin #Parameters
    SE.Params = SE.Params || {};
    SE.Params.Minimap = PluginManager.parameters('SE_Minimap');
    // Fix stupid RMMV bug (https://forums.rpgmakerweb.com/index.php?threads/parameter-string-does-not-equal-string.113697/):
    for (var key in SE.Params.Minimap) { SE.Params.Minimap[key] = SE.Params.Minimap[key].replace(/[\x00-\x1F\x7F-\x9F]/g, ""); }

Can someone please confirm if this is truly a RMMV bug and if so, when this will be fixed so we don't have to sanitize all of our parameters please.
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
Not sure what is wrong with orignial issue but the one you just posted for your "true" string is because you're not parsing the parameters before using them. It says right in the console your "isVisibleByDefault" is equal to a string which is "true" you can't compare a string with a boolean unless using ==. That being said "isVisibleByDefault === "true" will work fine but that is not a good solution, you want to correctly parse all parameters before using them in your plugin.

I'd recommend parsing beforehand with something like this
PHP:
function parseParameters (string) {
  try {
    return JSON.parse(string, (key, value) => {
      try {
        return parseParameters(value)
      } catch (e) {
        return value
      }
    })
  } catch (e) {
    return string
  }
}
Then you get your parameters from MV and parse them with that function

PHP:
SE.Params.Minimap = PluginManager.parameters('SE_Minimap')
// Stringify first, or incorporate the stringify in the parser function above first if you want.

const Params = parseParameters(JSON.stringify(SE.Params.Minimap))
Doing this may even solve your original problem but I'm not sure.
 

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
Not sure what is wrong with orignial issue but the one you just posted for your "true" string is because you're not parsing the parameters before using them.
You're right that I accidentally compared a string with a bool in the console using === (my fault!).
I do parse them but that might not be clear from my post, sorry. This line does that (uses the alias-variable Params which is SE.Params.Minimap):
Code:
SE.Minimap.VisibleByDefault = Params.IsVisibleByDefault.toLowerCase() === 'true';
I used the non-parsed-version in my screenshot on purpose. I keep my params separate from my actual implementation because they can be overriden through map-notes and such. That's why it looks like I don't parse them but I do. However, the parsing will fail anyway due to the hidden character from RMMV because that foo.toLowerCase() === 'true'; will always be false. So parse or not, it will bug.

Yes if you parse them through some custom function it'll work but I rather not do this in every plugin (=workarround), RMMV should do this properly and it smells like a "bug".
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
Hmm interesting I've never run into a hidden character before, is there an easy way to replicate this problem? I would love to look into this in my spare time to learn more.
 

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
I uploaded the demo project containing the problem (just run the game and the console will raise an error). Please don't re-post or use these plugins yet because they are not fully converted to the latest version of RMMV.
I last updated them ~4 years ago due to my inactivity and I need to refactor some stuff. I will hopefully finish them tomorrow if I don't run into any big problems anymore and then I'll post them.

Download here: https://filebin.net/86695i12om6kip6a/HiddenCharacterProblem.zip?t=ms3904qt

If it matters, I use the Steam version 1.6.2.
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
now I see the issue, interesting and definitely a bug in the parameter type "select", unfortunately, the dev who created the MV 1.5 Plugin Manager has been long gone but an easy solution would be to use the @value option for each possible option. This is why I've never seen this issue because I don't often use the select parameter type and when I do I usually use the value option with it.

So changing your parameter to this should work.

Code:
 * @param Menu_ResetScrollKey
 * @text Menu Reset Scroll Key
 * @desc Key to reset the mapscroll. You can find more values in SE_keys.
 * @parent Menu
 * @type select
 * @option none
 * @value none
 * @option home
 * @value home
 * @option end
 * @value end
 * @option insert
 * @value insert
 * @option delete
 * @value delete
 * @default end
It worked for me in this case
upload_2019-9-27_14-42-47.png

**Edit** I was so excited about this @type select bug I forgot to check over the other params, specifically the visibility param. Oddly I never had this issue either and it's very new to me, in fact, I believe this bug would break many older plugins created before 1.5 would it not?

I never have this problem because I use JSON.parse and it successfully parses every parameter without the need to declare every parameter .This is literally all I do for my parameters (the parseParameter function is what I showed you earlier)
upload_2019-9-27_15-9-27.png
and then all I have to do is...

_Params.IsVisibleByDefault // will return a true boolean
_Params.randomList // Will return an array

I'm interested in this issue though and plan to dig deeper when I have more time.

EDIT EDIT ***

Okay so not sure what the issue was but I fixed it all for you and it don't require anything special.

1) Delete the plugin from plugin manager ( I deleted the plugins.js)
the reason I did this is because I noticed that the parameters in plugin.js had "/r" the carriage return in many of the parameters which is odd because I checked my plguins and none of them had that.

2) Save the project (this ensures the plguin.js is had changes written to it)

3) Insert the plugin again

3) Go over each parameter and select the options one more time...apply changes and save project

The above step somehow removed every "/r" nopt sure why they contained it by default to begin with ‍♂ Your @Default parameters look normal to me

Anyways the results are as so
upload_2019-9-27_15-48-14.png

and if you don't want to do above steps simply copy my plugins.js
Code:
// Generated by RPG Maker.
// Do not edit this file directly.
var $plugins =
[
{"name":"Community_Basic","status":true,"description":"Plugin used to set basic parameters.","parameters":{"cacheLimit":"20","screenWidth":"1920","screenHeight":"1080","changeWindowWidthTo":"","changeWindowHeightTo":"","renderingMode":"auto","alwaysDash":"off"}},
{"name":"SE_Keys","status":true,"description":"v1.10 - This Key-Mapper is for plugin-developers and for other scripts that require this plugin.","parameters":{}},
{"name":"SE_Minimap","status":true,"description":"v1.20 - Minimap. Requires plugin \"SE_Keys\" (place this one below it).","parameters":{"General":"","MapStyle":"Scroll","GlobalMapZoom":"0.25","MinimapOpacity":"255","IsVisibleByDefault":"true","Positioning & Size":"","Window_X":"-2","Window_Y":"2","Width":"320","Height":"320","BorderWidth":"12","BorderHeight":"12","AlignmentHorizontal":"Right","AlignmentVertical":"Bottom","Player Blip":"","RenderPlayerBlip":"true","PlayerBlipGraphic":":player","PlayerIconWidth":"16","PlayerIconHeight":"16","PlayerBlinkDelay":"0","Vehicles":"","ShowVehicles":"true","ShowBoat":"true","ShowShip":"true","ShowAirship":"true","VehicleRenderWidth":"40","VehicleRenderHeight":"40","AlwaysShowVehicles":"false","Menu":"","MenuKey":"m","MenuPlayerDescription":"You","MenuZoom":"0.3. A value of 1 means 1:1","MenuLeft_WindowWidth":"240","MenuTopright_WindowHeight":"510","Menu_EventRenderSize":"24","Menu_PlayerIconSize":"64","Menu_MinManualZoom":"0.20","Menu_MaxManualZoom":"10.0","Menu_ZoominKey":"pageup","Menu_ZoomoutKey":"pagedown","Menu_ResetZoomKey":"home","Menu_ResetScrollKey":"end","Passability Map":"","PassabilityOverlayOpacity":"128","PassabilityColor":"#6B8E23","ImpassabilityColor":"#FF0000","Map Generator":"","MapGenTagColors":"#6B8E23 #00008B #8B4513 #006400 #F4A460 ####### ####### #FFFFFF","OverworldGenTagColors":"#6B8E23 #00008B #8B4513 #006400 #F4A460 ####### ####### #FFFFFF","MapGenRegionColors":"10:#6B8E23 11:#00008B 12:#8B4513 13:#006400 14:#F4A460","OverworldGenRegionColors":"10:#6B8E23 11:#00008B 12:#8B4513 13:#006400 14:#F4A460\r","Miscellaneous":"","AllowTeleportation":"true","StandardPadding":"0","WindowSkin":"Window_Minimap","FillColor":"0 0 0 255","MaintainAspectRatio":"true","FadeoutSpeed":"3","GlobalRequiredItem":"0","EventRenderSize":"16","AutoClearPOI":"false","RenderMinimapOverlay":"true","Fog of War":"","FoWEnabled":"false","DefaultFoWOverlay":"FoW","DefaultFoWRadius":"5","Manual Scrolling":"","AllowManualScrolling":"true","ManualScrollspeed":"24","ManualScrollKey_Up":"u","ManualScrollKey_Right":"k","ManualScrollKey_Down":"j","ManualScrollKey_Left":"h","Advanced & Debug":"","PlayerSpriteSourceframeWidth":"48","PlayerSpriteSourceframeHeight":"48","FrameSkip":"0","MapshotFilenameLength":"3","DebugMode":"true","RenderDebugGrid":"false","DebugGridImage":"DebugGrid01"}}
];
EDIT EDIT EDIT** Pretty sure the mnain problem is your use of ":"" and your headers using ========= in your parameters. which is causing MV to incorrectly determine which parameters and their options & values should be paried together. When I remove your headers and the : all default parameters are correctly inserted upon plugin installation.
 
Last edited:

Adventurer_inc.

Technically a Programmer
Veteran
Joined
Sep 12, 2015
Messages
99
Reaction score
42
First Language
English
Primarily Uses
RMMV
This... is actually not a bug. This is actually a feature of Game Engines that uses Literal Notations. The most common way to accomplish what you want is the eval() function (most languages has an Eval function in some form). However, it's never that simple, as long as you are careful about how you use it, you shouldn't run into problems such as code validation or latency issues.

You can actually find examples of this is many people work on many different Engine not just on rpgmaker. I'm certain I've seen examples of it in the popular Yanfly's work.

Code:
"true\n" === true
- false
"true\n" === "true"
- false
eval("true\n") === "true"
- false
eval("true\n") === true
- true
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
This... is actually not a bug. This is actually a feature of Game Engines that uses Literal Notations.
Actually, RPG Maker is only supposed to use JSON-escaped-string for notes, lists and structs not for any other parameters, this was to ensure backwards compatibility with older versions of plugins for it.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,118
First Language
English
Primarily Uses
RMMV
I was curious so I tried reproducing it.

Here's the param I added to a fresh plugin (without a dummy parameter after it)
Code:
* @param Menu_ResetScrollKey
* @text Menu Reset Scroll Key
* @desc Key to reset the mapscroll. You can find more values in SE_keys.
* @parent Menu
* @type select
* @option none
* @option home
* @option end
* @option insert
* @option delete
* @default end
Loading up got the expected value.
upload_2019-9-27_17-14-22.png
As long as you didn't manually edit the plugins.js file, I would agree that this is a bug. Carriage returns should not be inside of strings. However, unless you can come up with an easy way to reproduce the error on a fresh file, devs probably wouldn't look into it (I know it's bugged in the version you posted, but it needs to be recreate-able). (also we haven't heard much from any devs in a while so...)

Going through some of the earlier comments:
13 = carriage return. So that's the problematic character. It's also the one that makes the most sense and is likely caused by Javascript not using the semi-colon like proper programming languages. It also explains why it always happens to the last one (or in a group).
Nothing to do with the use (or not) of the semi-colon in JS, it would have to do with the MV editor itself (which is written in a "proper" language C++ that uses semi-colons) that modifies the plugins.js file adding the carriage return when it should not.

But I'm a bit disappointed though. No keymapper in 2019 in RMMV and a bug on top of it. Writing a proper key-mapped-parameter means we have to add every possible key to the parameter, for each parameter, which is holy hell (over 100 lines of code for each parameter).
Agree 100%. The input keymapper is awkward at best, basically it's only written to accommodate the keys which are used by default. Suggestion in the spoiler, but yeah I agree writing your own input key mapper in MV is not fun (and I've done it).
It could help to set letters in a loop like:
const myAmazingKeyMapper = {}
for (let i = 65; i <= 90; i++) {
myAmazingKeyMapper[String.fromCharCode(i)] = i
}
You can do numbers 0-9 this way also. "Special" keys like PageUp, CapsLock, etc. unfortunately you gotta do it manually.

Additionally, instead of that regex replace I recommend a simpler/more readable workaround to sanitize it.
Code:
str = str.trim()
LTN Games comments and edits looks like solves the issue. Perhaps it is still a bug (should MV not be confused by that format?) but at least it is manageable.

This... is actually not a bug. This is actually a feature of Game Engines that uses Literal Notations. The most common way to accomplish what you want is the eval() function (most languages has an Eval function in some form). However, it's never that simple, as long as you are careful about how you use it, you shouldn't run into problems such as code validation or latency issues.

You can actually find examples of this is many people work on many different Engine not just on rpgmaker. I'm certain I've seen examples of it in the popular Yanfly's work.
1. I disagree that it's a "feature" to add a unexpected carriage return inside a string
2. Recommending eval is *not* a good coding practice. Using 'eval' in general should be a last resort, and using it to parse parameters of a known format is at best lazy and at worst dangerous. There's almost no reason to use 'eval' in any context, unless you truly can't predict what the input is and must parse it as JS. I even disagree with the use of 'eval' in the damage formula (it should be a cached function with dynamic inputs).
3. Latency issues...? Did you mean performance/efficiency?

Just a small thing, but "\n" is the notation for a newline and "\r" is the notation for a carriage return.

Actually, RPG Maker is only supposed to use JSON-escaped-string for notes, lists and structs not for any other parameters, this was to ensure backwards compatibility with older versions of plugins for it.
100% agree, and carriage return inside a string is not valid JSON format. If that existed in a string, you would get a "Uncaught SyntaxError: Unexpected token in JSON at position __" when trying to use JSON.parse on that string. Of course, this doesn't happen because the configuration is stored in a .js file and not in a .json file, it kinda makes me think the devs didn't want to deal with asynchronous programming in order to load the plugin configuration.
 

Adventurer_inc.

Technically a Programmer
Veteran
Joined
Sep 12, 2015
Messages
99
Reaction score
42
First Language
English
Primarily Uses
RMMV
I feel like every time I mention eval on this forum, someone's cat goes without water. :kaoswt2:

Actually, RPG Maker is only supposed to use JSON-escaped-string for notes, lists and structs not for any other parameters, this was to ensure backwards compatibility with older versions of plugins for it.
I'm not sure exactly what you meant, but since you quoted me... Using eval for JSON-escaped-string for notes, lists and structs is can go either way for good for bad practice. What you should actually be doing is writing your own regex and parsing that; a popular example is Yanfly's Action Sequence. This way when codebase updates, only your adapters need to change, or not, depending on how polymorphic you made it. I think leaving it up to plugin writers is a good choice on the engine writer's behave. This is the reason why when the engine updates most plugins in RPGmakerMV becomes obsolete instantly.

Although Team Yanfly's stuff is a bit invasive, they are crazy experienced designers. :kaoswt:

Edit: I think I'm getting what you meant. I'm almost positive that the reason why JSON was used was because of its cross-platform friendliness and Nodejs's RESTful design. RPGmakerMV is a subset of Nodejs, after all, which was designed for the web. Don't quote me on this!:kaoback:
1. I disagree that it's a "feature" to add a unexpected carriage return inside a string.
I think you misinterpreted my sarcastic feature. This carriage return should actually be expected. From what I remember from my Compiler Class years ago, the reason why it is like that is that is because there is no other way to do it. You need a carry return, you need a delimiter, you need to know when something ends. It becomes exponentially times more difficult when using a high language like Javascript instead of a low one like C, how you do it is very much up to the designer. Take that as you will, my compiler in c wasn't very good.

Javascript chose that in 95, so they will have to live with it: http://timelessrepo.com/json-isnt-a-javascript-subset

If you are curious about what a decent parser looks like. LeCode's TBS's action sequence has a good one. It's actually quite impressive for someone who is only currently a student of Game Engine design. :kaothx:

2. Recommending eval is *not* a good coding practice. Using 'eval' in general should be a last resort, and using it to parse parameters of a known format is at best lazy and at worst dangerous. There's almost no reason to use 'eval' in any context, unless you truly can't predict what the input is and must parse it as JS. I even disagree with the use of 'eval' in the damage formula (it should be a cached function with dynamic inputs).
Hence, why I mentioned the warning. What you stated here is more opinion than fact. Performance-wise, eval can even make the game more efficient because you don't have to write a parser for a single used call. You should definitely not use eval if you can't truly predict the input. You can actually see examples of this if you benchmark people's code. Not even considering eval is simply bad practice.

From what I remember from my Game Engine class in college the true beauty of eval is to be used as a workaround the model-view-controller design most, if not all, Game Engine uses. However, use it too much and you'll get spaghetti code. Using it most other way is poor structure.

3. Latency issues...? Did you mean performance/efficiency?
One of the deadly sins of programming is using eval in a loop. Eval should never be called more than once. As you stated above, the ideal way to use it should be used once, then cache its value. This is exactly what OP is doing.

Just a small thing, but "\n" is the notation for a newline and "\r" is the notation for a carriage return.
I think this was a given. 'n' for newline and 'r' for return. :kaojoy: However, you can't see \r when calling it in a terminal, so I instinctively chose \n, which you can see because of where the cursor is. Seeing is believing.

100% agree, and carriage return inside a string is not valid JSON format. If that existed in a string, you would get a "Uncaught SyntaxError: Unexpected token in JSON at position __" when trying to use JSON.parse on that string. Of course, this doesn't happen because the configuration is stored in a .js file and not in a .json file, it kinda makes me think the devs didn't want to deal with asynchronous programming in order to load the plugin configuration.
Carry return inside JSON is a very valid format. This is especially useful when using PHP server-sided to create a dynamic website using HTML or using Java to create editable objects or C++ to easily add mods. :kaoswt2:
You can actually test this:
Code:
let obj = {x:1,y:"hello\n"};
JSON.stringify(obj);
- "{"x":1,"y":"hello\n"}"
I personally feel like there's too much "the designer is stupid" on this forum instead of "I wonder why someone chose this", so I won't pursue this any further.:kaodes:

I'm sure I'm far from an expert programmer but I've seen how eval is used in many hobbist, academic, and commercial engines I'm not allowed to list here. Calling eval dangerous is correct but calling it lazy is flat out uninformative to anyone reading this. :kaoluv:

I apologize for any slang, American English is my first language.
 
Last edited:

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
@Aloe Guvner I can rather simply reproduce this problem. I just created a new project and added 4 of my plugins, re-ordered them and ran the game and voila, the \r are visible in the plugins.js... For me the bug occurs 100% of the time so far.

I won't bother removing the carriage returns from the plugins.js, I'll just apply the fixes instead because they may reappear and they can also appear for other people using my plugin.
I hope you won't mind @LTN Games that I'll be using your parseParameters() function then.

the dev who created the MV 1.5 Plugin Manager has been long gone
The bug is as old as RMMV and I believe it was never looked into and Victor Sant (well-known scripter) also confirmed it. But they also never fixed some of our old annoyances dating back to other older RPG Makers.


I also wonder why the community never came up with 1 single core-script that everyone uses that includes RMMV bug-fixes, various annoyance fixes, common utilities, a math library, registering plugins, converting params, key-mapper, etc. Maybe Degica could have better facilitated this.
I hate adding a core-script just for a tiny script like a "skip-title-screen" or something (which imo should be an RMMV option).
The Community_Basic script is a nice start but I think we could use a more advanced one.
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
@Adventurer_inc. I mean plugin manager's struct, list and note parameters should use the json-escaped-string format wheras the single, boolean, number and string parameters should be simply a string only, and I mean the raw parameters that you recieve by using PluginManager.parameters() method. At least that is what was intended by the MV developers, apparently this is not that case according to this bug and it is now a string but with the addition of "/r" lol.

Also as for the eval, I would actually rather simply use JSON.parse(parameter) for parameters, unless of course its specifically for the plugin user who want to run some script calls, in that case I'll use an eval for them.

@SilverDash Absolutly use it all you please, in fact I can't even say the function was all mine it was brought to my attention a year or so ago by @waynee95 when he seen the insane way I used to parse my parameters lol. The method is free for use and I actually use it in my library I made for MV.

As for the "1 single core" plugin, I mean there has been many attempts at this but it just so happens every individual plugin author decided to make their own core and have their own fixes. I personally got rid of my core plugin over 1 /12 years ago and I never looked back, I absolutly love making plugins without a core plugin and I simply use my library and build tools to auto insert "common" methods into the plugin upon building.

That being said I agree the communitty basic core is a great start but it needs a lot more added to it to make it more viable for plugin devs.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

A part of me wants to return back to the beginning and first two chapters and remake them with parallax map. But I have decided not to. Every chapter is just another step in the journey. No need to walk back unless I have to revise dialouge.
Hey guys! Good news!
I just released the Games from Brazil - Part 2 on my Youtube Channel! I am really happy that part 1 had 100 views and I hope more people will be interested to see the potencial of Brazilian Game Devs!
Effervesce Fallacy™ - Attract Mode (proto)

Forum statistics

Threads
107,570
Messages
1,030,636
Members
139,671
Latest member
WDRS
Top