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.

How can i make like this? [RESCUED]

p.s
I'm not good at English writing or reading, because not English-speaking people. I hope you can understand my english.

-----------------------------------------------
hello.
by using script, i want a device which substitute a specific variable and a specific switch to each maps.

..
(eh.. it's hard to me explain correctly.)


for example,

if actor move to [MAP ID:0002], substitute a specific variable : "$A = 0002" and a specific switch on.
and
if actor move to [MAP ID:0003], substitute a specific variable : "$A = 0003" and a specific switch down.
and
if actor move to [MAP ID:0004], substitute a specific variable : "$A = 0004" and a specific switch on.
..
.
..
like this.
----------------

of course, it can make using by event, but it's too intricate.

please help me.
 

khmp

Sponsor

Code:
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  MAP_VAR_SWITCH = {
    # map_id => [{var_id => var_data, }, {switch_id => switch_data, }],
    1 => [{1 => 'Test1', }, {2 => true, }],
    2 => [{1 => 'Test2', }, {2 => false, }],
  }
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias just_variablefidget_spriteset_map_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    just_variablefidget_spriteset_map_initialize
    
    # Make sure these guys exist.
    return if $game_variables.nil? || $game_switches.nil? || 
      MAP_VAR_SWITCH[$game_map.map_id].nil?
      
    MAP_VAR_SWITCH[$game_map.map_id][0].each do |var_id, var_data|
      $game_variables[var_id] = var_data
    end
      
    MAP_VAR_SWITCH[$game_map.map_id][1].each do |switch_id, switch_data|
      $game_switches[switch_id] = switch_data
    end
  end
end

Alright take a quick look at:
Code:
MAP_VAR_SWITCH = {
    # map_id => [{var_id => var_data, }, {switch_id => switch_data, }],

Ok a map_id points to an Array. Within the Array are two Hashes. The first Hash holds all the variable ids you want to change and the value you want to change them to. The second Hash holds all the switch ids you want to change and the switch ids point to the true/false condition you want to set them to.

Example:
Let's say when you enter MAP004 you want to change two variables and one switch. The two variables being 3, and 4. And you want to set those variables to "Variable 3" and 128 respectively speaking. Switch number 1 will be set to true.
Code:
    4 => [{3 => "Variable 3", 4 => 128, }, {1 => true, }],

It's not as simple as I hoped but if you have any questions on it let me know. I hope that 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