AFRLme

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

Jan 6th, 2013
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.40 KB | None | 0 0
  1. --[[
  2. slide out any interface (deponia style)
  3. automatic slide version ...
  4. scripted & annotated by AFRLme
  5. -- * --
  6. antiquated (please use the new latest version[v2])
  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. -- * global integer variable default value for checking if mouse wheel is up, down or nil! * --
  21. local mwUp = 0
  22.  
  23. -- * this is the main loop which checks if the interface needs to slide out/in or stay in the current position! * --
  24. function OnMainLoop()
  25.  --[[ check condition equals true false to decide if interface should slide out or in on hover!
  26.  replace "mwheel?" & "slide?" with whatever you named the conditions! --]]
  27.  local mwheel = getObject('Conditions[mwheel?]'):getBool(VConditionValue)
  28.  local canSlide = getObject('Conditions[slide?]'):getBool(VConditionValue)
  29.  -- * begin on hover code * --
  30.  if not mwheel then
  31.   -- * check if mwUp equals default value if not then mwUp equals default value * --
  32.   if mwUp ~= 0 then mwUp = 0 end
  33.   if canSlide then
  34.    -- * check if x equals less than max offset; if not then x = x + 2 else x = max offset! * --
  35.    if check_offset.x < max_offset.x then check_offset.x = check_offset.x + 2 getintPos() end
  36.    if check_offset.x > max_offset.x then check_offset.x = max_offset.x getintPos() end
  37.    -- * check if y equals less than max offset; if not then y = y + 2 else y = max offset! * --
  38.    if check_offset.y < max_offset.y then check_offset.y = check_offset.y + 2 getintPos() end
  39.    if check_offset.y > max_offset.y then check_offset.y = max_offset.y getintPos() end
  40.   else
  41.    -- * check if x equals more than min offset; if not then x = x - 2 else x = min offset! * --
  42.    if check_offset.x > min_offset.x then check_offset.x = check_offset.x - 2 getintPos() end
  43.    if check_offset.x < min_offset.x then check_offset.x = min_offset.x getintPos() end
  44.    -- * check if y equals more than min offset; if not then y = y - 2 else y = min offset! * --
  45.    if check_offset.y > min_offset.y then check_offset.y = check_offset.y - 2 getintPos() end
  46.    if check_offset.y < min_offset.y then check_offset.y = min_offset.y getintPos() end
  47.   end
  48.  else
  49.   -- * begin mouse wheel code * --
  50.   if mwUp == 1 then
  51.    -- * check if x equals more than min offset; if not then x = x - 2 else x = min offset! * --
  52.    if check_offset.x > min_offset.x then check_offset.x = check_offset.x - 2 getintPos() end
  53.    if check_offset.x < min_offset.x then check_offset.x = min_offset.x getintPos() end
  54.    -- * check if y equals more than min offset; if not then y = y - 2 else y = min offset! * --
  55.    if check_offset.y > min_offset.y then check_offset.y = check_offset.y - 2 getintPos() end
  56.    if check_offset.y < min_offset.y then check_offset.y = min_offset.y getintPos() end
  57.   end
  58.   if mwUp == 2 then
  59.    -- * check if x equals less than max offset; if not then x = x + 2 else x = max offset! * --
  60.    if check_offset.x < max_offset.x then check_offset.x = check_offset.x + 2 getintPos() end
  61.    if check_offset.x > max_offset.x then check_offset.x = max_offset.x getintPos() end
  62.    -- * check if y equals less than max offset; if not then y = y + 2 else y = max offset! * --
  63.    if check_offset.y < max_offset.y then check_offset.y = check_offset.y + 2 getintPos() end
  64.    if check_offset.y > max_offset.y then check_offset.y = max_offset.y getintPos() end
  65.   end
  66.  end
  67. end
  68.  
  69.  -- * updates the current position of the interface * --
  70. function getintPos()
  71.  get_interface:setValue(VInterfaceOffset, check_offset)
  72. end
  73.  
  74. function OnMouseEvent(eventType)
  75.  if eventType == eEvtMouseWheelUp then mwUp = 1 end
  76.  if eventType == eEvtMouseWheelDown then mwUp = 2 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