Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.29 KB | None | 0 0
  1. local x,y = guiGetScreenSize()
  2.  
  3. function isCursorOnElement(x,y,w,h)
  4.     if isCursorShowing() then
  5.     local mx,my = getCursorPosition()
  6.     local fullx,fully = guiGetScreenSize()
  7.     cursorx,cursory = mx*fullx,my*fully
  8.         if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
  9.             return true
  10.         else
  11.             return false
  12.         end
  13.     end
  14. end
  15.  
  16.  
  17. function dxSetVisible( element, state )
  18.     if ( element ) then
  19.         element.activ = state;
  20.     else
  21.         return outputDebugString("Failed setVisible dxElement!");
  22.     end
  23. end
  24.  
  25. function dxGetVisible( element )
  26.     if ( element ) then
  27.         return(element.activ);
  28.     else
  29.         return outputDebugString("Failed getVisible dxElement!");
  30.     end
  31. end
  32.  
  33. function dxGetText( element )
  34.     if ( element ) then
  35.         return tostring(element.text);
  36.     else
  37.         return outputDebugString("Failed getText dxElement!");
  38.     end
  39. end
  40.  
  41. function dxSetText( element, text )
  42.     if ( element ) then
  43.         element.text = tostring(text)
  44.     else
  45.         return outputDebugString("Failed setText dxElement!");
  46.     end
  47. end
  48.  
  49. function dxGetPosition( element, relativ )
  50.     if ( element ) then
  51.         if ( relativ ) then
  52.             local rX, rY = element.x/100, element.y/100; -- Die genaue berechnung kenne ich nicht mehr.
  53.             return rX, rY;
  54.         else
  55.             return element.x, element.y;
  56.         end
  57.     else
  58.         return outputDebugString("Failed getPosition dxElement!");
  59.     end
  60. end
  61.  
  62. function dxSetPosition( element, rx, ry, relativ )
  63.     if ( element ) and ( rx ) and ( ry ) then
  64.         element.x = rx
  65.         element.y = ry
  66.     else
  67.         return outputDebugString("Failed setPosition dxElement!");
  68.     end
  69. end
  70.  
  71. function dxGetSize( element )
  72.     if ( element ) then
  73.         return element.w, element.h;
  74.     else
  75.         return outputDebugString("Failed getSize dxElement!");
  76.     end
  77. end
  78.  
  79. function dxSetSize( element, rw, rh )
  80.     if ( element ) and ( rw ) and ( rh ) then
  81.         element.w = rw;
  82.         element.h = rh;
  83.     else
  84.         return outputDebugString("Failed setSize dxElement!");
  85.     end
  86. end
  87.  
  88. function dxSetColor( element, r, g, b )
  89.     if ( element ) and ( r ) and ( g ) and ( b ) then
  90.         element.r = r;
  91.         element.g = g;
  92.         element.b = b;
  93.     else
  94.         return outputDebugString("Failed setColor dxElement!");
  95.     end
  96. end
  97.  
  98. function dxSetAlpha( element, newalpha )
  99.     if ( element ) and ( newalpha ) then
  100.         element.alpha = newalpha
  101.     else
  102.         return outputDebugString("Failed setAlpha dxElement!");
  103.     end
  104. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement