Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- slide out any interface (deponia style)
- automatic slide version (v2)
- scripted & annotated by AFRLme
- -- * --
- www.alternatingfrequencies.com | [email protected] | aim/skype/trillian: AFRLme
- --]]
- -- * let's create the initial variables for this script! * --
- local getInterface = getObject('Interfaces[inventory]') -- stores interface into a variable (replace "inventory" with your interface name)
- local minOffset = {x = -350, y = 240} -- replace min offset values with current x,y absolute position of your interface!
- local maxOffset = {x = -20, y = 240} -- replace max offset values with the x,y values that you want the interface to slide to!
- local mwOffset = 50 -- this should be same value or slightly larger than the overlap amount of minOffset!
- local checkOffset = getInterface:getPoint(VInterfaceOffset) -- stores current position of interface on start!
- local inSpeed = 1 -- replace "2" with x number of squares you want interface to move back to start position on each loop!
- local outSpeed = 2 -- replace "2" with x number of squares you want interface to move to max position on each loop!
- local slideDirection = 1 -- set direction interface should slide from! (1 = left, 2 = top, 3 = right, 4 = bottom)
- local mwUp = 0 -- this controls if mouse wheel up or down has been executed; by default "0" = nil (!important: do not edit)
- -- * let's create the slide function * --
- function intSlide()
- conds = {} -- create a blank table called "conds" ...
- conds['_temporary_'] = '' -- sets table to temporary; in other words: no data is stored in VS save games!
- conds[1] = getObject('Conditions[slide?]'):getBool(VConditionValue) -- check condition of "slide?"
- conds[2] = getObject('Conditions[mwheel?]'):getBool(VConditionValue) -- check condition of "mwheel?"
- conds[3] = getObject('Conditions[mwtoggle?]'):getBool(VConditionValue) -- check condition of "mwtoggle?"
- -- * let's create the on mouse over code * --
- if conds[1] and not conds[2] then -- check if "slide?" = true & "mwheel?" = false
- if mwUp ~= 0 then mwUp = 0 end -- check if mouse wheel is active; if it is, then set inactive!
- -- * let's slide the x position of the interface based on slideDirection (out) * --
- if (slideDirection == 1 or slideDirection == 2) and checkOffset.x < maxOffset.x then checkOffset.x = checkOffset.x + outSpeed setIntPos() end
- if (slideDirection == 1 or slideDirection == 2) and checkOffset.x > maxOffset.x then checkOffset.x = maxOffset.x setIntPos() end
- if (slideDirection == 3 or slideDirection == 4) and checkOffset.x > maxOffset.x then checkOffset.x = checkOffset.x - outSpeed setIntPos() end
- if (slideDirection == 3 or slideDirection == 4) and checkOffset.x < maxOffset.x then checkOffset.x = maxOffset.x setIntPos() end
- -- * let's slide the y position of the interface based on SlideDirection (out) * --
- if (slideDirection == 1 or slideDirection == 2) and checkOffset.y < maxOffset.y then checkOffset.y = checkOffset.y + outSpeed setIntPos() end
- if (slideDirection == 1 or slideDirection == 2) and checkOffset.y > maxOffset.y then checkOffset.y = maxOffset.y setIntPos() end
- if (slideDirection == 3 or slideDirection == 4) and checkOffset.y > maxOffset.y then checkOffset.y = checkOffset.y - outSpeed setIntPos() end
- if (slideDirection == 3 or slideDirection == 4) and checkOffset.y < maxOffset.y then checkOffset.y = maxOffset.y setIntPos() end
- elseif not conds[1] and not conds[2] then
- if mwUp ~= 0 then mwUp = 0 end -- check if mouse wheel is active; if it is, then set inactive!
- -- * let's slide the x position of the interface based on slideDirection (in) * --
- if (slideDirection == 1 or slideDirection == 2) and checkOffset.x > minOffset.x then checkOffset.x = checkOffset.x - inSpeed setIntPos() end
- if (slideDirection == 1 or slideDirection == 2) and checkOffset.x < minOffset.x then checkOffset.x = minOffset.x setIntPos() end
- if (slideDirection == 3 or slideDirection == 4) and checkOffset.x < minOffset.x then checkOffset.x = checkOffset.x + inSpeed setIntPos() end
- if (slideDirection == 3 or slideDirection == 4) and checkOffset.x > minOffset.x then checkOffset.x = minOffset.x setIntPos() end
- -- * let's slide the y position of the interface based on SlideDirection (in) * --
- if (slideDirection == 1 or slideDirection == 2) and checkOffset.y > minOffset.y then checkOffset.y = checkOffset.y - inSpeed setIntPos() end
- if (slideDirection == 1 or slideDirection == 2) and checkOffset.y < minOffset.y then checkOffset.y = minOffset.y setIntPos() end
- if (slideDirection == 3 or slideDirection == 4) and checkOffset.y < minOffset.y then checkOffset.y = checkOffset.y + inSpeed setIntPos() end
- if (slideDirection == 3 or slideDirection == 4) and checkOffset.y > minOffset.y then checkOffset.y = minOffset.y setIntPos() end
- end
- -- * let's create the mouse wheel code * --
- if not conds[1] and mwUp == 1 then -- check if mouse wheel up has been rotated!
- -- * let's slide the x position of the interface based on slideDirection (out) * --
- if (slideDirection == 1 or slideDirection == 2) and checkOffset.x < maxOffset.x then checkOffset.x = checkOffset.x + outSpeed setIntPos() end
- if (slideDirection == 1 or slideDirection == 2) and checkOffset.x > maxOffset.x then checkOffset.x = maxOffset.x setIntPos() end
- if (slideDirection == 3 or slideDirection == 4) and checkOffset.x > maxOffset.x then checkOffset.x = checkOffset.x - outSpeed setIntPos() end
- if (slideDirection == 3 or slideDirection == 4) and checkOffset.x < maxOffset.x then checkOffset.x = maxOffset.x setIntPos() end
- -- * let's slide the y position of the interface based on SlideDirection (out) * --
- if (slideDirection == 1 or slideDirection == 2) and checkOffset.y < maxOffset.y then checkOffset.y = checkOffset.y + outSpeed setIntPos() end
- if (slideDirection == 1 or slideDirection == 2) and checkOffset.y > maxOffset.y then checkOffset.y = maxOffset.y setIntPos() end
- if (slideDirection == 3 or slideDirection == 4) and checkOffset.y > maxOffset.y then checkOffset.y = checkOffset.y - outSpeed setIntPos() end
- if (slideDirection == 3 or slideDirection == 4) and checkOffset.y < maxOffset.y then checkOffset.y = maxOffset.y setIntPos() end
- end
- if not conds[1] and mwUp == 2 then -- check if mouse wheel down has been rotated!
- -- * let's slide the x position of the interface based on slideDirection (in) * --
- if slideDirection == 1 and checkOffset.x > minOffset.x - mwOffset then checkOffset.x = checkOffset.x - inSpeed setIntPos() end
- if slideDirection == 1 and checkOffset.x < minOffset.x - mwOffset then checkOffset.x = minOffset.x - mwOffset setIntPos() end
- if slideDirection == 2 and checkOffset.x > minOffset.x then checkOffset.x = checkOffset.x - inSpeed setIntPos() end
- if slideDirection == 2 and checkOffset.x < minOffset.x then checkOffset.x = minOffset.x setIntPos() end
- if slideDirection == 3 and checkOffset.x < minOffset.x + mwOffset then checkOffset.x = checkOffset.x + inSpeed setIntPos() end
- if slideDirection == 3 and checkOffset.x > minOffset.x + mwOffset then checkOffset.x = minOffset.x + mwOffset setIntPos() end
- if slideDirection == 4 and checkOffset.x < minOffset.x then checkOffset.x = checkOffset.x + inSpeed setIntPos() end
- if slideDirection == 4 and checkOffset.x > minOffset.x then checkOffset.x = minOffset.x setIntPos() end
- -- * let's slide the y position of the interface based on SlideDirection (in) * --
- if slideDirection == 1 and checkOffset.y > minOffset.y then checkOffset.y = checkOffset.y - inSpeed setIntPos() end
- if slideDirection == 1 and checkOffset.y < minOffset.y then checkOffset.y = minOffset.y setIntPos() end
- if slideDirection == 2 and checkOffset.y > minOffset.y - mwOffset then checkOffset.y = checkOffset.y - inSpeed setIntPos() end
- if slideDirection == 2 and checkOffset.y < minOffset.y - mwOffset then checkOffset.y = minOffset.y - mwOffset setIntPos() end
- if slideDirection == 3 and checkOffset.y < minOffset.y then checkOffset.y = checkOffset.y + inSpeed setIntPos() end
- if slideDirection == 3 and checkOffset.y > minOffset.y then checkOffset.y = minOffset.y setIntPos() end
- if slideDirection == 4 and checkOffset.y < minOffset.y + mwOffset then checkOffset.y = checkOffset.y + inSpeed setIntPos() end
- if slideDirection == 4 and checkOffset.y > minOffset.y + mwOffset then checkOffset.y = minOffset.y + mwOffset setIntPos() end
- end
- end -- end intSlide()
- -- * updates the current position of the interface * --
- function setIntPos()
- getInterface:setValue(VInterfaceOffset, checkOffset)
- end
- -- * let's check if mouse wheel mode = true; if true then hide the interface else overlap interface slightly * --
- function mwMode()
- if conds[2] then
- if slideDirection == 1 then checkOffset = {x = minOffset.x - mwOffset, y = minOffset.y} setIntPos() end
- if slideDirection == 2 then checkOffset = {x = minOffset.x, y = minOffset.y - mwOffset} setIntPos() end
- if slideDirection == 3 then checkOffset = {x = minOffset.x + mwOffset, y = minOffset.y} setIntPos() end
- if slideDirection == 4 then checkOffset = {x = minOffset.x, y = minOffset.y + mwOffset} setIntPos() end
- else
- checkOffset = {x = minOffset.x, y = minOffset.y}
- setIntPos()
- end
- end
- -- * this is the mainLoop event function! (all loop events & functions for looping should be added or linked here) * --
- function OnMainLoop()
- intSlide() -- loop the function which checks if interface should be sliding in, out or at default position!
- end
- -- * this is the mouse event listener! (all mouse events & functions should be added or linked here) * --
- function OnMouseEvent(eventType)
- if not conds[3] then
- if eventType == eEvtMouseWheelUp then mwUp = 1 end
- if eventType == eEvtMouseWheelDown then mwUp = 2 end
- else
- if eventType == eEvtMouseWheelUp then mwUp = 2 end
- if eventType == eEvtMouseWheelDown then mwUp = 1 end
- end
- end
- -- * let's create the mouse event listener! * --
- registerEventHandler('mouseEvent', 'OnMouseEvent', {eEvtMouseWheelUp, eEvtMouseWheelDown})
- -- * let's create the loop event handler! * --
- registerEventHandler('mainLoop', 'OnMainLoop')
Advertisement
Add Comment
Please, Sign In to add comment