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.

What's the simple way of hiding items in item screen using an element #?

I am making multipule Item Windows/Scene for different types of Items and I need to edit the Item window so it shows only Items of that class. From what I have read in the forums so far it seems the most simple way is to modify the Item screen lines,
Code:
   # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
with adding something like "Element_set" or something like that. I have yet to see a way that doesn't give me an error message.
 
...learning RGSS.

Okay, okay... Now, listen. An element set is a list of the item's elements. It's recorded on it all the elements of it. That kind of list (Array) has a method called .include? to check if that list has a value registered. Returns TRUE when the value is on the list and FALSE otherwise. Now, remember that it keeps only its elements! The rest isn't included.

If you know about "if", skip this paragraph. "If"s are conditions: it says what happens when something is TRUE. There are two kinds of "if" lines: pre-"if" and post-"if". Pre-"if"s are most common. It's line is written like this:  if (condition). The condition is evalued and, when true, the next lines are executed until it finds an "end" line, that'll close the last TRUE-evalued pre-"if". If it is FALSE-evalued, it skips to its "end" line. Every pre-"if" line has an end line. Post-"if"s are different. It is put on a common line of the script, and is written as: (do something) if (condition). In this case, there's no "end" line. "Do something" will only be executed if "condition" is TRUE-evalued.

You may know that the item object has the Array "element_set" property. You may not know that you must get, first, the item object (from $data_items). Soo, you can access "element_set" of the item by $data_items[i_id].element_set, where "i_id" is the item id. You'll probably be using a variable there. *cough "i" cough cough* ...Well, now you're able to figure it out how to make it work! :D


SEE YA!!!!!
Obs: No, I won't tell you the code like that. Better help you finding it than giving it. Jijingo!
 
If you are still confused on how to work out this method, use the following code:
Code:
   # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0 and $data_items[i].element_set.include?(element_id_here)
        @data.push($data_items[i])
      end
    end
 

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