Advertisement
Stoikiti

Untitled

Apr 13th, 2024
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. function widget:GetInfo()
  2.     return {
  3.       name = "repeat repeat orders",
  4.       desc = "a way to keep track of multiple sets of repeat orders and cycling through them",
  5.       author = "zombean",
  6.       date = "2024",
  7.       license = "GNU GPL, v2 or later",
  8.       layer = 0,
  9.       enabled = true
  10.     }
  11. end
  12.  
  13. local repeat_orders = {}
  14. local mode_activated = false
  15. local activate_mode_key = 420
  16. local go_to_next_repeat_key = 421
  17.  
  18. function widget:KeyPress(keyCode, mods, label, utf32char, scanCode, actionList)
  19.   if #actionList then return end -- do nothing if engine has actions for these key pressed
  20. end
  21.  
  22. function widget:KeyRelease(keyCode, mods, label, utf32char, scanCode, actionList)
  23.   if #actionList then return end -- do nothing if engine has actions for these key pressed
  24. end
  25.  
  26. function widget:UnitCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, options, cmdTag)
  27.   --if not on repeat orders return
  28. end
  29.  
  30. function widget:UnitDestroyed(unitID)
  31.   if repeat_orders[unitID] then
  32.     repeat_orders[unitID] = {}
  33.   end
  34. end
  35.  
  36. function widget:UnitTaken(unitIT)
  37.   if repeat_orders[unitID] then
  38.     repeat_orders[unitID] = {}
  39.   end
  40. end
  41.  
  42. function widget:UnitGiven(unitIT)
  43.   if repeat_orders[unitID] then
  44.     repeat_orders[unitID] = {}
  45.   end
  46. end
  47.  
  48. local millis_start_timer = Spring.GetTimer()
  49. local function millis()
  50.   return math.ceil(Spring.DiffTimers(Spring.GetTimer(), millis_start_timer) * 1000)
  51. end
  52.  
  53. local next_call = 0
  54.  
  55. function widget:Update()
  56.   local now_time = millis()
  57.   if next_call > now_time then return end
  58.   next_call = now_time + 1000
  59.   Spring.Echo(os.date("%H:%M:%S:%MS"), mode_activated)
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement