--[[
*********************************************************************************
INVENTORY
*********************************************************************************]]--
local inventory_States = {
[1] = function () end, -- Holding state
[2] = function () -- Lower State
local inventory = getObject("Interfaces[inventory]")
local p = inventory:getPoint(VInterfaceOffset)
if p.y<=640 then
getObject("Values[inventory_state]"):setValue(VValueInt, 1)
getObject("Conditions[inventory_lowered]"):setValue(VConditionValue, true)
else
p.y= p.y-2
inventory:setValue(VInterfaceOffset,p)
end
end,
[3] = function () -- Raise State
local inventory = getObject("Interfaces[inventory]")
local p = inventory:getPoint(VInterfaceOffset)
if p.y>=696 then
getObject("Values[inventory_state]"):setValue(VValueInt, 1)
getObject("Conditions[inventory_lowered]"):setValue(VConditionValue, false)
else
p.y= p.y+2
inventory:setValue(VInterfaceOffset,p)
end
end
}
--[[
*********************************************************************************
HANDLERS
*********************************************************************************]]--
function onMainLoop()
-- Update Inventory Interface
local inventory_state = getObject("Values[inventory_state]"):getInt(VValueInt)
inventory_States[inventory_state]()
end
registerEventHandler("mainLoop", "onMainLoop")
local int = Interfaces["example"]
if int.InterfaceOffset == 0 then -- slide in with slow easing
int:to(3000, { InterfaceOffset = {x = -200, y = int.InterfaceOffset.y} }, easeQuintIn)
elseif int.InterfaceOffset == -200 then -- slide out with bounce at end
int:to(3000, { InterfaceOffset = {x = 0, y = int.InterfaceOffset.y} }, easeBounceOut)
end
-- game/object/animation/character:to(delay, {data structure field you want to affect - can actually add multiple fields by separating with ,}, easing, loop, pendulum)
game.CurrentScene.SceneObjects["ball"]:to(10000, {Rotation = math.rad(360)}, easeLinearOut, true, false) -- rotate ball continous 360 degrees (clockwise - I think) over 10 seconds
ActiveAnimations["cloud"]:to(math.random(10000, 30000), { AnimationCurrentPosition = {x = -500, y = ActiveAnimations["cloud"].AnimationCurrentPosition.y} }, easeLinearOut, true, false) -- move cloud over random time then reset back to initial position once destination reached (only really good if animation initial position is outside of the scene)
P.S: pretty much any data structure field that is a number in some form or another can be affected by it, so that's position coordinates, opactity, volume levels, integer & float values, etc. Very useful & saves a lot of time. Wish it had been around when I wrote my first & second Deponia sliding interface scripts...