Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- slide out any interface (deponia style)
- automatic slide version ...
- scripted & annotated by AFRLme
- -- * --
- antiquated (please use the new latest version[v2])
- --]]
- --[[ 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)
- -- * global integer variable default value for checking if mouse wheel is up, down or nil! * --
- local mwUp = 0
- -- * 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)
- -- * begin on hover code * --
- if not mwheel then
- -- * check if mwUp equals default value if not then mwUp equals default value * --
- if mwUp ~= 0 then mwUp = 0 end
- 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 getintPos() end
- if check_offset.x > max_offset.x then check_offset.x = max_offset.x getintPos() 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 getintPos() end
- if check_offset.y > max_offset.y then check_offset.y = max_offset.y getintPos() 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 getintPos() end
- if check_offset.x < min_offset.x then check_offset.x = min_offset.x getintPos() 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 getintPos() end
- if check_offset.y < min_offset.y then check_offset.y = min_offset.y getintPos() end
- end
- else
- -- * begin mouse wheel code * --
- if mwUp == 1 then
- -- * 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 getintPos() end
- if check_offset.x < min_offset.x then check_offset.x = min_offset.x getintPos() 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 getintPos() end
- if check_offset.y < min_offset.y then check_offset.y = min_offset.y getintPos() end
- end
- if mwUp == 2 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 getintPos() end
- if check_offset.x > max_offset.x then check_offset.x = max_offset.x getintPos() 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 getintPos() end
- if check_offset.y > max_offset.y then check_offset.y = max_offset.y getintPos() end
- end
- end
- end
- -- * updates the current position of the interface * --
- function getintPos()
- get_interface:setValue(VInterfaceOffset, check_offset)
- end
- function OnMouseEvent(eventType)
- if eventType == eEvtMouseWheelUp then mwUp = 1 end
- if eventType == eEvtMouseWheelDown then mwUp = 2 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