Inventory on the top

  • #1, z JorkzSunday, 05. June 2016, 16:02 hodinky 9 years ago
    Hello.
    I want to create a top inventory, similar to the "Locked Out" game / template.(transparent and dropdown menu)
    How to do that ? I think it's an offset problem... I don't understand how this offset notion works

    Someone can shed light on this ?

    Bažant

    90 Posts


  • #2, z afrlmeSunday, 05. June 2016, 16:17 hodinky 9 years ago
    You mean the inventory is hidden by default & slides in when you move the mouse near it? I assume the person that made that game probably used one of my sliding interface Lua scripts. I highly recommend you try to get used to the basics of the engine before you delve into the scripting side of things.

    & just in case you want to dive into the deep end first... grin
    function mouseEvt(typ, pos)
     if typ == eEvtMouseMove then
       if game.CurrentScene:getName() == game.CurrentCharacter.Scene:getName() then 
        if getCursorPos().y < 50 and Interfaces["inventory"].InterfaceOffset.y == -100 then
         Interfaces["inventory"]:to(300, {  InterfaceOffset = {x = 0, y = 0} }, easeQuintOut)
        elseif getCursorPos().y > 100 and Interfaces["inventory"].InterfaceOffset.y == 0 then
          Interfaces["inventory"]:to(300, {  InterfaceOffset = {x = 0, y = -100} }, easeQuintIn)
        end
       end
     end
    end
    
    registerEventHandler("mouseEvent", "mouseEvt")
    


    Quick note: the script is not plug & play. You need to edit it to suit your needs, by changing the interface name values & the offset values.

    P.S: here's the last script I wrote for sliding interfaces. Be warned though, it contains a fair bit of code as I wrote it before we had shorthand Lua access. Also it's an advanced script - it's fairly complicated; especially if you compare it to the example I mocked up (in the code box above).

    Imperátor

    7285 Posts

  • #3, z JorkzThursday, 09. June 2016, 11:26 hodinky 9 years ago
    thanks

    Bažant

    90 Posts