Own distinct variables

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
I want to declare my own variables. In ace, we can do this via Modules. How can I make this in js so when I call certain variables, I can just say for example:

var overdrive_meter_start = Milena.overdrive_value;

and so on? I want this to be the variables that would receive the values from the params.

In general, how can you make something like this? is there a way to implement imported = {} as well?
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
Yes, we're able to do that like this:

Imported = Imported || {};Milena = Milena || {};Milena.whatever = "something";Personally, I prefer to keep all my scripts in separate areas of my 'module', like so:

Zale = Zale || {};Zale.Plugin = {};Zale.Plugin.Variable = "Something";This way, I can use the same variable name for separate scripts, in the event that they overlap. It also lets me easily check the variables another plugin has set in a loop or something similar.
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
If I understand correctly, does that code also applies the same in this manner?

Code:
var Imported = Imported || {};Imported.BasicMenuPlus = true;var Milena = Milena || {};Milena.params = PluginManager.parameters('Basic Menu Plus');
 

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
858
Reaction score
364
First Language
Spanish
Yes, the only difference is than You are using BasicMenuPlas without using Milena first.

You may use:

Milena.BasicMenuPlus = {};Milena.BasicMenuPlus.params = PluginManager.parameters('Basic Menu Plus');Because that way you don't have to worry about the params value if you make another script later.
 

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
One small thing, dont use snake case, all of Javascript is camelCase. Its the convention.
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
One small thing, dont use snake case, all of Javascript is camelCase. Its the convention.
Conventions aren't requirements. If you like it one way, we can recommend the other, but we can't force you into it. We can only be bigots about it.
 

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
858
Reaction score
364
First Language
Spanish
One small thing, dont use snake case, all of Javascript is camelCase. Its the convention.
except for class names, module names, and constants... ya' know.

A module cound be considered a singleton class, and classes uses the first letter in uppercase, right?... So first letter upper case for singleton classes :p
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,981
Members
137,563
Latest member
cexojow
Top