[Solve]convert swithces to number

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
529
Reaction score
275
First Language
thai
Primarily Uses
RMMV
sory It work
just my typo on var Lang and lang in other line -***-


-----------------
my code
var Lang = $gameSwitches.value(20) === true ? 1 : 0 ;


I want to use this in array work
I know I can just check boolean and set it or use variable instead

but this format is interesting me
var i = result ? 1 : 0;
I found in stackoverflow web
and in orher plugin that I open to learn
but when I try it my self it not work

thank you
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
It helps if you use the Code tags to format your code on here and make it easier to read.
upload_2019-4-10_22-15-45.png

Any of these lines will convert the true/false into 1/0:
Code:
// Any of these are fine
var Lang = $gameSwitches.value(20) ? 1 : 0;   // test truthiness
var Lang = $gameSwitches.value(20) === true ? 1 : 0 ;  // test explicit true
var Lang = Number($gameSwitches.value(20));  // Number constructor with boolean argument
// These are technically the same but very confusing to read. Don't use these unless you want to be crazy
var Lang = +$gameSwitches.value(20);  // coerce boolean to number
var Lang = $gameSwitches.value(20) | 0; // bitwise OR operator
var Lang = ~~$gameSwitches.value(20);  // double bitwise NOT operator
The first group is the most readable which is always preferred.
 

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

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,446
Members
137,820
Latest member
georg09byron
Top