[XP] Dynamic Gardening

Started by ForeverZer0, April 14, 2010, 05:44:04 pm

Previous topic - Next topic

ForeverZer0

April 14, 2010, 05:44:04 pm Last Edit: December 20, 2017, 12:16:30 am by KK20
Dynamic Gardening
Authors: ForeverZer0, ThallionDarkshine
Version: 3.01
Type: Advanced Garden System
Key Term: Misc System



Introduction

This system will allow you to easily set up a Gardening System very much like the one in "Legend of Mana" for PSX. For those who have never played that game, it is basically a system that lets the player plant seeds that they have acquired, which will grow over time into full plants. Once the plants are ripe, they can be harvested for items.



Features


  • Easy and total configuration for growth rates, item results, etc.

  • Each plant uses its own independent timer, which will be saved with the game.

  • Timers run constantly in the background unless player is in the menu, etc.

  • Different plant stages show the progression from sprout to full grown plant.

  • Events can be easily set-up, and you can use as many as needed





Screenshots

Screenshot 1: ShowHide

Screenshot 2: ShowHide

Screenshot 3: ShowHide

Screenshot 4: ShowHide



Demo

Demo Link


Script

Single and Double Seed Planting Version (originally written by Twb6543)
Spoiler: ShowHide

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Dynamic Gardening
# Authors: ForeverZer0, Twb6543, ThallionDarkshine
# Date: 7.17.2011
# Version: v.3.3
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#                            VERSION HISTORY
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#  v.1.1  (4.15.2010)
#   - Improved coding
#   - No longer uses game variables, events use self-switches instead
#   - Added ability to create different graphics for every plant, without
#     having to use more event pages
#   - Much less tedious setting up multiple events and changing the every
#     condition variable.
#  v.2.0  (10.10.2010)
#   - Total re-write. Code has been vastly improved and is much more efficient.
#   - Event setup has been simplified. Now requires only a single comment, and
#     does not require multiple pages.
#   - Added configurability for the number of stages each item requires.
#   - The timers no longer use Game_System to constantly update, but simply
#     compare themselves with the Graphics.frame_count when the event exists
#     on the current map, which also allows the plants to grow during scenes
#     other than Scene_Map and Scene_Battle.
#   - Got rid of Scene_Harvest. Scene_Garden now handles both aspects, and has
#     been improved.
#   - Added item icons to the help window display.
# v.3.0  (5.13.2011)
#   - Restructured code completely
#   - Increased compatibility and performance
#   - Fixed bug with final graphic not behaving correctly
# v.3.1  (7.14.2011) by Twb6543
#   - Changed Script to allow for Single Seeds
#   - Added the ability to set default values
# v.3.2 (7.17.2011) by Twb6543
#   - Changed Script to fix bugs in the last release
#   - Fixed Bugs from version 3.0 (May not be completely fixed but I(Twb6543)
#     believe that it is mostly fixed)
# v.3.3 (12.19.2017) by ThallionDarkshine
#   - Modified script to allow players to choose between single and double seed
#     when planting seeds.
#   - Fixed a bug where help window would not update correctly.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
#   This system allows the player to plant seeds, which will eventually grow
#   into plants that can be harvested for items. The system is very similar in
#   nature to that found in Legend of Mana. Seed's can be combined in different
#   ways, which will effect the total growth duration, the number of stages the
#   plant passes through, the graphics used, and of course the final result.
#
# Features:
#
#  - Totally configurable growth rates, results, and graphics for every plant.
#  - Can use arrays of items for each result, so the final item is not
#    neccessarily the same every time.
#  - Each plant timer is independent, and its progress is saved with the game.
#  - Easy setup. Need only a single comment in one of the event's pages.
#
# Instructions:
#   
#  - Place script below Debug and above Main
#  - Configure the options below (instructions are with each setting)
#  - Create an event, setting the graphic to whatever you want. This will be the
#    graphics used when nothing is growing on the plant.
#  - At the very top event's page, place a comment that reads "Garden Event",
#    omitting the quotation marks.
#  - As long as the page's conditions are met, this event can be clicked on to
#    initiate the Garden scene, and can grow plants.
#  - Note that plants can be harvested early, but they will yield nothing until
#    they are ripe.
#
# Note:
#
#  - Any method modified or added in 3.1 or 3.2 has an headed attached to it.
#  - The header will be "Double and Single Seed" or
#    "Double and Single Seed Method" for modified Methods.
#  - The header will be "Double and Single Seed New Method" for new Methods.
#  - Headers may also have extra information.
#  - The Code for Scene_Garden and Window_Seed can definitely be optimised
#    but as I(Twb6543) finally squashed the bug preventing release of v 3.2
#    I do not want to change anything with out a bit of forethought.
#
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  BEGIN CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
#===============================================================================
# ** Garden
#===============================================================================

module Garden
 
  SEED_IDS = [1, 2, 3, 4, 5, 6, 7, 8]
  # IDs of the items in the database that are seeds. Add them into the array in
  # the order of value/rarity in your game this currently includes any single
  # seeds
 
  HARVEST_SE = '056-Right02'
  # This is the SE that will be played when the player harvests the plant.
 
  SEED_DISPLAY = true
  # If true, all seeds will be displayed in the seed window, including those
  # that the player does not have, though they will be disabled. If false, only
  # seeds that that the player currently has will be displayed.
 
  # Define the growth rates here. (the average of both seeds will be used)
  def self.growth_rate(seed)
    return case seed
    # when SEED_ID then SECONDS
    when 1 then 10
    when 2 then 12
    when 3 then 15
    when 4 then 20
    when 5 then 23
    when 6 then 25
    when 7 then 30
    when 8 then 35
    else
      10 # Default Value to return if no speed is specified
    end
  end
 
#-------------------------------------------------------------------------------
# Define the number of stages that each item uses. The stages will still cycle
# in the same order, but only use up to the defined number of them before going
# to the final graphic. This will not effect the duration that the seed takes to
# grow, only how many times the graphic changes.
#
# You do not have to define anything that uses a three stage configuration.
#-------------------------------------------------------------------------------
  def self.number_stages(result)
    case result
    when 8..16
      return 4
    when 17..24
      return 5
    else
      return 3
    end
  end
 
#-------------------------------------------------------------------------------
# Define the final result of the seeds. A random item from the array will be
# given as the final result.

# Each seed is given a value from 0 to the total number of seeds in the SEED_IDS
# array, and both values are added together to determine which 'produce' array
# will be used for the final result. This is why it is important that you have
# the SEED_IDS array in order of value/rarity. You can find the total number of
# cases you will need by subtracting 1 from the total number of different seeds
# in SEED_IDS, and multiplying that number by 2.
#
#   EX. Player uses one each of the first and last seed in the SEED_IDS array,
#       and there are 8 total seeds in the array...
#
#       FIRST_SEED = 2
#       LAST_SEED = 5         2 + 5 = RESULT
#
# By placing multiple copies of the same value in an array, you can increase
# the odds of receiving that item over another in the same array.
#-------------------------------------------------------------------------------

  #-------------------------------#
  #   - Double and Single Seed -  #
  #-------------------------------#
  #  Now with Else/Defualt Clause #
  #-------------------------------#
  def self.produce(seed)
    return case seed
    when 0 then [9, 10]      # Only if both seed are the lowest seeds
    when 1 then [10, 11]
    when 2 then [12, 13]
    when 3 then [13, 14]
    when 4 then [14, 15]
    when 5 then [15, 16]
    when 6 then [16, 17]      # Every combination in between
    when 7 then [17, 18]
    when 8 then [18, 19]
    when 9 then [19, 20]
    when 10 then [20, 21]
    when 11 then [21, 22]
    when 12 then [22, 23]
    when 13 then [23, 24]
    when 14 then [24]         # Only if both seeds are the highest seeds
    else
      [9] # Default Value to return, Brackets are important,
          # May contain more than one value e.g [9,10] or [9,10,11,12,13]
    end
  end
 
  #------------------------------------------#
  #   - Double and Single Seed New Method -  #
  #------------------------------------------#
  #   Table set up much in the same way as   #
  #  .produce, however items come from seed  #
  #        _ID_  not position in array       #
  #------------------------------------------#
  #  Also the ids are taken from SINGLE_IDS  #
  #                   Array                  #
  #------------------------------------------#
  def self.produce_single(seed)
    return case seed
    when 25 then [9, 10]      # Only if seed is item with Id 25
    else
      [9] # Default Value to return, Brackets are important,
          # May contain more than one value e.g [9,10] or [9,10,11,12,13]
    end
  end
 
#-------------------------------------------------------------------------------
#  Define graphics for the final results, and each stage. Follow the below
#  template to set it up.
#
#   when ITEM_ID/STAGE then ['FILENAME', X, Y]
#
#   ITEM_ID = The ID number of the item in your database
#   STAGE = The stage during which to display the graphic
#
#   FILENAME = The name of the character file the needed graphic is on
#   X = The x-coordinate of the correct picture on the charset (1 - 4)
#   Y = The y-coordinate of the correct picture on the charset (1 - 4)
#
#           ← X →             Ex.   If the needed graphic was in the bottom
#         1  2  3  4                left corner:   X = 1    Y = 4
#       ┌──┬──┬──┬──┐                   
#     1 │  │  │  │  │
#       ├──┼──┼──┼──┤
#  ↑  2 │  │  │  │  │
#  Y    ├──┼──┼──┼──┤
#  ↓  3 │  │  │  │  │
#       ├──┼──┼──┼──┤
#     4 │  │  │  │  │
#       └──┴──┴──┴──┘
#-------------------------------------------------------------------------------

  def self.stage_graphics(stage)
    return case stage
    when 0 then ['Plants1', 1, 1]
    when 1 then ['Plants1', 2, 3]
    when 2 then ['Plants1', 2, 1]
    when 3 then ['Plants1', 4, 2]
    when 4 then ['Plants1', 2, 4]
    end
  end

  def self.final_graphic(item)
    return case item   
    when 9 then  ['Garden Plants', 1, 1]
    when 10 then ['Garden Plants', 2, 4]
    when 11 then ['Garden Plants', 3, 4]
    when 12 then ['Garden Plants', 4, 4]
    when 13 then ['Garden Plants', 1, 4]
    when 14 then ['Garden Plants', 2, 2]
    when 15 then ['Garden Plants', 3, 2]   
    when 16 then ['Garden Plants', 4, 2]
    when 17 then ['Garden Plants', 1, 2]
    when 18 then ['Garden Plants', 2, 3]
    when 19 then ['Garden Plants', 3, 3]
    when 20 then ['Garden Plants', 4, 3]
    when 21 then ['Garden Plants', 1, 3]
    when 22 then ['Garden Plants', 2, 1]
    when 23 then ['Garden Plants', 3, 1]
    when 24 then ['Garden Plants', 4, 1]
    end
  end
 
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  END CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  #              ! Warning !             #
  #                                      #
  # This rearranges the order of the def #
  #  variables to allow for Single Seed  #
  #--------------------------------------#
  def self.plant_seeds(event_id, seed1, seed2=nil)
    # Create a new instance of a Garden::Plant
    if seed2 != nil
      # Double Seed Method
      plant = self::Plant.new(event_id, seed1, seed2)
      if $game_system.garden[$game_map.map_id] == nil
        $game_system.garden[$game_map.map_id] = [plant]
      else
        $game_system.garden[$game_map.map_id].push(plant)
      end
    else
      #Single Seed Method
      plant = self::Plant.new(event_id, seed1)
      if $game_system.garden[$game_map.map_id] == nil
        $game_system.garden[$game_map.map_id] = [plant]
      else
        $game_system.garden[$game_map.map_id].push(plant)
      end
    end
     
  end
 
  def self.harvest(id)
    # Find the appropriate plant.
    plant = $game_system.garden[$game_map.map_id].find {|plant| plant.id == id }
    return nil if plant == nil
    # Return the result, and delete plant data from array.
    result = plant.produce
    plant.restore_event
    $game_system.garden[$game_map.map_id] -= [plant]
    return result
  end

#===============================================================================
# ** Garden::Plant
#===============================================================================

  class Plant
   
    attr_reader :id, :ripe
   
    #--------------------------------------#
    #   - Double and Single Seed Method -  #
    #--------------------------------------#
    def initialize(id, seed1, seed2=nil)
      if seed2 != nil
        # Initialize needed instance variables.
        @id, @seed1, @seed2, @single = id, seed1, seed2, false
      else
        # Initialize needed instance variables.
        @id, @seed1, @single = id, seed1, true
      end
      @ripe, @stage = false, -1
      # Run setup method, using data in Garden config for this plant's seeds
       setup
    end
   
    #--------------------------------------#
    #   - Double and Single Seed Method -  #
    #--------------------------------------#
    #   Similar to old method but adds a   #
    #       check for the single flag      #
    #--------------------------------------#
    def setup
      # Store original graphic, direction, and pattern in variable.
      event = $game_map.events[@id]
      @original_event = [event.character_name, event.direction, event.pattern]
      # Calculate the total duration of the seed combination.
      if @single == true # If single then only the duration of that seed
        @duration = Garden.growth_rate(@seed1)
      else # IF double then duration of both seeds
        @duration = (Garden.growth_rate(@seed1) + Garden.growth_rate(@seed2))
      end
      # Find the produce that this combination will grow into
      if @single == true
        @produce = Garden.produce_single(@seed1)
        # Get a random produce from case Seed1 id
        @produce = @produce[rand(@produce.size)]
      else
        comb = Garden::SEED_IDS.index(@seed1) + Garden::SEED_IDS.index(@seed2)
        @produce = Garden.produce(comb)
        @produce = @produce[rand(@produce.size)]
      end
      # Get the number of stages this plant will use, then setup counts for it
      number, count = Garden.number_stages(@produce), 0
      dur = (@duration / number.to_f).to_i
      @stages = (0...number).to_a
      @stages.collect! {|i| $game_system.garden_counter + (i * dur) }
      # Refresh the plant to apply changes
      refresh
    end
   
    def refresh
      unless @ripe
        # Initialize local variable that will determine if graphic needs redrawn.
        previous = @stage
        count = @stages.find_all {|rate| $game_system.garden_counter <= rate }
        @stage = (@stages.size - count.size)
        @ripe = (@stage >= @stages.size - 1)
        # Redraw bitmap if needed.
        change_graphic(@ripe) if previous != @stage
      end
    end
   
    def change_graphic(final)
      # Set local variable to this plant's event
      event = $game_map.events[@id]
      data = final ? Garden.final_graphic(@produce) :
        Garden.stage_graphics(@stage)
      # Apply graphical change by simply altering event's stance and source
      event.character_name = data[0] # If you get an error on this line it means
      # that the final or stage graphics have not been set up properly or that
      # there is missing data in the config for a certain (pair of) item(s).
      event.direction = (2 * data[2])
      event.pattern = (data[1] - 1)
      event.refresh
    end
   
    def restore_event
      # Restore event to original state before planting.
      event = $game_map.events[@id]
      event.character_name = @original_event[0]
      event.direction = @original_event[1]
      event.pattern = @original_event[2]
    end
   
    def produce
      # Return nil if not yet ripe, else return an item ID.
      return (@ripe ? @produce : nil)
    end
  end
end

#===============================================================================
# ** Game_System
#===============================================================================

class Game_System
 
  attr_accessor :garden, :garden_counter
 
  alias zer0_garden_init initialize
  def initialize
    # Initialize variables used for the garden system.
    @garden_counter = 0
    @garden = {}
    zer0_garden_init
  end
 
  alias zer0_garden_upd update
  def update
    # Increase garden counter and check if update is needed every second.
    if (Graphics.frame_count % 40) == 0
      @garden_counter += 1
      # Check if current map has any plants on it. If so, refresh them.
      if @garden[$game_map.map_id] != nil && !@garden[$game_map.map_id].empty?
        @garden[$game_map.map_id].each {|plant| plant.refresh }
      end
    end
    zer0_garden_upd
  end
end

#===============================================================================
# ** Game_Event
#===============================================================================

class Game_Event
 
  attr_accessor :character_name, :direction, :pattern
 
  alias zer0_garden_event_refresh refresh
  def refresh
    # Normal refresh method.
    zer0_garden_event_refresh
    # Set flag for this event being a garden event.
    @garden_event = (@page != nil && @page.list[0].code == 108 &&
      @page.list[0].parameters[0] == 'Garden Event')
  end
 
  alias zer0_garden_upd update
  def update
    # Skip update method foe this event if it is a plant.
    @garden_event ? return : zer0_garden_upd
  end
 
  alias zer0_garden_event_start start
  def start
    # Redefine the 'start' method if Garden Event flag is present.
    if @garden_event
      plants, harvest = $game_system.garden[$game_map.map_id], false
      # Check if plant exists, and if so check if it is ripe.
      pick = plants != nil ? (plants.find {|obj| obj.id == @id }) != nil : false
      $scene = Scene_Garden.new(@id, pick)
    else
      zer0_garden_event_start
    end
  end
end
 
#===============================================================================
# ** Game_Map
#===============================================================================

class Game_Map
 
  alias zer0_garden_setup setup
  def setup(map_id)
    zer0_garden_setup(map_id)
    # Refresh each plant when map is set up
    if $game_system.garden[@map_id] != nil
      $game_system.garden[@map_id].each {|obj| obj.change_graphic(obj.ripe) }
    end
  end
end

#===============================================================================
# * Window_Seed
#===============================================================================

class Window_Seed < Window_Selectable
 
  def initialize
    super(160, 304, 320, 160)
    self.index = 0
    refresh
  end
 
  def refresh
    # Clear the bitmap.
    self.contents = self.contents.dispose if self.contents != nil
    # Determine what seeds to display.
    @seeds = Garden::SEED_IDS.collect {|id| $data_items[id] }
    unless Garden::SEED_DISPLAY
      @seeds.reject! {|seed| $game_party.item_number(seed.id) < 1 }
    end
    @item_max = @seeds.size
    # Draw the items on the bitmap.
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, @item_max * 32)
      @seeds.each_index {|i|
        item = @seeds[i]
        number = $game_party.item_number(item.id)
        self.contents.font.color = number > 0 ? normal_color : disabled_color
        opacity = number > 0 ? 255 : 128
        # Find icon bitmap and set it to window, and draw the text.
        bitmap = RPG::Cache.icon(item.icon_name)
        self.contents.blt(4, i*32+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
        self.contents.draw_text(32, i*32, 288, 32, item.name)
        self.contents.draw_text(-32, i*32, 288, 32, ':', 2)
        self.contents.draw_text(-4, i*32, 288, 32, number.to_s, 2)
      }
    end
  end
 
  def seed
    # Returns currently highlighted seed item.
    return @seeds[self.index]
  end
end

#===============================================================================
# * Scene_Garden
#===============================================================================

class Scene_Garden
 
  def initialize(id, harvest)
    @event_id, @harvest = id, harvest
    # Play SE to give impression that scene never changed.
    $game_system.se_play($data_system.decision_se)
    $game_player.straighten
    garden = $game_system.garden[$game_map.map_id]
    if garden != nil
      @plant = garden.find {|plant| plant.id == id }
    end
  end
 
  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  def main
    # Create map sprite and required windows.
    @map, @help_window = Spriteset_Map.new, Window_Help.new
    # Create Confirmation window.
    @confirm_window = Window_Command.new(128, ['Yes', 'No'])
    @confirm_window.x, @confirm_window.y = 496, 336
    # Initialize sprites array. Used to handle all the sprites together.
    @sprites = [@map, @help_window, @confirm_window]
    # Create seed window if plant is not being harvested.
    unless @harvest
      @seed_window = Window_Seed.new
      @sprites.push(@seed_window)
      @seed_window.active = @seed_window.visible = false
      # Create Seed Count window
      @seed_count_window = Window_Command.new(192, ['Yes, plant 1 seed', 'Yes, plant 2 seeds', "No"])
      @seed_count_window.x, @seed_count_window.y = 640 - 192 - 16, 480 - 3 * 24 - 96
      @sprites.push(@seed_count_window)
      @confirm_window.visible = @confirm_window.active = false
      @help_window.set_text('Plant seeds here?')
    else
      @data = $game_system.garden[$game_map.map_id][@event_id]
      if @plant != nil && @plant.ripe
        text = 'This plant is ripe. Would you like to harvest it?'
      else
        text = 'Nothing is growing yet on this plant. Harvest it anyway?'
      end
      @help_window.set_text(text)
    end
    # Transition instantly then start main loop.
    Graphics.transition(0)
    loop { Graphics.update; Input.update; update; break if $scene != self }
    # Dispose of all the sprites.
    @sprites.each {|sprite| sprite.dispose }
    # Have map refresh to update any changes made.
    $game_map.need_refresh = true
  end
 
  def update
    @sprites.each {|sprite| sprite.update }
    # Branch update method depending on what window is active.
    if @confirm_window.active
      update_confirm
    elsif @seed_count_window != nil && @seed_count_window.active
      update_seed_count_select
    elsif @seed_window != nil && @seed_window.active
      update_seed_select
    end
  end
 
  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  def update_confirm
    if Input.trigger?(Input::B)
      # Branch by what action is being canceled.
      if @harvest
        back_to_map
      else
        cancel_seed_selection
      end
    elsif Input.trigger?(Input::C)
      # Branch by what action is being confirmed.
      if @harvest
        if @confirm_window.index == 0
          item_id = Garden.harvest(@event_id)
          if item_id != nil
            @confirm_window.active = @confirm_window.visible = false
            # Gain item, play the harvest SE, then return to the map.
            $game_party.gain_item(item_id, 1)
            $game_system.se_play(RPG::AudioFile.new(Garden::HARVEST_SE, 80, 100))
            show_results($data_items[item_id])
            $scene = Scene_Map.new
          else
            back_to_map
          end
        else
          back_to_map
        end
      else
        # If asking if player would like to plant seeds at this location.
        if @seed1 == nil
          back_to_map
          return
        else # If confirming seed selection.
          if @confirm_window.index == 0
            # Plant seeds and return to map.
            @single = @seed_count_window.index == 0
            # This is how Twb6543 reloaded the single command (in case of index
            # movement)
            if @single == true && @seed2 == nil
              # If Single only
              Garden.plant_seeds(@event_id, @seed1.id)
            else
              # If Double or Includes Double Seed
              Garden.plant_seeds(@event_id, @seed1.id, @seed2.id)
            end
            $scene = Scene_Map.new
          else # If canceling seed selection
            cancel_seed_selection
            return
          end
        end
        $game_system.se_play($data_system.decision_se)
      end
    end
  end
 
  def update_seed_count_select
    if Input.trigger?(Input::B)
      back_to_map
    elsif Input.trigger?(Input::C)
      case @seed_count_window.index
      when 0
        @seed_window.active = @seed_window.visible = true
        @seed_count_window.active = @seed_count_window.visible = false
        @help_window.set_text('Which seed would you like to plant?')
      when 1
        @seed_window.active = @seed_window.visible = true
        @seed_count_window.active = @seed_count_window.visible = false
        @help_window.set_text('Which seeds would you like to plant?')
      when 2
        back_to_map
        return
      end
      $game_system.se_play($data_system.decision_se)
    end
  end
 
  def show_results(result)
    @help_window.contents.clear
    # Display the message in the help window.
    @help_window.draw_item_name(result, 0, 0)
    cw = @help_window.contents.text_size(result.name).width + 32
    @help_window.contents.draw_text(cw, 0, 608, 32, ' received!')
    # Call Input.update to the clear key press.
    Input.update
    # Loop until it is pressed again.
    until Input.trigger?(Input::C)
      Graphics.update; Input.update; update
    end
  end
 
  #------------------------------------------#
  #   - Double and Single Seed New Method -  #
  #------------------------------------------#
  def cancel_seed_selection
    # Play cancel SE, reset seeds, and activate/deactivate windows.
    $game_system.se_play($data_system.cancel_se)
    $game_party.gain_item(@seed1.id, 1) unless @seed1.nil? # Added to re add the seeds
    $game_party.gain_item(@seed2.id, 1) unless @seed2.nil? # Added to re add the seeds
    @seed_window.active = @seed_window.visible = true
    @seed_window.refresh
    @confirm_window.active = @confirm_window.visible = false
    @help_window.set_text('Which seeds would you like to plant?')
    @seed1 = @seed2 = nil
  end
 
  def back_to_map
    # Play cancel SE and return to map.
    $game_system.se_play($data_system.cancel_se)
    $scene = Scene_Map.new
  end
 
  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  def update_seed_select
    if Input.trigger?(Input::B)
      # If first seed is selected, go back to re-select, else return to map.
      if @seed1 != nil
        cancel_seed_selection
      else
        back_to_map
      end
    elsif Input.trigger?(Input::C)
      # Play Cancle SE if displayed and party has none.
      if $game_party.item_number(@seed_window.seed.id) < 1
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @single = @seed_count_window.index == 0
      # Can use @idsingle = @seed_window.seed.id
      if @single == true && @seed1 == nil
        # Set first seed then continue
        @seed1 = @seed_window.seed
        $game_party.lose_item(@seed1.id, 1)
        @seed_window.active = false
        @confirm_window.active = @confirm_window.visible = true
      elsif @single == true && @seed1 != nil
        # Set second seed then continue
        @seed2, @seed_window.active = @seed_window.seed, false
        $game_party.lose_item(@seed2.id, 1)
        @confirm_window.active = @confirm_window.visible = true
      else # 2 seeds
        # Set first seed if not defined, else set the second seed and continue.
        if @seed1 == nil
          @seed1 = @seed_window.seed
          $game_party.lose_item(@seed1.id, 1)
        else
          @seed2, @seed_window.active = @seed_window.seed, false
          $game_party.lose_item(@seed2.id, 1)
          @confirm_window.active = @confirm_window.visible = true
        end
      end
      # Refresh seed window to show changes in inventory.
      set_help
      @seed_window.refresh
    end
  end
 
  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  def set_help
    # Clear help window.
    @help_window.contents.clear
    # Draw items
    @single = @seed_count_window.index == 0
    if @single == true && @seed2 == nil
      text = 'Plant this seed?'
    else
      text = @seed2 != nil ? 'Plant these two seeds?' : 'Select second seed...'
    end
    @help_window.set_text(text)
    @help_window.draw_item_name(@seed1, 224, 0)
    if @seed2 != nil
      cw = @help_window.contents.text_size(@seed1.name).width + 320
      @help_window.draw_item_name(@seed2, cw, 0)
    end
  end
end


Original version
Spoiler: ShowHide

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Dynamic Gardening
# Author: ForeverZer0, ThallionDarkshine
# Date: 5.13.2011
# Version: v.3.01
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#                            VERSION HISTORY
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#  v.1.1  (4.15.2010)
#   - Improved coding
#   - No longer uses game variables, events use self-switches instead
#   - Added ability to create different graphics for every plant, without
#     having to use more event pages
#   - Much less tedious setting up multiple events and changing the every
#     condition variable.
#  v.2.0  (10.10.2010)
#   - Total re-write. Code has been vastly improved and is much more efficient.
#   - Event setup has been simplified. Now requires only a single comment, and
#     does not require multiple pages.
#   - Added configurability for the number of stages each item requires.
#   - The timers no longer use Game_System to constantly update, but simply
#     compare themselves with the Graphics.frame_count when the event exists
#     on the current map, which also allows the plants to grow during scenes
#     other than Scene_Map and Scene_Battle.
#   - Got rid of Scene_Harvest. Scene_Garden now handles both aspects, and has
#     been improved.
#   - Added item icons to the help window display.
# v.3.0  (5.13.2011)
#   - Restructured code completely
#   - Increased compatibility and performance
#   - Fixed bug with final graphic not behaving correctly
# v.3.01 (12.19.2017) by ThallionDarkshine
#   - Fixed bug with help window not updating correctly.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
#   This system allows the player to plant seeds, which will eventually grow
#   into plants that can be harvested for items. The system is very similar in
#   nature to that found in Legend of Mana. Seed's can be combined in different
#   ways, which will effect the total growth duration, the number of stages the
#   plant passes through, the graphics used, and of course the final result.
#
# Features:
#
#  - Totally configurable growth rates, results, and graphics for every plant.
#  - Can use arrays of items for each result, so the final item is not
#    neccessarily the same every time.
#  - Each plant timer is independent, and its progress is saved with the game.
#  - Easy setup. Need only a single comment in one of the event's pages.
#
# Instructions:
#   
#  - Place script below Debug and above Main
#  - Configure the options below (instructions are with each setting)
#  - Create an event, setting the graphic to whatever you want. This will be the
#    graphics used when nothing is growing on the plant.
#  - At the very top event's page, place a comment that reads "Garden Event",
#    omitting the quotation marks.
#  - As long as the page's conditions are met, this event can be clicked on to
#    initiate the Garden scene, and can grow plants.
#  - Note that plants can be harvested early, but they will yield nothing until
#    they are ripe.
#
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  BEGIN CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
#===============================================================================
# ** Garden
#===============================================================================

module Garden
 
  SEED_IDS = [1, 2, 3, 4, 5, 6, 7, 8]
  # IDs of the items in the database that are seeds. Add them into the array in
  # the order of value/rarity in your game
 
  HARVEST_SE = '056-Right02'
  # This is the SE that will be played when the player harvests the plant.
 
  SEED_DISPLAY = true
  # If true, all seeds will be displayed in the seed window, including those
  # that the player does not have, though they will be disabled. If false, only
  # seeds that that the player currently has will be displayed.
 
  # Define the growth rates here. (the average of both seeds will be used)
  def self.growth_rate(seed)
    return case seed
    # when SEED_ID then SECONDS
    when 1 then 10
    when 2 then 12
    when 3 then 15
    when 4 then 20
    when 5 then 23
    when 6 then 25
    when 7 then 30
    when 8 then 35
    end
  end
 
#-------------------------------------------------------------------------------
# Define the number of stages that each item uses. The stages will still cycle
# in the same order, but only use up to the defined number of them before going
# to the final graphic. This will not effect the duration that the seed takes to
# grow, only how many times the graphic changes.
#
# You do not have to define anything that uses a three stage configuration.
#-------------------------------------------------------------------------------
  def self.number_stages(result)
    case result
    when 8..16
      return 4
    when 17..24
      return 5
    else
      return 3
    end
  end
 
#-------------------------------------------------------------------------------
# Define the final result of the seeds. A random item from the array will be
# given as the final result.

# Each seed is given a value from 0 to the total number of seeds in the SEED_IDS
# array, and both values are added together to determine which 'produce' array
# will be used for the final result. This is why it is important that you have
# the SEED_IDS array in order of value/rarity. You can find the total number of
# cases you will need by subtracting 1 from the total number of different seeds
# in SEED_IDS, and multiplying that number by 2.
#
#   EX. Player uses one each of the first and last seed in the SEED_IDS array,
#       and there are 8 total seeds in the array...
#
#       FIRST_SEED = 2
#       LAST_SEED = 5         2 + 5 = RESULT
#
# By placing multiple copies of the same value in an array, you can increase
# the odds of receiving that item over another in the same array.
#-------------------------------------------------------------------------------

  def self.produce(seed)
    return case seed
    when 0 then [9, 10]      # Only if both seed are the lowest seeds
    when 1 then [10, 11]
    when 2 then [12, 13]
    when 3 then [13, 14]
    when 4 then [14, 15]
    when 5 then [15, 16]
    when 6 then [16, 17]      # Every combination in between
    when 7 then [17, 18]
    when 8 then [18, 19]
    when 9 then [19, 20]
    when 10 then [20, 21]
    when 11 then [21, 22]
    when 12 then [22, 23]
    when 13 then [23, 24]
    when 14 then [24]         # Only if both seeds are the highest seeds
    end
  end
 
#-------------------------------------------------------------------------------
#  Define graphics for the final results, and each stage. Follow the below
#  template to set it up.
#
#   when ITEM_ID/STAGE then ['FILENAME', X, Y]
#
#   ITEM_ID = The ID number of the item in your database
#   STAGE = The stage during which to display the graphic
#
#   FILENAME = The name of the character file the needed graphic is on
#   X = The x-coordinate of the correct picture on the charset (1 - 4)
#   Y = The y-coordinate of the correct picture on the charset (1 - 4)
#
#           ? X ?             Ex.   If the needed graphic was in the bottom
#         1  2  3  4                left corner:   X = 1    Y = 4
#       +-----------+                   
#     1 ¦  ¦  ¦  ¦  ¦
#       +--+--+--+--¦
#  ?  2 ¦  ¦  ¦  ¦  ¦
#  Y    +--+--+--+--¦
#  ?  3 ¦  ¦  ¦  ¦  ¦
#       +--+--+--+--¦
#     4 ¦  ¦  ¦  ¦  ¦
#       +-----------+
#-------------------------------------------------------------------------------

  def self.stage_graphics(stage)
    return case stage
    when 0 then ['Plants1', 1, 1]
    when 1 then ['Plants1', 2, 3]
    when 2 then ['Plants1', 2, 1]
    when 3 then ['Plants1', 4, 2]
    when 4 then ['Plants1', 2, 4]
    end
  end

  def self.final_graphic(item)
    return case item   
    when 9 then  ['Garden Plants', 1, 1]
    when 10 then ['Garden Plants', 2, 4]
    when 11 then ['Garden Plants', 3, 4]
    when 12 then ['Garden Plants', 4, 4]
    when 13 then ['Garden Plants', 1, 4]
    when 14 then ['Garden Plants', 2, 2]
    when 15 then ['Garden Plants', 3, 2]   
    when 16 then ['Garden Plants', 4, 2]
    when 17 then ['Garden Plants', 1, 2]
    when 18 then ['Garden Plants', 2, 3]
    when 19 then ['Garden Plants', 3, 3]
    when 20 then ['Garden Plants', 4, 3]
    when 21 then ['Garden Plants', 1, 3]
    when 22 then ['Garden Plants', 2, 1]
    when 23 then ['Garden Plants', 3, 1]
    when 24 then ['Garden Plants', 4, 1]
    end
  end
 
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  END CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  def self.plant_seeds(seed1, seed2, event_id)
    # Create a new instance of a Garden::Plant
    plant = self::Plant.new(event_id, seed1, seed2)
    if $game_system.garden[$game_map.map_id] == nil
      $game_system.garden[$game_map.map_id] = [plant]
    else
      $game_system.garden[$game_map.map_id].push(plant)
    end
  end
 
  def self.harvest(id)
    # Find the appropriate plant.
    plant = $game_system.garden[$game_map.map_id].find {|plant| plant.id == id }
    return nil if plant == nil
    # Return the result, and delete plant data from array.
    result = plant.produce
    plant.restore_event
    $game_system.garden[$game_map.map_id] -= [plant]
    return result
  end

#===============================================================================
# ** Garden::Plant
#===============================================================================

  class Plant
   
    attr_reader :id, :ripe
   
    def initialize(id, seed1, seed2)
      # Initialize needed instance variables.
      @id, @seed1, @seed2 = id, seed1, seed2
      @ripe, @stage = false, -1
      # Run setup method, using data in Garden config for this plant's seeds
      setup
    end
   
    def setup
      # Store original graphic, direction, and pattern in variable.
      event = $game_map.events[@id]
      @original_event = [event.character_name, event.direction, event.pattern]
      # Calculate the total duration of the seed combination.
      @duration = (Garden.growth_rate(@seed1) + Garden.growth_rate(@seed2))
      # Find the produce that this combination will grow into
      comb = Garden::SEED_IDS.index(@seed1) + Garden::SEED_IDS.index(@seed2)
      @produce = Garden.produce(comb)
      @produce = @produce[rand(@produce.size)]
      # Get the number of stages this plant will use, then setup counts for it
      number, count = Garden.number_stages(@produce), 0
      dur = (@duration / number.to_f).to_i
      @stages = (0...number).to_a
      @stages.collect! {|i| $game_system.garden_counter + (i * dur) }
      # Refresh the plant to apply changes
      refresh
    end
   
    def refresh
      unless @ripe
        # Initialize local variable that will determine if graphic needs redrawn.
        previous = @stage
        count = @stages.find_all {|rate| $game_system.garden_counter <= rate }
        @stage = (@stages.size - count.size)
        @ripe = (@stage >= @stages.size - 1)
        # Redraw bitmap if needed.
        change_graphic(@ripe) if previous != @stage
      end
    end
   
    def change_graphic(final)
      # Set local variable to this plant's event
      event = $game_map.events[@id]
      data = final ? Garden.final_graphic(@produce) :
        Garden.stage_graphics(@stage)
      # Apply graphical change by simply altering event's stance and source
      event.character_name = data[0]
      event.direction = (2 * data[2])
      event.pattern = (data[1] - 1)
      event.refresh
    end
   
    def restore_event
      # Restore event to original state before planting.
      event = $game_map.events[@id]
      event.character_name = @original_event[0]
      event.direction = @original_event[1]
      event.pattern = @original_event[2]
    end
   
    def produce
      # Return nil if not yet ripe, else return an item ID.
      return (@ripe ? @produce : nil)
    end
  end
end

#===============================================================================
# ** Game_System
#===============================================================================

class Game_System
 
  attr_accessor :garden, :garden_counter
 
  alias zer0_garden_init initialize
  def initialize
    # Initialize variables used for the garden system.
    @garden_counter = 0
    @garden = {}
    zer0_garden_init
  end
 
  alias zer0_garden_upd update
  def update
    # Increase garden counter and check if update is needed every second.
    if (Graphics.frame_count % 40) == 0
      @garden_counter += 1
      # Check if current map has any plants on it. If so, refresh them.
      if @garden[$game_map.map_id] != nil && !@garden[$game_map.map_id].empty?
        @garden[$game_map.map_id].each {|plant| plant.refresh }
      end
    end
    zer0_garden_upd
  end
end

#===============================================================================
# ** Game_Event
#===============================================================================

class Game_Event
 
  attr_accessor :character_name, :direction, :pattern
 
  alias zer0_garden_event_refresh refresh
  def refresh
    # Normal refresh method.
    zer0_garden_event_refresh
    # Set flag for this event being a garden event.
    @garden_event = (@page != nil && @page.list[0].code == 108 &&
      @page.list[0].parameters[0] == 'Garden Event')
  end
 
  alias zer0_garden_upd update
  def update
    # Skip update method foe this event if it is a plant.
    @garden_event ? return : zer0_garden_upd
  end
 
  alias zer0_garden_event_start start
  def start
    # Redefine the 'start' method if Garden Event flag is present.
    if @garden_event
      plants, harvest = $game_system.garden[$game_map.map_id], false
      # Check if plant exists, and if so check if it is ripe.
      pick = plants != nil ? (plants.find {|obj| obj.id == @id }) != nil : false
      $scene = Scene_Garden.new(@id, pick)
    else
      zer0_garden_event_start
    end
  end
end
 
#===============================================================================
# ** Game_Map
#===============================================================================

class Game_Map
 
  alias zer0_garden_setup setup
  def setup(map_id)
    zer0_garden_setup(map_id)
    # Refresh each plant when map is set up
    if $game_system.garden[@map_id] != nil
      $game_system.garden[@map_id].each {|obj| obj.change_graphic(obj.ripe) }
    end
  end
end

#===============================================================================
# * Window_Seed
#===============================================================================

class Window_Seed < Window_Selectable
 
  def initialize
    super(160, 304, 320, 160)
    self.index = 0
    refresh
  end
 
  def refresh
    # Clear the bitmap.
    self.contents = self.contents.dispose if self.contents != nil
    # Determine what seeds to display.
    @seeds = Garden::SEED_IDS.collect {|id| $data_items[id] }
    unless Garden::SEED_DISPLAY
      @seeds.reject! {|seed| $game_party.item_number(seed.id) < 1 }
    end
    @item_max = @seeds.size
    # Draw the items on the bitmap.
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, @item_max * 32)
      @seeds.each_index {|i|
        item = @seeds[i]
        number = $game_party.item_number(item.id)
        self.contents.font.color = number > 0 ? normal_color : disabled_color
        opacity = number > 0 ? 255 : 128
        # Find icon bitmap and set it to window, and draw the text.
        bitmap = RPG::Cache.icon(item.icon_name)
        self.contents.blt(4, i*32+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
        self.contents.draw_text(32, i*32, 288, 32, item.name)
        self.contents.draw_text(-32, i*32, 288, 32, ':', 2)
        self.contents.draw_text(-4, i*32, 288, 32, number.to_s, 2)
      }
    end
  end
 
  def seed
    # Returns currently highlighted seed item.
    return @seeds[self.index]
  end
end

#===============================================================================
# * Scene_Garden
#===============================================================================

class Scene_Garden
 
  def initialize(id, harvest)
    @event_id, @harvest = id, harvest
    # Play SE to give impression that scene never changed.
    $game_system.se_play($data_system.decision_se)
    $game_player.straighten
    garden = $game_system.garden[$game_map.map_id]
    if garden != nil
      @plant = garden.find {|plant| plant.id == id }
    end
  end
 
  def main
    # Create map sprite and required windows.
    @map, @help_window = Spriteset_Map.new, Window_Help.new
    # Create Confirmation window.
    @confirm_window = Window_Command.new(128, ['Yes', 'No'])
    @confirm_window.x, @confirm_window.y = 496, 336
    # Initialize sprites array. Used to handle all the sprites together.
    @sprites = [@map, @help_window, @confirm_window]
    # Create seed window if plant is not being harvested.
    unless @harvest
      @seed_window = Window_Seed.new
      @sprites.push(@seed_window)
      @seed_window.active = @seed_window.visible = false
      @help_window.set_text('Plant seeds here?')
    else
      @data = $game_system.garden[$game_map.map_id][@event_id]
      if @plant != nil && @plant.ripe
        text = 'This plant is ripe. Would you like to harvest it?'
      else
        text = 'Nothing is growing yet on this plant. Harvest it anyway?'
      end
      @help_window.set_text(text)
    end
    # Transition instantly then start main loop.
    Graphics.transition(0)
    loop { Graphics.update; Input.update; update; break if $scene != self }
    # Dispose of all the sprites.
    @sprites.each {|sprite| sprite.dispose }
    # Have map refresh to update any changes made.
    $game_map.need_refresh = true
  end
 
  def update
    @sprites.each {|sprite| sprite.update }
    # Branch update method depending on what window is active.
    if @confirm_window.active
      update_confirm
    elsif @seed_window != nil && @seed_window.active
      update_seed_select
    end
  end
 
  def update_confirm
    if Input.trigger?(Input::B)
      # Branch by what action is being canceled.
      if @harvest
        back_to_map
      else
        @seed1 == nil ? back_to_map : cancel_seed_selection
      end
    elsif Input.trigger?(Input::C)
      # Branch by what action is being confirmed.
      if @harvest
        if @confirm_window.index == 0
          item_id = Garden.harvest(@event_id)
          if item_id != nil
            @confirm_window.active = @confirm_window.visible = false
            # Gain item, play the harvest SE, then return to the map.
            $game_party.gain_item(item_id, 1)
            $game_system.se_play(RPG::AudioFile.new(Garden::HARVEST_SE, 80, 100))
            show_results($data_items[item_id])
            $scene = Scene_Map.new
          else
            back_to_map
          end
        else
          back_to_map
        end
      else
        # If asking if player would like to plant seeds at this location.
        if @seed1 == nil
          if @confirm_window.index == 0
            @seed_window.active = @seed_window.visible = true
            @confirm_window.active = @confirm_window.visible = false
            @help_window.set_text('Which seeds would you like to plant?')
          else
            back_to_map
            return
          end
        else # If confirming seed selection.
          if @confirm_window.index == 0
            # Plant seeds and return to map.
            Garden.plant_seeds(@seed1.id, @seed2.id, @event_id)
            $scene = Scene_Map.new
          else # If canceling seed selection
            cancel_seed_selection
            return
          end
        end
        $game_system.se_play($data_system.decision_se)
      end
    end
  end
 
  def show_results(result)
    @help_window.contents.clear
    # Display the message in the help window.
    @help_window.draw_item_name(result, 0, 0)
    cw = @help_window.contents.text_size(result.name).width + 32
    @help_window.contents.draw_text(cw, 0, 608, 32, ' received!')
    # Call Input.update to the clear key press.
    Input.update
    # Loop until it is pressed again.
    until Input.trigger?(Input::C)
      Graphics.update; Input.update; update
    end
  end
 
  def cancel_seed_selection
    # Play cancel SE, reset seeds, and activate/deactivate windows.
    $game_system.se_play($data_system.cancel_se)
    $game_party.gain_item(@seed1.id, 1) unless @seed1.nil? # Added to re add the seeds
    $game_party.gain_item(@seed2.id, 1) unless @seed2.nil? # Added to re add the seeds
    @seed_window.active = @seed_window.visible = true
    @seed_window.refresh
    @confirm_window.active = @confirm_window.visible = false
    @help_window.set_text('Which seeds would you like to plant?')
    @seed1 = @seed2 = nil
  end
 
  def back_to_map
    # Play cancel SE and return to map.
    $game_system.se_play($data_system.cancel_se)
    $scene = Scene_Map.new
  end
 
  def update_seed_select
    if Input.trigger?(Input::B)
      # If first seed is selected, go back to re-select, else return to map.
      if @seed1 != nil
        cancel_seed_selection
      else
        back_to_map
      end
    elsif Input.trigger?(Input::C)
      # Play Cancle SE if displayed and party has none.
      if $game_party.item_number(@seed_window.seed.id) < 1
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      # Set first seed if not defined, else set the second seed and continue.
      if @seed1 == nil
        @seed1 = @seed_window.seed
        $game_party.lose_item(@seed1.id, 1)
      else
        @seed2, @seed_window.active = @seed_window.seed, false
        $game_party.lose_item(@seed2.id, 1)
        @confirm_window.active = @confirm_window.visible = true
      end
      # Refresh seed window to show changes in inventory.
      set_help
      @seed_window.refresh
    end
  end
 
  def set_help
    # Clear help window.
    @help_window.contents.clear
    # Draw items
    text = @seed2 != nil ? 'Plant these two seeds?' : 'Select second seed...'
    @help_window.set_text(text)
    @help_window.draw_item_name(@seed1, 224, 0)
    if @seed2 != nil
      cw = @help_window.contents.text_size(@seed1.name).width + 320
      @help_window.draw_item_name(@seed2, cw, 0)
    end
  end
end




Instructions


  • Place script below default scripts, and above "Main".

  • Fill out the configuration in the script (instructions within)

  • Simple create a blank event with a comment on its first page that reads "Garden Event", and your done!





Compatibility

No known compatibility issues.



Credits and Thanks

  • ForeverZer0, for writing the script.
  • Twb6543, for the single-seed variation to the script
  • ThallionDarkshine, for updating to v3.01




Author's Notes

Some graphics for the seeds can be found in the demo. I ripped them from Legend of Mana.
If you have any problems or find any bugs, be sure to let me know so I can fix them.
Be sure to give proper credit. Hope you enjoy!
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

Can you please make sure that you type the title as "[XP] Dynamic Gardening" and not "[XP]Dynamic Gardening" in future? I think I noticed that on one of your other topics as well (which I fixed as well). The automated index might not recognize your topic properly and not display it in the index if you don't separate the [XP] tag with a space from the topic title.

Other than that... *levels up* *moves to database* Nice work. Can this also be used for a Harvest Moon game?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Nadim13

Great work! It works with no problem!

I've tried also to save and load everything and it has no bug! A simple/cool script! ;)

Jragyn

Wahh!

Its about time someone created something of this epic simplistic proportion!
Legend of Mana was a spectacular game.

...

Can I expect its crafting system to be replicated as well? :D


--JeR
A bright light can either illuminate or blind, but how will you know which until you open your eyes?

ShinyToyGuns

Quote from: jragyn00 on April 15, 2010, 06:34:50 am
Its about time someone created something of this epic simplistic proportion!
Legend of Mana was a spectacular game.

...

Can I expect its crafting system to be replicated as well? :D


:D Level ++ for Foreverzero
Days
I've missed so many days
In a world that has become an unfamiliar place
Now to you, I'm just an unfamiliar face

~Shiny Toy Guns, Blown Away (2008)

legacyblade

Quote from: Blizzard on April 15, 2010, 02:49:25 am
Other than that... *levels up* *moves to database* Nice work. Can this also be used for a Harvest Moon game?


From what I see, this is designed to work with traditional RPGs. While it WOULD be possible to make a harvest moon, it wouldn't feel like a traditional harvest moon game. It'd need to be customized quite a bit (from what I saw in the demo at least) to make a harvest moon game. It'd be interesting to see someone try it though.

Agckuu Coceg

April 20, 2010, 01:32:43 am #6 Last Edit: April 20, 2010, 01:35:17 am by Agckuu Coceg
That's cool. Really cool. Level + + +

It can tries to modify the system for example, to create a Chao Garden in the fan-games for SA.  ;)
I'm not retarded, but I'm busy. Sorry for patience.


