AFRLme

Slide Out Any Interface (deponia style) [VS] (new version)

Feb 26th, 2013
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.98 KB | None | 0 0
  1. --[[
  2. slide out any interface (deponia style)
  3. automatic slide version (v2)
  4. scripted & annotated by AFRLme
  5. -- * --
  6. www.alternatingfrequencies.com | [email protected] | aim/skype/trillian: AFRLme
  7. --]]
  8.  
  9. -- * let's create the initial variables for this script! * --
  10. local getInterface = getObject('Interfaces[inventory]') -- stores interface into a variable (replace "inventory" with your interface name)
  11.  
  12. local minOffset = {x = -350, y = 240} -- replace min offset values with current x,y absolute position of your interface!
  13. local maxOffset = {x = -20, y = 240} -- replace max offset values with the x,y values that you want the interface to slide to!
  14. local mwOffset = 50 -- this should be same value or slightly larger than the overlap amount of minOffset!
  15. local checkOffset = getInterface:getPoint(VInterfaceOffset) -- stores current position of interface on start!
  16.  
  17. local inSpeed = 1 -- replace "2" with x number of squares you want interface to move back to start position on each loop!
  18. local outSpeed = 2 -- replace "2" with x number of squares you want interface to move to max position on each loop!
  19.  
  20. local slideDirection = 1 -- set direction interface should slide from! (1 = left, 2 = top, 3 = right, 4 = bottom)
  21.  
  22. local mwUp = 0 -- this controls if mouse wheel up or down has been executed; by default "0" = nil (!important: do not edit)
  23.  
  24. -- * let's create the slide function * --
  25. function intSlide()
  26.  conds = {} -- create a blank table called "conds" ...
  27.  conds['_temporary_'] = '' -- sets table to temporary; in other words: no data is stored in VS save games!
  28.  conds[1] = getObject('Conditions[slide?]'):getBool(VConditionValue) -- check condition of "slide?"
  29.  conds[2] = getObject('Conditions[mwheel?]'):getBool(VConditionValue) -- check condition of "mwheel?"
  30.  conds[3] = getObject('Conditions[mwtoggle?]'):getBool(VConditionValue) -- check condition of "mwtoggle?"
  31.  -- * let's create the on mouse over code * --
  32.  if conds[1] and not conds[2] then -- check if "slide?" = true & "mwheel?" = false
  33.   if mwUp ~= 0 then mwUp = 0 end -- check if mouse wheel is active; if it is, then set inactive!
  34.   -- * let's slide the x position of the interface based on slideDirection (out) * --
  35.   if (slideDirection == 1 or slideDirection == 2) and checkOffset.x < maxOffset.x then checkOffset.x = checkOffset.x + outSpeed setIntPos() end
  36.   if (slideDirection == 1 or slideDirection == 2) and checkOffset.x > maxOffset.x then checkOffset.x = maxOffset.x setIntPos() end
  37.   if (slideDirection == 3 or slideDirection == 4) and checkOffset.x > maxOffset.x then checkOffset.x = checkOffset.x - outSpeed setIntPos() end
  38.   if (slideDirection == 3 or slideDirection == 4) and checkOffset.x < maxOffset.x then checkOffset.x = maxOffset.x setIntPos() end
  39.   -- * let's slide the y position of the interface based on SlideDirection (out) * --
  40.   if (slideDirection == 1 or slideDirection == 2) and checkOffset.y < maxOffset.y then checkOffset.y = checkOffset.y + outSpeed setIntPos() end
  41.   if (slideDirection == 1 or slideDirection == 2) and checkOffset.y > maxOffset.y then checkOffset.y = maxOffset.y setIntPos() end
  42.   if (slideDirection == 3 or slideDirection == 4) and checkOffset.y > maxOffset.y then checkOffset.y = checkOffset.y - outSpeed setIntPos()  end
  43.   if (slideDirection == 3 or slideDirection == 4) and checkOffset.y < maxOffset.y then checkOffset.y = maxOffset.y setIntPos() end
  44.  elseif not conds[1] and not conds[2] then
  45.   if mwUp ~= 0 then mwUp = 0 end -- check if mouse wheel is active; if it is, then set inactive!
  46.   -- * let's slide the x position of the interface based on slideDirection (in) * --
  47.   if (slideDirection == 1 or slideDirection == 2) and checkOffset.x > minOffset.x then checkOffset.x = checkOffset.x - inSpeed setIntPos() end
  48.   if (slideDirection == 1 or slideDirection == 2) and checkOffset.x < minOffset.x then checkOffset.x = minOffset.x setIntPos() end
  49.   if (slideDirection == 3 or slideDirection == 4) and checkOffset.x < minOffset.x then checkOffset.x = checkOffset.x + inSpeed setIntPos() end
  50.   if (slideDirection == 3 or slideDirection == 4) and checkOffset.x > minOffset.x then checkOffset.x = minOffset.x setIntPos() end
  51.   -- * let's slide the y position of the interface based on SlideDirection (in) * --
  52.   if (slideDirection == 1 or slideDirection == 2) and checkOffset.y > minOffset.y then checkOffset.y = checkOffset.y - inSpeed setIntPos() end
  53.   if (slideDirection == 1 or slideDirection == 2) and checkOffset.y < minOffset.y then checkOffset.y = minOffset.y setIntPos() end
  54.   if (slideDirection == 3 or slideDirection == 4) and checkOffset.y < minOffset.y then checkOffset.y = checkOffset.y + inSpeed setIntPos() end
  55.   if (slideDirection == 3 or slideDirection == 4) and checkOffset.y > minOffset.y then checkOffset.y = minOffset.y setIntPos() end
  56.  end
  57.  -- * let's create the mouse wheel code * --
  58.   if not conds[1] and mwUp == 1 then -- check if mouse wheel up has been rotated!
  59.   -- * let's slide the x position of the interface based on slideDirection (out) * --
  60.   if (slideDirection == 1 or slideDirection == 2) and checkOffset.x < maxOffset.x then checkOffset.x = checkOffset.x + outSpeed setIntPos() end
  61.   if (slideDirection == 1 or slideDirection == 2) and checkOffset.x > maxOffset.x then checkOffset.x = maxOffset.x setIntPos() end
  62.   if (slideDirection == 3 or slideDirection == 4) and checkOffset.x > maxOffset.x then checkOffset.x = checkOffset.x - outSpeed setIntPos() end
  63.   if (slideDirection == 3 or slideDirection == 4) and checkOffset.x < maxOffset.x then checkOffset.x = maxOffset.x setIntPos() end
  64.   -- * let's slide the y position of the interface based on SlideDirection (out) * --
  65.   if (slideDirection == 1 or slideDirection == 2) and checkOffset.y < maxOffset.y then checkOffset.y = checkOffset.y + outSpeed setIntPos() end
  66.   if (slideDirection == 1 or slideDirection == 2) and checkOffset.y > maxOffset.y then checkOffset.y = maxOffset.y setIntPos() end
  67.   if (slideDirection == 3 or slideDirection == 4) and checkOffset.y > maxOffset.y then checkOffset.y = checkOffset.y - outSpeed setIntPos()  end
  68.   if (slideDirection == 3 or slideDirection == 4) and checkOffset.y < maxOffset.y then checkOffset.y = maxOffset.y setIntPos() end
  69.  end
  70.  if not conds[1] and mwUp == 2 then -- check if mouse wheel down has been rotated!
  71.   -- * let's slide the x position of the interface based on slideDirection (in) * --
  72.   if slideDirection == 1 and checkOffset.x > minOffset.x - mwOffset then checkOffset.x = checkOffset.x - inSpeed setIntPos() end
  73.   if slideDirection == 1 and checkOffset.x < minOffset.x - mwOffset then checkOffset.x = minOffset.x - mwOffset setIntPos() end
  74.   if slideDirection == 2 and checkOffset.x > minOffset.x then checkOffset.x = checkOffset.x - inSpeed setIntPos() end
  75.   if slideDirection == 2 and checkOffset.x < minOffset.x then checkOffset.x = minOffset.x setIntPos() end
  76.   if slideDirection == 3 and checkOffset.x < minOffset.x + mwOffset then checkOffset.x = checkOffset.x + inSpeed setIntPos() end
  77.   if slideDirection == 3 and checkOffset.x > minOffset.x + mwOffset then checkOffset.x = minOffset.x + mwOffset setIntPos() end
  78.   if slideDirection == 4 and checkOffset.x < minOffset.x then checkOffset.x = checkOffset.x + inSpeed setIntPos() end
  79.   if slideDirection == 4 and checkOffset.x > minOffset.x then checkOffset.x = minOffset.x setIntPos() end
  80.   -- * let's slide the y position of the interface based on SlideDirection (in) * --
  81.   if slideDirection == 1 and checkOffset.y > minOffset.y then checkOffset.y = checkOffset.y - inSpeed setIntPos() end
  82.   if slideDirection == 1 and checkOffset.y < minOffset.y then checkOffset.y = minOffset.y setIntPos() end
  83.   if slideDirection == 2 and checkOffset.y > minOffset.y - mwOffset then checkOffset.y = checkOffset.y - inSpeed setIntPos() end
  84.   if slideDirection == 2 and checkOffset.y < minOffset.y - mwOffset then checkOffset.y = minOffset.y - mwOffset setIntPos() end
  85.   if slideDirection == 3 and checkOffset.y < minOffset.y then checkOffset.y = checkOffset.y + inSpeed setIntPos() end
  86.   if slideDirection == 3 and checkOffset.y > minOffset.y then checkOffset.y = minOffset.y setIntPos() end
  87.   if slideDirection == 4 and checkOffset.y < minOffset.y + mwOffset then checkOffset.y = checkOffset.y + inSpeed setIntPos() end
  88.   if slideDirection == 4 and checkOffset.y > minOffset.y + mwOffset then checkOffset.y = minOffset.y + mwOffset setIntPos() end
  89.  end
  90. end -- end intSlide()
  91.  
  92.  -- * updates the current position of the interface * --
  93. function setIntPos()
  94.  getInterface:setValue(VInterfaceOffset, checkOffset)
  95. end
  96.  
  97. -- * let's check if mouse wheel mode = true; if true then hide the interface else overlap interface slightly * --
  98. function mwMode()
  99.  if conds[2] then
  100.   if slideDirection == 1 then checkOffset = {x = minOffset.x - mwOffset, y = minOffset.y} setIntPos() end
  101.   if slideDirection == 2 then checkOffset = {x = minOffset.x, y = minOffset.y - mwOffset} setIntPos() end
  102.   if slideDirection == 3 then checkOffset = {x = minOffset.x + mwOffset, y = minOffset.y} setIntPos() end
  103.   if slideDirection == 4 then checkOffset = {x = minOffset.x, y = minOffset.y + mwOffset} setIntPos() end
  104.  else
  105.   checkOffset = {x = minOffset.x, y = minOffset.y}
  106.   setIntPos()
  107.  end
  108. end
  109.  
  110. -- * this is the mainLoop event function! (all loop events & functions for looping should be added or linked here) * --
  111. function OnMainLoop()
  112.  intSlide() -- loop the function which checks if interface should be sliding in, out or at default position!
  113. end
  114.  
  115. -- * this is the mouse event listener! (all mouse events & functions should be added or linked here) * --
  116. function OnMouseEvent(eventType)
  117.  if not conds[3] then
  118.   if eventType == eEvtMouseWheelUp then mwUp = 1 end
  119.   if eventType == eEvtMouseWheelDown then mwUp = 2 end
  120.  else
  121.   if eventType == eEvtMouseWheelUp then mwUp = 2 end
  122.   if eventType == eEvtMouseWheelDown then mwUp = 1 end
  123.  end
  124. end
  125.  
  126. -- * let's create the mouse event listener! * --
  127. registerEventHandler('mouseEvent', 'OnMouseEvent', {eEvtMouseWheelUp, eEvtMouseWheelDown})
  128. -- * let's create the loop event handler! * --
  129. registerEventHandler('mainLoop', 'OnMainLoop')
Advertisement
Add Comment
Please, Sign In to add comment