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.

Check an Item/Weapon/Armor's Element

Status
Not open for further replies.

OS

Sponsor

As the title suggests, I would like to know how to check an Item/Weapon/Armor's Element. I can't find out how anywhere, and I need it for my Good Alchemy Script. If anyone helps, thanks. Peace out!

~Broken
 
Code:
item = $data_items[item_id]
element_set = item.element_set

# OR

weapon = $data_weapons[weapon_id]
element_set = weapon.element_set

# OR

armor = $data_armors[armor_id]
element_set = armor.guard_element_set

# Then

for element_id in element_set
  p $data_system.elements[element_id]
end


The element set is an array of element ids. The name of elements in the game is stored in $data_system.elements array. The index being element_ids and name as what is stored in the index.


If you want, here is something I did real quick. It will return an array of all elements names for items, weapons & armors.

Code:
class RPG::Item
  def element_names
    names = []
    for id in @element_set
      names << $data_system.elements[id]
    end
    return names
  end
end

class RPG::Weapon
  def element_names
    names = []
    for id in @element_set
      names << $data_system.elements[id]
    end
    return names
  end
end

class RPG::Armor
  def element_names
    names = []
    for id in @guard_element_set
      names << $data_system.elements[id]
    end
    return names
  end
end

You can just use:
Code:
<rpg_item>.element_names or <rpg_weapon>.element_names or <rpg_armor>..element_names
 

OS

Sponsor

Thanks, Seph! I don't know what I'd do without your help? This is perfect,a nd thanks for that bit of code. You will be at the top of the Credits list for helping me so much! Peace Out, and stay Cool!

~Broken
 
Status
Not open for further replies.

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