Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //Global namespaces
  3. o = {};
  4. o.tog = {};
  5. o.cond = {};
  6. tmp = {};
  7. tmp.arr = [];
  8.  
  9. //Function to get target from Nexus
  10. setTar = set => {
  11.   tar = get_variable("tar")
  12. };
  13.  
  14. //Action sequence namespaces
  15. prefix = [];
  16. action = [];
  17. suffix = [];
  18. string = "";
  19.  
  20. //Action manipulation functions
  21.  
  22. //Parse each array
  23. parsePrefix = (val, index) => {
  24.   if (typeof val == "object") {
  25.     prefix.splice(arg.join(sep), index, 0)
  26.   }
  27. };
  28.  
  29. parseAction = (val, index) => {
  30.   if (typeof val == "object") {
  31.     action.splice(arg.join(sep), index, 0)
  32.   }
  33. };
  34.  
  35. parseSuffix = (val, index) => {
  36.   if (typeof val == "object") {
  37.     suffix.splice(arg.join(sep), index, 0)
  38.   }
  39. };
  40.  
  41. parseConditions = (val, index, array) => {
  42.   if (o.cond[val]) { removeItem(val, array) }
  43. };
  44.  
  45.  
  46. //Pre-process each array
  47. processPrefix = () => {
  48.   if (o.tog.get_gold) {
  49.     addItem("put money in pack")
  50.     addItem("get money")
  51.   } else {
  52.     removeItem("get money", prefix)
  53.     removeItem("put money in pack", prefix)
  54.   }
  55.  
  56.   addItem("light pipes", prefix)
  57.   addItem("stand", prefix)
  58.   addItem("stand", prefix)
  59.  
  60.   prefix.forEach(parsePrefix)
  61. };
  62.  
  63. processAction = () => {
  64.   action.forEach(parseAction)
  65.   action.forEach(parseConditions)
  66. };
  67.  
  68. processSuffix = () => {
  69.   suffix.forEach(parseSuffix)
  70. };
  71.  
  72. //Send the entire block
  73. sendAction = () => {
  74.   //Pre-processing functions
  75.   processPrefix()
  76.   processAction()
  77.   processSuffix()
  78.  
  79.   //Handle first action in action list
  80.   var act = []
  81.   act.push(action[0])
  82.    
  83.   //Combine prefix, action, and suffix and send
  84.   var combined = prefix.concat(act, suffix)
  85.   combined = combined.join(sep)
  86.   sent = combined
  87.   send_command("queue addclear eqbal " + combined)
  88. };
  89.  
  90. //Repeat the current block
  91. repeatAction = q => {
  92.   if (o.tog.repeat==true && stop.repeat!=true) {
  93.     sendAction(q);
  94.     stop.on("repeat", 1000)
  95.   } else {
  96.     return
  97.   }
  98. };
  99.  
  100. //Used to listen and unlisten condition triggers for an action
  101. listenCondition = name => {
  102.   var name = "condition_" + name
  103.   var reflex = reflex_find_by_name("group", name, true, false)
  104.   reflex_enable(reflex)
  105. };
  106.  
  107. unlistenCondition = name => {
  108.   var name = "condition_" + name
  109.   var reflex = reflex_find_by_name("group", name, true, false)
  110.   reflex_disable(reflex)
  111. };
  112.  
  113. //Toggle manipulation
  114. tog = (arg, val) => {
  115.   if (val===true || val===false) {
  116.     o.tog[arg] = val
  117.   } else if (o.tog[arg]==true) {
  118.     o.tog[arg] = false
  119.   } else {
  120.     o.tog[arg] = true
  121.   }
  122.   print(o.tog[arg])
  123. };
  124.  
  125. //Condition manipulation
  126. cond = (arg, val) => {
  127.   if (val===true || val===false) {
  128.     o.cond[arg] = val
  129.   } else if (o.cond[arg]==true) {
  130.     o.cond[arg] = false
  131.   } else {
  132.     o.cond[arg] = true
  133.   }
  134. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement