RGGS3 Script help

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Posted in the wrong section before.

Wondering if anyone could tell me whats wrong with this code:

def activate() $game_switches[998] = trueendactivate()I keep getting this error:

 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
Is the script that contains it above Game_Switches in the list?
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
No, is that the problem?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
No, that would have been a problem had it been the case.

Hmm, is the snippet just by itself or is it part of a larger script?
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
By itself.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
And where exactly in the script editor is it currently located?
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Below a few other scripts under Materials.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
But above Main, yes?
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Of course lol.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
Aha. I'll tell you what the problem is:

RGSS, being based on Ruby which is an interpreted language, basically runs through your entire script list when you start the game and interprets all the code. Your call to "activate" is outside of a class or module, so Ruby takes it as something it has to process immediately, so it tries to set $game_switches[998] to a value...but because it hasn't yet reached the part where it has DataManager create all the global variables, $game_switches doesn't exist yet.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
Do you want the switch set at game start-up or whenever a new game is started?
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Aha. I'll tell you what the problem is:

RGSS, being based on Ruby which is an interpreted language, basically runs through your entire script list when you start the game and interprets all the code. Your call to "activate" is outside of a class or module, so Ruby takes it as something it has to process immediately, so it tries to set $game_switches[998] to a value...but because it hasn't yet reached the part where it has DataManager create all the global variables, $game_switches doesn't exist yet.
Ah! Makes sense.

Do you want the switch set at game start-up or whenever a new game is started?
Whenever a new game is started.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
Use something like this, then. Make your own module, then call the new method just after the databases are loaded in DataManager.

Code:
#==============================================================================# ** Addendum#==============================================================================module Addendum  #--------------------------------------------------------------------------  # * Activate  #--------------------------------------------------------------------------    def self.activate    $game_switches[998] = true  endend # Addendum#==============================================================================# ** DataManager#==============================================================================module DataManager  #--------------------------------------------------------------------------  # * Set Up New Game  #--------------------------------------------------------------------------  class << self    unless method_defined?(:data_q36N9Sjn_dm_setup_new_game)      alias_method(:data_q36N9Sjn_dm_setup_new_game, :setup_new_game)    end  end    def self.setup_new_game(*args, &block)    data_q36N9Sjn_dm_setup_new_game(*args, &block)    Addendum.activate  end  end # DataManager
 
Last edited by a moderator:

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Well that worked, thanks a lot.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
You can keep adding methods, constants and so on to the 'Addendum' module, as well. Use it for a dumping ground for anything that is too small for its own dedicated module.
 

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

Latest Threads

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,081
Members
137,582
Latest member
Spartacraft
Top