[SOLVED] Moving an interface

  • #1, by sebastianSunday, 04. September 2016, 00:59 7 years ago
    Hey there,

    i know that i read that one line i need here in the forum but can't find it anymore (damn search function).
    I need to animate an interface. Kind of the sliding interfaces stuff but not so bloated and more dynamic.
    Is it possible to do something like a one liner as it is possible with moving animations with easing?


    Interfaces["MyInterface"]:to(0, { InterfacePosition = {x = 72, y = 69} }, easingstufff) 

    Thanks in advance


    PS: If not: feature request for 4.3 wink

    Thread Captain

    2346 Posts

  • #2, by afrlmeSunday, 04. September 2016, 01:21 7 years ago
    Yes it's possible & I shared the method multiple times throughout the forum already. I probably should add it as an alternative method in the sliding interface script on the wiki, no?
    local int = Interfaces["name"]
    if int.InterfaceOffset.x == 0 then
     int:to(1000, { InterfaceOffset = {x = -200, y = int.InterfaceOffset.y } }, easeQuintIn)
    elseif int.InterfaceOffset.x == -200 then
     int:to(1000, { InterfaceOffset = {x = 0, y = int.InterfaceOffset.y } }, easeQuintOut)

    ... what we have here is a simple 2 query that checks if interface is at one position or another or neither (if it's neither then it's because it's currently moving). One position will make it slide back to the default position & the other will make it slide out to the target position.

    This method is a lot faster than the Deponia interface script I wrote a while back, but we didn't have the tweening functions or Lua shorthand back when I wrote that.

    P.S: this script is kind of basic as it prevents the player from cancelling the slide in/out order & they will have to wait until it's reached its destination before they can slide it back in or out, unlike the deponia interface script I wrote, because I used various math equations to calculate the needed pixels / speed it would need to make it slide in/out at the same speed regardless of the current position it was at.


    7272 Posts

  • #3, by sebastianSunday, 04. September 2016, 01:25 7 years ago
    yes, that was the thing i searched for
    Thanks =)

    Thread Captain

    2346 Posts

  • #4, by sebastianThursday, 08. September 2016, 20:18 7 years ago
    Works like a charm =)

    Thread Captain

    2346 Posts