Advertisement
blurose

[hgss] berry tree dynamic menu excerpt

Sep 23rd, 2022 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. RESULT_NEXT_PAGE equ 100
  2. RESULT_PREVIOUS_PAGE equ 101
  3. RESULT_CANCEL equ 102
  4.  
  5. VAR_BERRY_ID equ VAR_SPECIAL_x8001
  6. VAR_ENTRIES equ VAR_SPECIAL_x8002
  7. VAR_PAGE equ VAR_SPECIAL_x8003
  8. VAR_UPPER_LIMIT_PG0 equ VAR_SPECIAL_x8007
  9. VAR_UPPER_LIMIT_PG1 equ VAR_SPECIAL_x8008
  10.  
  11.  
  12. // script for the berry trees
  13. scr_seq_0003_072_BerryTree:
  14. // ... _plantberryinit starts the menu
  15.  
  16.  
  17. _plantberryinit:
  18. setvar VAR_PAGE, 0 // initial page
  19.  
  20. _plantberry:
  21. swap_out_list_std // custom script command to swap the text bank that the list pulls from
  22. // create berry menu, store result in VAR_SPECIAL_x8004
  23. prepare_list_std_text 1, 1, 0, 1, VAR_SPECIAL_x8004
  24. compare VAR_PAGE, 1
  25. goto_if_eq _page1
  26. compare VAR_PAGE, 2
  27. goto_if_eq _page2
  28. _page0:
  29. setvar VAR_BERRY_ID, 0
  30. goto _afterPages
  31. _page1:
  32. copyvar VAR_BERRY_ID, VAR_UPPER_LIMIT_PG0
  33. goto _afterPages
  34. _page2:
  35. copyvar VAR_BERRY_ID, VAR_UPPER_LIMIT_PG1
  36. //goto _afterPages
  37. _afterPages:
  38. setvar VAR_ENTRIES, 0 // actual entries printed on the page
  39.  
  40. _loopMenuIncrement:
  41. convert_var_between_berry_ids VAR_BERRY_ID // convert to berry item, custom script command
  42. hasitem VAR_BERRY_ID, 1, VAR_SPECIAL_RESULT
  43. convert_var_between_berry_ids VAR_BERRY_ID // convert back to berryid, custom script command
  44.  
  45. compare VAR_SPECIAL_RESULT, 0
  46. goto_if_eq _skipAdd
  47.  
  48. add_list_option VAR_BERRY_ID, 64, VAR_BERRY_ID // berry id corresponds with text entry in the new text bank. all have a blurb that is entry 64
  49. addvar VAR_ENTRIES, 1 // increment amount of entries shown
  50.  
  51. _skipAdd:
  52. addvar VAR_BERRY_ID, 1
  53. compare VAR_PAGE, 0
  54. goto_if_ne _skipIncPg0Up
  55. copyvar VAR_UPPER_LIMIT_PG0, VAR_BERRY_ID
  56. _skipIncPg0Up:
  57. compare VAR_PAGE, 1
  58. goto_if_ne _skipIncPg1Up
  59. copyvar VAR_UPPER_LIMIT_PG1, VAR_BERRY_ID
  60. _skipIncPg1Up:
  61. compare VAR_BERRY_ID, NUM_OF_BERRIES
  62. goto_if_eq _skipNext // if the last possible berry is encountered, skip the rest of the menu creation and printing next to just print previous if possible
  63. compare VAR_ENTRIES, 25 // entries per page
  64. goto_if_ne _loopMenuIncrement
  65.  
  66. _printLastOptions:
  67. compare VAR_PAGE, 2
  68. goto_if_eq _skipNext
  69. add_list_option 66, 68, RESULT_NEXT_PAGE // add next
  70. _skipNext:
  71. compare VAR_PAGE, 0
  72. goto_if_eq _skipPrevious
  73. add_list_option 65, 69, RESULT_PREVIOUS_PAGE // add previous if required
  74. _skipPrevious:
  75. add_list_option 67, 70, RESULT_CANCEL // add cancel after the above
  76. _showlist:
  77. show_prepared_list
  78. swap_out_list_std // revert the above swap
  79.  
  80. // handle page inputs
  81.  
  82.  
  83. compare VAR_SPECIAL_x8004, RESULT_NEXT_PAGE
  84. goto_if_eq _incrementPage
  85. compare VAR_SPECIAL_x8004, RESULT_PREVIOUS_PAGE
  86. goto_if_eq _decrementPage
  87. compare VAR_SPECIAL_x8004, RESULT_CANCEL
  88. goto_if_eq _endPlant
  89. compare VAR_SPECIAL_x8004, 0xFFFE // the "final slot"
  90. goto_if_eq _endPlant
  91.  
  92. closemsg
  93.  
  94. // ... update berry when planted
  95.  
  96. _endPlant:
  97. closemsg
  98. endstd
  99. end
  100.  
  101. _incrementPage:
  102. addvar VAR_PAGE, 1
  103. goto _plantberry
  104. _decrementPage:
  105. subvar VAR_PAGE, 1
  106. goto _plantberry
  107. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement