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.

Need help combining two scripts so that they remain compatible.

Before anyone says anything, these scripts do not belong to me, they belong to OS!

I need help combining his plug-ins for his random weather generator so that they remain compatible with it, specifically i want to combine these two:

Code:
module OS
  W_Regions = {
  #Region => [[Maps],[Weathers]]
  "Plains" => [[1,2],[1,2,3]]
  }
  class Weather
    # Initialize
    def initialize
      # Type
      @type = 0
      # Power
      @power = 0
      # Memorized Weather Effects 
      @memorized = []
      # Weathers available in the current map
      @weathers = []
      # The current map id
      @map_id = 0
      # Randomly selected frame count using W_MacCount
      @count = rand(W_MaxCount - 1) + 1
      # Weather Affects Allowed
      @allowed = true
      # Regional Data
      for i in 0..W_Regions.keys.size - 1
        if W_Regions.values[i][0].includes?(@map_id)
          reg = W_Regions.values[i]
          @region = [W_Regions.keys[i],reg[1]]
          break
        end
      end
    end
    # Update
    def update
      # If weather effects are allowed
      if @allowed == true
        # And if the map id is different than the current map
        if @map_id != $game_map.map_id
          # Fix the map id and current weathers
          @map_id = $game_map.map_id
          @weathers = @region[1]
        end
        # Count Down
        @count -= 1
        # If count reaches 0
        if @count <= 0
          # Reset Count randomly
          @count = rand(W_MaxCount - 1) + 1
          # Generate Weather
          gen_weather
        end
        # Fixes power so it isn't above 50
        fix_power
        # Fix Tone (Not perfect yet)
        fix_tone
        # Set weather effects
        $game_screen.weather(@type,@power,rand(19) + 1)
      end
      return
    end
  end
  # Region?
  def region?
    return @region[0]
  end
end

Code:
module OS
  W_Seasons = {
  #Region => [[Maps],[Weathers]]
  "Summer" => [],
  "Autumn" => [1,2],
  "Winter" => [3],
  "Spring" => [1,2]
  }
  class Weather
    # Initialize
    def initialize
      # Type
      @type = 0
      # Power
      @power = 0
      # Memorized Weather Effects 
      @memorized = []
      # Weathers available in the current map
      @weathers = []
      # The current map id
      @map_id = 0
      # Randomly selected frame count using W_MacCount
      @count = rand(W_MaxCount - 1) + 1
      # Weather Affects Allowed
      @allowed = true
      # Seasonal Data
      sea = W_Seasons[current_season?]
      @season = [current_season?,sea]
    end
    # Update
    def update
      # If weather effects are allowed
      if @allowed == true
        # And if the map id is different than the current map
        if @map_id != $game_map.map_id
          # Fix the map id and current weathers and Season
          sea = W_Seasons[current_season?]
          @season = [current_season?,sea]
          @map_id = $game_map.map_id
          @weathers = @season[1]
        end
        # Count Down
        @count -= 1
        # If count reaches 0
        if @count <= 0
          # Reset Count randomly
          @count = rand(W_MaxCount - 1) + 1
          # Generate Weather
          gen_weather
        end
        # Fixes power so it isn't above 50
        fix_power
        # Fix Tone (Not perfect yet)
        fix_tone
        # Set weather effects
        $game_screen.weather(@type,@power,rand(19) + 1)
      end
      return
    end
  end
  # Current Season?
  def current_season?
    if $game_time != nil
      return $game_time.season?
    elsif $game_world != nil
      return $game_world.time.season?
    else
      return W_Season.keys[rand(W_Season.size - 1)]
    end
  end
  # Season?
  def season?
    return @season[0]
  end
end

Use code tags, please.
-Regi
 

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