R96 Lua update!

Discussion in 'Lua Discussions' started by DavidDC, Nov 17, 2021.

  1. DavidDC

    DavidDC Programmer Moderator SOTA Developer

    Messages:
    1,255
    Likes Received:
    2,652
    Trophy Points:
    113
    Gender:
    Male
    Hey guys!

    I have updated the Lua API with some more functionalities. You can check them out in the API Doc.

    Fixed that bug with multiple script which needed all global function to work and some more !

    Like before, i have made a little example of some of the new functionality like the input box and resizable panel.

    Release R96 is tomorrow but this new functionalities can be tested on QA.

    Code:
    --Here we have our table of object we want to create. Also used to save objectID and parentID (See the R95 LuaDemo example if you need more information about this)
    local _panels = {{ x = 400.0, y = 300.0, width = 300, height = 200, objectID = -1, parendID = -1}}
    local _inputs = {{ x = 30.0, y = 100.0, width = 200, height = 30, objectID = -1, parendID = -1}}
    local _texts = {{ text = "Hello world!", x = 30.0, y = 30.0, width = 200, height = 40, fontSize = 30, objectID = -1, parentID = -1 }}
    
    function ShroudOnStart()
        _panels[1].objectID = ShroudUIPanel(_panels[1].x,
                                             _panels[1].y,
                                             _panels[1].width,
                                             _panels[1].height);
        ShroudSetColor(_panels[1].objectID, UI.Panel, "#000000");
        
        ShroudSetResizable(_panels[1].objectID, UI.Panel); --Possible option are "Vertical", "Horizontal", "None", or not passing a 3rd argument at all will make both vertical and horizontal enabled with corner
        
        _texts[1].objectID = ShroudUIText(_texts[1].text,
                 _texts[1].fontSize,
                 _texts[1].x,
                 _texts[1].y,
                 _texts[1].width,
                 _texts[1].height,
                 _panels[1].objectID,
                 UI.Panel);
                
        ShroudRaycastObject(_texts[1].objectID, UI.Text, false); --Makes click go through the object
        ShroudSetColor(_texts[1].objectID, UI.Panel, "#FF0000"); --Change color of text since our panel is black
        
        _inputs[1].objectID = ShroudUIInput(_inputs[1].x,
                                             _inputs[1].y,
                                             _inputs[1].width,
                                             _inputs[1].height,
                                             _panels[1].objectID,
                                             UI.Panel);
    end
    --Here we return to console log whatever text was entered in the input field
    function ShroudOnInputChange(objectID, text)
        ConsoleLog(string.format("Text changed (%s)", text));
    end
     
    Archer, Elgarion, FrostII and 4 others like this.
  2. Tirrag

    Tirrag Avatar

    Messages:
    538
    Likes Received:
    1,116
    Trophy Points:
    63
    Location:
    Iowa, USA / Maiden's Blush, SotA
    FrostII likes this.
  3. DavidDC

    DavidDC Programmer Moderator SOTA Developer

    Messages:
    1,255
    Likes Received:
    2,652
    Trophy Points:
    113
    Gender:
    Male
    I might have missed the release date for the bug where window disapear when switching scene! Not sure why but some code magically appeared which decided to destroy that function ESPECIALLY when changing scene! I must have been sleeping while writing that.. lol
    It will be in first patch if this fix doesnt make release!
     
    Feldon Grimshaw, Anpu and FrostII like this.
  4. FrostII

    FrostII Bug Hunter

    Messages:
    5,502
    Likes Received:
    10,607
    Trophy Points:
    153
    Gender:
    Male
    Location:
    Pacific Northwest
    +1 :)
     
    Archer likes this.
  5. tervalas

    tervalas Avatar

    Messages:
    44
    Likes Received:
    7
    Trophy Points:
    8
    I have an object I've created at position 1100, 400. When I call GetPosition and access the x and y attributes of the vector, I'm getting 550, 400.
    I also ran it on an object created at 1000, 400 and it returned 550, 400.
    Ran it on an object created at 850, 400....and it returned 850, 400.

    And looking more into things....those first two objects were an input and a toggle object while the last one is a button. When I changed the button to 1450, 400, I got 1450, 400 for GetPosition.

    Also...an enhancement or for clarity if it already exists.....can something be added for resizable objects to return their new width and height?
     
  6. DavidDC

    DavidDC Programmer Moderator SOTA Developer

    Messages:
    1,255
    Likes Received:
    2,652
    Trophy Points:
    113
    Gender:
    Male
    ShroudGetPosition return the anchored position of the object, i have it set differently for input and toggle and im not totally sure as of why i have set it this way but ill look into it and maybe fix it if its wrong.
    And yeah i can add something to return the size width/length. Will be either in patch or next release!

    Thanks for feedback guys!
     
    FrostII likes this.
  7. tervalas

    tervalas Avatar

    Messages:
    44
    Likes Received:
    7
    Trophy Points:
    8
    Not sure if this is because of a recent change....but are the object ID numbers for objects automatically changing if one with a lower ID number is deleted?

    Now there may be a good reason for this, but it wasn't how it worked before.