dubiousdeeds 0 Posted February 28, 2016 So I'm trying to create an event that optimizes the armor my character is wearing. I've come across the script... $game_actors[1].optimize_equipments Which sort of does what I need but it optimizes everything (weapon, head, shield, etc). Does anyone know of a way to make this work on just one slot such as Body? This is being used for taking off a spacesuit. The character is required to have it on when outside the spaceship but when they come inside they have the choice of multiple outfits. So since I couldn't figure out how to just put back on the outfit that was worn previous to putting on the spacesuit (the spacesuit is equipped at anytime by the player and not forced on by an event) I figured I would just go with the best outfit. Thanks ahead for anyone who can help me with this. Share this post Link to post Share on other sites
Shiggy 633 Posted February 28, 2016 Try thisitems = $game_party.equip_items.select do |item| item.etype_id == equip_slots && equippable?(item) && item.performance >= 0 end $game_actors[1].change_equip(i, items.max_by {|item| item.performance }) where you should replace i by the id of the slot you want to change 1 Share this post Link to post Share on other sites
dubiousdeeds 0 Posted February 28, 2016 Try this items = $game_party.equip_items.select do |item| item.etype_id == equip_slots && equippable?(item) && item.performance >= 0 end $game_actors[1].change_equip(i, items.max_by {|item| item.performance }) where you should replace i by the id of the slot you want to change OK, like many have said before me, "sorry for being a Newbie", but I can't seem to get this to work. So first I copied all of that into my event via a script, changed the two instances of i to 3 (since I believe 3 is the standard slot id for body"), and I received the following error... Script 'Game_Interpreter' line 1411: NameError occurred. undefined local variable or method 'equip_slots' for #<Game_Interpreter:0xcee92a4> Then I thought well maybe the first chunk from "items" to "end" should be added via the script editor and the "$" statement should be placed in my event. That didn't work because upon game start I received the following error. Script " line:1 NoMethodError occured. undefined method 'equip_items' for nil:NilClass So as you can see I greatly appreciate your help, but I may need a little more guidance on getting this to work. Should this all be placed inside my event and if so do you know why it's crashing? Share this post Link to post Share on other sites
Shiggy 633 Posted February 28, 2016 I was too fast my bad try this instead class Game_Actor def optimize_equip(i) items = $game_party.equip_items.select do |item| item.etype_id == equip_slots && equippable?(item) && item.performance >= 0 end change_equip(i, items.max_by {|item| item.performance })endend Put this in a new script( below Materials and above Main) and use $game_actors[1].optimize_equip(3) as a script call Share this post Link to post Share on other sites
dubiousdeeds 0 Posted February 28, 2016 I was too fast my bad try this instead class Game_Actor def optimize_equip(i) items = $game_party.equip_items.select do |item| item.etype_id == equip_slots && equippable?(item) && item.performance >= 0 end change_equip(i, items.max_by {|item| item.performance }) end end Put this in a new script( below Materials and above Main) and use $game_actors[1].optimize_equip(3) as a script call This did the trick perfectly. Thank you so much for your speedy help with this! Share this post Link to post Share on other sites
Rikifive 3,464 Posted February 28, 2016 Then I'll close it. ^^ If something happens, let me know. (= This thread is closed, due to being solved. If for some reason anybody would like to re-open this thread, just send me a PM. (= Share this post Link to post Share on other sites