Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. function widget:GetInfo()
  2.   return {
  3.     name      = "Shortmarkers",
  4.     desc      = "Shortkeys for markers",
  5.     author    = "banana_Ai",
  6.     date      = "11 March 2014",
  7.     license   = "GNU GPL, v2 or later",
  8.     layer     = 0,
  9.     enabled   = true,
  10.   }
  11. end
  12.  
  13. include("keysym.h.lua")
  14.  
  15. local activation_key=KEYSYMS.Z
  16.  
  17. local texts={
  18.         [KEYSYMS.N_1]="enemies incoming!",
  19.         [KEYSYMS.N_2]="push now!",
  20.         [KEYSYMS.N_3]="back! retreat fast!",
  21.         [KEYSYMS.N_4]="too much Anti-Air!",
  22.         [KEYSYMS.N_5]="help here fast!",
  23.         [KEYSYMS.N_6]="Reinforce the front line. NOW.",
  24.         [KEYSYMS.N_7]="Connect Eco/Grid!",
  25.         [KEYSYMS.N_8]="Wait for me. lets attack together.",
  26.         [KEYSYMS.N_9]="Valuable target to attack/bomb.",
  27.         [KEYSYMS.N_0]="This is doomed to fail. Please stop.",
  28.     }
  29.  
  30. local function getText()
  31.     for key,text in pairs(texts) do
  32.         if Spring.GetKeyState(key) then
  33.             return text
  34.         end
  35.     end
  36.     return nil
  37. end
  38.  
  39. function widget:MousePress(x,y,button)
  40.     if Spring.GetKeyState(activation_key) then
  41.         local txt=getText()
  42.         if txt then
  43.             local _,pos=Spring.TraceScreenRay(x,y,true)
  44.             Spring.MarkerAddPoint(pos[1],pos[2],pos[3],txt,false)
  45.         end
  46.     end
  47. end
  48.  
  49. function widget:DrawWorld()
  50.     if Spring.GetKeyState(activation_key) then
  51.         local txt=getText()
  52.         if txt then
  53.             local mx,my=Spring.GetMouseState()
  54.             local _,pos=Spring.TraceScreenRay(mx,my,true)
  55.             gl.PushMatrix()
  56.             gl.Translate(pos[1],pos[2],pos[3])
  57.             gl.Billboard()         
  58.             gl.Text(txt,10,20,18,"cvo")
  59.             gl.PopMatrix()
  60.         end
  61.     end
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement