Sorting Items in Shop Window
#1
I'm looking for a way to sort the items in the shop window individually like it was in RM2k and not by ID.

Maybe a simple scriptcall would be enough, but at this point I'm not sure how to do it.
Reply }
#2
It would require a custom script because all items or weapons or armors are hashes that store ID's and amounts, not items per se. Even if you separate every potion or bronze sword, they will be identical, you may pick any of them or the next one that it would not matter at all. Before anybody offers a solution, you would need to specify how you pretend to use it and where you need it, i.e. a bag menu, a shop menu, etc.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
#3
Just the normal shop window but with a custom order instead of sorted by ID.

Maybe you know the Call Shop command from RPG Maker 2000. There the items in the shop windows were sorted by the order how you put it into the command windows in the editor.

So you could have it like this:

[1] Bronze Sword
[5] Bronze Spear
[9] Bronze Axe
[2] Iron Sword
[6] Iron Spear
[10] Iron Axe

Without rearranging the whole database.
Reply }
#4
Try this. Not sure if this is what you are looking for but trying replacing refresh method in Shop Buy with this.

Code:
def refresh
   if self.contents != nil
     self.contents.dispose
     self.contents = nil
   end
   @data = []
   for goods_item in @shop_goods
     case goods_item[0]
     when 0
       item = $data_items[goods_item[1]]
     when 1
       item = $data_weapons[goods_item[1]]
     when 2
       item = $data_armors[goods_item[1]]
     end
     if item != nil
       @data.push(item)
     end
   end
   # Sort by Name
   @data.sort! { |a,b| a.name <=> b.name }
   # If item count is not 0, make a bit map and draw all items
   @item_max = @data.size
   if @item_max > 0
     self.contents = Bitmap.new(width - 32, row_max * 32)
     for i in 0...@item_max
       draw_item(i)
     end
   end
 end
Reply }
#5
That helps alot.
Thank you!

At least as long as the alphabetical order does the trick.^^
Reply }
#6
(01-17-2018, 12:55 AM)Melana Wrote: That helps alot.
Thank you!

At least as long as the alphabetical order does the trick.^^

if not, change .name to the attribute you need. You can sort by name, occasion, price, etc. As long as it is shared by items, weapons, and armor. Otherwise you have to edit a little more to specify when to apply the sorting and what to sort by.
Reply }
#7
Yes, that works fine.

The only complicated thing is to have a complete uncommon order without a specific sorting.
Like adding weapon[67],weapon[64] and weapon[70], and then weapon[5], weapon[8] and weapon[2] just because you want them in that specific order without a reason.

Might be very unlikely though.
Reply }
#8
(01-17-2018, 01:35 AM)Melana Wrote: Yes, that works fine.

The only complicated thing is to have a complete uncommon order without a specific sorting.
Like adding weapon[67],weapon[64] and weapon[70], and then weapon[5], weapon[8] and weapon[2] just because you want them in that specific order without a reason.

Might be very unlikely though.

Im not sure why it changes the natural order of the array in the first place other than it is creating a new one that is referencing the original $game_temp.shop_goods but not directly using it. 

Maybe someone a little more experienced than I would know.
Reply }
#9
I don't recall quite clearly, but I thought the event command window tries to order them once you close the add goods subwindow, or was it during the addition of new goods? If there's no order implied by the maker itself, it should be showed the way they were added. If that's not the case, then it's obvious you'd need to check the corresponding Interpreter command that handles the shop option, there you may find if there is a sort method at some point. Keep in mind it stores info like this: [[0,1],[1,2],[2,4]]
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
#10
Yes the event command sorts them already in the editor by ID.
If you put in the Iron Sword first and then the Bronze Sword, the Bronze Sword will stay on top.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Special Items Separate Menu Diorm 41 42,459 02-10-2018, 06:06 PM
Last Post: Diorm
   Shop Issues :P LunarBerry 4 8,167 11-23-2016, 02:53 AM
Last Post: LunarBerry
   Showing only specific skills in a window Mel 2 5,887 01-12-2016, 01:34 PM
Last Post: Mel
   Dargor's Large Party script and shop menu Simon Greedwell 2 6,583 08-28-2013, 10:12 PM
Last Post: Simon Greedwell
   Help with Shop Menu [RPG Maker XP] JackMonty 6 12,976 05-23-2013, 10:14 AM
Last Post: JackMonty
  Changing Window Styles in Game JackMonty 8 11,009 03-22-2013, 11:54 PM
Last Post: JackMonty
   Something I noticed about the Advanced Shop Status Window yamina-chan 5 9,975 08-21-2011, 09:16 PM
Last Post: yamina-chan
   [Atoa SBS] Changing the command window font MegaPowerNinja 3 8,322 04-12-2011, 10:23 PM
Last Post: Victor Sant
   Repositioning the actor command window. MegaPowerNinja 4 9,391 04-12-2011, 05:21 AM
Last Post: MegaPowerNinja
   Need Help on Making Battle Status Window riou 4 10,887 03-22-2011, 06:04 AM
Last Post: Victor Sant



Users browsing this thread: 3 Guest(s)