Well, you can directly modify Window_Item, Window_ShopBuy and Window_ShopSell, in this area:
@data = []
# Add item
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
# Also add weapons and items if outside of battle
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
end
All the different classes have that block, or a block very similar to that. Now, let me explain what this does. First, we create an blank list, @data, called an array.
Now, our next part:
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
This block passes through all the different items your game has. (Personally, I would have rather granted access to the different keys in the @items hash in $game_party, rather than passing though dozens possibly hundreds of numbers running several test that aren't needed. $game_party.items.each do |item_id, n| would have been more effective basically.)
What you need to modify is this line right here: if $game_party.item_number(i) > 0
From here, you just need to add: && <insert your code here>.
Let say you wanted to only add items that have your element 17. Your code would be:
if $game_party.item_number(i) > 0 && $data_items
.element_set.include?(17)
You would do the same thing for items, weapons and armors, just replacing $game_party.item_number, $game_party.weapon_number, $game_party.armor_number respectively and $data_items, $data_weapons and $data_armors respectively as well. You can do this changes in any of your classes.
You can also run different filters by creating a new refresh method, that allows you to pass certain parameters to the method to allow you to have a more dynamic filter that isn't always the same.
class Window_Item
def refresh_filter(args = {})
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
# add special args here
if <code>
@data << $data_items[i]
end
end
# ...
end
end
Now I would use a module for testing items with your arguments where it says # add special args here. But that's a little advanced. If you would like to see, I had an old item filtering and sorting system that isn't complete, but I could show you what I have done if you are interested.
Let me know if you need any more help.