Deponia Based Sliding Interface

  • #1, by andi5Saturday, 10. May 2014, 17:10 10 years ago
    Hi! :-)
    Ich habe das "Deponia Based Sliding Interface [v4] (18/03/2013)" von AFRLme heute ausprobiert. Allerdings bekomme ich die ganze Sache nicht so hin, wie ich das gerne hätte. Ich schaffe es nicht einzustellen, dass sich mein Inventar sowohl mit dem Mausrad als auch per Linksklick auf das ensprechende Symbol öffnet. Wenn ich das eine per Visionaire in den Bedingungen aktiviere bzw. deaktiviere, klappt das andere nicht. Welchen Code im Script muss ich genau anpassen, damit beides klappt?

    Außerdem wollte ich noch wissen, wie sich das Inventar automatisch per Mausrad wieder schließt, wenn ich die entsprechende Stelle im Inventar überschreite? Wenn ich es manuell (Linksklick) öffne, verschwindet es wenn ich den angegebenen Bereich verlasse - per Mausrad allerdings nicht.

    Hier das Scrpit das ich benutze (die dicken Stellen habe ich angepasst):

    --[[
    Deponia Based Sliding Interface [v4] (18/03/2013)
    Written by AFRLme [Lee Clarke]
    -- + --
    alternatingfrequencies@hotmail.com | skype @ AFRLme
    -- + --
    This script is donation optional. In game credit is non-negotiable.
    You are free to: ¹ use it in your game(s). ² modify the script.
    Do not remove - or edit - this comment block.
    --]]
    
    -- * local variables * --
    local getInterface = getObject("Interfaces[inventory]") -- stores interface into a variable (replace "inventory" with your interface name)
    
    local minOffset = {x = [b]402[/b], y = [b]549[/b]} -- replace min offset values with current x,y absolute position of your interface
    local maxOffset = {x = [b]402[/b], y = [b]0[/b]} -- replace max offset values with the x,y values that you want the interface to slide to
    local mwOffset = [b]0[/b] -- this should be same value or slightly larger than the overlap amount of minOffset
    local checkOffset = getInterface:getPoint(VInterfaceOffset) -- stores current position of interface on start
    
    local inSpeed = [b]40[/b] -- replace "1" with x number of squares you want interface to move back to start position on each loop
    local outSpeed = [b]40[/b] -- replace "2" with x number of squares you want interface to move to max position on each loop
    
    local slideDirection = [b]4[/b] -- set direction interface should slide from (1 = left, 2 = top, 3 = right, 4 = bottom)
    
    local hover = getObject("Conditions[hover]") -- store hover condition
    local mwheel = getObject("Conditions[mwheel]") -- store mouse mwheel condition
    
    -- * global variables * --
    mwUp = 0 -- this controls if mouse wheel up or down has been executed; by default "0" = nil (!important: do not edit)
    
    -- * function that moves the linked interface * --
    function intSlide()
     -- * let's create the on mouse over code * --
     if hover:getBool(VConditionValue) and not mwheel:getBool(VConditionValue) then -- check if "hover" = true & "mwheel" = false
      if mwUp ~= 0 then mwUp = 0 end -- check if mouse wheel is active; if it is, then set inactive
      -- * let's slide the x position of the interface based on slideDirection (out) * --
      if (slideDirection == 1 or slideDirection == 2) and checkOffset.x < maxOffset.x then checkOffset.x = checkOffset.x + outSpeed setIntPos() end
      if (slideDirection == 1 or slideDirection == 2) and checkOffset.x > maxOffset.x then checkOffset.x = maxOffset.x setIntPos() end
      if (slideDirection == 3 or slideDirection == 4) and checkOffset.x > maxOffset.x then checkOffset.x = checkOffset.x - outSpeed setIntPos() end
      if (slideDirection == 3 or slideDirection == 4) and checkOffset.x < maxOffset.x then checkOffset.x = maxOffset.x setIntPos() end
      -- * let's slide the y position of the interface based on SlideDirection (out) * --
      if (slideDirection == 1 or slideDirection == 2) and checkOffset.y < maxOffset.y then checkOffset.y = checkOffset.y + outSpeed setIntPos() end
      if (slideDirection == 1 or slideDirection == 2) and checkOffset.y > maxOffset.y then checkOffset.y = maxOffset.y setIntPos() end
      if (slideDirection == 3 or slideDirection == 4) and checkOffset.y > maxOffset.y then checkOffset.y = checkOffset.y - outSpeed setIntPos()  end
      if (slideDirection == 3 or slideDirection == 4) and checkOffset.y < maxOffset.y then checkOffset.y = maxOffset.y setIntPos() end
     elseif not hover:getBool(VConditionValue) and not mwheel:getBool(VConditionValue) then
      if mwUp ~= 0 then mwUp = 0 end -- check if mouse wheel is active; if it is, then set inactive
      -- * let's slide the x position of the interface based on slideDirection (in) * --
      if (slideDirection == 1 or slideDirection == 2) and checkOffset.x > minOffset.x then checkOffset.x = checkOffset.x - inSpeed setIntPos() end
      if (slideDirection == 1 or slideDirection == 2) and checkOffset.x < minOffset.x then checkOffset.x = minOffset.x setIntPos() end
      if (slideDirection == 3 or slideDirection == 4) and checkOffset.x < minOffset.x then checkOffset.x = checkOffset.x + inSpeed setIntPos() end
      if (slideDirection == 3 or slideDirection == 4) and checkOffset.x > minOffset.x then checkOffset.x = minOffset.x setIntPos() end
      -- * let's slide the y position of the interface based on SlideDirection (in) * --
      if (slideDirection == 1 or slideDirection == 2) and checkOffset.y > minOffset.y then checkOffset.y = checkOffset.y - inSpeed setIntPos() end
      if (slideDirection == 1 or slideDirection == 2) and checkOffset.y < minOffset.y then checkOffset.y = minOffset.y setIntPos() end
      if (slideDirection == 3 or slideDirection == 4) and checkOffset.y < minOffset.y then checkOffset.y = checkOffset.y + inSpeed setIntPos() end
      if (slideDirection == 3 or slideDirection == 4) and checkOffset.y > minOffset.y then checkOffset.y = minOffset.y setIntPos() end
     end
     -- * let's create the mouse wheel code * --
     if not hover:getBool(VConditionValue) and mwheel:getBool(VConditionValue) and mwUp == 1 then -- check if mouse wheel up has been rotated
      -- * let's slide the x position of the interface based on slideDirection (out) * --
      if (slideDirection == 1 or slideDirection == 2) and checkOffset.x < maxOffset.x then checkOffset.x = checkOffset.x + outSpeed setIntPos() end
      if (slideDirection == 1 or slideDirection == 2) and checkOffset.x > maxOffset.x then checkOffset.x = maxOffset.x setIntPos() end
      if (slideDirection == 3 or slideDirection == 4) and checkOffset.x > maxOffset.x then checkOffset.x = checkOffset.x - outSpeed setIntPos() end
      if (slideDirection == 3 or slideDirection == 4) and checkOffset.x < maxOffset.x then checkOffset.x = maxOffset.x setIntPos() end
      -- * let's slide the y position of the interface based on SlideDirection (out) * --
      if (slideDirection == 1 or slideDirection == 2) and checkOffset.y < maxOffset.y then checkOffset.y = checkOffset.y + outSpeed setIntPos() end
      if (slideDirection == 1 or slideDirection == 2) and checkOffset.y > maxOffset.y then checkOffset.y = maxOffset.y setIntPos() end
      if (slideDirection == 3 or slideDirection == 4) and checkOffset.y > maxOffset.y then checkOffset.y = checkOffset.y - outSpeed setIntPos()  end
      if (slideDirection == 3 or slideDirection == 4) and checkOffset.y < maxOffset.y then checkOffset.y = maxOffset.y setIntPos() end
     end
     if not hover:getBool(VConditionValue) and mwheel:getBool(VConditionValue) and mwUp == 2 then -- check if mouse wheel down has been rotated
      -- * let's slide the x position of the interface based on slideDirection (in) * --
      if slideDirection == 1 and checkOffset.x > minOffset.x - mwOffset then checkOffset.x = checkOffset.x - inSpeed setIntPos() end
      if slideDirection == 1 and checkOffset.x < minOffset.x - mwOffset then checkOffset.x = minOffset.x - mwOffset setIntPos() end
      if slideDirection == 2 and checkOffset.x > minOffset.x then checkOffset.x = checkOffset.x - inSpeed setIntPos() end
      if slideDirection == 2 and checkOffset.x < minOffset.x then checkOffset.x = minOffset.x setIntPos() end
      if slideDirection == 3 and checkOffset.x < minOffset.x + mwOffset then checkOffset.x = checkOffset.x + inSpeed setIntPos() end
      if slideDirection == 3 and checkOffset.x > minOffset.x + mwOffset then checkOffset.x = minOffset.x + mwOffset setIntPos() end
      if slideDirection == 4 and checkOffset.x < minOffset.x then checkOffset.x = checkOffset.x + inSpeed setIntPos() end
      if slideDirection == 4 and checkOffset.x > minOffset.x then checkOffset.x = minOffset.x setIntPos() end
      -- * let's slide the y position of the interface based on SlideDirection (in) * --
      if slideDirection == 1 and checkOffset.y > minOffset.y then checkOffset.y = checkOffset.y - inSpeed setIntPos() end
      if slideDirection == 1 and checkOffset.y < minOffset.y then checkOffset.y = minOffset.y setIntPos() end
      if slideDirection == 2 and checkOffset.y > minOffset.y - mwOffset then checkOffset.y = checkOffset.y - inSpeed setIntPos() end
      if slideDirection == 2 and checkOffset.y < minOffset.y - mwOffset then checkOffset.y = minOffset.y - mwOffset setIntPos() end
      if slideDirection == 3 and checkOffset.y < minOffset.y then checkOffset.y = checkOffset.y + inSpeed setIntPos() end
      if slideDirection == 3 and checkOffset.y > minOffset.y then checkOffset.y = minOffset.y setIntPos() end
      if slideDirection == 4 and checkOffset.y < minOffset.y + mwOffset then checkOffset.y = checkOffset.y + inSpeed setIntPos() end
      if slideDirection == 4 and checkOffset.y > minOffset.y + mwOffset then checkOffset.y = minOffset.y + mwOffset setIntPos() end
     end
    end
    
     -- * updates the current position of the interface * --
    function setIntPos()
     getInterface:setValue(VInterfaceOffset, checkOffset)
    end
    
    -- * let's check if mouse wheel mode = true; if true then hide the interface else overlap interface slightly * --
    function mwMode()
     if mwheel:getBool(VConditionValue) then
      if slideDirection == 1 then checkOffset = {x = minOffset.x - mwOffset, y = minOffset.y} setIntPos() end
      if slideDirection == 2 then checkOffset = {x = minOffset.x, y = minOffset.y - mwOffset} setIntPos() end
      if slideDirection == 3 then checkOffset = {x = minOffset.x + mwOffset, y = minOffset.y} setIntPos() end
      if slideDirection == 4 then checkOffset = {x = minOffset.x, y = minOffset.y + mwOffset} setIntPos() end
     else
      checkOffset = {x = minOffset.x, y = minOffset.y}
      setIntPos()
     end
    end
    

    Newbie

    28 Posts


  • #2, by afrlmeSaturday, 10. May 2014, 17:34 10 years ago
    You used the script found at this page?

    If you could post the message in English, then that would be much appreciated cheers, as the the bing translation of your message is not making much sense.

    Imperator

    7278 Posts

  • #3, by andi5Saturday, 10. May 2014, 18:42 10 years ago
    yeah, from this page.
    the functions are great and works fine, but i can only choose the mouse wheel or a different setting. so i must change the code, because i need two settings. my inventory ist permanently displayed and i will it open with the left mouse button and with the mouse wheel. so how can i deactivate or change the condition?

    my other problem is, when i open my inventory with the mouse wheel function, the inventory does not close? only the slide-function works. sorry for my bad english, AFRLme.

    Newbie

    28 Posts

  • #4, by afrlmeSaturday, 10. May 2014, 19:01 10 years ago
    The idea was to work in similar fashion to that of the sliding interface system used in Deponia; as in it should be hidden when using mouse wheel mode but visible (overlapping the scene slightly) when using the left click mode which I substituted for hover instead of left click.

    Because of mouse wheel mode we couldn't have it automatically slide back in when the mouse cursor was outside of the interface area, so we only enabled automatically slide in on mouse out for the hover mode.

    To make it work in the way you want with mouse wheel & left click on a button or certain section of the interface to make it slide in/out you would need to adjust the code slightly & some of the action parts used in the editor.

    For instance you wouldn't need the hover part of the code, only the code in the mouse wheel section.

    Ok quick solution just make so that mousewheel mode is enabled. Set the offset value inside of the script by how much you want the inventory interface to overlap onto the screen by (pixels) & then for the left click action/object area in which you want it to open & close the interface with: create left click immediate & add an execute a script containing...
    if mwUp ~= 1 then mwUp = 1 else mwUp = 2 end
    

    This should trigger the slide in/out with the current script.

    Quick note: I do not recommend adding an on mouse leave event for the interface for either mousewheel mode or left clicking because it will slide in when you don't want it to.

    Hope this helps?

    Regards,
    Lee.

    Imperator

    7278 Posts

  • #5, by andi5Sunday, 11. May 2014, 00:43 10 years ago
    [...] Because of mouse wheel mode we couldn't have it automatically slide back in when the mouse cursor was outside of the interface area, so we only enabled automatically slide in on mouse out for the hover mode.

    very sad. and when the cursor come from outside in the inventory and then leaves the button area? it this not feasible? that works great in deponia.

    Hope this helps?

    thanks for your help! but unfortunately not. maybe you can make some adjustments in the script?

    Newbie

    28 Posts

  • #6, by afrlmeSunday, 11. May 2014, 01:17 10 years ago
    ok fine you could have it trigger slide in on mouse leaves interface area... not sure what I was thinking really. wink

    just add an execute a script action containing...
    mwUp = 2
    

    Imperator

    7278 Posts

  • #7, by andi5Sunday, 11. May 2014, 02:31 10 years ago
    I'm confused. What should I do? Only create a execution type with
    "cursor leaves button area" and a execute scrpit with "mwUp = 2" ?

    Newbie

    28 Posts

  • #8, by afrlmeSunday, 11. May 2014, 02:58 10 years ago
    no... in the properties tab of the interface is a bit which says action on leaving: click on the lightning icon & then add an execute a script action containing...
    mwUp = 2
    

    Leave the script as is & do what I mentioned earlier on in my earlier post the day about the left click.

    If you manage to sort it out correctly then what you will have is the ability to slide the interface in/out via the mouse wheel, or toggle interface in/out by left clicking on a button or specific section of the interface (depending on how you are going to design that part) or when you hover mouse cursor over the interface & then leave the defined interface area, it should automatically slide back in.

    Imperator

    7278 Posts

  • #9, by andi5Sunday, 11. May 2014, 03:44 10 years ago
    It doesn't work, AFRLme. I'm doing something wrong. Can you please check my files? You got a mail.

    Newbie

    28 Posts