Hi there!
I have some doubts while making my plugins and the game. And it is about performance.
For example, I know that it depends on the code of the plugin for it to lag the game.
But, what is the most thing that can lag a game in the plugins?
1 - A lot of global variables, instead of local ones?
2 - Also, many aliases of the same function, in different plugins, (like one alias "Scene_ItemBase.prototype.createActorWindow = function()" and other aliases that too)?
3 - Another one is to make a script call like a plugin( I don't know if I use the right expression here...). I mean, for example, at the beginning of the game, in a script call:
Or
Another code, more complex, utilizing "var banana = something"
These things is saved in the save file of the game, right? And the "var" that I create on script calls, will be global? I mean, I can use that in another event? Or do I have to assign a value to it again?
Thanks a lot! ^^
I have some doubts while making my plugins and the game. And it is about performance.
For example, I know that it depends on the code of the plugin for it to lag the game.
But, what is the most thing that can lag a game in the plugins?
1 - A lot of global variables, instead of local ones?
9. Prioritize access to local variables
JavaScript first searches to see if a variable exists locally, then searches progressively in higher levels of scope until global variables. Saving variables in a local scope allows JavaScript to access them much faster.
Local variables are found based on the most specific scope and can pass through multiple levels of scope, the look-ups can result in generic queries. When defining the function scope, within a local variable without a preceding variable declaration, it is important to precede each variable with let or const in order to define the current scope in order to prevent the look-up and to speed up the code.
10. Avoid using global variables
Because the scripting engine needs to look through the scope when referencing global variables from within function or another scope, the variable will be destroyed when the local scope is lost. If variables in the global scope can not persist through the lifetime of the script, the performance will be improved.
2 - Also, many aliases of the same function, in different plugins, (like one alias "Scene_ItemBase.prototype.createActorWindow = function()" and other aliases that too)?
3 - Another one is to make a script call like a plugin( I don't know if I use the right expression here...). I mean, for example, at the beginning of the game, in a script call:
Code:
If(Utils.isMobileDevice()) { $gameSwitches.setValue(1, true)};
Another code, more complex, utilizing "var banana = something"
These things is saved in the save file of the game, right? And the "var" that I create on script calls, will be global? I mean, I can use that in another event? Or do I have to assign a value to it again?
Thanks a lot! ^^

