--[[
Deponia Based Sliding Interface [v4] (18/03/2013)
Written by AFRLme [Lee Clarke]
-- + --
alternatingfrequencies@hotmail.com | skype @ AFRLme
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]
-- * local variables * --
local getInterface = getObject("Interfaces[inventory]") -- stores interface into a variable (replace "inventory" with your interface name)
local minOffset = {x = [b]402[/b], y = [b]549[/b]} -- replace min offset values with current x,y absolute position of your interface
local maxOffset = {x = [b]402[/b], y = [b]0[/b]} -- replace max offset values with the x,y values that you want the interface to slide to
local mwOffset = [b]0[/b] -- 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 = [b]40[/b] -- replace "1" with x number of squares you want interface to move back to start position on each loop
local outSpeed = [b]40[/b] -- replace "2" with x number of squares you want interface to move to max position on each loop
local slideDirection = [b]4[/b] -- set direction interface should slide from (1 = left, 2 = top, 3 = right, 4 = bottom)
local hover = getObject("Conditions[hover]") -- store hover condition
local mwheel = getObject("Conditions[mwheel]") -- store mouse mwheel condition
-- * global variables * --
mwUp = 0 -- this controls if mouse wheel up or down has been executed; by default "0" = nil (!important: do not edit)
-- * function that moves the linked interface * --
function intSlide()
-- * let's create the on mouse over code * --
if hover:getBool(VConditionValue) and not mwheel:getBool(VConditionValue) then -- check if "hover" = 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 hover:getBool(VConditionValue) and not mwheel:getBool(VConditionValue) 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 hover:getBool(VConditionValue) and mwheel:getBool(VConditionValue) 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 hover:getBool(VConditionValue) and mwheel:getBool(VConditionValue) 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
-- * 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 mwheel:getBool(VConditionValue) 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
if mwUp ~= 1 then mwUp = 1 else mwUp = 2 end
[...] Because of mouse wheel mode we couldn't have it automatically slide back in when the mouse cursor was outside of the interface area, so we only enabled automatically slide in on mouse out for the hover mode.
Hope this helps?
mwUp = 2
mwUp = 2