Vamperica

DR Setup

Sep 3rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Geniehunter Globals Setup Menu
  2.  
  3. # This script is designed to facilitate the initial setup for Geniehunter.
  4. # The options below are for setting the initial global variables needed
  5. # for basic functions such as: spell casting, ammo collection, box storage
  6. # gem storage and weapon sheathes.
  7. # It it *strongly recommended* [but not required] that you set a value for
  8. # every item, even if you do not currently utilize it. This is to ensure
  9. # that the necessary values are in place in case you decide to utilize them
  10. # in the future.
  11. #
  12.  
  13. #debug 10
  14.  
  15. Setup:
  16.         var MAIN Settables|Done
  17.         var SETTABLES Bow Ammo|Crossbow Ammo|Sling Ammo|Quiver|LT Sheath|HT Sheath|Box Container|Gem Container|Junk Container|Default Container|Pouch Container|Prep Message|Main Cambrinth|Second Cambrinth|Ritual Focus|Focus Container|Ritual Stance|Back
  18.         var GLOBALS GH_CONTAINER_BOW_AMMO|GH_CONTAINER_XB_AMMO|GH_CONTAINER_SLING_AMMO|GH_CONTAINER_QUIVER|GH_CONTAINER_LT_SHEATH|GH_CONTAINER_HT_SHEATH|GH_CONTAINER_BOX_CONTAINER|GH_CONTAINER_GEM_CONTAINER|GH_CONTAINER_JUNK_CONTAINER|GH_CONTAINER_DEFAULT_CONTAINER|GH_CONTAINER_POUCH_CONTAINER|PREP_MESSAGE|cambrinth|secondcambrinth|focusr|focusc|rstance
  19.         var DESCS your bow ammo (for example, arrow)|your crossbow ammo (for example, bolt)|your sling ammo (for example, rock)|the container where you store ammunition|the container where you store LT weapons|the container where you store HT weapons|the container where you store boxes|the container where you store gems|the container where you store junk|your default container (for example, pack)|the container where you store pouches|Your spell preparation messaging. (Use the full, exact messaging up to the spell name.)|your primary cambrinth item|your secondary cambrinth item|the item you use to cast ritual spells|If your focus is worn, set as WORN. Otherwise, set as the container where it's stored.|Your best defensive stance to use during ritual spells. Set as all numbers: [EVASION #] [PARRY #] [SHIELD #] [ATTACK #]
  20.         var MENU_WINDOW Geniehunter Menu
  21.         put #var selection MAIN
  22.  
  23.         pause 1
  24.         echo
  25.         echo ################
  26.         put #echo yellow All typed user input MUST be preceded by tilde (~) character.
  27.         echo ################
  28.  
  29. MenuDisplay:
  30.         var last.selection $selection
  31.         counter set 0
  32.         pause 0.3
  33.         gosub Menu.Build "%$selection" "selection" "continue.script" "" "%MENU_WINDOW"
  34.         waitforre continue.script
  35.         put #var selection {#eval toupper("$selection")}
  36.         if $selection = BACK then
  37.             {
  38.             put #var selection MAIN
  39.             goto MenuDisplay
  40.             }
  41.         if $selection = DONE then gosub Finish
  42.         if ($selection = SETTABLES) then goto MenuDisplay
  43.         gosub array.match "%SETTABLES" "%GLOBALS" "$selection" "this.global"
  44.         gosub array.match "%SETTABLES" "%DESCS" "$selection" "this.desc"
  45.         gosub GlobalSet "%this.global" "%this.desc"
  46.  
  47. Finish:
  48.         echo Globals set. Saving...
  49.         put #var save
  50.         echo Globals saved. Exiting.
  51.         put #window close "%this.window"
  52.         exit
  53.  
  54. exit
  55.  
  56. Menu.Build:
  57. ##Menu Building Routine
  58. ##Function - Builds a numbered menu of options in link format that saves option information into a variable.
  59. ##pre - First parameter must be an array of the option names/values. Second parameter is the name of the
  60. ##  target global variable to store the result of the link click. Third parameyer is a string
  61. ##  that will be parsed to continue the script after the menu item has been selected. Fourth parameter
  62. ##  is a string or array of items that are exceptions to be excluded from the menu list. Fifth parameter is a
  63. ##  window name to echo output to (leave out to echo to Game window).
  64. ##post - Value of clicked link is stored in target global variable.
  65.  
  66.         action (input) var input $1;put #parse input.done when ~(.*)
  67.  
  68.         if !%c then
  69.                 {
  70.                 var this.array $1
  71.                 var target.variable $2
  72.                 var script.trigger $3
  73.                 var exceptions $4
  74.                 if !($5 = "") then
  75.                         {
  76.                         var this.window $5
  77.                         put #window add "%this.window"
  78.                         put #window open "%this.window"
  79.                         put #clear %this.window
  80.                         send #echo ">%this.window" cyan $selection Menu
  81.                         send #echo ">%this.window"
  82.                         }
  83.                 else var this.window Game
  84.                 var this.option 0
  85.                 eval array.length count("%this.array","|")
  86.                 }
  87.         if %c > %array.length then
  88.                 {
  89.                 var this.option 0
  90.                 counter set 0
  91.                 return
  92.                 }
  93.         var this.choice %this.array(%c)
  94.         if matchre("%exceptions","%this.choice") then
  95.                 {
  96.                 counter add 1
  97.                 goto menu.build
  98.                 }
  99.         counter add 1
  100.         math this.option add 1
  101.         send #link ">%this.window" "%this.option. - %this.choice" "#var %target.variable %this.choice;#parse %script.trigger"
  102.         goto menu.build
  103.  
  104. GlobalSet:
  105.         put #clear "%this.window"
  106.         var this.global $1
  107.         var extra_message $2
  108.         action (input) on
  109.         if matchre("$selection", "%TOGGLES") then goto TOGGLE
  110.         if !(%extra_message = "") then put #echo ">%this.window" cyan %extra_message
  111.         put #echo ">%this.window" cyan Enter value for $selection:
  112.         waitforre input.done
  113.         put #var %this.global %input
  114.         action (input) off
  115.         put #clear "%this.window"
  116.         put #echo ">%this.window" cyan $selection has been set to: %input
  117.         put #echo ">%this.window"
  118.         send #link ">%this.window" "Click to continue..." "#parse %script.trigger"
  119.         waitforre %script.trigger
  120.         put #var selection %last.selection
  121.         gosub clear
  122.         goto MenuDisplay
  123.  
  124. array.match:
  125.     var this.array $1
  126.     var that.array $2
  127.     var search.str $3
  128.     var result.str $4
  129.     eval this.array tolower("%this.array")
  130.     eval this.array replacere("%this.array", "\(|\)", "")
  131.     eval search.str tolower("%search.str")
  132.     if !matchre("%this.array", "(.*(?:\||^)%search.str)(?:\||$)") then
  133.         {
  134.         var %result.str Null
  135.         echo String %search.str does not exist in array.
  136.         }
  137.     else
  138.         {
  139.         var substring_element $1
  140.         eval array.index count("%substring_element","|")
  141.         var %result.str %that.array(%array.index)
  142.         }
  143.     return
Add Comment
Please, Sign In to add comment