Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Slide out any interface (hover only)
- 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!
- replace "slide?" with whatever you name the condition! --]]
- local cond = getObject('Conditions[slide?]'):getBool(VConditionValue)
- if cond 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
- -- * 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
Advertisement