Advertisement
Guest User

Untitled

a guest
Apr 9th, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.33 KB | None | 0 0
  1. createObject(1999, 93, 1047.25793, 12.6, 0, 0, 180)
  2.  
  3. local width, height = 1600, 900
  4. local cursorX, cursorY = width/2, height/2
  5.  
  6. -- Create the browser
  7. local webBrowser = createBrowser(width, height)
  8.  
  9. -- There is an issue with alpha at the moment --> render everything into a renderTarget first
  10. local renderTarget = dxCreateRenderTarget(width, height, true)
  11.  
  12. -- Request the pages
  13. requestBrowserPages({"www.youtube.com", "nyan.cat"})
  14.  
  15. addEventHandler("onClientRender", root,
  16.     function()
  17.         -- Update pixel data
  18.         updateBrowser(webBrowser)
  19.  
  20.         -- Switch to the rendertarget (@issue above)
  21.         dxSetRenderTarget(renderTarget)
  22.         dxDrawImage(0, 0, width, height, webBrowser)
  23.         dxDrawImage(cursorX, cursorY, 50, 50, "cursor.png")
  24.         dxSetRenderTarget()
  25.  
  26.         -- Draw the line
  27.         local x, y = 110.7, 1024.15
  28.         dxDrawMaterialLine3D(x, y, 23.25, x, y, 14.75, renderTarget, 18.2, tocolor(255, 255, 255, 255), x, y+1, 19)
  29.         x, y = 92.025, 1047.38
  30.         dxDrawMaterialLine3D(x, y, 13.83, x, y, 13.47, renderTarget, 0.43, tocolor(255, 255, 255, 255), x, y+1, 19)
  31.     end
  32. )
  33.  
  34. addCommandHandler("nyan",
  35.     function()
  36.         outputChatBox("Nyan!")
  37.         loadBrowserURL(webBrowser, "http://nyan.cat")
  38.     end
  39. )
  40.  
  41. addCommandHandler("url",
  42.     function(cmd, url)
  43.         if not url then return end
  44.        
  45.         requestBrowserPages({url})
  46.         outputChatBox("Opening: "..url)
  47.         loadBrowserURL(webBrowser, url)
  48.     end
  49. )
  50.  
  51. addCommandHandler("left",
  52.     function(cmd,dist)
  53.         cursorX = cursorX - (dist or 10)
  54.         if cursorX < 0 then
  55.             cursorX = 0
  56.         end
  57.         injectBrowserMouseMove(webBrowser, cursorX, cursorY)
  58.     end
  59. )
  60.  
  61. addCommandHandler("right",
  62.     function(cmd,dist)
  63.         cursorX = cursorX + (dist or 10)
  64.         if cursorX > width then
  65.             cursorX = width
  66.         end
  67.         injectBrowserMouseMove(webBrowser, cursorX, cursorY)
  68.     end
  69. )
  70.  
  71. addCommandHandler("up",
  72.     function(cmd,dist)
  73.         cursorY = cursorY - (dist or 10)
  74.         if cursorY < 0 then
  75.             cursorY = 0
  76.         end
  77.         injectBrowserMouseMove(webBrowser, cursorX, cursorY)
  78.     end
  79. )
  80.  
  81. addCommandHandler("down",
  82.     function(cmd,dist)
  83.         cursorY = cursorY + (dist or 10)
  84.         if cursorY > height then
  85.             cursorY = height
  86.         end
  87.         injectBrowserMouseMove(webBrowser, cursorX, cursorY)
  88.     end
  89. )
  90.  
  91. addCommandHandler("click",
  92.     function()
  93.         injectBrowserMouseMove(webBrowser, cursorX, cursorY)
  94.         injectBrowserMouseDown(webBrowser, 0)
  95.         injectBrowserMouseUp(webBrowser, 0)
  96.     end
  97. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement