Help with $gameSystem

The_D

Dr
Member
Joined
Sep 9, 2016
Messages
12
Reaction score
3
First Language
English
Primarily Uses
Hello,


I am new to javascript, and I currently have a .js file with 


//Game_System variables and functions


Game_System.prototype.variable = "value";


Game_System.prototype.print_variable = function(){


     console.log(this.variable);


}


I try to make a call to the function in RPG Maker MV


$gameSystem.print_variable();


,and I get an error message reading


Undefined is not a function.


I'm not entirely sure what I'm doing wrong, but any help would be greatly appreciated.


Thank you.
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,430
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
I've moved this thread to Learning Javascript. Please be sure to post your threads in the correct forum next time. Thank you.
 

2DGameStudios

Veteran
Veteran
Joined
Oct 11, 2015
Messages
184
Reaction score
45
First Language
English
When I get home I can send you a ex of how it should look so you can see how the .js should be formatted
 
Last edited by a moderator:

2DGameStudios

Veteran
Veteran
Joined
Oct 11, 2015
Messages
184
Reaction score
45
First Language
English
When I get home I can send you a ex of how it should look so you can see how the .js should be formatted
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
Are you sure your plugin is enabled, and thus adding the variable and function to Game_System? If you just print out the $gameSystem variable itself, you can check to see if it has your variable in it.
 

The_D

Dr
Member
Joined
Sep 9, 2016
Messages
12
Reaction score
3
First Language
English
Primarily Uses
My plugin is enabled, and I changed to in-game code to


window.alert($gameSystem.variable);


and it says the variable is undefined as well as the function. I'm sure I must be doing something wrong, but I can't figure it out.
 
Last edited by a moderator:

The_D

Dr
Member
Joined
Sep 9, 2016
Messages
12
Reaction score
3
First Language
English
Primarily Uses
I've still been unsuccessful with my issue. Maybe 2DGameStudios could send that text file if it's not too much trouble.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,430
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
The_D, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


If you have to add something and your own post is the last one, please edit it. 72 hours have to pass before bumping is allowed.
 

Ricksoaz

Villager
Member
Joined
Aug 6, 2016
Messages
11
Reaction score
0
Primarily Uses
Do you really need to use Game_System.prototype.variable = "value"? I'm new to this kind of stuff too so I might not be grasping what is your goal, but I think that you can just make:


var myVar1 = 45; // your custom global variable

// you could also use $gameVariables.value(12); ingame global variable. 12 is the id of the variable (you can see from the editor), change it to any other id you want like "0030" without the "00" and quotes.

Game_System.prototype.print_variable = function(){
var myVar2 = 110; // same things as myVar1 except this one has a local scope
console.log(myVar1, myVar2);
}


Maybe is this what you want? Anyway, you should reall reall really start using the console to debug and watch your variables and functions. Press F8, go to sources, find your plugin and breakpoint the hell out of stuff. Trust me, it saved me from a lot of headaches.
 

The_D

Dr
Member
Joined
Sep 9, 2016
Messages
12
Reaction score
3
First Language
English
Primarily Uses
Sorry for the double post,and the reason I'm trying to use game_system is because I'm following a tutorial on YouTube, and I'm having trouble getting past my problem. I've already finished 2 JavaScript tutorials on codeacademy but I'm trying to learn the rpg maker engine now. I've written scripts in the past with Ruby, and now having to learn another language and rpg core is a bit overwhelming.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,430
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
Then I suggest you give us a link to that tutorials, so we can check if the tutorial is simply wrong here or did something differently.


But really? Video tutorials are probably the worst way to learn scripting/programming - simply because they are usually too short and skip over too much details for time restrictions.


And that doesn't even adress the problem of visibility (there are a lot of script videos where it is difficult to see the difference between () and []) or the fact that you can't type in the code as fast as a video describes it.


You should better look for a written tutorial in a PDF or so.
 

The_D

Dr
Member
Joined
Sep 9, 2016
Messages
12
Reaction score
3
First Language
English
Primarily Uses
Sorry I tried two different ones on YouTube one bu SumRndmDude and one by soulpour. I would link but I'm on my phone now. Could you maybe suggest a non video tutorial I'm not opposed to learning with a document, but I would like to find a good one.Sorry, again. I just saw the links in your post, and I'll try those out. Thanks for your help.
 
Last edited by a moderator:

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

Latest Threads

Latest Posts

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,035
Messages
1,018,455
Members
137,821
Latest member
Capterson
Top