Advertisement
Guest User

Pre-envenoming tracker

a guest
Sep 14th, 2014
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. Script name: CommandInput
  2. Event: sysDataSendRequest
  3. Code:
  4.  
  5. pendingVenoms = pendingVenoms or {}
  6. venoms = venoms or {
  7. left = {},
  8. right = {}
  9. }
  10.  
  11. function CommandInput(_, command)
  12. if string.find(command, "envenom %a+ with %a+") then
  13. local weapon = string.match(command, "envenom (%a+)")
  14. local venom = string.match(command, "with (%a+)")
  15. -- TODO: convert item numbers into left/right based on wielded tracking? Will the %a+ pattern work for an actual number?
  16. table.insert(pendingVenoms, {
  17. hand = weapon,
  18. venom = venom
  19. })
  20. end
  21. end
  22.  
  23. function handlePendingVenom(venom)
  24. local pendingVenom = pendingVenoms[1]
  25. if not pendingVenom then
  26. return
  27. end
  28. table.remove(pendingVenoms, 1)
  29. if pendingVenom.venom ~= venom then
  30. -- something went wrong, likely stupidity or aeon caused this command to not be sent so we'll look at the next one
  31. -- Note: won't handle combinations with the same venom that get screwed up
  32. handlePendingVenom(venom)
  33. else
  34. table.insert(venoms[pendingVenom.hand], 1, pendingVenom.venom)
  35. end
  36. end
  37.  
  38. Trigger name: Envenom
  39. Perl regex: ^You rub some (\w+) on .+\.$
  40. Line spacer: 1
  41. Lua function: return isPrompt()
  42. Multiline / AND: Yes
  43. Line delta: 1
  44. Code: handlePendingVenom(multimatches[1][2])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement