A 'next page' button!

Status
Not open for further replies.
Level 5
Joined
Aug 19, 2021
Messages
40
Okay so to make it clear, i was thinking if there's a way to possibly make like a 'next page' button or a separate button that allows you to access all of the unit the building sold/train? I just got back to world editing again and need it for a building i'm making right now, so any ideas and suggestion is greatly appreciated, thank you!
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I don't think you need to replace the building. You can add as many trainable units to a building as you want (hold shift to bypass editor limits), it's just that only 12 can be displayed on the command card at a time. So what you do is add all of the desired units to the building, create two abilities - Next Page and Previous Page and add them to the building, and create some triggers that take advantage of the Limit Training action to enable and disable these units based on the current page.

So assuming you had 16 units, you would disable the last 6 of them by default (these are our Page 2 units). Then when you cast the Next Page ability you would run a trigger to disable the first 10 units and and enable the last 6 units. If you cast the Previous Page ability then you would reverse the process.

This is handled globally so it will affect all buildings owned by the Player that can train these units.

Something like this:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Next Page
  • Actions
    • Set Variable PN = (Player number of (Owner of (Casting unit))
    • Set Variable CurrentPage[PN] = (CurrentPage[PN] + 1)
    • // limit training based on current page
Other requirements:
  • A Unit-Type array that contains all of the trainable units
  • A For Loop that enables/disables units from the Array in response to changing a page
  • A For Loop that disables non-Page 1 units by default (during map initialization for instance)
  • Going back to Page 1 or to the last Page when going over a Page limit. If you had 3 pages, casting Previous Page at Page 1 could bring you to Page 3. Casting Next Page at Page 3 could bring you back to page 1. Or just do nothing in these cases.
 
Last edited:
Level 5
Joined
Aug 19, 2021
Messages
40
I don't think you need to replace the building. You can add as many trainable units to a building as you want (hold shift to bypass editor limits), it's just that only 12 can be displayed on the command card at a time. So what you do is add all of the desired units to the building, create two abilities - Next Page and Previous Page and add them to the building, and create some triggers that take advantage of the Limit Training action to enable and disable these units based on the current page.

So assuming you had 16 units, you would disable 6 of them by default (these are our Page 2 units). Then when you cast the Next Page ability you would run a trigger to disable the first 10 units and and enable the last 6 units. If you cast the Previous Page ability then you reverse the process.

This is handled globally so it will affect all buildings owned by the Player that can train these units.

Something like this:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Next Page
  • Actions
    • Set Variable PN = (Player number of (Owner of (Casting unit))
    • Set Variable CurrentPage[PN] = (CurrentPage[PN] + 1)
    • // limit training based on current page
Other requirements:
  • A Unit-Type array that contains all of the trainable units
  • A For Loop that enables/disables units from the Array in response to changing a page
  • A For Loop the disables non-Page 1 units by default (during map initialization for instance)
  • Going back to Page 1 or to the last Page when going over a Page limit (If you had 3 pages, casting Previous Page at Page 1 could bring you to Page 3. Casting Next Page at Page 3 could bring you back to page 1). Or just do nothing in these cases.
Woah, these sure are alot, but thank you! Now lemme get my fidgety finger on the triggers and just hope i don't break anything while trying this trigger-

Oh! And lastly, is this applicable to SOLD units? Like the one from Taverns? Or is only for units that uses the training section, cause i wanna make sure of em
 
Level 21
Joined
Mar 16, 2008
Messages
955
This is how I added more "pages" to hero altar but not sure a trigger function exists for "sold" units?

  • page altar hero
    • Events
      • Unit - A unit owned by Player 1 (Red) Finishes casting an ability
      • Unit - A unit owned by Player 2 (Blue) Finishes casting an ability
      • Unit - A unit owned by Player 3 (Teal) Finishes casting an ability
      • Unit - A unit owned by Player 4 (Purple) Finishes casting an ability
      • Unit - A unit owned by Player 13 (Maroon) Finishes casting an ability
      • Unit - A unit owned by Player 14 (Navy) Finishes casting an ability
      • Unit - A unit owned by Player 15 (Turquoise) Finishes casting an ability
      • Unit - A unit owned by Player 16 (Violet) Finishes casting an ability
    • Conditions
      • ((Casting unit) is A structure) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Page 2
        • Then - Actions
          • -------- disable page 1 stuff --------
          • Player - Disable Page 2 for (Owner of (Casting unit))
          • Player - Make Keeper of the Grove Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Priestess of the Moon Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Demon Hunter Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Warden (for users) Unavailable for training/construction by (Owner of (Casting unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player number of (Owner of (Casting unit))) Greater than 12
            • Then - Actions
              • Player - Make Runner's Altar of Kings (hidden upgrade) Unavailable for training/construction by (Owner of (Casting unit))
              • Player - Make Runner's Pandaren Shrine (hidden upgrade) Unavailable for training/construction by (Owner of (Casting unit))
              • Player - Make Runner's Altar of Storms (hidden upgrade) Unavailable for training/construction by (Owner of (Casting unit))
              • Player - Make Runner's Altar of the Depths (hidden upgrade) Unavailable for training/construction by (Owner of (Casting unit))
            • Else - Actions
          • -------- enable page 2 stuff --------
          • Player - Enable Page 3 for (Owner of (Casting unit))
          • Player - Make Warden (heroic cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Priestess of the Moon (normal cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Priestess of the Moon (heroic cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Keeper of the Grove (heroic cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Keeper of the Grove (normal hardcore cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Keeper of the Grove (mythic cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Priestess of the Moon (mythic cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Demon Hunter (mythic cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Warden (mythic cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Page 3
        • Then - Actions
          • -------- disable page 2 stuff --------
          • Player - Disable Page 3 for (Owner of (Casting unit))
          • Player - Make Warden (heroic cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Priestess of the Moon (normal cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Priestess of the Moon (heroic cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Keeper of the Grove (heroic cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Keeper of the Grove (normal hardcore cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Keeper of the Grove (mythic cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Priestess of the Moon (mythic cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Demon Hunter (mythic cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Warden (mythic cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • -------- enable page 3 stuff --------
          • Player - Enable Page 1 for (Owner of (Casting unit))
          • Player - Make Keeper of the Grove (plus cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Priestess of the Moon (plus cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Demon Hunter (plus cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Warden (plus cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Priestess of the Moon (mythic hardcore cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Keeper of the Grove (exploration plus cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Demon Hunter (heroic hardcore cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Warden (no demon magic normal cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Player - Make Keeper of the Grove (no demon magic heroic cosmetic) Available for training/construction by (Owner of (Casting unit))
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Page 1
        • Then - Actions
          • -------- disable page 3 stuff --------
          • Player - Disable Page 1 for (Owner of (Casting unit))
          • Player - Make Keeper of the Grove (plus cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Priestess of the Moon (plus cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Demon Hunter (plus cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Warden (plus cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Priestess of the Moon (mythic hardcore cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Keeper of the Grove (exploration plus cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Demon Hunter (heroic hardcore cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Warden (no demon magic normal cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • Player - Make Keeper of the Grove (no demon magic heroic cosmetic) Unavailable for training/construction by (Owner of (Casting unit))
          • -------- enable page 1 stuff --------
          • Player - Enable Page 2 for (Owner of (Casting unit))
          • Player - Make Keeper of the Grove Available for training/construction by (Owner of (Casting unit))
          • Player - Make Priestess of the Moon Available for training/construction by (Owner of (Casting unit))
          • Player - Make Demon Hunter Available for training/construction by (Owner of (Casting unit))
          • Player - Make Warden (for users) Available for training/construction by (Owner of (Casting unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player number of (Owner of (Casting unit))) Greater than 12
            • Then - Actions
              • Player - Make Runner's Altar of Kings (hidden upgrade) Available for training/construction by (Owner of (Casting unit))
              • Player - Make Runner's Pandaren Shrine (hidden upgrade) Available for training/construction by (Owner of (Casting unit))
              • Player - Make Runner's Altar of Storms (hidden upgrade) Available for training/construction by (Owner of (Casting unit))
              • Player - Make Runner's Altar of the Depths (hidden upgrade) Available for training/construction by (Owner of (Casting unit))
            • Else - Actions
          • Skip remaining actions
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Woah, these sure are alot, but thank you! Now lemme get my fidgety finger on the triggers and just hope i don't break anything while trying this trigger-

Oh! And lastly, is this applicable to SOLD units? Like the one from Taverns? Or is only for units that uses the training section, cause i wanna make sure of em
Yes, it disables sold units as well.
 
Level 18
Joined
Dec 20, 2012
Messages
269
I uses next page and previous buttons for the neutral taverns in my map if you want an example but it uses a hidden dummy taverns created after map initialization in the location of the original preplaced taverns. It's located in the Tavern Pages trigger folder.
 
Level 5
Joined
Aug 19, 2021
Messages
40
Okayy, so i'm a little confused on how to get that CurrentPage variable to have the +1 handle and about those requirements, but hey! At least now i'm getting somewhere with it! I could still use some more explanation to help if that's okay
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Okayy, so i'm a little confused on how to get that CurrentPage variable to have the +1 handle and about those requirements, but hey! At least now i'm getting somewhere with it! I could still use some more explanation to help if that's okay
Before I answer your first question, understand that CurrentPage is an Integer array variable. An Array is what enables the [index] that you see after the name of the variable. You can change any variable into an Array during the variable creation process by checking the little Array box.

Integer with Array off:
  • Set Variable CurrentPage = 10
Integer with Array on:
  • Set Variable CurrentPage[1] = 10
This gives us multiple instances of the same variable which can each hold their own value. It's sort of like turning your variable into a grocery list which can contain multiple numbered items. In this case we're using the Array as a way to track each Player's current page number. This is achieved by using the (Player number) function as the [index] in our array variable. Since no two Players share the same Player Number (Red = 1, Blue = 2, Teal = 3, etc) then we know for certain that each Player will have their own unique entry in the Array.
  • // P1 - Red //
  • Set Variable CurrentPage[1] = 55
  • // P2 - Blue //
  • Set Variable CurrentPage[2] = 204
  • // P3 - Teal //
  • Set Variable CurrentPage[3] = 100
Player 1 (Red) has a value of 55, Player 2 (Blue) has a value of 204, and Player 3 (Teal) has a value of 100.


Regarding your first question, anytime you see math like (10 + 10) or (Variable + 1), etc. know that it's done using the Arithmetic function. So when choosing the value for CurrentPage you would click the Function bubble which gives you access to a list of functions to choose from. In there you would scroll down until you find the Math category and select Math - Arithmetic. Then you'll see you now have two values to edit. For the first value you would choose the CurrentPage variable again and for the second value you would manually write the number 1. Then make sure your operation is set to addition (+).

In my example I use another Integer variable called PN. This is used as a shortcut to store our player's Player Number and quickly and efficiently reference it as the [index] for CurrentPage[]. Try not to overthink it too much, it's not actually necessary but it will make your life easier so I highly recommend using it.

 
Last edited:
Level 5
Joined
Aug 19, 2021
Messages
40
Before I answer your first question, understand that CurrentPage is an Integer array variable. An Array is what enables the [index] that you see after the name of the variable. You can change any variable into an Array during the variable creation process by checking the little Array box.

Integer with Array off:
  • Set Variable CurrentPage = 10
Integer with Array on:
  • Set Variable CurrentPage[1] = 10
This gives us multiple instances of the same variable which can each hold their own value. It's sort of like turning your variable into a grocery list which can contain multiple numbered items. In this case we're using the Array as a way to track each Player's current page number. This is achieved by using the (Player number) function as the [index] in our array variable. Since no two Players share the same Player Number (Red = 1, Blue = 2, Teal = 3, etc) then we know for certain that each Player will have their own unique entry in the Array.
  • // P1 - Red //
  • Set Variable CurrentPage[1] = 55
  • // P2 - Blue //
  • Set Variable CurrentPage[2] = 204
  • // P3 - Teal //
  • Set Variable CurrentPage[3] = 100
Player 1 (Red) has a value of 55, Player 2 (Blue) has a value of 204, and Player 3 (Teal) has a value of 100.


Regarding your first question, anytime you see math like (10 + 10) or (Variable + 1), etc. know that it's done using the Arithmetic function. So when choosing the value for CurrentPage you would click the Function bubble which gives you access to a list of functions to choose from. In there you would scroll down until you find the Math category and select Math - Arithmetic. Then you'll see you now have two values to edit. For the first value you would choose the CurrentPage variable again and for the second value you would manually write the number 1. Then make sure your operation is set to addition (+).

In my example I use another Integer variable called PN. This is used as a shortcut to store our player's Player Number and quickly and efficiently reference it as the [index] for CurrentPage[]. Try not to overthink it too much, it's not actually necessary but it will make your life easier so I highly recommend using it.

What variable type are you setting them as, both the CurrentPage and PN? I couldn't seem to get CurrentPage to use PN as an Index for it, was there a need to match their variable type, or is there a sort of grouping for them that i am missing? (As in Player type variable only goes with other Player related variable like Player Color and Player Group, etc etc...)
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I listed the variable types in my post. CurrentPage is an Integer array and PN is an Integer.

An index [] only takes Integers.

We're setting PN to be equal to the Player NUMBER, not the Player itself.
  • Set Variable PN = (Player number of (Owner of (Casting unit))
(Owner of (Casting unit)) is the Player.
Player number is an Integer that we get from the given Player.
 
Last edited:
Level 5
Joined
Aug 19, 2021
Messages
40
I listed the variable types in my post. CurrentPage is an Integer array and PN is an Integer.

An index [] only takes Integers.

We're setting PN to be equal to the Player NUMBER, not the Player itself.
Alright! Got it all set, and lastly for that unit limit on page, it is using the Unit Array and For Loop in it right? Can you show me an example of how it'll looked like?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Alright! Got it all set, and lastly for that unit limit on page, it is using the Unit Array and For Loop in it right? Can you show me an example of how it'll looked like?
It gets a bit more complicated so I figured I'd just create the final product. Hopefully you can open the map I attached, it requires the latest patch.
  • PageSystem Setup
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Define how many units you can display per page (max should probably be 10 or 11): --------
      • Set VariableSet PS_Page_Unit_Count = 10
      • -------- --------
      • -------- Define your different unit-types and keep track of how many you have: --------
      • Set VariableSet PS_Unit_Type_Count = 11
      • Set VariableSet PS_Unit_Type[1] = Peasant
      • Set VariableSet PS_Unit_Type[2] = Footman
      • Set VariableSet PS_Unit_Type[3] = Footman
      • Set VariableSet PS_Unit_Type[4] = Footman
      • Set VariableSet PS_Unit_Type[5] = Footman
      • Set VariableSet PS_Unit_Type[6] = Footman
      • Set VariableSet PS_Unit_Type[7] = Footman
      • Set VariableSet PS_Unit_Type[8] = Footman
      • Set VariableSet PS_Unit_Type[9] = Footman
      • Set VariableSet PS_Unit_Type[10] = Footman
      • Set VariableSet PS_Unit_Type[11] = Knight
      • -------- --------
      • -------- STOP! You don't need to change anything else below this line. --------
      • -------- --------
      • -------- Some math to determine how many pages we will have in total: --------
      • Custom script: set udg_PS_Page_Count = ((udg_PS_Unit_Type_Count + udg_PS_Page_Unit_Count) - 1) / udg_PS_Page_Unit_Count
      • -------- --------
      • -------- Disable any unit-types that don't belong on Page 1 (we also set the starting Page to 1): --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set VariableSet PS_Player = (Picked player)
          • Set VariableSet PS_Current_Page[(Player number of PS_Player)] = 1
          • For each (Integer PS_Loop) from (PS_Page_Unit_Count + 1) to PS_Unit_Type_Count, do (Actions)
            • Loop - Actions
              • Player - Make PS_Unit_Type[PS_Loop] Unavailable for training/construction by PS_Player
      • -------- --------
      • -------- A shortcut to help with our math in the Change Page trigger: --------
      • Set VariableSet PS_Page_Adjustment = (PS_Page_Unit_Count - 1)
  • PageSystem Change Page
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Next Page (Page System)
          • (Ability being cast) Equal to Previous Page (Page System)
    • Actions
      • Set VariableSet PS_Player = (Owner of (Triggering unit))
      • Set VariableSet PS_PN = (Player number of PS_Player)
      • -------- --------
      • -------- Disable current page units: --------
      • For each (Integer PS_Loop) from ((PS_Page_Unit_Count x PS_Current_Page[PS_PN]) - PS_Page_Adjustment) to (PS_Page_Unit_Count x PS_Current_Page[PS_PN]), do (Actions)
        • Loop - Actions
          • Player - Make PS_Unit_Type[PS_Loop] Unavailable for training/construction by PS_Player
      • -------- --------
      • -------- Adjust current page: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Next Page (Page System)
        • Then - Actions
          • Set VariableSet PS_Current_Page[PS_PN] = (PS_Current_Page[PS_PN] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PS_Current_Page[PS_PN] Greater than PS_Page_Count
            • Then - Actions
              • Set VariableSet PS_Current_Page[PS_PN] = 1
            • Else - Actions
        • Else - Actions
          • Set VariableSet PS_Current_Page[PS_PN] = (PS_Current_Page[PS_PN] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PS_Current_Page[PS_PN] Less than 1
            • Then - Actions
              • Set VariableSet PS_Current_Page[PS_PN] = PS_Page_Count
            • Else - Actions
      • -------- --------
      • -------- Enable NEW current page units: --------
      • For each (Integer PS_Loop) from ((PS_Page_Unit_Count x PS_Current_Page[PS_PN]) - PS_Page_Adjustment) to (PS_Page_Unit_Count x PS_Current_Page[PS_PN]), do (Actions)
        • Loop - Actions
          • Player - Make PS_Unit_Type[PS_Loop] Available for training/construction by PS_Player
Note that I got lazy with my example and only used 3 Unit-Types (peasant, footman, knight) despite setting it up as if I had [11] different Unit-Types. I hope this doesn't confuse you, in your case you wouldn't have any repeats like you see me doing with the Footman.

Remember that you have to hold the Shift key while opening the Units Sold or Units Trained fields in the Object Editor in order to add more than 12 units to it. Shift is the "bypass limit" key which can be used on ANY field!

Also, if you change some of the variable names you may get an error. I suggest keeping them as is. Speaking of errors, don't forget to enable JassHelper in the Trigger Editor if you haven't already.
 

Attachments

  • Page System 1.w3m
    20.4 KB · Views: 13
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
It requires the latest patch to open -> 1.36

Any map saved on a later version of Warcraft 3 will not open on an older version of Warcraft 3, which makes sense since the new version could change/add/remove something in the editor. You wouldn't be able to load a new addition to the game if you haven't actually patched the game and downloaded those new files.

The good news is that everything you see in those triggers should exist and work on just about any version.

Anyway, it's always a great help to let people know which version you're on in your opening post - although nobody does this and I understand that it's not obvious that you should do this. But doing this could help you get your question answered with the best solution possible (and sometimes save me time, but I should also learn to ask this first before creating a map).
 
Last edited:
Level 5
Joined
Aug 19, 2021
Messages
40
Oh, nevermind, i managed to export it out, but nonetheless! Thank you so much for the insight, so sorry if it's a little too much asking, but i'll be sure to learn some more of these crazy stuff if i have the time, again thank you!
 
Level 11
Joined
Jun 20, 2017
Messages
380
Can I somehow define how many items I can display per page?!
For example first page can have 11 items, second page 8 items, third 5 items.
  • PageSystem Setup
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Define how many units you can display per page (max should probably be 10 or 11): --------
      • Set VariableSet PS_PageTechCount = 11
      • -------- --------
      • -------- Define your different unit-types and keep track of how many you have: --------
      • Set VariableSet PS_TechTypeCount = 21
      • -------- --------
      • -------- First Page --------
      • Set VariableSet PS_TechType[1] = Iron Forged Swords
      • Set VariableSet PS_TechType[2] = Black Gunpowder
      • Set VariableSet PS_TechType[3] = Storm Hammers
      • Set VariableSet PS_TechType[4] = Iron Plating
      • Set VariableSet PS_TechType[5] = Flying Machine Bombs
      • Set VariableSet PS_TechType[6] = Improved Masonry
      • Set VariableSet PS_TechType[7] = Defend
      • Set VariableSet PS_TechType[8] = Animal War Training
      • Set VariableSet PS_TechType[9] = Priest Adept Training
      • Set VariableSet PS_TechType[10] = Sorceress Adept Training
      • Set VariableSet PS_TechType[11] = Studded Leather Armor
      • -------- --------
      • -------- Second Page --------
      • Set VariableSet PS_TechType[12] = Long Rifles
      • Set VariableSet PS_TechType[13] = Improved Lumber Harvesting
      • Set VariableSet PS_TechType[14] = Magic Sentry
      • Set VariableSet PS_TechType[15] = Flare
      • Set VariableSet PS_TechType[16] = Control Magic
      • Set VariableSet PS_TechType[17] = Barrage
      • -------- --------
      • -------- Third Page --------
      • Set VariableSet PS_TechType[18] = Backpack (Human)
      • Set VariableSet PS_TechType[19] = Flak Cannons
      • Set VariableSet PS_TechType[20] = Fragmentation Shards
      • Set VariableSet PS_TechType[21] = Cloud
      • -------- --------
      • -------- STOP! You don't need to change anything else below this line. --------
      • -------- --------
      • -------- Some math to determine how many pages we will have in total: --------
      • Custom script: set udg_PS_PageCount = ((udg_PS_TechTypeCount + udg_PS_PageTechCount) - 1) / udg_PS_PageTechCount
      • -------- --------
      • -------- Disable any unit-types that don't belong on Page 1 (we also set the starting Page to 1): --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set VariableSet PS_Player = (Picked player)
          • Set VariableSet PS_CurrentPage[(Player number of PS_Player)] = 1
          • For each (Integer PS_Loop) from (PS_PageTechCount + 1) to PS_TechTypeCount, do (Actions)
            • Loop - Actions
              • Player - Set the max research level of PS_TechType[PS_Loop] to 0 for PS_Player
      • -------- --------
      • -------- A shortcut to help with our math in the Change Page trigger: --------
      • Set VariableSet PS_PageAdjustment = (PS_PageTechCount - 1)
  • PageSystem Change Page
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to More Researches [Channel]
          • (Ability being cast) Equal to Next Page (Page System)
          • (Ability being cast) Equal to Previous Page (Page System)
    • Actions
      • Set VariableSet PS_Player = (Owner of (Triggering unit))
      • Set VariableSet PS_PN = (Player number of PS_Player)
      • -------- --------
      • -------- Disable current page units: --------
      • For each (Integer PS_Loop) from ((PS_PageTechCount x PS_CurrentPage[PS_PN]) - PS_PageAdjustment) to (PS_PageTechCount x PS_CurrentPage[PS_PN]), do (Actions)
        • Loop - Actions
          • Player - Set the max research level of PS_TechType[PS_Loop] to 0 for PS_Player
      • -------- --------
      • -------- Adjust current page: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Next Page (Page System)
        • Then - Actions
          • Set VariableSet PS_CurrentPage[PS_PN] = (PS_CurrentPage[PS_PN] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PS_CurrentPage[PS_PN] Greater than PS_PageCount
            • Then - Actions
              • Set VariableSet PS_CurrentPage[PS_PN] = 1
            • Else - Actions
        • Else - Actions
          • Set VariableSet PS_CurrentPage[PS_PN] = (PS_CurrentPage[PS_PN] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PS_CurrentPage[PS_PN] Less than 1
            • Then - Actions
              • Set VariableSet PS_CurrentPage[PS_PN] = PS_PageCount
            • Else - Actions
      • -------- --------
      • -------- Enable NEW current page units: --------
      • For each (Integer PS_Loop) from ((PS_PageTechCount x PS_CurrentPage[PS_PN]) - PS_PageAdjustment) to (PS_PageTechCount x PS_CurrentPage[PS_PN]), do (Actions)
        • Loop - Actions
          • Player - Set the max research level of PS_TechType[PS_Loop] to 1 for PS_Player
 

Attachments

  • Page System 2.w3m
    20.9 KB · Views: 5

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Can I somehow define how many items I can display per page?!
For example first page can have 11 items, second page 8 items, third 5 items.
Yeah, you can redesign it to use a simple approach where you define your number of Pages and the Ranges of each Page yourself:
  • PageSystem Setup
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Define your total number of Pages: --------
      • Set VariableSet PS_PageCount = 3
      • -------- --------
      • -------- First Page --------
      • Set VariableSet PS_PageMinRange[1] = 1
      • Set VariableSet PS_PageMaxRange[1] = 10
      • Set VariableSet PS_TechType[1] = Iron Forged Swords
      • Set VariableSet PS_TechType[2] = Black Gunpowder
      • Set VariableSet PS_TechType[3] = Storm Hammers
      • Set VariableSet PS_TechType[4] = Iron Plating
      • Set VariableSet PS_TechType[5] = Flying Machine Bombs
      • Set VariableSet PS_TechType[6] = Improved Masonry
      • Set VariableSet PS_TechType[7] = Defend
      • Set VariableSet PS_TechType[8] = Animal War Training
      • Set VariableSet PS_TechType[9] = Priest Adept Training
      • Set VariableSet PS_TechType[10] = Sorceress Adept Training
      • -------- --------
      • -------- Second Page --------
      • Set VariableSet PS_PageMinRange[2] = 11
      • Set VariableSet PS_PageMaxRange[2] = 17
      • Set VariableSet PS_TechType[11] = Studded Leather Armor
      • Set VariableSet PS_TechType[12] = Long Rifles
      • Set VariableSet PS_TechType[13] = Improved Lumber Harvesting
      • Set VariableSet PS_TechType[14] = Magic Sentry
      • Set VariableSet PS_TechType[15] = Flare
      • Set VariableSet PS_TechType[16] = Control Magic
      • Set VariableSet PS_TechType[17] = Barrage
      • -------- --------
      • -------- Third Page --------
      • Set VariableSet PS_PageMinRange[3] = 18
      • Set VariableSet PS_PageMaxRange[3] = 21
      • Set VariableSet PS_TechType[18] = Backpack (Human)
      • Set VariableSet PS_TechType[19] = Flak Cannons
      • Set VariableSet PS_TechType[20] = Fragmentation Shards
      • Set VariableSet PS_TechType[21] = Cloud
      • -------- --------
      • -------- STOP! You don't need to change anything else below this line. --------
      • -------- --------
      • -------- Disable any unit-types that don't belong on Page 1 (we also set the starting Page to 1): --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set VariableSet PS_Player = (Picked player)
          • Set VariableSet PS_CurrentPage[(Player number of PS_Player)] = 1
          • For each (Integer PS_Loop) from PS_PageMinRange[2] to PS_PageMaxRange[PS_PageCount], do (Actions)
            • Loop - Actions
              • Player - Set the max research level of PS_TechType[PS_Loop] to 0 for PS_Player
  • PageSystem Change Page
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Next Page (Page System)
          • (Ability being cast) Equal to Previous Page (Page System)
    • Actions
      • Set VariableSet PS_Player = (Owner of (Triggering unit))
      • Set VariableSet PS_PN = (Player number of PS_Player)
      • -------- --------
      • -------- Disable current page units: --------
      • For each (Integer PS_Loop) from PS_PageMinRange[PS_CurrentPage[PS_PN]] to PS_PageMaxRange[PS_CurrentPage[PS_PN]], do (Actions)
        • Loop - Actions
          • Player - Set the max research level of PS_TechType[PS_Loop] to 0 for PS_Player
      • -------- --------
      • -------- Adjust current page: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Next Page (Page System)
        • Then - Actions
          • Set VariableSet PS_CurrentPage[PS_PN] = (PS_CurrentPage[PS_PN] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PS_CurrentPage[PS_PN] Greater than PS_PageCount
            • Then - Actions
              • Set VariableSet PS_CurrentPage[PS_PN] = 1
            • Else - Actions
        • Else - Actions
          • Set VariableSet PS_CurrentPage[PS_PN] = (PS_CurrentPage[PS_PN] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PS_CurrentPage[PS_PN] Less than 1
            • Then - Actions
              • Set VariableSet PS_CurrentPage[PS_PN] = PS_PageCount
            • Else - Actions
      • -------- --------
      • -------- Enable NEW current page units: --------
      • For each (Integer PS_Loop) from PS_PageMinRange[PS_CurrentPage[PS_PN]] to PS_PageMaxRange[PS_CurrentPage[PS_PN]], do (Actions)
        • Loop - Actions
          • Player - Set the max research level of PS_TechType[PS_Loop] to 1 for PS_Player
I got rid of your More Research ability since it doesn't play nice with the Change Page trigger. If you really need up to 11 items per Page then delete the Previous Page ability and modify the Next Page ability to act like More Research. Also, note my usage of the Art - Button positions of the Upgrades in order to keep things nice and organized.

Edit: Added Page System 4 UnitTypes map which is the same design but setup for UnitTypes.
 

Attachments

  • Page System 3.w3m
    20.4 KB · Views: 11
  • Page System 4 UnitTypes.w3m
    20.5 KB · Views: 9
Last edited:
Status
Not open for further replies.
Top