Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

New Switches's Set?

Hello Again.

This time, I have a question about switches, How to create a different set of switches?.

For example, I am making a script that works with the following line:

If Meph_switches 
 
First copy the "Game_Variables" script to a new section and change
Code:
class Game_Variables
to
Code:
class Meph_Variables
then in Scene_Title's "command_new_game" method, change
Code:
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
to
Code:
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    $meph_variables     = Meph_Variables.new
and you can use them as the normal game_variables (ie "$meph_variables[32] = 234")
You can also do the same with switches or self_switches.

Hope it helps :thumb:
 
Thanks, but I have problems with the new switches, when I try to make a conditional I get an error. (about undefined method [] for nil class).

Is there another form to make it?
 
Copy the Game_Switches one instead of the Game_Variables one. Change the name of course, use the same stuff for Scene_Title as mentioned by S S Muu, just swap '$meph_variables' with '$meph_switches' and make sure the class name match with the actual class. Now, make sure you use the following code to set switches:
Code:
$meph_switches[0] = true
And the likes. Also note that these switches will not save to the save file, nor load for that matter.
To fix this, go into Scene_Save, right after this line:
Code:
Marshal.dump($game_player, file)
add:
Code:
Marshal.dump($meph_switches, file)
Now go to Scene_Load. Right after this line:
Code:
$game_player        = Marshal.load(file)
add:
Code:
$meph_switches        = Marshal.load(file)
Hope this helps.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top