Bahamut 0 Report post Posted November 11, 2008 Hello I would like some help here. I am trying to check if the player has a type of item. That is, an item with a special icon I have chosen in their inventory. I have tried this in the script section of a conditional branch with no luck. $game_party.item.icon_name.include?("name of the icon") What am I missing? Share this post Link to post Share on other sites
Polraudio 122 Report post Posted November 11, 2008 Just use the conditional branch to find out if they have a certain item. Share this post Link to post Share on other sites
Bahamut 0 Report post Posted November 11, 2008 Just use the conditional branch to find out if they have a certain item. There are too many items of each type to make a conditional branch for each one of them. So that is why I want to check their icon instead, which would cut it to 6 conditional branches instead of hundreds of them. :rolleyes: Share this post Link to post Share on other sites
Polraudio 122 Report post Posted November 12, 2008 I would have to mess around with scripting more to see if i can be done. I will get back to you after i figure it out. Share this post Link to post Share on other sites
Leon 55 Report post Posted November 12, 2008 What you are missing in your initial coding in the first post is the ID of the item. Without that, you cannot distiguish 1 item from the others. Further, there is not variable or method named 'item' in Game_Party, so calling on that will not work. If I had more information on how you plan on using the code snippet, i could offer a better method. For instance, if you plan on using this in-script, or in an event and calling it that way. If you are planning calling it through event, I suggest a variable identifying the item's ID. Then use: $game_party.items[x].icon_name == "icon_name" Of course, to use that, you have to use the 4th tab under conditional branch in the event setup AND add this small script into your game to allow you to access the hash setup for items the party owns: class Game_Party attr_accessor :items end Now, the other way doesn't include using Game_Party, but goes straight to the item database. To use this method, use: $data_items[x].icon_name == "icon_name" Now, x must equal the item's ID. For instance, if the item is item number 4, then x must equal 4. Share this post Link to post Share on other sites
Bahamut 0 Report post Posted November 12, 2008 Thanks for the replies. I've changed things a little bit so this may be easier. Now I'm handling things inside a script (namely, a module). I need to generate arrays with the item_id of items in the party's possession with a certain icon. For example: Blue Gem Icon = [] Red Gen Icon = [] etc... Right now I am manually writing each ID within these arrays, but I plan on a large list of items so it would be useful to generate these arrays by the icon of the items, I guess that is possible, the value with the icon for each item has to be somewhere. =/ Share this post Link to post Share on other sites
Leon 55 Report post Posted November 13, 2008 alias Game_System's initialize method to loop through the array of items in $data_items, then have it sort them based on the item's icon name. Like this: class Game_System alias leon_examplesort_gamesystem_init initialize def initialize leon_examplesort_gamesystem_init for i in 1...$data_items.size if $data_items[i].icon_name == "example_name" Module_Name::Variable_Name.push($data_items[i].id) end end end end I'm writing this from memory, so it may not be perfect. Share this post Link to post Share on other sites
Bahamut 0 Report post Posted November 13, 2008 Thanks a lot! Isn't $data_items the whole array of items in the database? Because what I want to check is only the items possessed by the party. If it is I will try to modify it. EDIT: It works perfect. Thanks man, your name is in the credits. Share this post Link to post Share on other sites
Leon 55 Report post Posted November 13, 2008 It is, it will go through the entire database. to do the party way, you gotta set it up a method that can be called through a trigger, such as accessing the menu. And as for the method, have it run through the party's possessions. Share this post Link to post Share on other sites
Bahamut 0 Report post Posted November 13, 2008 Nevermind. It is working like this because I have a common event that cycles through the array checking if the party has each item in it or not. Share this post Link to post Share on other sites
Leon 55 Report post Posted November 13, 2008 careful, that can lag the system Share this post Link to post Share on other sites
Bahamut 0 Report post Posted November 13, 2008 It's not lagging now, but you're right, when I have over 200 items it's possible it does. The method should be called when the player speaks to an event. So that is easy to set up. But as for the method itself, how should I modify it to run through the party's possessions instead? I guess it's aliasing the Game_Party initialize method instead of the Game_System's. Share this post Link to post Share on other sites
Leon 55 Report post Posted November 13, 2008 just add an accessor attribute for the items hash in Game_Party, then run $game_party.items, that calls up the entire list, and how many they have of each in a hash format. Share this post Link to post Share on other sites