Guest User

Untitled

a guest
Mar 11th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function widget:GetInfo()
  2.   return {
  3.     name      = "Shortmarkers",
  4.     desc      = "Shirtkeys 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]="raiders",
  19.         [KEYSYMS.N_2]="push",
  20.         [KEYSYMS.N_3]="back",
  21.         [KEYSYMS.N_4]="too many aa",
  22.         [KEYSYMS.N_5]="help",
  23.         [KEYSYMS.N_6]="Reinforce the front line",
  24.         [KEYSYMS.N_7]="Into the motherland\nThe Robot's army march",
  25.         [KEYSYMS.N_8]="It's time has come to an end\nThe end of an era is here\nIt's time to attack!",
  26.         [KEYSYMS.N_9]="Banana wrath unleashed!",
  27.         [KEYSYMS.N_0]="Send in all the reserves\nSecuring their defeat",
  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