Envision, Create, Share

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

[Resolved] Help with Herb Gathering script to add a value to a vairable if...

I suppose you want to add it to the game variable. If so, change this:
Code:
    if !@plant_window.done
      @plant_window.update
      @time_window.update
    else
      if Input.trigger?(Input::C)
        $scene = Scene_Map.new
      end
    end
into this:
Code:
    if !@plant_window.done
      @plant_window.update
      @time_window.update
    else
      if Input.trigger?(Input::C)
        $game_variables[1] += @amount
        $scene = Scene_Map.new
      end
    end
Of course change the number to the specific number you want.

Hope this helps.
 
It did help in the way of adding a 1 xp point to the herbalism skill when you successfully gather an herb, but it also does it when you fail to gather it. Any idea's how I can get it so it adds for success but not for failure?
 
This block:
Code:
      if done?
        $game_system.me_play($game_system.battle_end_me)
        $game_party.gain_item(@id, 1)
        extra = ""
        if @amount > 1
          extra = "(" + @amount.to_s + ")"
        end
        @time_window.set_text("Gained " + @name + extra + "! Press action key to continue...", 1)
        @time_window.update
        @done = true
      end
Is the success code. Add your variable operation anywhere inside this block and you should be fine just for the success of the gathering.

If interested, this is the code for the failure:
Code:
      if @time < 0 or @stuff[@x][@y] == 2
        refresh
        Audio.se_play("Audio/SE/057-Wrong01")
        @time_window.set_text("You cut the root! Press action key to continue...", 1)
        @time_window.update
        @done = true
        return
      end

Hope this helps.
 
Woo hoo I figure it out with your help :D

I took this "$game_variables[1] += @amount" from your first reply and added it in to
Code:
      if done?
        $game_system.me_play($game_system.battle_end_me)
        $game_party.gain_item(@id, 1)
        extra = ""
        if @amount > 1
          extra = "(" + @amount.to_s + ")"
        end
        @time_window.set_text("Gained " + @name + extra + "! Press action key to continue...", 1)
        @time_window.update
        @done = true
      end
of your second reply so it looks like this

Code:
if done?
        $game_system.me_play($game_system.battle_end_me)
        $game_party.gain_item(@id, 1)
        $game_variables[104] += 1
        extra = ""
        if @amount > 1
          extra = "(" + @amount.to_s + ")"
        end
        @time_window.set_text("Gained " + @name + extra + "! Press action key to continue...", 1)
        @time_window.update
        @done = true
      end

and now it works perfectly adding 1 xp point to the variable labled Herbalism XP (104) when the player successfully gains an herb, but not when they fail at it. Thanks for your help.
 

Thank you for viewing

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

Discord

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

Content

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