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.

Adding Item Characteristics and New Parameters

Hi, I was wondering, how would I go about giving an item a characteristic? For example, I would like $game_party.item_number[1] to be [/B]$game_party.item_number[1].stackable[1]
whereas $game_party.item_number[2].not_stackable
but $game_party.item_number[3].stackable[2]
Code:
stackable = [1 => 99999999, 2 => 99, 3 => 25,  4 => 10]
not_stackable = 1
Thus begin, able to determine whether the item will show up again in user inventory, or whether item will stack.
Sorta like this:
Code:
for i in 1..$game_party.item_number[i]
if $game_party.item_number[i].is_stackable?
return true
else
return $game_party.item_number[i].non_stackable
end
end

Just doesnt work when i try to implement it. Says something about wrong number of arguments(0 for 1)

Same goes with Rarity:
$game_party.item_number[1].rare[1], etc...
Code:
rare = [1 => [COLOR=Lime]system_color[/COLOR], 2 => [COLOR=Red]normal_color[/COLOR]]

Lastly, How would I create, and implement a new Parameter, creating my own, I know RPG::Actor has the 6, but i would like to create one, and keep track of it my self, and have whether the player would like to just focus on gaining experience in his defense, strength, accuracy and so on.
I'm not looking to find someone elses script yet to find a way to start my own, Thanks! *Although a reference to a similiar project would also be appreciated!*
 
This is what I did for any database editing in a new script.
Code:
module RPG
  class Armor
    attr_reader   :test_instant
    
    alias old_initialize initialize
    def initialize
      old_initialize
      @test_instant = false
    end
    
    def change_data
      @test_instant = false
      case @id
      when 2
        @test_instant = true
      when 51
        @test_instant = true
      else
        @test_instant = false
      end
    end
  end
end

Then I'd put this next part in a new script as well.
Code:
class Game_Temp
  alias setup initialize
  def initialize
    setup
    for armor in $data_armors
      next unless armor
      armor.change_data
    end
  end
end

The best thing to do is to just put all the variables and stuff as instances and then add an attr_reader to them so you can pick them in other places.
 

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