ForeverZer0

* updates to 1.1 *

- Uses self-switches instead of variables
- Automatic graphics for different plant results
- Code improvement
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Agckuu Coceg

Quote from: ForeverZero on April 21, 2010, 04:54:07 pm
* updates to 1.1 *

- Uses self-switches instead of variables
- Automatic graphics for different plant results
- Code improvement


Wo-o-o-a-hhh... Do not have time to unsubscribe on the past, as has a new version... Class... Level up...
I'm not retarded, but I'm busy. Sorry for patience.


Nadim13

A perfect work that become even more perfect! Level ++! ;)

edwardthefma

can you make a addon to your script that can remember what is planted and its current growth rate as
rmx-os saves the game i think this would be cool to have  so wen you log out you dont loose your plants
wen you log out so you can have plants that can take hours or days of game play to grow  maby a watering
system so if you water your plants thay will grow faster
i am the lead dev for the shellium mmorpg project
http://wiki.shellium.org/w/Mmorpg
shellium.org :) free linux shells pm me and i will gladly
help you get 1

ForeverZer0

Quote from: edwardthefma on May 13, 2010, 05:54:21 pm
can you make a addon to your script that can remember what is planted and its current growth rate as
rmx-os saves the game i think this would be cool to have  so wen you log out you dont loose your plants
wen you log out so you can have plants that can take hours or days of game play to grow  maby a watering
system so if you water your plants thay will grow faster


Honestly, I've never messed with RMX-OS, but I'll be sure to include that when I get a better understanding of it.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Xel

Your script has a bug. If you turn a tile of the tileset into an event, the graphic of the event won't appear.

ForeverZer0

Quote from: Xel on June 16, 2010, 12:33:29 am
Your script has a bug. If you turn a tile of the tileset into an event, the graphic of the event won't appear.


It was graphic change works by the normal 4x4 char set. I never tested it with the tileset graphics. Just make a char set using the graphic from the tileset that you want to use. That will work.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

XaineC

I get an error when i initiate the script. It says, NoMethodError occurred while running script. undefined method `Scene_Gardening' for # <Interpreter:0x3e61570>

Memor-X

Quote from: legacyblade on April 16, 2010, 03:24:35 am
Quote from: Blizzard on April 15, 2010, 02:49:25 am
Other than that... *levels up* *moves to database* Nice work. Can this also be used for a Harvest Moon game?


From what I see, this is designed to work with traditional RPGs. While it WOULD be possible to make a harvest moon, it wouldn't feel like a traditional harvest moon game. It'd need to be customized quite a bit (from what I saw in the demo at least) to make a harvest moon game. It'd be interesting to see someone try it though.


depends on what level of harvest Moon you want, i reckon you could get away with Harvest Moon 64 with this but you'll need a script for the shipment box, i think someones made a storage box script somehow here, just get that and mod it a bit to scan all the times in the box and remove them, but of variable manipulation and you got the daily shipments, marriage is easy, i have a prototype of a dating system which i have has yet to but into a game, was thinking about making a Harvest Moon game myself to use that system in, ofcause like you said, you'll need to customize it quite a bit if you want it to the level of Harvest Moon DS but that made that game good was the fact you could build on your farm using different materials (giving a actual use for rocks), i remember on Creation Asylum that there was a test bed made by someone (wasn't Seph, it was Near.....something), anyway, one of the scripts in the test bed was being able to place furniture in a house, bit of modding and you might be able to get the building system from DS in RPG Maker XP

ForeverZer0

Quote from: XaineC on November 05, 2010, 05:02:03 pm
I get an error when i initiate the script. It says, NoMethodError occurred while running script. undefined method `Scene_Gardening' for # <Interpreter:0x3e61570>


Unlike the original version, where you have to call the scene, version 2.0 only requires you to place a comment in the event page that will define it as a garden event. You should never have to explicitly call the scene. And by the way the script call would be:
$scene = Scene_Garden.new

...but it also needs called with arguments from the Game_Event class that you won't know without knowing the script itself.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

XaineC

QuoteUnlike the original version, where you have to call the scene, version 2.0 only requires you to place a comment in the event page that will define it as a garden event. You should never have to explicitly call the scene. And by the way the script call would be:
$scene = Scene_Garden.new
...but it also needs called with arguments from the Game_Event class that you won't know without knowing the script itself.

Then should i use
$scene = Scene_Garden(*THIS_EVENTS_ID*)
as is in the script or just
$scene = Scene_Garden.new

ForeverZer0

You don't use a script call at all.
Just follow the instructions in the script. Make an event, put a comment in the event's page, and you are done.
All the scene calling and processing is taken care of from there.
I repeat, DO NOT USE A SCRIPT CALL.

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

XaineC

But, your instructions call for script calling. Look:
Quote#- Place script below Debug and above Main
#   - To setup an event you need 5 total pages. The first page should have no
#     condition requirements, and each following page needs to have the condition
#     being self-switch = A, B, C, and D in order.
#   - Have all event page's triggers set to 'Action Button'
#   - On the first page, only have this script call:
#
#                $scene = Scene_Garden(*THIS_EVENTS_ID*)
#
#   - Every other page should have this script call:
#
#                $scene = Scene_Harvest(*THIS_EVENTS_ID*)
#
#   - Pages 2-4 should have their character graphic set to increasing stages
#     of plant growth.
#   - For the graphic changer to work, you have to have a comment at the top
#     of page 5 that simply reads 'Final Stage'. (without quotes)
#   - Once you get this made, you can copy and paste this event for as many
#     seperate events as you need. You only have to change the event ID used
#     in the script calls.
#   - Plants can be harvested early, but they will yield nothing until they are
#     ripe.
#   - If you don not want the Garden scene to initiate right after you harvest
#     something every time, use this for the script call in the first page:
#
#                   if !$game_temp.message_window_showing
#                   $scene = Scene_Garden(*THIS_EVENTS_ID*)
#                   end

XaineC

Please disregard my posts. It seems I've been using the wrong version. Sorry!

ForeverZer0

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Mimi Chan

Why do you always make such awsum scripts O.O
This will definitely be in my game *.* (your weather thingy too ^^)

Would be cool though if you can water the plants or apply fertilizer (reduces growth time)
And is weather affected (rain will make it grow fast, though a storm might lower the produce, some plants grow faster on certain season, etc)
Different soil types o.O (for games that has a variety of environment, like a desert soil will be different from forest soil and certain seeds prefer certain stuffs)
I dunno if plants do cycle themselves (if left fully grown, will return to seed state, either random of the two seeds, or their combination)

And finally...a plant catalog O.O (to see the list of your grown plants *.*)

Might be too much though ^^;
Enough to make a Harvest Moon game I guess o.oa

What's a sig?

ForeverZer0

Those are some good ideas.

I especially like the idea of having weather, fertilizer, etc. affecting plant growth.
I am a little busy with my first CBS at the moment since I have taken it off hold, but I will definitely create an add-on once it is about done, or I may even squeeze it in if I feel the need for a little break from the CBS.

Thanks for the suggestions.  ;)
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Mimi Chan

November 12, 2010, 01:08:10 am #24 Last Edit: November 12, 2010, 02:38:08 am by Blizzard
Too bad idea is all I have @.@
I wish I could script too then I would make tons of unique script *.*

Anyway, I always like the idea of different scripts working together so they are seen as a big system, not isolated once that is just put there for the sake of it o.O

Also would be cool if map ID can be also used to affect growth/yield rate depending on the plant.  Like for example in densely tree'd forrest plants will go a tad slower (low sunlight condition) and will yield less (wild animals eating it) unless you put a scarecrow or other animal scaring stuffs o.O

And an open mountain area will make a seed grow faster because it has more sunlight o.O (though more devastating lost if hit by a storm)

Then different seeds will have different needs too *.* (Some like more water/light, while others don't)
While it may be too demanding to grow seeds, you can always just plant and leave them (but yeah, growth time and yield) Plus maybe if you grow the plant well, some might give you a rare different seed instead O.O

A berry catalog should prolly look like this (sorry for the quality, 5 mins mock up ^^;)
Spoiler: ShowHide
What's a sig?

Taiine

How about making the watering and such optional so those that want the more simple version of planting and letting it grow can have that. Also, what about needing just one seed to plant something?

Does this continue tom let thing's grow if you leave the map or must you stay on it?
I was thinking you could tie it to the games play time, so when you leave the map, and come back, it'll update the events with the correct growth to that of how much time has passed and have plants of various growth times.

Mimi Chan

Yeah everything is optional, but if you want to have the most yield with shortest time and probably a chance for a rare seed then you have to take care of them well *.*

You either just plant randomly and get a little, or you plan your planting and get a lot O.O
And I am pretty sure they grow even if you are out of the map, at least if Zero was the scripter ^^;
What's a sig?

ForeverZer0

Yeah, when I get around to to this idea, it will all be optional. It will likely be an add-on to this script, instead of a newer version, depends on what I come up with. I usually do try to keep features in newer versions optional, so that the script can still be used just as before if the user doesn't want all the extra features. This script's version 2.0 was one exception with how en event is set up, but it is only a one time deal, but it was an easy fix and the script itself is much more efficient because of it.

@taiine
To answer your questions, yes the plants continue to grow when the player is not on the map, and they are based off the game time, which was one of the changes made in 2.0. It is actually based off the Graphics frame count, but the game time is based off of that, so its all the same really.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Taiine

Well then... wonder how well this may work in my game.. or if not that then this smaller game project I've been tinkering with... hmmmmmmmmmm...

Should drop this in my test game of OMGTHATSALOTOFSCRIPS to test for conflicts  :P

Cavegiraffe


ForeverZer0

Quote from: Cavegiraffe on January 29, 2011, 02:52:47 pm
I found pedobear


Congratualations!  :D
I know WhiteRose found it, but I do believe you are the first to unwittingly stumble upon it (as far as I know).
I had completely forgot I had even put that in there until just recently. Isn't nice to know that pedobear is always watching?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

radioacitve12

Hi. I cant configurate your awesome script, the Dynamic Gardening. I dont want to produce 16 products, only 1. This one is generated by every seed combinaton.
When i practice this script, this line have an error message: @character_name = graphic[0].
Thanks your help, yours sincelery

Xtar

You are probably making some mistake when adding stages or final graphics, it happened to me too once because of an error.

The system works almost perfectly, I just have one issue: sometimes the final graphics "move". There's a neverending looping between stage 0 and the last one. I kept the standard format of the script, I just changed IDs.

ForeverZer0

@radioactive12:
I am unsure exactly what is causing that error, but it most definitely sounds like a configuration error. Make sure that the graphic file is in the appropriate place, and named correctly in the script.

@Everone:
Xtar is right, there is a bug with the "final graphics". They will not "stick" and display the wrong graphic. Will update very soon when I get the time to fix it. Sorry for the inconvenience.  :shy:
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

ForeverZer0

May 12, 2011, 07:22:27 pm #34 Last Edit: May 13, 2011, 07:36:46 pm by Baraka
* Begins the rewrite  *

I have some ideas for vastly improving how the script is structured and how data is handled.
It will also remove the current bug of the final graphic not changing correctly.

EDIT:
The script is done, and working flawlessly with the new system. I'll post once I do some more extensive debugging and commenting.
It works completely different, but I managed to keep it so that you won't have to change a single line of your config for the new system, everything from the current version works in this one.

Compatibility has been improved, and the bug with the final graphic is a thing of the past.

EDIT 2:
Updated the script and the main topic.
Script has been improved and bug has been removed.
Screenshots have been added as well.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Taiine

Sorry for bumping. But I am having a issue and not sure if it's just me not understanding it right or if I'm doing things the wrong way.

I would like to only use one seed per plant rather then mixing two seeds and getting a random plant back based on the added values of the two seeds used. But I'm not really seeing away to do that with this script.


I am also getting this error when I tried adding in my own seed to your demo.

Pretty much made a new seed on the 25th item slot, and a new item to be grown in the 26th.

Went though everywhere, adding 25 as a seed, added it's growth rate,  didn't mess with the stages, added the produce matching the pattern, just adding 26 to it. Then added the when 26 use such and such sprite for final. Boom error.

Spoiler: ShowHide
SEED_IDS = [1, 2, 3, 4, 5, 6, 7, 8, 25]
 # IDs of the items in the database that are seeds. Add them into the array in
 # the order of value/rarity in your game
 
 HARVEST_SE = '056-Right02'
 # This is the SE that will be played when the player harvests the plant.
 
 SEED_DISPLAY = true
 # If true, all seeds will be displayed in the seed window, including those
 # that the player does not have, though they will be disabled. If false, only
 # seeds that that the player currently has will be displayed.
 
 # Define the growth rates here. (the average of both seeds will be used)
 def self.growth_rate(seed)
   return case seed
   # when SEED_ID then SECONDS
   when 1 then 10
   when 2 then 12
   when 3 then 15
   when 4 then 20
   when 5 then 23
   when 6 then 25
   when 7 then 30
   when 8 then 35
   when 25 then 50
   end
 end
 
#-------------------------------------------------------------------------------
# Define the number of stages that each item uses. The stages will still cycle
# in the same order, but only use up to the defined number of them before going
# to the final graphic. This will not effect the duration that the seed takes to
# grow, only how many times the graphic changes.
#
# You do not have to define anything that uses a three stage configuration.
#-------------------------------------------------------------------------------
 def self.number_stages(result)
   case result
   when 8..16
     return 4
   when 17..24
     return 5
   else
     return 3
   end
 end
 
#-------------------------------------------------------------------------------
# Define the final result of the seeds. A random item from the array will be
# given as the final result.
#  
# Each seed is given a value from 0 to the total number of seeds in the SEED_IDS
# array, and both values are added together to determine which 'produce' array
# will be used for the final result. This is why it is important that you have
# the SEED_IDS array in order of value/rarity. You can find the total number of
# cases you will need by subtracting 1 from the total number of different seeds
# in SEED_IDS, and multiplying that number by 2.
#
#   EX. Player uses one each of the first and last seed in the SEED_IDS array,
#       and there are 8 total seeds in the array...
#
#       FIRST_SEED = 2
#       LAST_SEED = 5         2 + 5 = RESULT
#
# By placing multiple copies of the same value in an array, you can increase
# the odds of receiving that item over another in the same array.
#-------------------------------------------------------------------------------

 def self.produce(seed)
   return case seed
   when 0 then [9, 10]      # Only if both seed are the lowest seeds
   when 1 then [10, 11]
   when 2 then [12, 13]
   when 3 then [13, 14]
   when 4 then [14, 15]
   when 5 then [15, 16]
   when 6 then [16, 17]      # Every combination in between
   when 7 then [17, 18]
   when 8 then [18, 19]
   when 9 then [19, 20]
   when 10 then [20, 21]
   when 11 then [21, 22]
   when 12 then [22, 23]
   when 13 then [23, 24]
   when 14 then [24, 26]         # Only if both seeds are the highest seeds
   when 15 then [26]        
   end
 end
 
#-------------------------------------------------------------------------------
#  Define graphics for the final results, and each stage. Follow the below
#  template to set it up.
#
#   when ITEM_ID/STAGE then ['FILENAME', X, Y]
#
#   ITEM_ID = The ID number of the item in your database
#   STAGE = The stage during which to display the graphic
#
#   FILENAME = The name of the character file the needed graphic is on
#   X = The x-coordinate of the correct picture on the charset (1 - 4)
#   Y = The y-coordinate of the correct picture on the charset (1 - 4)
#
#           ← X →             Ex.   If the needed graphic was in the bottom
#         1  2  3  4                left corner:   X = 1    Y = 4
#       ┌──┬──┬──┬──┐                    
#     1 │  │  │  │  │
#       ├──┼──┼──┼──┤
#  ↑  2 │  │  │  │  │
#  Y    ├──┼──┼──┼──┤
#  ↓  3 │  │  │  │  │
#       ├──┼──┼──┼──┤
#     4 │  │  │  │  │
#       └──┴──┴──┴──┘
#-------------------------------------------------------------------------------

 def self.stage_graphics(stage)
   return case stage
   when 0 then ['Plants1', 1, 1]
   when 1 then ['Plants1', 2, 3]
   when 2 then ['Plants1', 2, 1]
   when 3 then ['Plants1', 4, 2]
   when 4 then ['Plants1', 2, 4]
   end
 end

 def self.final_graphic(item)
   return case item  
   when 9 then  ['Garden Plants', 1, 1]
   when 10 then ['Garden Plants', 2, 4]
   when 11 then ['Garden Plants', 3, 4]
   when 12 then ['Garden Plants', 4, 4]
   when 13 then ['Garden Plants', 1, 4]
   when 14 then ['Garden Plants', 2, 2]
   when 15 then ['Garden Plants', 3, 2]  
   when 16 then ['Garden Plants', 4, 2]
   when 17 then ['Garden Plants', 1, 2]
   when 18 then ['Garden Plants', 2, 3]
   when 19 then ['Garden Plants', 3, 3]
   when 20 then ['Garden Plants', 4, 3]
   when 21 then ['Garden Plants', 1, 3]
   when 22 then ['Garden Plants', 2, 1]
   when 23 then ['Garden Plants', 3, 1]
   when 24 then ['Garden Plants', 4, 1]
     
     when 26 then ['Garden Plants', 4, 2]
   end
 end


Can you point out what I did wrong in the config? Everything works until I put two of the new seed together. I can mix the new one with others and no error, I just can't mix it with it's self.


I'd still like to only use one seed for each plant. But experimenting it just threw more errors attempting such.

ForeverZer0

The result of the combo is nil. Just missing the configuration in the "self.produce(seed)" method.
Your new seeds index is 8. If you combine two of them, the result is 16. You do not have a configuration for that combination. Try adding that and things will work fine.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Taiine

Alright thanks. Where did it read the new index as 8? I think that's the only part I am not understanding where it gets the values for such.

Also what about using just one seed for each plant?

ForeverZer0

The seeds array. The index (starting at 0) where the ID for that seed is in the array is the value. Since your seed is the 9th seed in the SEEDS array, it has an index of 8.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Taiine

Ah okay I get it now.


Still no answer on being able to use just one seed for plants. Is there anyway to do such? This system would work very nice for my game to have bonus plants you can grow to give you healing herbs or foods (and the only such plant system that still grows even if you leave the map). But would prefer use one seed per plant rather then two and receiving an item based on the id value of the two.


ForeverZer0

The two seed way of working is implemented into the script.  It would not be terribly difficult to edit to allow for only one seed, but more than I'll be doing at the very moment.  If anyone else would like to volunteer to make the required edits, I'd be more than happy to post it up and give credit.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Twb6543

July 14, 2011, 03:17:52 am #41 Last Edit: July 14, 2011, 01:46:46 pm by Twb6543
I'll have a go at it tonight, Would you like me to post the script or pm you with it for you to add.

- Script Edit 80% -
TODO:
Key: item(Percentage of script)
- General Clean up (Makes up 5%)-
- Change the Seeds Array Used (Makes up 3%)-
- Windows Edit (Makes up 12%)-



-Script Edit 95%-
TODO:
- Clean up(5%) -
o Pm ForeverZer0 the new Script
o Write up the documentation(change logs, etc)
If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.
The rest of them will write Perl programs.

Taiine

Thanks for taking it on :3 I'm trying to gather and make sure all the scrips I have are up to date and working as due to being laid off, have to cut back on some of the bills and sadly the net is one of them. So after the 30th I may be gone for a few months until I find another job. But I hope to still work on my game and by the time I come back have a good sized demo for people to test place. :3

Twb6543

Finished the Script for now, It's been pm'd to ForeverZer0. Just need to check he's ok with it (as it tries to replicate the script style) and whether he wants to post it himself... Also currently you can not use a seed as a double and single plant, but I am going to fix it.
If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.
The rest of them will write Perl programs.

ForeverZer0

Quote from: Twb6543 on July 15, 2011, 11:00:04 am
Finished the Script for now, It's been pm'd to ForeverZer0. Just need to check he's ok with it (as it tries to replicate the script style) and whether he wants to post it himself... Also currently you can not use a seed as a double and single plant, but I am going to fix it.


I'll update the topic when I get from from work in a few hours.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

ForeverZer0

Single seed variation to the script has been added to the main post.
All credit goes to Twb6543 for the edits. 

@Twb6543:
Thanks again!   ;)
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Twb6543

July 16, 2011, 06:44:47 am #46 Last Edit: July 17, 2011, 09:53:44 am by Twb6543
It's fine, I'm currently trying to change it so that seeds can be used singly or in a pair. Current process on that is about 10%, sorry for making another update for the script but some people may like the option to use a seed either way and also I found a few faults in the system.

Current Bugs in Single Seed Variation of ForeverZer0's Dynamic Gardening
- Nil graphics error may occur if you choose a Double seed then a Single seed
 - Reason, Forgot to change what seeds are shown after choosing a seed... Fix will be with the new version
