AFRLme

Slide Out Any Interface (deponia style) [VS] (works)

Jan 4th, 2013
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.34 KB | None | 0 0
  1. --[[
  2. Slide out any interface (deponia style)
  3. incremental slide version ...
  4. scripted & annotated by AFRLme
  5. -- * --
  6. dropped!
  7. --]]
  8.  
  9. --[[ global getObject variable; used for getting & setting current interface position!
  10. replace "inventory" with whatever your interface is called! --]]
  11. local get_interface = getObject('Interfaces[inventory]')
  12.  
  13. --[[ global values containing the minimum, maximum & current offset values!
  14. replace min_offset x,y with the default absolute position you set in the interface to be used for sliding
  15. replace max_offset x,y with the x,y position you want the interface to slide to! --]]
  16. local min_offset = {x = -350, y = 240}
  17. local max_offset = {x = -20, y = 240}
  18. local check_offset = get_interface:getPoint(VInterfaceOffset)
  19.  
  20. -- * this is the main loop which checks if the interface needs to slide out/in or stay in the current position! * --
  21. function OnMainLoop()
  22.  --[[ check condition equals true false to decide if interface should slide out or in on hover!
  23. replace "mwheel?" & "slide?" with whatever you named the conditions! --]]
  24.  local mwheel = getObject('Conditions[mwheel?]'):getBool(VConditionValue)
  25.  local canSlide = getObject('Conditions[slide?]'):getBool(VConditionValue)
  26.  if mwheel == false then
  27.   if canSlide then
  28.    -- * check if x equals less than max offset; if not then x = x + 2 else x = max offset! * --
  29.    if check_offset.x < max_offset.x then check_offset.x = check_offset.x + 2 end
  30.    if check_offset.x > max_offset.x then check_offset.x = max_offset.x end
  31.    -- * check if y equals less than max offset; if not then y = y + 2 else y = max offset! * --
  32.    if check_offset.y < max_offset.y then check_offset.y = check_offset.y + 2 end
  33.    if check_offset.y > max_offset.y then check_offset.y = max_offset.y end
  34.   else
  35.    -- * check if x equals more than min offset; if not then x = x - 2 else x = min offset! * --
  36.    if check_offset.x > min_offset.x then check_offset.x = check_offset.x - 2 end
  37.    if check_offset.x < min_offset.x then check_offset.x = min_offset.x end
  38.    -- * check if y equals more than min offset; if not then y = y - 2 else y = min offset! * --
  39.    if check_offset.y > min_offset.y then check_offset.y = check_offset.y - 2 end
  40.    if check_offset.y < min_offset.y then check_offset.y = min_offset.y end
  41.   end
  42.   -- * updates the current position of the interface * --
  43.   get_interface:setValue(VInterfaceOffset, check_offset)  
  44.  end
  45. end
  46.  
  47. -- * slides the interface back in on mouse wheel up if condition mwheel? equals true! * --
  48. function OnMwUp()
  49.  -- * check if x equals more than min offset; if not then x = x - 10 else x = min offset! * --
  50.  if check_offset.x > min_offset.x then check_offset.x = check_offset.x - 10 end
  51.  if check_offset.x < min_offset.x then check_offset.x = min_offset.x end
  52.  -- * check if y equals more than min offset; if not then y = y - 10 else y = min offset! * --
  53.  if check_offset.y > min_offset.y then check_offset.y = check_offset.y - 10 end
  54.  if check_offset.y < min_offset.y then check_offset.y = min_offset.y end
  55.  -- * updates the current position of the interface * --
  56.  get_interface:setValue(VInterfaceOffset, check_offset)
  57. end
  58.  
  59. -- * slides the interface out on mouse wheel down if condition mwheel? equals true! * --
  60. function OnMwDown()
  61.  -- * check if x equals less than max offset; if not then x = x + 10 else x = max offset! * --
  62.  if check_offset.x < max_offset.x then check_offset.x = check_offset.x + 10 end
  63.  if check_offset.x > max_offset.x then check_offset.x = max_offset.x end
  64.  -- * check if y equals less than max offset; if not then y = y + 10 else y = max offset! * --
  65.  if check_offset.y < max_offset.y then check_offset.y = check_offset.y + 10 end
  66.  if check_offset.y > max_offset.y then check_offset.y = max_offset.y end
  67.  -- * updates the current position of the interface * --
  68.  get_interface:setValue(VInterfaceOffset, check_offset)
  69. end
  70.  
  71. function OnMouseEvent(eventType)
  72.  local mwheel = getObject('Conditions[mwheel?]'):getBool(VConditionValue)
  73.  if mwheel then
  74.   if eventType == eEvtMouseWheelUp then OnMwUp() end
  75.   if eventType == eEvtMouseWheelDown then OnMwDown() end
  76.  end
  77. end
  78.  
  79. -- * let's create the mouse event listener! * --
  80. registerEventHandler('mouseEvent', 'OnMouseEvent', {eEvtMouseWheelUp, eEvtMouseWheelDown})
  81. -- * let's create the loop to check if the interface is in the correct position! * --
  82. registerEventHandler('mainLoop', 'OnMainLoop')
Advertisement
Add Comment
Please, Sign In to add comment