Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Slide out any interface (deponia style)
- incremental slide version ...
- scripted & annotated by AFRLme
- -- * --
- dropped!
- --]]
- --[[ global getObject variable; used for getting & setting current interface position!
- replace "inventory" with whatever your interface is called! --]]
- local get_interface = getObject('Interfaces[inventory]')
- --[[ global values containing the minimum, maximum & current offset values!
- replace min_offset x,y with the default absolute position you set in the interface to be used for sliding
- replace max_offset x,y with the x,y position you want the interface to slide to! --]]
- local min_offset = {x = -350, y = 240}
- local max_offset = {x = -20, y = 240}
- local check_offset = get_interface:getPoint(VInterfaceOffset)
- -- * this is the main loop which checks if the interface needs to slide out/in or stay in the current position! * --
- function OnMainLoop()
- --[[ check condition equals true false to decide if interface should slide out or in on hover!
- replace "mwheel?" & "slide?" with whatever you named the conditions! --]]
- local mwheel = getObject('Conditions[mwheel?]'):getBool(VConditionValue)
- local canSlide = getObject('Conditions[slide?]'):getBool(VConditionValue)
- if mwheel == false then
- if canSlide then
- -- * check if x equals less than max offset; if not then x = x + 2 else x = max offset! * --
- if check_offset.x < max_offset.x then check_offset.x = check_offset.x + 2 end
- if check_offset.x > max_offset.x then check_offset.x = max_offset.x end
- -- * check if y equals less than max offset; if not then y = y + 2 else y = max offset! * --
- if check_offset.y < max_offset.y then check_offset.y = check_offset.y + 2 end
- if check_offset.y > max_offset.y then check_offset.y = max_offset.y end
- else
- -- * check if x equals more than min offset; if not then x = x - 2 else x = min offset! * --
- if check_offset.x > min_offset.x then check_offset.x = check_offset.x - 2 end
- if check_offset.x < min_offset.x then check_offset.x = min_offset.x end
- -- * check if y equals more than min offset; if not then y = y - 2 else y = min offset! * --
- if check_offset.y > min_offset.y then check_offset.y = check_offset.y - 2 end
- if check_offset.y < min_offset.y then check_offset.y = min_offset.y end
- end
- -- * updates the current position of the interface * --
- get_interface:setValue(VInterfaceOffset, check_offset)
- end
- end
- -- * slides the interface back in on mouse wheel up if condition mwheel? equals true! * --
- function OnMwUp()
- -- * check if x equals more than min offset; if not then x = x - 10 else x = min offset! * --
- if check_offset.x > min_offset.x then check_offset.x = check_offset.x - 10 end
- if check_offset.x < min_offset.x then check_offset.x = min_offset.x end
- -- * check if y equals more than min offset; if not then y = y - 10 else y = min offset! * --
- if check_offset.y > min_offset.y then check_offset.y = check_offset.y - 10 end
- if check_offset.y < min_offset.y then check_offset.y = min_offset.y end
- -- * updates the current position of the interface * --
- get_interface:setValue(VInterfaceOffset, check_offset)
- end
- -- * slides the interface out on mouse wheel down if condition mwheel? equals true! * --
- function OnMwDown()
- -- * check if x equals less than max offset; if not then x = x + 10 else x = max offset! * --
- if check_offset.x < max_offset.x then check_offset.x = check_offset.x + 10 end
- if check_offset.x > max_offset.x then check_offset.x = max_offset.x end
- -- * check if y equals less than max offset; if not then y = y + 10 else y = max offset! * --
- if check_offset.y < max_offset.y then check_offset.y = check_offset.y + 10 end
- if check_offset.y > max_offset.y then check_offset.y = max_offset.y end
- -- * updates the current position of the interface * --
- get_interface:setValue(VInterfaceOffset, check_offset)
- end
- function OnMouseEvent(eventType)
- local mwheel = getObject('Conditions[mwheel?]'):getBool(VConditionValue)
- if mwheel then
- if eventType == eEvtMouseWheelUp then OnMwUp() end
- if eventType == eEvtMouseWheelDown then OnMwDown() end
- end
- end
- -- * let's create the mouse event listener! * --
- registerEventHandler('mouseEvent', 'OnMouseEvent', {eEvtMouseWheelUp, eEvtMouseWheelDown})
- -- * let's create the loop to check if the interface is in the correct position! * --
- registerEventHandler('mainLoop', 'OnMainLoop')
Advertisement
Add Comment
Please, Sign In to add comment