- Seeds do not return if you choose not to plant them (This is from ForeverZer0's version)
 - Mostly Fixed (once got a duplication bug but mainly it's fine) - Fix is in next version
- Refresh issue (item numbers do not refresh) (This is from ForeverZer0's version and also my edits to the script)
 - Fix is in next version
- And Others


Script Status: Not Finished // 90% One annoying bug to squash and code cleanup left to do.
BUG left is the seeds still not updating... (pick double/s-d seed single seeds still stay the same (s-d means a single/double seed) )...


Script Status: Finished // 100%
- Code still needs quite a bit of cleanup


Bug fixed due to me stupidly using .concat() instead of + whilst making the seed list. :facepalm:
If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.
The rest of them will write Perl programs.

Twb6543

- Twb6543's Single Variation of Dynamic Gardening by ForeverZer0 is now Version 3.2 -

- Main post has been updated -


ChangeLog :
- Changed Scene_Garden to ask if the player wants to plant only one seed if the the first seed selected is a   
   Single seed Id...
- Single Seeds can now also be Double Seeds (and vice versa)

BugFixes:
- Fixed the Graphics not updating issue...
- Fixed the Seeds not being given back to the player if cancelling a seed option...
- Fixed Nil graphics Issue...
- Fixed Single seeds option removed when second seed is being chosen...

NewBugs:
- Duplication bug may occur (this happened whilst testing 3.2s release (unfinished at that time, may be fixed))

Notes:
- The code is not optimised and is over the top in the class Window_Seed and class Scene_Garden, this is due
    to an annoying bug that occurred in the unfinished version that was the last thing stopping release of Ver
    3.2, the over the top code was my attempt to stop this bug before I realised I was using '.concat()' rather
    than '+'.
If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.
The rest of them will write Perl programs.

Sacrifyx

I'm having an issue with this script, more precisely with its configuration. I'm using a single seed dealie-o.
For testing purposes, I've set up one seed and one result item.
The seed has ID 980, the result item has ID 970.
I get the seed_id, single_id bit, that works fine.
I get the growth rate bit as well - when 980 then 10 - so seed grows at 10 second intervals or some such? Don't know for sure, but that bit works fine too.
The next bit is throwing me off. I don't understand how to define the number of stages - the numbers already there don't make any sense. when 8..16 return 4...eh?
Anyhow, if I can avoid messing with that, I will - I don't see any need to change it anyway. The big problem is the end result - it always gives me item ID 10, which is something I definitely don't want growing in the ground. How would I change it so a specific seed gives me a specific item every time? I can't seem to find that anywhere in the script...

ForeverZer0

Read the instructions more carefully in the section for the results.
Here's an a quick example:

SEED_INDEX = [4, 5, 78, 980]


This makes seed with Item ID of 980 have a seed index of 3 (array indices start at 0, not 1)

Then, in the config for the item results (if you are using the single-seed variant), it would look something like this:

when 3 then return [970]


I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Sacrifyx

Well...I got the first item to work, so I decided to throw another one in to see if it was just a fluke.
SEED_IDS = [980, 981](this is what you meant by SEED_INDEX?)
SINGLE_IDS = [980, 981] (not sure if I needed this in both spots, but doesn't seem to hurt)

Set up the time...didn't mess with the stages as I still don't understand how that works.

Under results:
when 980 then [970]
when 981 then [3] (already had an item for this seed set up)

Duplicated that under the single seed part, again not sure if that's necessary or not. So, it looks like my method is a little off compared to yours and I still don't understand how or why it works or why it didn't before, but it works now and that's all I care about. I believe you said earlier in the thread you might add a watering feature to it at some point in the future, definitely looking forward to that! Thanks for the quick reply!


Twb6543

Lets me just go through the script and try and explain it slightly more for you:


#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  BEGIN CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
#===============================================================================
# ** Garden
#===============================================================================

module Garden
 
  SEED_IDS = [980, 981]
  # This means that 980 will have a seed index of 0 and 981 a seed index of 1
 
  SINGLE_IDS = [980,981]
  # This means that both seeds could be planted seperately
 
  HARVEST_SE = '056-Right02'
  # This is the SE that will be played when the player harvests the plant.
 
  SEED_DISPLAY = true
  # If true, all seeds will be displayed in the seed window, including those
  # that the player does not have, though they will be disabled. If false, only
  # seeds that that the player currently has will be displayed.
 
  # Define the growth rates here. (the average of both seeds will be used)
  def self.growth_rate(seed)
    return case seed
    # when SEED_ID then SECONDS
    when 980 then 12
      # This means the Seed with Item Id of 980
      # will have a growth rate of 12 seconds
    when 981 then 6
      # This means the Seed with Item Id of 981
      # will have a growth rate of 6 seconds
    else
      10 # Default Value to return if no speed is specified
    end
  end
 
#-------------------------------------------------------------------------------
# Define the number of stages that each item uses. The stages will still cycle
# in the same order, but only use up to the defined number of them before going
# to the final graphic. This will not effect the duration that the seed takes to
# grow, only how many times the graphic changes.
#
# You do not have to define anything that uses a three stage configuration.
#-------------------------------------------------------------------------------
  def self.number_stages(result)
    case result
    when 8..16
      return 4
      # This means if the result Item id is 8, 9, 10, 11, 12, 13, 14, 15 or 16
      # Then it will have 4 stages of growth
    when 17..24
      return 5
      # This means if the result Item id is 18, 19, 20, 21, 22, 23 or 24
      # Then it will have 5 stages of growth
    else
      return 3 # Otherwise it will have 3 stages of growth
    end
  end
 
#-------------------------------------------------------------------------------
# Define the final result of the seeds. A random item from the array will be
# given as the final result.

# Each seed is given a value from 0 to the total number of seeds in the SEED_IDS
# array, and both values are added together to determine which 'produce' array
# will be used for the final result. This is why it is important that you have
# the SEED_IDS array in order of value/rarity. You can find the total number of
# cases you will need by subtracting 1 from the total number of different seeds
# in SEED_IDS, and multiplying that number by 2.
#
#   EX. Player uses one each of the first and last seed in the SEED_IDS array,
#       and there are 8 total seeds in the array...
#
#       FIRST_SEED = 2
#       LAST_SEED = 5         2 + 5 = RESULT
#
# By placing multiple copies of the same value in an array, you can increase
# the odds of receiving that item over another in the same array.
#-------------------------------------------------------------------------------

  #-------------------------------#
  #   - Double and Single Seed -  #
  #-------------------------------#
  #  Now with Else/Defualt Clause #
  #-------------------------------#
  def self.produce(seed)
    return case seed
    when 0 then [9, 10]
      # Only if both seed are the lowest seeds, 980 and 980
      # This means it will produce an Item with the id of either 9 or 10
    when 1 then [10, 11]
      # Only if both seeds are 981 and 980
      # This means it will produce an Item with the id of either 10 or 11
    when 2 then [12, 13]
      # Only if both seeds are the highest seeds, 981 and 981
      # This means it will produce an Item with the id of either 12 or 13
    else
      [9] # Default Value to return, Brackets are important,
          # May contain more than one value e.g [9,10] or [9,10,11,12,13]
    end
  end
 
  #------------------------------------------#
  #   - Double and Single Seed New Method -  #
  #------------------------------------------#
  #   Table set up much in the same way as   #
  #  .produce, however items come from seed  #
  #        _ID_  not position in array       #
  #------------------------------------------#
  #  Also the ids are taken from SINGLE_IDS  #
  #                   Array                  #
  #------------------------------------------#
  def self.produce_single(seed)
    return case seed
    when 980 then [970]      # Only if seed is the item with Id 980
    # will it produce a resulting item of 970 if planted seperatley
    when 981 then [3] # If the seed is the item id 981 then it will
    # produce an item with the id of 3
    else
      [9] # Default Value to return, Brackets are important,
          # May contain more than one value e.g [9,10] or [9,10,11,12,13]
    end
  end
 
#-------------------------------------------------------------------------------
#  Define graphics for the final results, and each stage. Follow the below
#  template to set it up.
#
#   when ITEM_ID/STAGE then ['FILENAME', X, Y]
#
#   ITEM_ID = The ID number of the item in your database
#   STAGE = The stage during which to display the graphic
#
#   FILENAME = The name of the character file the needed graphic is on
#   X = The x-coordinate of the correct picture on the charset (1 - 4)
#   Y = The y-coordinate of the correct picture on the charset (1 - 4)
#
#           ← X →             Ex.   If the needed graphic was in the bottom
#         1  2  3  4                left corner:   X = 1    Y = 4
#       ┌──┬──┬──┬──┐                   
#     1 │  │  │  │  │
#       ├──┼──┼──┼──┤
#  ↑  2 │  │  │  │  │
#  Y    ├──┼──┼──┼──┤
#  ↓  3 │  │  │  │  │
#       ├──┼──┼──┼──┤
#     4 │  │  │  │  │
#       └──┴──┴──┴──┘
#-------------------------------------------------------------------------------

  def self.stage_graphics(stage)
    return case stage
    when 0 then ['Plants1', 1, 1]
      # If stage is 0 then return the graphic 1,1 ifrom the file plants
    when 1 then ['Plants1', 2, 3]
    when 2 then ['Plants1', 2, 1]
    when 3 then ['Plants1', 4, 2]
    when 4 then ['Plants1', 2, 4]
    end
  end

  def self.final_graphic(item)
    return case item   
    when 9 then  ['Garden Plants', 1, 1]
      # If the resulting item is id of 9 then show the final graphic of 1,1
      # from the file Garden Plants
    when 10 then ['Garden Plants', 2, 4]
    when 11 then ['Garden Plants', 3, 4]
    when 12 then ['Garden Plants', 4, 4]
    when 13 then ['Garden Plants', 1, 4]
    when 14 then ['Garden Plants', 2, 2]
    when 15 then ['Garden Plants', 3, 2]   
    when 16 then ['Garden Plants', 4, 2]
    when 17 then ['Garden Plants', 1, 2]
    when 18 then ['Garden Plants', 2, 3]
    when 19 then ['Garden Plants', 3, 3]
    when 20 then ['Garden Plants', 4, 3]
    when 21 then ['Garden Plants', 1, 3]
    when 22 then ['Garden Plants', 2, 1]
    when 23 then ['Garden Plants', 3, 1]
    when 24 then ['Garden Plants', 4, 1]
    end
  end
 
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  END CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


This is an extract and is not meant for you to plug it in to the script, I've added extra comments and tried to follow roughly your example to show you how it can be set up.
If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.
The rest of them will write Perl programs.

Sacrifyx

October 25, 2011, 02:18:39 pm #52 Last Edit: October 25, 2011, 02:56:03 pm by Sacrifyx
That was beautiful, and actually cleared up quite a bit of confusion, particularly around the growth stages bit. I'm gonna copy the comments from your example into the comments in the script (old age and memory, you know how it goes) so I have that reference. Thanks much!

Quick edit for a question: If the seed IDs are also in single IDs, will I still be able to use them in a two-seed process, or will they only work individually? I initially shied away from the two seed thing, but after thinking on it, that kind of thing will be handy for what I have planned.

Edit 2: In testing it looks like I've answered my own question above, however, in the test event, I have the farmer give the player 1 carrot seed and 1 potato seed. When I go to plant, carrot seeds are listed once, but potato seeds are listed twice, like so:
Potato seed: 1
Potato seed: 1
Using one potato seed causes the other instance to disappear as it should, and this did occur using the other method I was prior to your explanation, just wondering if this is a bug in the script or if you've heard of or seen this happening before.

Edit 3: Additional testing (adding a 3rd seed/item and swapping around the seed index) would seem to indicate that the issue is with whatever has seed index of 1.

Twb6543

October 26, 2011, 05:19:22 am #53 Last Edit: October 26, 2011, 05:32:48 am by Twb6543
I'll look into it, in a second or two, As I probably have said this more of a hashed together edit and the first single seed variant did have a few problems which may have carried other into the recent version.




I currently can not replicate the results, Would you pm me a link to a archive of the project (e.g. a rar or zip file uploaded to the media fire, dropbox, etc). So I can look into it, So far I have not found anything in the code that would cause that.



The way the system of the seed list works is that it creates the normal double seeds list and then adds to it any seed in the single seed ids that are not in the double.

For example
Double Seeds 1,2,3
Single Seeds 1,3,4,5
Would Result in a seed list of 1,2,3,4,5
If you plant 1 or 3 first then a choice menu should appear with the options to add a new seed to the mix or just plant one.
If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.
The rest of them will write Perl programs.

Sacrifyx

October 26, 2011, 05:36:37 am #54 Last Edit: October 26, 2011, 06:07:19 am by Sacrifyx
Gimme a bit to slap together the necessary bits and I'll pm you a link.

Edit: Check your inbox.

Twb6543

October 26, 2011, 06:45:42 am #55 Last Edit: October 26, 2011, 06:53:01 am by Twb6543
- Twb6543's Single Variation of Dynamic Gardening by ForeverZer0 is now Version 3.2.1 -


ChangeLog :
- Optimised the code for generating the seed lists.

BugFixes:
- Fixed the Extra Seed Glitch that occured (Still have no Idea how it happened)

NewBugs:
- None Found whilst Testing

Notes:
- Yet to be integrated into the normal script, first version was pm'd to Sacrifyx.
If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.
The rest of them will write Perl programs.

ShadowIce

Can u make this script online so other players can see ur garden? :) Thanks! :D

firevenge007

Can you get this to give farming experience in the single seed script or is this not possible?

Thanks.

KK20

It shouldn't be too hard to implement. It will require another configuration option, something like when ITEM_ID then return EXP, and another variable stored in $game_party most likely to hold the farming experience.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

firevenge007

How about seed level requirements as well? Would that be hard to add on?

KK20

Just a few conditional statement checks in a couple areas in the script as well as configuration for levels and seed level requirements. How does the exp scale? Example: level 1 to 2 is 50 EXP, 2 to 3 is 150 EXP, etc.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Twb6543

Been looking at my old code  :facepalm:,
Anyway here's a fix for pretty much all the bugs mentioned whilst I was gone.

- Single Seeds Patch for Dynamic Gardening by ForeverZer0 v3.3 -

Change Log:
- Rebuilt on Zer0's v3
- Fixed just about every bug I could find or was mentioned in the last 2.5 years
- Cleaner Source (Sort Of, everything is kind of logical now)

DropBox Link:
- Download the txt file via Dropbox here

If used:
You must give credit to ForeverZer0 for the bulk of the code.




To add Level Requirements and such would be possible, just add a couple of checks in WindowSeed::refresh to remove any seeds that require a higher level. Farming experience could be added via Scene_Garden::update_confirm by just adding a couple of lines at :
ln601: # Gain item, play the harvest SE, then return to the map.

If requested I could probably add a small API wrapper for both places, but it shouldn't really be needed.
If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.
The rest of them will write Perl programs.

AliveDrive

Wow, I've been reading through this thread and this script looks awesome!

It doesn't surprise me that someone else has thought about a Harvest Moon game.

I'll definitely try it out.
Quote from: Blizzard on September 09, 2011, 02:26:33 am
The permanent solution for your problem would be to stop hanging out with stupid people.

KK20

Oh yeah, I completely forgot about updating this script. xP
Thanks for your fix (haven't checked it yet) and welcome back :D

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

AliveDrive

So, how does the single seed method work? How does the double seed method work? I read the post but I'm still a little unclear.

Is it like a genetic hybrid for the multiple seeds?

I assume the single seed works similar to Harvest Moon? (Plant one get one).
Quote from: Blizzard on September 09, 2011, 02:26:33 am
The permanent solution for your problem would be to stop hanging out with stupid people.

Twb6543

January 20, 2014, 12:41:23 pm #65 Last Edit: January 20, 2014, 12:44:11 pm by Twb6543
I actually posted the wrong script  :^_^':, Dropbox should contain the right version now.
I had actually added the functions for the Single Seed produce and Growth as I was coding but removed them for testing and posted the testing script. :shy:

As to Produce return, The script currently just selects a random Item from the array for that combination, just only include 1 id to make sure its a certain type, and Yes currently it only provides 1 of the return Produce, I'll probably add a config for that when I get the chance.

The script should make more sense now that the produce and Growth functions are re-added, however here's a partial example of a set-up. I can probably do a more in depth at some point if you need one.


module Garden
 
 #=====
 # Database has 5 Seeds (ids 21 to 25) and 9 Produces (ids 9 to 17)
 #=====

 SEED_IDS = [21, 22, 23, 24] # The Seeds that can be planted with another seed
 # IDs of the items in the database that are seeds. Add them into the array in
 # the order of value/rarity in your game
 #* CAN BE LEFT BLANK (e.g. = []) TO DISABLE DOUBLE SEEDS
 
 SINGLE_IDS = [21, 25]
 #* IDs of the items in the database that can be planted by themselves
 #* The IDs do not have to be in the SEED_ID Array!
 #* CAN BE LEFT BLANK (e.g. = []) TO DISABLE SINGLE SEEDS
 
 def self.growth_rate(seed)
   return case seed
   #* when ITEM_ID then SECONDS
   when 21 then 10
   when 22 then 12
   when 23 then 15
   when 24 then 20
   else
     10 #* Default Return Value : Set this just in case of Bugs
   end
 end

 def self.growth_rate_Single(seed)
   return case seed
   # when ITEM_ID then SECONDS
   when 21 then 10
   when 25 then 12
   else
     10 #* Default Return Value : Set this just in case of Bugs
   end
 end
 end

 # For Seed at position 1 the index is 0
 # For Seed at position 2 the index is 1
 def self.produce(seed)
   return case seed
   # when Combined Array Index then Array of Produce Item Ids
   when 0 then [9, 10]   # Result of 21,21
   when 1 then [10, 11] # Result of 22,21
   when 2 then [12, 13] # Result of 23,21 or 22,22
   when 3 then [13, 14, 15] # Result of 24,21 or 23,22
   when 4 then [14, 15] # Result of 24,22 or 23,23
   when 5 then [15, 16] # Result of 24,23
   when 6 then [17] # Result of 24,24
   else
     [9,10] #* Default Return Values : Set this just in case of Bugs
   end
 end
 
 # For Seed at position 1 the index is 0
 # For Seed at position 2 the index is 1
 # ... etc ...
 def self.produceSingle(seed)
   return case seed
   # when Index then ArrayOfProduce
   when 0 then [9,10] # Result of 21
   when 1 then [10,11] # Result of 25
   else
     [9,10] #* Default Return Values : Set this just in case of Bugs
   end
 end

If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.
The rest of them will write Perl programs.

AliveDrive

Oh so it's based on rarity?

Is this a similar manner to say the method for breeding rare chocobos?



Not sure why I thought of this example but could you use this to "discover" new breeds of plant/seed?
Quote from: Blizzard on September 09, 2011, 02:26:33 am
The permanent solution for your problem would be to stop hanging out with stupid people.

ForeverZer0

January 20, 2014, 02:45:07 pm #67 Last Edit: January 22, 2014, 06:31:09 pm by ForeverZer0
The whole 2 seed method, and inspiration for the script, was based on Legend of Mana for the PlayStation, not so much Harvest Moon, which I have never played.  In LoM, you plant two seeds, which can have a number of different results, each with different odds.


EDIT:
I was thinking a small configuration program might be helpful for this script.  I might work on something like that when I get some free time.

EDIT 2:
Actually, I am just going to rewrite this script before I do that. I see room for improvement, and it has gotten quite messy with the addition of all the single seed edits. I am already almost done, and it seems much better. Now there is just an additional setting that determines how many seeds are required for a plant, so you can set it to '1' for a single seed variation, or however many you wish for a combo variation.

It will also make the config program much easier to make...
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Ruffsta

December 11, 2017, 11:05:39 am #68 Last Edit: December 11, 2017, 01:19:47 pm by Ruffsta
i would like to use both scripts in my game, however.. i see 1 issue right off the bat..

when creating the event.. both are to commented Garden Event... personally i think they should have been commented differently so both would work without issue.. the reason i want to use both in the same game is because there may be a time i want to use 2 seeds to say make a crossplant and other times i just want to plant 1 seed...

any help on this?
I have TONS of script ideas.. If yer a scriptor just ask me and i will help - i do NOT code scripts but if yer gonna code one of mine i will help with any questions to see it through as to how it's supposed to act/do.

KK20

Looking at Twb6543's edit, it looks like you can choose to plant one or two seeds at a time. It's not ONLY one seed. So just use his script instead.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ruffsta

if that's the case.. that would be AWESOME!!!!! i shall try.. wish there was a demo like the original from forever0.
I have TONS of script ideas.. If yer a scriptor just ask me and i will help - i do NOT code scripts but if yer gonna code one of mine i will help with any questions to see it through as to how it's supposed to act/do.

Ruffsta

nope, i replaced his code in forever0's demo.. still asks for 2 seeds.. :/

i see alot of scripts on here but not a lot of demos or screenshots.. really kinda disappointing.. anybody have a demo they can make real quick with Twb6543's edit? would really be helpful
I have TONS of script ideas.. If yer a scriptor just ask me and i will help - i do NOT code scripts but if yer gonna code one of mine i will help with any questions to see it through as to how it's supposed to act/do.

KK20

December 11, 2017, 04:53:48 pm #72 Last Edit: December 11, 2017, 05:03:28 pm by KK20
Send F0 a PM to re-upload the demo.

BTW, just checked, and yes, you can choose to plant one seed. You need to configure it.

  SINGLE_IDS = []
  # IDS of the items in the database that are seeds that are grown singularly.
  # These can be any Id's (They used to have to be different to the SEED_IDS)
  # Any reference to SEED_ID in the Configuration also refers to this


But the seed selection process is a bit broken (i.e. windows displaying wrong text). I'll take a look at it later.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ruffsta

ok, i still don't know what to do to make it 1 seed when i want to have 1 seed and what to do when i want to have 2 seeds..
I have TONS of script ideas.. If yer a scriptor just ask me and i will help - i do NOT code scripts but if yer gonna code one of mine i will help with any questions to see it through as to how it's supposed to act/do.

KK20

You fill the array I mentioned in my last post with item ID values. Put a 1 into SINGLE_IDS and you're telling the game "item ID 1 can be used alone".

Please read through the configuration and instructions thoroughly.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ruffsta

i did put a 1 in there.. still asked me to plant 2 seeds..:/


again, i think the script needs to be commented... just my opinion.
I have TONS of script ideas.. If yer a scriptor just ask me and i will help - i do NOT code scripts but if yer gonna code one of mine i will help with any questions to see it through as to how it's supposed to act/do.

ThallionDarkshine

At the request of Ruffsta, I modified the script to allow the player to choose between planting 1 or 2 seeds when planting seeds. In addition, I fixed a minor bug with the help window displaying the incorrect content.

Single/Double Planting Script
Spoiler: ShowHide

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Dynamic Gardening
# Authors: ForeverZer0, Twb6543, ThallionDarkshine
# Date: 7.17.2011
# Version: v.3.3
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#                            VERSION HISTORY
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#  v.1.1  (4.15.2010)
#   - Improved coding
#   - No longer uses game variables, events use self-switches instead
#   - Added ability to create different graphics for every plant, without
#     having to use more event pages
#   - Much less tedious setting up multiple events and changing the every
#     condition variable.
#  v.2.0  (10.10.2010)
#   - Total re-write. Code has been vastly improved and is much more efficient.
#   - Event setup has been simplified. Now requires only a single comment, and
#     does not require multiple pages.
#   - Added configurability for the number of stages each item requires.
#   - The timers no longer use Game_System to constantly update, but simply
#     compare themselves with the Graphics.frame_count when the event exists
#     on the current map, which also allows the plants to grow during scenes
#     other than Scene_Map and Scene_Battle.
#   - Got rid of Scene_Harvest. Scene_Garden now handles both aspects, and has
#     been improved.
#   - Added item icons to the help window display.
# v.3.0  (5.13.2011)
#   - Restructured code completely
#   - Increased compatibility and performance
#   - Fixed bug with final graphic not behaving correctly
# v.3.1  (7.14.2011) by Twb6543
#   - Changed Script to allow for Single Seeds
#   - Added the ability to set default values
# v.3.2 (7.17.2011) by Twb6543
#   - Changed Script to fix bugs in the last release
#   - Fixed Bugs from version 3.0 (May not be completely fixed but I(Twb6543)
#     believe that it is mostly fixed)
# v.3.3 (12.19.2017) by ThallionDarkshine
#   - Modified script to allow players to choose between single and double seed
#     when planting seeds.
#   - Fixed a bug where help window would not update correctly.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
#   This system allows the player to plant seeds, which will eventually grow
#   into plants that can be harvested for items. The system is very similar in
#   nature to that found in Legend of Mana. Seed's can be combined in different
#   ways, which will effect the total growth duration, the number of stages the
#   plant passes through, the graphics used, and of course the final result.
#
# Features:
#
#  - Totally configurable growth rates, results, and graphics for every plant.
#  - Can use arrays of items for each result, so the final item is not
#    neccessarily the same every time.
#  - Each plant timer is independent, and its progress is saved with the game.
#  - Easy setup. Need only a single comment in one of the event's pages.
#
# Instructions:
#   
#  - Place script below Debug and above Main
#  - Configure the options below (instructions are with each setting)
#  - Create an event, setting the graphic to whatever you want. This will be the
#    graphics used when nothing is growing on the plant.
#  - At the very top event's page, place a comment that reads "Garden Event",
#    omitting the quotation marks.
#  - As long as the page's conditions are met, this event can be clicked on to
#    initiate the Garden scene, and can grow plants.
#  - Note that plants can be harvested early, but they will yield nothing until
#    they are ripe.
#
# Note:
#
#  - Any method modified or added in 3.1 or 3.2 has an headed attached to it.
#  - The header will be "Double and Single Seed" or
#    "Double and Single Seed Method" for modified Methods.
#  - The header will be "Double and Single Seed New Method" for new Methods.
#  - Headers may also have extra information.
#  - The Code for Scene_Garden and Window_Seed can definitely be optimised
#    but as I(Twb6543) finally squashed the bug preventing release of v 3.2
#    I do not want to change anything with out a bit of forethought.
#
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  BEGIN CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
#===============================================================================
# ** Garden
#===============================================================================

module Garden
 
  SEED_IDS = [1, 2, 3, 4, 5, 6, 7, 8]
  # IDs of the items in the database that are seeds. Add them into the array in
  # the order of value/rarity in your game this currently includes any single
  # seeds
 
  HARVEST_SE = '056-Right02'
  # This is the SE that will be played when the player harvests the plant.
 
  SEED_DISPLAY = true
  # If true, all seeds will be displayed in the seed window, including those
  # that the player does not have, though they will be disabled. If false, only
  # seeds that that the player currently has will be displayed.
 
  # Define the growth rates here. (the average of both seeds will be used)
  def self.growth_rate(seed)
    return case seed
    # when SEED_ID then SECONDS
    when 1 then 10
    when 2 then 12
    when 3 then 15
    when 4 then 20
    when 5 then 23
    when 6 then 25
    when 7 then 30
    when 8 then 35
    else
      10 # Default Value to return if no speed is specified
    end
  end
 
#-------------------------------------------------------------------------------
# Define the number of stages that each item uses. The stages will still cycle
# in the same order, but only use up to the defined number of them before going
# to the final graphic. This will not effect the duration that the seed takes to
# grow, only how many times the graphic changes.
#
# You do not have to define anything that uses a three stage configuration.
#-------------------------------------------------------------------------------
  def self.number_stages(result)
    case result
    when 8..16
      return 4
    when 17..24
      return 5
    else
      return 3
    end
  end
 
#-------------------------------------------------------------------------------
# Define the final result of the seeds. A random item from the array will be
# given as the final result.

# Each seed is given a value from 0 to the total number of seeds in the SEED_IDS
# array, and both values are added together to determine which 'produce' array
# will be used for the final result. This is why it is important that you have
# the SEED_IDS array in order of value/rarity. You can find the total number of
# cases you will need by subtracting 1 from the total number of different seeds
# in SEED_IDS, and multiplying that number by 2.
#
#   EX. Player uses one each of the first and last seed in the SEED_IDS array,
#       and there are 8 total seeds in the array...
#
#       FIRST_SEED = 2
#       LAST_SEED = 5         2 + 5 = RESULT
#
# By placing multiple copies of the same value in an array, you can increase
# the odds of receiving that item over another in the same array.
#-------------------------------------------------------------------------------

  #-------------------------------#
  #   - Double and Single Seed -  #
  #-------------------------------#
  #  Now with Else/Defualt Clause #
  #-------------------------------#
  def self.produce(seed)
    return case seed
    when 0 then [9, 10]      # Only if both seed are the lowest seeds
    when 1 then [10, 11]
    when 2 then [12, 13]
    when 3 then [13, 14]
    when 4 then [14, 15]
    when 5 then [15, 16]
    when 6 then [16, 17]      # Every combination in between
    when 7 then [17, 18]
    when 8 then [18, 19]
    when 9 then [19, 20]
    when 10 then [20, 21]
    when 11 then [21, 22]
    when 12 then [22, 23]
    when 13 then [23, 24]
    when 14 then [24]         # Only if both seeds are the highest seeds
    else
      [9] # Default Value to return, Brackets are important,
          # May contain more than one value e.g [9,10] or [9,10,11,12,13]
    end
  end
 
  #------------------------------------------#
  #   - Double and Single Seed New Method -  #
  #------------------------------------------#
  #   Table set up much in the same way as   #
  #  .produce, however items come from seed  #
  #        _ID_  not position in array       #
  #------------------------------------------#
  #  Also the ids are taken from SINGLE_IDS  #
  #                   Array                  #
  #------------------------------------------#
  def self.produce_single(seed)
    return case seed
    when 25 then [9, 10]      # Only if seed is item with Id 25
    else
      [9] # Default Value to return, Brackets are important,
          # May contain more than one value e.g [9,10] or [9,10,11,12,13]
    end
  end
 
#-------------------------------------------------------------------------------
#  Define graphics for the final results, and each stage. Follow the below
#  template to set it up.
#
#   when ITEM_ID/STAGE then ['FILENAME', X, Y]
#
#   ITEM_ID = The ID number of the item in your database
#   STAGE = The stage during which to display the graphic
#
#   FILENAME = The name of the character file the needed graphic is on
#   X = The x-coordinate of the correct picture on the charset (1 - 4)
#   Y = The y-coordinate of the correct picture on the charset (1 - 4)
#
#           ← X →             Ex.   If the needed graphic was in the bottom
#         1  2  3  4                left corner:   X = 1    Y = 4
#       ┌──┬──┬──┬──┐                   
#     1 │  │  │  │  │
#       ├──┼──┼──┼──┤
#  ↑  2 │  │  │  │  │
#  Y    ├──┼──┼──┼──┤
#  ↓  3 │  │  │  │  │
#       ├──┼──┼──┼──┤
#     4 │  │  │  │  │
#       └──┴──┴──┴──┘
#-------------------------------------------------------------------------------

  def self.stage_graphics(stage)
    return case stage
    when 0 then ['Plants1', 1, 1]
    when 1 then ['Plants1', 2, 3]
    when 2 then ['Plants1', 2, 1]
    when 3 then ['Plants1', 4, 2]
    when 4 then ['Plants1', 2, 4]
    end
  end

  def self.final_graphic(item)
    return case item   
    when 9 then  ['Garden Plants', 1, 1]
    when 10 then ['Garden Plants', 2, 4]
    when 11 then ['Garden Plants', 3, 4]
    when 12 then ['Garden Plants', 4, 4]
    when 13 then ['Garden Plants', 1, 4]
    when 14 then ['Garden Plants', 2, 2]
    when 15 then ['Garden Plants', 3, 2]   
    when 16 then ['Garden Plants', 4, 2]
    when 17 then ['Garden Plants', 1, 2]
    when 18 then ['Garden Plants', 2, 3]
    when 19 then ['Garden Plants', 3, 3]
    when 20 then ['Garden Plants', 4, 3]
    when 21 then ['Garden Plants', 1, 3]
    when 22 then ['Garden Plants', 2, 1]
    when 23 then ['Garden Plants', 3, 1]
    when 24 then ['Garden Plants', 4, 1]
    end
  end
 
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  END CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  #              ! Warning !             #
  #                                      #
  # This rearranges the order of the def #
  #  variables to allow for Single Seed  #
  #--------------------------------------#
  def self.plant_seeds(event_id, seed1, seed2=nil)
    # Create a new instance of a Garden::Plant
    if seed2 != nil
      # Double Seed Method
      plant = self::Plant.new(event_id, seed1, seed2)
      if $game_system.garden[$game_map.map_id] == nil
        $game_system.garden[$game_map.map_id] = [plant]
      else
        $game_system.garden[$game_map.map_id].push(plant)
      end
    else
      #Single Seed Method
      plant = self::Plant.new(event_id, seed1)
      if $game_system.garden[$game_map.map_id] == nil
        $game_system.garden[$game_map.map_id] = [plant]
      else
        $game_system.garden[$game_map.map_id].push(plant)
      end
    end
     
  end
 
  def self.harvest(id)
    # Find the appropriate plant.
    plant = $game_system.garden[$game_map.map_id].find {|plant| plant.id == id }
    return nil if plant == nil
    # Return the result, and delete plant data from array.
    result = plant.produce
    plant.restore_event
    $game_system.garden[$game_map.map_id] -= [plant]
    return result
  end

#===============================================================================
# ** Garden::Plant
#===============================================================================

  class Plant
   
    attr_reader :id, :ripe
   
    #--------------------------------------#
    #   - Double and Single Seed Method -  #
    #--------------------------------------#
    def initialize(id, seed1, seed2=nil)
      if seed2 != nil
        # Initialize needed instance variables.
        @id, @seed1, @seed2, @single = id, seed1, seed2, false
      else
        # Initialize needed instance variables.
        @id, @seed1, @single = id, seed1, true
      end
      @ripe, @stage = false, -1
      # Run setup method, using data in Garden config for this plant's seeds
       setup
    end
   
    #--------------------------------------#
    #   - Double and Single Seed Method -  #
    #--------------------------------------#
    #   Similar to old method but adds a   #
    #       check for the single flag      #
    #--------------------------------------#
    def setup
      # Store original graphic, direction, and pattern in variable.
      event = $game_map.events[@id]
      @original_event = [event.character_name, event.direction, event.pattern]
      # Calculate the total duration of the seed combination.
      if @single == true # If single then only the duration of that seed
        @duration = Garden.growth_rate(@seed1)
      else # IF double then duration of both seeds
        @duration = (Garden.growth_rate(@seed1) + Garden.growth_rate(@seed2))
      end
      # Find the produce that this combination will grow into
      if @single == true
        @produce = Garden.produce_single(@seed1)
        # Get a random produce from case Seed1 id
        @produce = @produce[rand(@produce.size)]
      else
        comb = Garden::SEED_IDS.index(@seed1) + Garden::SEED_IDS.index(@seed2)
        @produce = Garden.produce(comb)
        @produce = @produce[rand(@produce.size)]
      end
      # Get the number of stages this plant will use, then setup counts for it
      number, count = Garden.number_stages(@produce), 0
      dur = (@duration / number.to_f).to_i
      @stages = (0...number).to_a
      @stages.collect! {|i| $game_system.garden_counter + (i * dur) }
      # Refresh the plant to apply changes
      refresh
    end
   
    def refresh
      unless @ripe
        # Initialize local variable that will determine if graphic needs redrawn.
        previous = @stage
        count = @stages.find_all {|rate| $game_system.garden_counter <= rate }
        @stage = (@stages.size - count.size)
        @ripe = (@stage >= @stages.size - 1)
        # Redraw bitmap if needed.
        change_graphic(@ripe) if previous != @stage
      end
    end
   
    def change_graphic(final)
      # Set local variable to this plant's event
      event = $game_map.events[@id]
      data = final ? Garden.final_graphic(@produce) :
        Garden.stage_graphics(@stage)
      # Apply graphical change by simply altering event's stance and source
      event.character_name = data[0] # If you get an error on this line it means
      # that the final or stage graphics have not been set up properly or that
      # there is missing data in the config for a certain (pair of) item(s).
      event.direction = (2 * data[2])
      event.pattern = (data[1] - 1)
      event.refresh
    end
   
    def restore_event
      # Restore event to original state before planting.
      event = $game_map.events[@id]
      event.character_name = @original_event[0]
      event.direction = @original_event[1]
      event.pattern = @original_event[2]
    end
   
    def produce
      # Return nil if not yet ripe, else return an item ID.
      return (@ripe ? @produce : nil)
    end
  end
end

#===============================================================================
# ** Game_System
#===============================================================================

class Game_System
 
  attr_accessor :garden, :garden_counter
 
  alias zer0_garden_init initialize
  def initialize
    # Initialize variables used for the garden system.
    @garden_counter = 0
    @garden = {}
    zer0_garden_init
  end
 
  alias zer0_garden_upd update
  def update
    # Increase garden counter and check if update is needed every second.
    if (Graphics.frame_count % 40) == 0
      @garden_counter += 1
      # Check if current map has any plants on it. If so, refresh them.
      if @garden[$game_map.map_id] != nil && !@garden[$game_map.map_id].empty?
        @garden[$game_map.map_id].each {|plant| plant.refresh }
      end
    end
    zer0_garden_upd
  end
end

#===============================================================================
# ** Game_Event
#===============================================================================

class Game_Event
 
  attr_accessor :character_name, :direction, :pattern
 
  alias zer0_garden_event_refresh refresh
  def refresh
    # Normal refresh method.
    zer0_garden_event_refresh
    # Set flag for this event being a garden event.
    @garden_event = (@page != nil && @page.list[0].code == 108 &&
      @page.list[0].parameters[0] == 'Garden Event')
  end
 
  alias zer0_garden_upd update
  def update
    # Skip update method foe this event if it is a plant.
    @garden_event ? return : zer0_garden_upd
  end
 
  alias zer0_garden_event_start start
  def start
    # Redefine the 'start' method if Garden Event flag is present.
    if @garden_event
      plants, harvest = $game_system.garden[$game_map.map_id], false
      # Check if plant exists, and if so check if it is ripe.
      pick = plants != nil ? (plants.find {|obj| obj.id == @id }) != nil : false
      $scene = Scene_Garden.new(@id, pick)
    else
      zer0_garden_event_start
    end
  end
end
 
#===============================================================================
# ** Game_Map
#===============================================================================

class Game_Map
 
  alias zer0_garden_setup setup
  def setup(map_id)
    zer0_garden_setup(map_id)
    # Refresh each plant when map is set up
    if $game_system.garden[@map_id] != nil
      $game_system.garden[@map_id].each {|obj| obj.change_graphic(obj.ripe) }
    end
  end
end

#===============================================================================
# * Window_Seed
#===============================================================================

class Window_Seed < Window_Selectable
 
  def initialize
    super(160, 304, 320, 160)
    self.index = 0
    refresh
  end
 
  def refresh
    # Clear the bitmap.
    self.contents = self.contents.dispose if self.contents != nil
    # Determine what seeds to display.
    @seeds = Garden::SEED_IDS.collect {|id| $data_items[id] }
    unless Garden::SEED_DISPLAY
      @seeds.reject! {|seed| $game_party.item_number(seed.id) < 1 }
    end
    @item_max = @seeds.size
    # Draw the items on the bitmap.
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, @item_max * 32)
      @seeds.each_index {|i|
        item = @seeds[i]
        number = $game_party.item_number(item.id)
        self.contents.font.color = number > 0 ? normal_color : disabled_color
        opacity = number > 0 ? 255 : 128
        # Find icon bitmap and set it to window, and draw the text.
        bitmap = RPG::Cache.icon(item.icon_name)
        self.contents.blt(4, i*32+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
        self.contents.draw_text(32, i*32, 288, 32, item.name)
        self.contents.draw_text(-32, i*32, 288, 32, ':', 2)
        self.contents.draw_text(-4, i*32, 288, 32, number.to_s, 2)
      }
    end
  end
 
  def seed
    # Returns currently highlighted seed item.
    return @seeds[self.index]
  end
end

#===============================================================================
# * Scene_Garden
#===============================================================================

class Scene_Garden
 
  def initialize(id, harvest)
    @event_id, @harvest = id, harvest
    # Play SE to give impression that scene never changed.
    $game_system.se_play($data_system.decision_se)
    $game_player.straighten
    garden = $game_system.garden[$game_map.map_id]
    if garden != nil
      @plant = garden.find {|plant| plant.id == id }
    end
  end
 
  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  def main
    # Create map sprite and required windows.
    @map, @help_window = Spriteset_Map.new, Window_Help.new
    # Create Confirmation window.
    @confirm_window = Window_Command.new(128, ['Yes', 'No'])
    @confirm_window.x, @confirm_window.y = 496, 336
    # Initialize sprites array. Used to handle all the sprites together.
    @sprites = [@map, @help_window, @confirm_window]
    # Create seed window if plant is not being harvested.
    unless @harvest
      @seed_window = Window_Seed.new
      @sprites.push(@seed_window)
      @seed_window.active = @seed_window.visible = false
      # Create Seed Count window
      @seed_count_window = Window_Command.new(192, ['Yes, plant 1 seed', 'Yes, plant 2 seeds', "No"])
      @seed_count_window.x, @seed_count_window.y = 640 - 192 - 16, 480 - 3 * 24 - 96
      @sprites.push(@seed_count_window)
      @confirm_window.visible = @confirm_window.active = false
      @help_window.set_text('Plant seeds here?')
    else
      @data = $game_system.garden[$game_map.map_id][@event_id]
      if @plant != nil && @plant.ripe
        text = 'This plant is ripe. Would you like to harvest it?'
      else
        text = 'Nothing is growing yet on this plant. Harvest it anyway?'
      end
      @help_window.set_text(text)
    end
    # Transition instantly then start main loop.
    Graphics.transition(0)
    loop { Graphics.update; Input.update; update; break if $scene != self }
    # Dispose of all the sprites.
    @sprites.each {|sprite| sprite.dispose }
    # Have map refresh to update any changes made.
    $game_map.need_refresh = true
  end
 
  def update
    @sprites.each {|sprite| sprite.update }
    # Branch update method depending on what window is active.
    if @confirm_window.active
      update_confirm
    elsif @seed_count_window != nil && @seed_count_window.active
      update_seed_count_select
    elsif @seed_window != nil && @seed_window.active
      update_seed_select
    end
  end
 
  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  def update_confirm
    if Input.trigger?(Input::B)
      # Branch by what action is being canceled.
      if @harvest
        back_to_map
      else
        cancel_seed_selection
      end
    elsif Input.trigger?(Input::C)
      # Branch by what action is being confirmed.
      if @harvest
        if @confirm_window.index == 0
          item_id = Garden.harvest(@event_id)
          if item_id != nil
            @confirm_window.active = @confirm_window.visible = false
            # Gain item, play the harvest SE, then return to the map.
            $game_party.gain_item(item_id, 1)
            $game_system.se_play(RPG::AudioFile.new(Garden::HARVEST_SE, 80, 100))
            show_results($data_items[item_id])
            $scene = Scene_Map.new
          else
            back_to_map
          end
        else
          back_to_map
        end
      else
        # If asking if player would like to plant seeds at this location.
        if @seed1 == nil
          back_to_map
          return
        else # If confirming seed selection.
          if @confirm_window.index == 0
            # Plant seeds and return to map.
            @single = @seed_count_window.index == 0
            # This is how Twb6543 reloaded the single command (in case of index
            # movement)
            if @single == true && @seed2 == nil
              # If Single only
              Garden.plant_seeds(@event_id, @seed1.id)
            else
              # If Double or Includes Double Seed
              Garden.plant_seeds(@event_id, @seed1.id, @seed2.id)
            end
            $scene = Scene_Map.new
          else # If canceling seed selection
            cancel_seed_selection
            return
          end
        end
        $game_system.se_play($data_system.decision_se)
      end
    end
  end
 
  def update_seed_count_select
    if Input.trigger?(Input::B)
      back_to_map
    elsif Input.trigger?(Input::C)
      case @seed_count_window.index
      when 0
        @seed_window.active = @seed_window.visible = true
        @seed_count_window.active = @seed_count_window.visible = false
        @help_window.set_text('Which seed would you like to plant?')
      when 1
        @seed_window.active = @seed_window.visible = true
        @seed_count_window.active = @seed_count_window.visible = false
        @help_window.set_text('Which seeds would you like to plant?')
      when 2
        back_to_map
        return
      end
      $game_system.se_play($data_system.decision_se)
    end
  end
 
  def show_results(result)
    @help_window.contents.clear
    # Display the message in the help window.
    @help_window.draw_item_name(result, 0, 0)
    cw = @help_window.contents.text_size(result.name).width + 32
    @help_window.contents.draw_text(cw, 0, 608, 32, ' received!')
    # Call Input.update to the clear key press.
    Input.update
    # Loop until it is pressed again.
    until Input.trigger?(Input::C)
      Graphics.update; Input.update; update
    end
  end
 
  #------------------------------------------#
  #   - Double and Single Seed New Method -  #
  #------------------------------------------#
  def cancel_seed_selection
    # Play cancel SE, reset seeds, and activate/deactivate windows.
    $game_system.se_play($data_system.cancel_se)
    $game_party.gain_item(@seed1.id, 1) unless @seed1.nil? # Added to re add the seeds
    $game_party.gain_item(@seed2.id, 1) unless @seed2.nil? # Added to re add the seeds
    @seed_window.active = @seed_window.visible = true
    @seed_window.refresh
    @confirm_window.active = @confirm_window.visible = false
    @help_window.set_text('Which seeds would you like to plant?')
    @seed1 = @seed2 = nil
  end
 
  def back_to_map
    # Play cancel SE and return to map.
    $game_system.se_play($data_system.cancel_se)
    $scene = Scene_Map.new
  end
 
  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  def update_seed_select
    if Input.trigger?(Input::B)
      # If first seed is selected, go back to re-select, else return to map.
      if @seed1 != nil
        cancel_seed_selection
      else
        back_to_map
      end
    elsif Input.trigger?(Input::C)
      # Play Cancle SE if displayed and party has none.
      if $game_party.item_number(@seed_window.seed.id) < 1
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @single = @seed_count_window.index == 0
      # Can use @idsingle = @seed_window.seed.id
      if @single == true && @seed1 == nil
        # Set first seed then continue
        @seed1 = @seed_window.seed
        $game_party.lose_item(@seed1.id, 1)
        @seed_window.active = false
        @confirm_window.active = @confirm_window.visible = true
      elsif @single == true && @seed1 != nil
        # Set second seed then continue
        @seed2, @seed_window.active = @seed_window.seed, false
        $game_party.lose_item(@seed2.id, 1)
        @confirm_window.active = @confirm_window.visible = true
      else # 2 seeds
        # Set first seed if not defined, else set the second seed and continue.
        if @seed1 == nil
          @seed1 = @seed_window.seed
          $game_party.lose_item(@seed1.id, 1)
        else
          @seed2, @seed_window.active = @seed_window.seed, false
          $game_party.lose_item(@seed2.id, 1)
          @confirm_window.active = @confirm_window.visible = true
        end
      end
      # Refresh seed window to show changes in inventory.
      set_help
      @seed_window.refresh
    end
  end
 
  #--------------------------------------#
  #   - Double and Single Seed Method -  #
  #--------------------------------------#
  def set_help
    # Clear help window.
    @help_window.contents.clear
    # Draw items
    @single = @seed_count_window.index == 0
    if @single == true && @seed2 == nil
      text = 'Plant this seed?'
    else
      text = @seed2 != nil ? 'Plant these two seeds?' : 'Select second seed...'
    end
    @help_window.set_text(text)
    @help_window.draw_item_name(@seed1, 224, 0)
    if @seed2 != nil
      cw = @help_window.contents.text_size(@seed1.name).width + 320
      @help_window.draw_item_name(@seed2, cw, 0)
    end
  end
end


Original script w/bugfix
Spoiler: ShowHide

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Dynamic Gardening
# Author: ForeverZer0, ThallionDarkshine
# Date: 5.13.2011
# Version: v.3.01
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#                            VERSION HISTORY
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#  v.1.1  (4.15.2010)
#   - Improved coding
#   - No longer uses game variables, events use self-switches instead
#   - Added ability to create different graphics for every plant, without
#     having to use more event pages
#   - Much less tedious setting up multiple events and changing the every
#     condition variable.
#  v.2.0  (10.10.2010)
#   - Total re-write. Code has been vastly improved and is much more efficient.
#   - Event setup has been simplified. Now requires only a single comment, and
#     does not require multiple pages.
#   - Added configurability for the number of stages each item requires.
#   - The timers no longer use Game_System to constantly update, but simply
#     compare themselves with the Graphics.frame_count when the event exists
#     on the current map, which also allows the plants to grow during scenes
#     other than Scene_Map and Scene_Battle.
#   - Got rid of Scene_Harvest. Scene_Garden now handles both aspects, and has
#     been improved.
#   - Added item icons to the help window display.
# v.3.0  (5.13.2011)
#   - Restructured code completely
#   - Increased compatibility and performance
#   - Fixed bug with final graphic not behaving correctly
# v.3.01 (12.19.2017) by ThallionDarkshine
#   - Fixed bug with help window not updating correctly.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
#   This system allows the player to plant seeds, which will eventually grow
#   into plants that can be harvested for items. The system is very similar in
#   nature to that found in Legend of Mana. Seed's can be combined in different
#   ways, which will effect the total growth duration, the number of stages the
#   plant passes through, the graphics used, and of course the final result.
#
# Features:
#
#  - Totally configurable growth rates, results, and graphics for every plant.
#  - Can use arrays of items for each result, so the final item is not
#    neccessarily the same every time.
#  - Each plant timer is independent, and its progress is saved with the game.
#  - Easy setup. Need only a single comment in one of the event's pages.
#
# Instructions:
#   
#  - Place script below Debug and above Main
#  - Configure the options below (instructions are with each setting)
#  - Create an event, setting the graphic to whatever you want. This will be the
#    graphics used when nothing is growing on the plant.
#  - At the very top event's page, place a comment that reads "Garden Event",
#    omitting the quotation marks.
#  - As long as the page's conditions are met, this event can be clicked on to
#    initiate the Garden scene, and can grow plants.
#  - Note that plants can be harvested early, but they will yield nothing until
#    they are ripe.
#
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  BEGIN CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
#===============================================================================
# ** Garden
#===============================================================================

module Garden
 
  SEED_IDS = [1, 2, 3, 4, 5, 6, 7, 8]
  # IDs of the items in the database that are seeds. Add them into the array in
  # the order of value/rarity in your game
 
  HARVEST_SE = '056-Right02'
  # This is the SE that will be played when the player harvests the plant.
 
  SEED_DISPLAY = true
  # If true, all seeds will be displayed in the seed window, including those
  # that the player does not have, though they will be disabled. If false, only
  # seeds that that the player currently has will be displayed.
 
  # Define the growth rates here. (the average of both seeds will be used)
  def self.growth_rate(seed)
    return case seed
    # when SEED_ID then SECONDS
    when 1 then 10
    when 2 then 12
    when 3 then 15
    when 4 then 20
    when 5 then 23
    when 6 then 25
    when 7 then 30
    when 8 then 35
    end
  end
 
#-------------------------------------------------------------------------------
# Define the number of stages that each item uses. The stages will still cycle
# in the same order, but only use up to the defined number of them before going
# to the final graphic. This will not effect the duration that the seed takes to
# grow, only how many times the graphic changes.
#
# You do not have to define anything that uses a three stage configuration.
#-------------------------------------------------------------------------------
  def self.number_stages(result)
    case result
    when 8..16
      return 4
    when 17..24
      return 5
    else
      return 3
    end
  end
 
#-------------------------------------------------------------------------------
# Define the final result of the seeds. A random item from the array will be
# given as the final result.

# Each seed is given a value from 0 to the total number of seeds in the SEED_IDS
# array, and both values are added together to determine which 'produce' array
# will be used for the final result. This is why it is important that you have
# the SEED_IDS array in order of value/rarity. You can find the total number of
# cases you will need by subtracting 1 from the total number of different seeds
# in SEED_IDS, and multiplying that number by 2.
#
#   EX. Player uses one each of the first and last seed in the SEED_IDS array,
#       and there are 8 total seeds in the array...
#
#       FIRST_SEED = 2
#       LAST_SEED = 5         2 + 5 = RESULT
#
# By placing multiple copies of the same value in an array, you can increase
# the odds of receiving that item over another in the same array.
#-------------------------------------------------------------------------------

  def self.produce(seed)
    return case seed
    when 0 then [9, 10]      # Only if both seed are the lowest seeds
    when 1 then [10, 11]
    when 2 then [12, 13]
    when 3 then [13, 14]
    when 4 then [14, 15]
    when 5 then [15, 16]
    when 6 then [16, 17]      # Every combination in between
    when 7 then [17, 18]
    when 8 then [18, 19]
    when 9 then [19, 20]
    when 10 then [20, 21]
    when 11 then [21, 22]
    when 12 then [22, 23]
    when 13 then [23, 24]
    when 14 then [24]         # Only if both seeds are the highest seeds
    end
  end
 
#-------------------------------------------------------------------------------
#  Define graphics for the final results, and each stage. Follow the below
#  template to set it up.
#
#   when ITEM_ID/STAGE then ['FILENAME', X, Y]
#
#   ITEM_ID = The ID number of the item in your database
#   STAGE = The stage during which to display the graphic
#
#   FILENAME = The name of the character file the needed graphic is on
#   X = The x-coordinate of the correct picture on the charset (1 - 4)
#   Y = The y-coordinate of the correct picture on the charset (1 - 4)
#
#           ? X ?             Ex.   If the needed graphic was in the bottom
#         1  2  3  4                left corner:   X = 1    Y = 4
#       +-----------+                   
#     1 ¦  ¦  ¦  ¦  ¦
#       +--+--+--+--¦
#  ?  2 ¦  ¦  ¦  ¦  ¦
#  Y    +--+--+--+--¦
#  ?  3 ¦  ¦  ¦  ¦  ¦
#       +--+--+--+--¦
#     4 ¦  ¦  ¦  ¦  ¦
#       +-----------+
#-------------------------------------------------------------------------------

  def self.stage_graphics(stage)
    return case stage
    when 0 then ['Plants1', 1, 1]
    when 1 then ['Plants1', 2, 3]
    when 2 then ['Plants1', 2, 1]
    when 3 then ['Plants1', 4, 2]
    when 4 then ['Plants1', 2, 4]
    end
  end

  def self.final_graphic(item)
    return case item   
    when 9 then  ['Garden Plants', 1, 1]
    when 10 then ['Garden Plants', 2, 4]
    when 11 then ['Garden Plants', 3, 4]
    when 12 then ['Garden Plants', 4, 4]
    when 13 then ['Garden Plants', 1, 4]
    when 14 then ['Garden Plants', 2, 2]
    when 15 then ['Garden Plants', 3, 2]   
    when 16 then ['Garden Plants', 4, 2]
    when 17 then ['Garden Plants', 1, 2]
    when 18 then ['Garden Plants', 2, 3]
    when 19 then ['Garden Plants', 3, 3]
    when 20 then ['Garden Plants', 4, 3]
    when 21 then ['Garden Plants', 1, 3]
    when 22 then ['Garden Plants', 2, 1]
    when 23 then ['Garden Plants', 3, 1]
    when 24 then ['Garden Plants', 4, 1]
    end
  end
 
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  END CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  def self.plant_seeds(seed1, seed2, event_id)
    # Create a new instance of a Garden::Plant
    plant = self::Plant.new(event_id, seed1, seed2)
    if $game_system.garden[$game_map.map_id] == nil
      $game_system.garden[$game_map.map_id] = [plant]
    else
      $game_system.garden[$game_map.map_id].push(plant)
    end
  end
 
  def self.harvest(id)
    # Find the appropriate plant.
    plant = $game_system.garden[$game_map.map_id].find {|plant| plant.id == id }
    return nil if plant == nil
    # Return the result, and delete plant data from array.
    result = plant.produce
    plant.restore_event
    $game_system.garden[$game_map.map_id] -= [plant]
    return result
  end

#===============================================================================
# ** Garden::Plant
#===============================================================================

  class Plant
   
    attr_reader :id, :ripe
   
    def initialize(id, seed1, seed2)
      # Initialize needed instance variables.
      @id, @seed1, @seed2 = id, seed1, seed2
      @ripe, @stage = false, -1
      # Run setup method, using data in Garden config for this plant's seeds
      setup
    end
   
    def setup
      # Store original graphic, direction, and pattern in variable.
      event = $game_map.events[@id]
      @original_event = [event.character_name, event.direction, event.pattern]
      # Calculate the total duration of the seed combination.
      @duration = (Garden.growth_rate(@seed1) + Garden.growth_rate(@seed2))
      # Find the produce that this combination will grow into
      comb = Garden::SEED_IDS.index(@seed1) + Garden::SEED_IDS.index(@seed2)
      @produce = Garden.produce(comb)
      @produce = @produce[rand(@produce.size)]
      # Get the number of stages this plant will use, then setup counts for it
      number, count = Garden.number_stages(@produce), 0
      dur = (@duration / number.to_f).to_i
      @stages = (0...number).to_a
      @stages.collect! {|i| $game_system.garden_counter + (i * dur) }
      # Refresh the plant to apply changes
      refresh
    end
   
    def refresh
      unless @ripe
        # Initialize local variable that will determine if graphic needs redrawn.
        previous = @stage
        count = @stages.find_all {|rate| $game_system.garden_counter <= rate }
        @stage = (@stages.size - count.size)
        @ripe = (@stage >= @stages.size - 1)
        # Redraw bitmap if needed.
        change_graphic(@ripe) if previous != @stage
      end
    end
   
    def change_graphic(final)
      # Set local variable to this plant's event
      event = $game_map.events[@id]
      data = final ? Garden.final_graphic(@produce) :
        Garden.stage_graphics(@stage)
      # Apply graphical change by simply altering event's stance and source
      event.character_name = data[0]
      event.direction = (2 * data[2])
      event.pattern = (data[1] - 1)
      event.refresh
    end
   
    def restore_event
      # Restore event to original state before planting.
      event = $game_map.events[@id]
      event.character_name = @original_event[0]
      event.direction = @original_event[1]
      event.pattern = @original_event[2]
    end
   
    def produce
      # Return nil if not yet ripe, else return an item ID.
      return (@ripe ? @produce : nil)
    end
  end
end

#===============================================================================
# ** Game_System
#===============================================================================

class Game_System
 
  attr_accessor :garden, :garden_counter
 
  alias zer0_garden_init initialize
  def initialize
    # Initialize variables used for the garden system.
    @garden_counter = 0
    @garden = {}
    zer0_garden_init
  end
 
  alias zer0_garden_upd update
  def update
    # Increase garden counter and check if update is needed every second.
    if (Graphics.frame_count % 40) == 0
      @garden_counter += 1
      # Check if current map has any plants on it. If so, refresh them.
      if @garden[$game_map.map_id] != nil && !@garden[$game_map.map_id].empty?
        @garden[$game_map.map_id].each {|plant| plant.refresh }
      end
    end
    zer0_garden_upd
  end
end

#===============================================================================
# ** Game_Event
#===============================================================================

class Game_Event
 
  attr_accessor :character_name, :direction, :pattern
 
  alias zer0_garden_event_refresh refresh
  def refresh
    # Normal refresh method.
    zer0_garden_event_refresh
    # Set flag for this event being a garden event.
    @garden_event = (@page != nil && @page.list[0].code == 108 &&
      @page.list[0].parameters[0] == 'Garden Event')
  end
 
  alias zer0_garden_upd update
  def update
    # Skip update method foe this event if it is a plant.
    @garden_event ? return : zer0_garden_upd
  end
 
  alias zer0_garden_event_start start
  def start
    # Redefine the 'start' method if Garden Event flag is present.
    if @garden_event
      plants, harvest = $game_system.garden[$game_map.map_id], false
      # Check if plant exists, and if so check if it is ripe.
      pick = plants != nil ? (plants.find {|obj| obj.id == @id }) != nil : false
      $scene = Scene_Garden.new(@id, pick)
    else
      zer0_garden_event_start
    end
  end
end
 
#===============================================================================
# ** Game_Map
#===============================================================================

class Game_Map
 
  alias zer0_garden_setup setup
  def setup(map_id)
    zer0_garden_setup(map_id)
    # Refresh each plant when map is set up
    if $game_system.garden[@map_id] != nil
      $game_system.garden[@map_id].each {|obj| obj.change_graphic(obj.ripe) }
    end
  end
end

#===============================================================================
# * Window_Seed
#===============================================================================

class Window_Seed < Window_Selectable
 
  def initialize
    super(160, 304, 320, 160)
    self.index = 0
    refresh
  end
 
  def refresh
    # Clear the bitmap.
    self.contents = self.contents.dispose if self.contents != nil
    # Determine what seeds to display.
    @seeds = Garden::SEED_IDS.collect {|id| $data_items[id] }
    unless Garden::SEED_DISPLAY
      @seeds.reject! {|seed| $game_party.item_number(seed.id) < 1 }
    end
    @item_max = @seeds.size
    # Draw the items on the bitmap.
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, @item_max * 32)
      @seeds.each_index {|i|
        item = @seeds[i]
        number = $game_party.item_number(item.id)
        self.contents.font.color = number > 0 ? normal_color : disabled_color
        opacity = number > 0 ? 255 : 128
        # Find icon bitmap and set it to window, and draw the text.
        bitmap = RPG::Cache.icon(item.icon_name)
        self.contents.blt(4, i*32+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
        self.contents.draw_text(32, i*32, 288, 32, item.name)
        self.contents.draw_text(-32, i*32, 288, 32, ':', 2)
        self.contents.draw_text(-4, i*32, 288, 32, number.to_s, 2)
      }
    end
  end
 
  def seed
    # Returns currently highlighted seed item.
    return @seeds[self.index]
  end
end

#===============================================================================
# * Scene_Garden
#===============================================================================

class Scene_Garden
 
  def initialize(id, harvest)
    @event_id, @harvest = id, harvest
    # Play SE to give impression that scene never changed.
    $game_system.se_play($data_system.decision_se)
    $game_player.straighten
    garden = $game_system.garden[$game_map.map_id]
    if garden != nil
      @plant = garden.find {|plant| plant.id == id }
    end
  end
 
  def main
    # Create map sprite and required windows.
    @map, @help_window = Spriteset_Map.new, Window_Help.new
    # Create Confirmation window.
    @confirm_window = Window_Command.new(128, ['Yes', 'No'])
    @confirm_window.x, @confirm_window.y = 496, 336
    # Initialize sprites array. Used to handle all the sprites together.
    @sprites = [@map, @help_window, @confirm_window]
    # Create seed window if plant is not being harvested.
    unless @harvest
      @seed_window = Window_Seed.new
      @sprites.push(@seed_window)
      @seed_window.active = @seed_window.visible = false
      @help_window.set_text('Plant seeds here?')
    else
      @data = $game_system.garden[$game_map.map_id][@event_id]
      if @plant != nil && @plant.ripe
        text = 'This plant is ripe. Would you like to harvest it?'
      else
        text = 'Nothing is growing yet on this plant. Harvest it anyway?'
      end
      @help_window.set_text(text)
    end
    # Transition instantly then start main loop.
    Graphics.transition(0)
    loop { Graphics.update; Input.update; update; break if $scene != self }
    # Dispose of all the sprites.
    @sprites.each {|sprite| sprite.dispose }
    # Have map refresh to update any changes made.
    $game_map.need_refresh = true
  end
 
  def update
    @sprites.each {|sprite| sprite.update }
    # Branch update method depending on what window is active.
    if @confirm_window.active
      update_confirm
    elsif @seed_window != nil && @seed_window.active
      update_seed_select
    end
  end
 
  def update_confirm
    if Input.trigger?(Input::B)
      # Branch by what action is being canceled.
      if @harvest
        back_to_map
      else
        @seed1 == nil ? back_to_map : cancel_seed_selection
      end
    elsif Input.trigger?(Input::C)
      # Branch by what action is being confirmed.
      if @harvest
        if @confirm_window.index == 0
          item_id = Garden.harvest(@event_id)
          if item_id != nil
            @confirm_window.active = @confirm_window.visible = false
            # Gain item, play the harvest SE, then return to the map.
            $game_party.gain_item(item_id, 1)
            $game_system.se_play(RPG::AudioFile.new(Garden::HARVEST_SE, 80, 100))
            show_results($data_items[item_id])
            $scene = Scene_Map.new
          else
            back_to_map
          end
        else
          back_to_map
        end
      else
        # If asking if player would like to plant seeds at this location.
        if @seed1 == nil
          if @confirm_window.index == 0
            @seed_window.active = @seed_window.visible = true
            @confirm_window.active = @confirm_window.visible = false
            @help_window.set_text('Which seeds would you like to plant?')
          else
            back_to_map
            return
          end
        else # If confirming seed selection.
          if @confirm_window.index == 0
            # Plant seeds and return to map.
            Garden.plant_seeds(@seed1.id, @seed2.id, @event_id)
            $scene = Scene_Map.new
          else # If canceling seed selection
            cancel_seed_selection
            return
          end
        end
        $game_system.se_play($data_system.decision_se)
      end
    end
  end
 
  def show_results(result)
    @help_window.contents.clear
    # Display the message in the help window.
    @help_window.draw_item_name(result, 0, 0)
    cw = @help_window.contents.text_size(result.name).width + 32
    @help_window.contents.draw_text(cw, 0, 608, 32, ' received!')
    # Call Input.update to the clear key press.
    Input.update
    # Loop until it is pressed again.
    until Input.trigger?(Input::C)
      Graphics.update; Input.update; update
    end
  end
 
  def cancel_seed_selection
    # Play cancel SE, reset seeds, and activate/deactivate windows.
    $game_system.se_play($data_system.cancel_se)
    $game_party.gain_item(@seed1.id, 1) unless @seed1.nil? # Added to re add the seeds
    $game_party.gain_item(@seed2.id, 1) unless @seed2.nil? # Added to re add the seeds
    @seed_window.active = @seed_window.visible = true
    @seed_window.refresh
    @confirm_window.active = @confirm_window.visible = false
    @help_window.set_text('Which seeds would you like to plant?')
    @seed1 = @seed2 = nil
  end
 
  def back_to_map
    # Play cancel SE and return to map.
    $game_system.se_play($data_system.cancel_se)
    $scene = Scene_Map.new
  end
 
  def update_seed_select
    if Input.trigger?(Input::B)
      # If first seed is selected, go back to re-select, else return to map.
      if @seed1 != nil
        cancel_seed_selection
      else
        back_to_map
      end
    elsif Input.trigger?(Input::C)
      # Play Cancle SE if displayed and party has none.
      if $game_party.item_number(@seed_window.seed.id) < 1
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      # Set first seed if not defined, else set the second seed and continue.
      if @seed1 == nil
        @seed1 = @seed_window.seed
        $game_party.lose_item(@seed1.id, 1)
      else
        @seed2, @seed_window.active = @seed_window.seed, false
        $game_party.lose_item(@seed2.id, 1)
        @confirm_window.active = @confirm_window.visible = true
      end
      # Refresh seed window to show changes in inventory.
      set_help
      @seed_window.refresh
    end
  end
 
  def set_help
    # Clear help window.
    @help_window.contents.clear
    # Draw items
    text = @seed2 != nil ? 'Plant these two seeds?' : 'Select second seed...'
    @help_window.set_text(text)
    @help_window.draw_item_name(@seed1, 224, 0)
    if @seed2 != nil
      cw = @help_window.contents.text_size(@seed1.name).width + 320
      @help_window.draw_item_name(@seed2, cw, 0)
    end
  end
end

KK20

December 19, 2017, 09:57:56 pm #77 Last Edit: December 19, 2017, 10:14:25 pm by KK20
Script looks good. But the request was to make it so an event can be configured to plant only 1 or only 2 seeds, not just give the player the option to choose. This can probably be made with a quick edit to the naming of the event. Do something like "Garden Event 1" or "Garden Event 2" to specify. If no number specified, then do what your script currently does.

To get you started, you can use

/Garden Event(\s*\d)?/.match(@page.list[0].parameters[0])

for checking if the event is properly named.

I can move it to the front page once you make that edit.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

ThallionDarkshine

I was talking with Ruffsta to see what he wanted, and implemented it how he told me. He hasn't complained at all about that aspect of its functionality, so I assume it's working correctly.

Ruffsta

ThallionDarkshine's edit works just fine..
I have TONS of script ideas.. If yer a scriptor just ask me and i will help - i do NOT code scripts but if yer gonna code one of mine i will help with any questions to see it through as to how it's supposed to act/do.

KK20


Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ruffsta

December 20, 2017, 02:27:29 pm #81 Last Edit: December 20, 2017, 02:32:46 pm by Ruffsta
i'm still having an issue with the following:


  def self.produce(seed)
    return case seed
    when 0 then [9, 10]      # Only if both seed are the lowest seeds
    when 1 then [10, 11]
    when 2 then [12, 13]
    when 3 then [13, 14]
    when 4 then [14, 15]
    when 5 then [15, 16]
    when 6 then [16, 17]      # Every combination in between
    when 7 then [17, 18]
    when 8 then [18, 19]
    when 9 then [19, 20]
    when 10 then [20, 21]
    when 11 then [21, 22]
    when 12 then [22, 23]
    when 13 then [23, 24]
    when 14 then [24]         # Only if both seeds are the highest seeds
    else
      [9] # Default Value to return, Brackets are important,
          # May contain more than one value e.g [9,10] or [9,10,11,12,13]


AND


when 25 then [9, 10]      # Only if seed is item with Id 25


no matter what numbers i change i get error for 392...

and secondly, the first line is 1-8

SEED_IDS = [1, 2, 3, 4, 5, 6, 7, 8] - (mine is altered 33-40.. kk20 & ThallionDarkshine know why...)

what if i had 100 seeds or more? after all there are TONS of stuff one could plant..

i tried changing the numbers and adding lines but again all i get is errors.. honestly, i'm just getting frustrated at this point
I have TONS of script ideas.. If yer a scriptor just ask me and i will help - i do NOT code scripts but if yer gonna code one of mine i will help with any questions to see it through as to how it's supposed to act/do.

Ruffsta

December 20, 2017, 05:54:10 pm #82 Last Edit: December 20, 2017, 05:58:45 pm by Ruffsta
there's also not enough plant growth stages.. we need more.. i have requested for some in the resources.. but we just need more.. like the following for example.. i know they are vectors, but just to show a point..





what's a gardening script if there isn't enough resources? don't get me wrong, i like the script and all.. but just not enough icons from one source so that they all look right and as a set and not enough growth stages to go with it..

i know this this isn't the forum/topic for resources.. but it had to be said here since everything i am saying does go hand in hand with this gardening script.. so can anyone fulfill some nice icon sets and growth stages to make this script way awesome???
I have TONS of script ideas.. If yer a scriptor just ask me and i will help - i do NOT code scripts but if yer gonna code one of mine i will help with any questions to see it through as to how it's supposed to act/do.

KK20

December 20, 2017, 06:00:58 pm #83 Last Edit: December 20, 2017, 06:02:22 pm by KK20
That's because you, the user, are supposed to provide the graphics yourself. F0 is a programmer, not an artist. If his demo had plant stage graphics, he got them from somewhere else. This script is not designed to do everything for you. It's a tool that you have to work with.

Also, since this script was designed based on another game's system, the idea of 100 different seeds was never really a thought. Maybe the system you want cannot, and will not, be truly satisfied by this script.

And don't double post within 24 hours.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ruffsta

December 20, 2017, 06:16:32 pm #84 Last Edit: December 20, 2017, 06:20:09 pm by Ruffsta
Quote
That's because you, the user, are supposed to provide the graphics yourself. F0 is a programmer, not an artist. If his demo had plant stage graphics, he got them from somewhere else. This script is not designed to do everything for you. It's a tool that you have to work with.


no kidding... but i have been asking for resources.. he had the right idea when he used the growth stages in his example, trust me if i knew how to do graphics i would.. but having these kinds of graphics would definitely make this script so much better is all i'm saying.

Quote
Also, since this script was designed based on another game's system, the idea of 100 different seeds was never really a thought. Maybe the system you want cannot, and will not, be truly satisfied by this script.


actually it "could" be if we really wanted it to be. my request has already made it better and we still working on it.. well, he is to be honest, just with my ideas.

QuoteAnd don't double post within 24 hours.

and i didn't mean to double post.. it was an after thought..
I have TONS of script ideas.. If yer a scriptor just ask me and i will help - i do NOT code scripts but if yer gonna code one of mine i will help with any questions to see it through as to how it's supposed to act/do.

KK20

Quote from: Ruffsta on December 20, 2017, 06:16:32 pm
but having these kinds of graphics would definitely make this demo so much better is all i'm saying.

Fixed that for you

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Wraith89

I'll post this here as a bit of an minor issue, or perhaps the coding clashes, but if you try to use LittleDrago's RPG Maker XP Internal Bug Fix for Parallel Process in the first map in this thread, "back_to_map" feature when hitting cancel doesn't work as intended and instead you're automatically engaging in the Gardening Event when it should not, as if you pushed confirm again. Replicate it by using that fix and this code together and you will see what I mean.

KK20

October 15, 2021, 12:46:32 am #87 Last Edit: October 15, 2021, 12:51:51 am by KK20
I think it's because you're standing in front of the garden event and the Input C from the Garden Scene when you select "No" gets carried over to Scene_Map and triggers the event. So the only thing I can think of is to reset the Input by adding an update call here in Drago's fix:
  def init_parallel_process_fix
    Input.update #<=================
    @spriteset = Nothing.new

You can even reproduce this with just Drago's script alone. Just make a map with an event that gets triggered by the action button (make it show text). Place the player's starting position directly above the event. Upon hitting "New Game" on the title screen, the event will start playing.

I will update the script on that thread. Thanks for reporting

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!