Advertisement
AFRLme

Slide Out Any Interface [VS] (works)

Jan 2nd, 2013
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.33 KB | None | 0 0
  1. --[[
  2. Slide out any interface (hover only)
  3. scripted & annotated by AFRLme
  4. -- * --
  5. dropped!
  6. --]]
  7.  
  8. --[[ global getObject variable; used for getting & setting current interface position!
  9. replace "inventory" with whatever your interface is called! --]]
  10. local get_interface = getObject('Interfaces[inventory]')
  11.  
  12. --[[ global values containing the minimum, maximum & current offset values!
  13. replace min_offset x,y with the default absolute position you set in the interface to be used for sliding
  14. replace max_offset x,y with the x,y position you want the interface to slide to! --]]
  15. local min_offset = {x = -350, y = 240}
  16. local max_offset = {x = -20, y = 240}
  17. local check_offset = get_interface:getPoint(VInterfaceOffset)
  18.  
  19. -- * this is the main loop which checks if the interface needs to slide out/in or stay in the current position! * --
  20. function OnMainLoop()
  21.  --[[ check condition equals true false to decide if interface should slide out or in!
  22. replace "slide?" with whatever you name the condition! --]]
  23.  local cond = getObject('Conditions[slide?]'):getBool(VConditionValue)
  24.  if cond then
  25.   -- * check if x equals less than max offset; if not then x = x + 2 else x = max offset! * --
  26.   if check_offset.x < max_offset.x then check_offset.x = check_offset.x + 2 end
  27.   if check_offset.x > max_offset.x then check_offset.x = max_offset.x end
  28.   -- * check if y equals less than max offset; if not then y = y + 2 else y = max offset! * --
  29.   if check_offset.y < max_offset.y then check_offset.y = check_offset.y + 2 end
  30.   if check_offset.y > max_offset.y then check_offset.y = max_offset.y end
  31.  else
  32.   -- check if x equals more than min offset; if not then x = x - 2 else x = min offset! * --
  33.   if check_offset.x > min_offset.x then check_offset.x = check_offset.x - 2 end
  34.   if check_offset.x < min_offset.x then check_offset.x = min_offset.x end
  35.   -- check if y equals more than min offset; if not then y = y - 2 else y = min offset! * --
  36.   if check_offset.y > min_offset.y then check_offset.y = check_offset.y - 2 end
  37.   if check_offset.y < min_offset.y then check_offset.y = min_offset.y end
  38.  end
  39.  -- * updates the current position of the interface * --
  40.  get_interface:setValue(VInterfaceOffset, check_offset)
  41. end
  42.  
  43. -- * let's create the loop to check if the interface is in the correct position! * --
  44. registerEventHandler("mainLoop", "OnMainLoop")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement