libsota - a helper library in lua for Shroud in lua.

Discussion in 'Lua Discussions' started by CatweazleX, Nov 14, 2019.

Thread Status:
Not open for further replies.
  1. Archer

    Archer Avatar

    Messages:
    285
    Likes Received:
    196
    Trophy Points:
    40
    Location:
    UK, EU, Terra
    Could be a bug. Raise it with @DevilCult
     
  2. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,823
    Trophy Points:
    93
    Location:
    Iowa, USA
    definitely feels like its a bug. even the demo provided by DC has issues in the current QA.
     
  3. Archer

    Archer Avatar

    Messages:
    285
    Likes Received:
    196
    Trophy Points:
    40
    Location:
    UK, EU, Terra
    Have you got a minimal version of a script I can use to test this? I retried DC's Demo and it works as expected for me on QA: i.e. the close button at top right does not produce duplicate clicks. I tested with no other scripts running to eliminate weird stuff from that situation.
     
  4. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,823
    Trophy Points:
    93
    Location:
    Iowa, USA
    maybe there is an updated demo somewhere? here is what i am using. panels dont line up and all mouse events fire multiple times at once. this is on latest QA.

    EDIT: yes apparently demo link updated since i last pulled which fixed the alignment issues. with new code though i still get the duplicate mouse events. below is the code and excerpt from my chatlog.

    Code:
    --[[ Lua Demo Example for Shroud of the Avatar
    A concept to understand before starting (Parent and child):
    Imagine a genealogy tree, where there is parent and their child and grand child linked together by a line, this is the same.
    We use this method to attach object to each other and keep track of what belong to what, also keep track of depth (image or text shown over each other).
    We can then, for example, move a parent position and all its child and grand childs will follow since they are attached to that parent.
    Hiding a parent object would also hide all of its child.
    Setting a child on a parent will make the child show in front of that parent UI element and any previous child of that element.
    If you want a child to show over another child, set that child as the parent of that other child.
    --]]
    -- Lua Demo Example
    --First we create an array of a UI element that will references all our images and attributes.
    --The value objectID, parentID and depth will be returned when you create one of this UI element: Panel, Image, Text or Button.
    --An ID with -1 mean its null or 'nil' in lua language. It's very important to save this value if you want to keep tracks of your UI elements.
    --Losing this mean you wont have access to that UI element anymore and won't be able to change position or image etc later.
    --The reason why each kind of object is separated here is to keep track what kind of UI it is. You know when it is a UI.Panel or UI.Image for example. (See the new UI enum on SOTA API doc)
    local _panels = {{ x = 300.0, y = 300.0, width = 622, height = 700, objectID = -1, parendID = -1}}
    local _images = {{ sprite = "ShroudLuaTest/Background.jpg", x = 5.0, y = 75.0, width = 612, height = 612, textureID = -1, objectID = -1, parentID = -1 },
                      { sprite = "ShroudLuaTest/Logo.png", x = 100.0, y = 100.0, width = 387, height = 65, textureID = -1, objectID = -1, parentID = -1 }}
    local _texts = {{ text = "This is just a demo!", x = 0.0, y = 0.0, width = 300, height = 50, fontSize = 30, objectID = -1, parentID = -1 },
                    { text = "Click and drag me!", x = 0.0, y = 0.0, width = 300, height = 50, fontSize = 30, objectID = -1, parentID = -1 },
                    { text = "X", x = 0.0, y = 0.0, width = 50, height = 50, fontSize = 30, objectID = -1, parentID = -1 }}
                  
    local _buttons = {{ x = 0.0, y = 0.0, width = 50, height = 50, objectID = -1, parentID = -1 }}
    --Here we start creating the UI elements
    --I did this on ShroudOnStart() function but it could be done anywhere.
    function ShroudOnStart()
        -- Adding a new Panel and making sure we save the returned ID
        _panels[1].objectID = ShroudUIPanel(_panels[1].x,
                                        _panels[1].y,
                                        _panels[1].width,
                                        _panels[1].height);
        -- Adding Images and saving IDs, same way as you did before with textures
      
        _images[1].textureID = ShroudLoadTexture(_images[1].sprite);
      
        _images[1].objectID = ShroudUIImage(_images[1].x,
                                                _images[1].y,
                                                _images[1].width,
                                                _images[1].height,
                                                _images[1].textureID);
        _images[2].textureID = ShroudLoadTexture(_images[2].sprite);
      
        _images[2].objectID = ShroudUIImage(_images[2].x,
                                                _images[2].y,
                                                _images[2].width,
                                                _images[2].height,
                                                _images[2].textureID);
                                                    
        --Here we set the logo as a child of the background, so later, if we move the background, the childs will follow.
        --If you are not familiar with parent and chi
        ShroudSetParent(_images[2].objectID, UI.Image, _images[1].objectID, UI.Image);
        -- Adding texts
      
        _texts[1].objectID = ShroudUIText(_texts[1].text,
                    _texts[1].fontSize,
                    _texts[1].x,
                    _texts[1].y,
                    _texts[1].width,
                    _texts[1].height,
                    _images[1].objectID, --you can also set the parent directly to a previously created object. objectID and depth are optional parameters
                    UI.Image); --Here is the defined UI element of that _images[1].objectID.
                    -- It's important to set this with the object ID we want to access because object IDs are saved by element kind.
                    -- It could be a panel or image and both would have an id of 1 so the game would'nt know which kind of object you want to access if it's not set.
                      
                    
        _texts[2].objectID = ShroudUIText(_texts[2].text,
                    _texts[2].fontSize,
                    _texts[2].x,
                    _texts[2].y,
                    _texts[2].width,
                    _texts[2].height,
                    _panels[1].objectID,
                    UI.Panel);
                    
        ShroudRaycastObject(_texts[2].objectID, UI.Text, false); -- This text "drag me" which will be shown over the panel would have blocked our click to move the panel if this was not set to false
      
        -- Suddenly we decide to attach background.jpg image as a child of panel. All child attached to our image will move with it.
        ShroudSetParent(_images[1].objectID, UI.Image, _panels[1].objectID, UI.Panel);
                    
        ShroudSetAnchorMin(_texts[1].objectID, UI.Text, 0.5, 0.5); --This is where we place the object in relation of the parent, in this case, the middle
        ShroudSetAnchorMax(_texts[1].objectID, UI.Text, 0.5, 0.5);
        ShroudSetPivot(_texts[1].objectID, UI.Text, 0.5, 0.5); --Setting the point of pivot to middle of the image (where the position and rotation will occur from)
        ShroudSetTextAlignment(_texts[1].objectID, TextAnchor.MiddleCenter); -- This is where the text is displayed within the width and height of the box. MiddleCenter and UpperLeft will be the most used. It goes from LowerLeft to MiddleCenter to UpperRight (uppercenter... middleright... etc)
        ShroudSetTextAlignment(_texts[2].objectID, TextAnchor.UpperLeft);
        ShroudSetColor(_texts[2].objectID, UI.Text, "#FF0000");
      
      
        --Lets add a button
        _buttons[1].objectID = ShroudUIButton(_buttons[1].x,
                                            _buttons[1].y,
                                            _buttons[1].width,
                                            _buttons[1].height,
                                            _images[1].textureID, --Texture argument is needed before setting an object parent optional but can be set to null with the value -1
                                                                   --Here we will use the same image as background.jpg (this could have been saved in a different lua table called _textures for efficacity)
                                            _panels[1].objectID, --We set this button on the panel parent
                                            UI.Panel);
        --We are going to set this button anchor top right of the panel, then set the pivot point of the button itself top right
        --This will make our "hide window" button fixed in the right corner of the panel even if we would increase the size of the panel or reduce it.
        ShroudSetAnchorMin(_buttons[1].objectID, UI.Button, 1.0,1.0);
        ShroudSetAnchorMax(_buttons[1].objectID, UI.Button, 1.0,1.0);
        ShroudSetPivot(_buttons[1].objectID, UI.Button, 1.0, 1.0);
      
        --Lets add a X text on that button
        _texts[3].objectID = ShroudUIText(_texts[3].text,
                    _texts[3].fontSize,
                    _texts[3].x,
                    _texts[3].y,
                    _texts[3].width,
                    _texts[3].height,
                    _buttons[1].objectID,
                    UI.Button);
                    
        ShroudSetColor(_texts[3].objectID, UI.Text, "#FF0000"); -- and make it red
      
        ShroudSetAnchorMin(_texts[3].objectID, UI.Text, 0.5, 0.5); --set the middle of the button as the anchor
        ShroudSetAnchorMax(_texts[3].objectID, UI.Text, 0.5, 0.5);
        ShroudSetPivot(_texts[3].objectID, UI.Text, 0.5, 0.5); -- set center of our text as our middle
        ShroudSetTextAlignment(_texts[3].objectID, TextAnchor.MiddleCenter); --set text within the text rect in middle also
    end
    --some variable for our little animation of the logo
    local goUp = false;
    local goUpAndDownMax = 0;
    --Here we made a small animation of the logo moving up and down in the background.
    function ShroudOnUpdate()
        -- After pressing the X button of our window, pressing F8 will show it again
        if ShroudGetOnKeyUp("F8") then
            ShroudShowObject(_panels[1].objectID, UI.Panel);
        end
      
        --Make note that our animation will continue to play even if the window is hidden. Might want to set a bool on this to enable/disable number of codes running
        if goUp then
            _images[2].y = _images[2].y + 1;
            ShroudSetPosition(_images[2].objectID, UI.Image, _images[2].x, _images[2].y);
            goUpAndDownMax = goUpAndDownMax + 1;
            if goUpAndDownMax == 60 then
                goUp = false;
                goUpAndDownMax = 0;
            end
        else
            _images[2].y = _images[2].y - 1;
            ShroudSetPosition(_images[2].objectID, UI.Image, _images[2].x, _images[2].y);
            goUpAndDownMax = goUpAndDownMax + 1;
            if goUpAndDownMax == 60 then
                goUp = true;
                goUpAndDownMax = 0;
            end
        end
      
    end
    function ShroudOnMouseClick(objectID, objectKind)
        ConsoleLog(string.format("MouseClick: %s - %s", tostring(objectID), tostring(objectKind)));
      
        --Here we check for our button click and hide the whole window when pressed
        if objectKind == UI.Button and objectID == _buttons[1].objectID then
                ShroudHideObject(_panels[1].objectID, UI.Panel);
        end
    end
    function ShroudOnMouseOver(objectID, objectKind)
        ConsoleLog(string.format("MouseOver: %s - %s", tostring(objectID), tostring(objectKind)));
        --could highlight stuff here when mouse is over or whatever you want
    end
    function ShroudOnMouseOut(objectID, objectKind)
        ConsoleLog(string.format("MouseOut: %s - %s", tostring(objectID), tostring(objectKind)));
        --to know when mouse has left the object
    end
    
    Code:
    [11/6/2021 6:55:02 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Text
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Text
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Text
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Text
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Text
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Text
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Text
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Text
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Text
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Text
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:02 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:04 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:04 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:04 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:04 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:04 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:05 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:05 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:05 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:05 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:05 PM]  (Lua): MouseClick: 0 - Panel
    [11/6/2021 6:55:06 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOver: 1 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOver: 1 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOver: 1 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOver: 1 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOver: 1 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOut: 1 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOut: 1 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOut: 1 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOut: 1 - Image
    [11/6/2021 6:55:06 PM]  (Lua): MouseOut: 1 - Image
    [11/6/2021 6:55:08 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:08 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:08 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:08 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:08 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:08 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:08 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:08 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:08 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:08 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:09 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:09 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:09 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:09 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:09 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:09 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:09 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:09 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:09 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:09 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOver: 1 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOver: 1 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOver: 1 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOver: 1 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOver: 1 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOut: 1 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOut: 1 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOut: 1 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOut: 1 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOut: 1 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:11 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:13 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:13 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:13 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:13 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:13 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:13 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:13 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:13 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:13 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:13 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:13 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:13 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:13 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:13 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:13 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:14 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:14 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:14 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:14 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:14 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:14 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:14 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:14 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:14 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:14 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:14 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:14 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:14 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:14 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:14 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:19 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:19 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:19 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:19 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:19 PM]  (Lua): MouseOver: 0 - Image
    [11/6/2021 6:55:19 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:19 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:19 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:19 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:19 PM]  (Lua): MouseOut: 0 - Panel
    [11/6/2021 6:55:19 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:19 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:19 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:19 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:19 PM]  (Lua): MouseOut: 0 - Image
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 2 - Text
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 2 - Text
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 2 - Text
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 2 - Text
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 2 - Text
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 0 - Button
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 0 - Button
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 0 - Button
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 0 - Button
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 0 - Button
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:27 PM]  (Lua): MouseOver: 0 - Panel
    [11/6/2021 6:55:28 PM]  (Lua): MouseClick: 0 - Button
    [11/6/2021 6:55:28 PM]  (Lua): MouseClick: 0 - Button
    [11/6/2021 6:55:28 PM]  (Lua): MouseClick: 0 - Button
    [11/6/2021 6:55:28 PM]  (Lua): MouseClick: 0 - Button
    [11/6/2021 6:55:28 PM]  (Lua): MouseClick: 0 - Button
    
     
    Last edited: Nov 6, 2021
  5. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,823
    Trophy Points:
    93
    Location:
    Iowa, USA
    @Archer, @tervalas i have confirmed it is something with using libsota that causes the issue. havent narrowed it down yet so the base code is good.
     
  6. Archer

    Archer Avatar

    Messages:
    285
    Likes Received:
    196
    Trophy Points:
    40
    Location:
    UK, EU, Terra
    Libsota scripts do not have all of the Shroud* events included (because new ones have been added since the last update) and that can cause problems with other scripts. try adding the newer events (even if they are empty) into each one.
     
  7. tervalas

    tervalas Avatar

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    8
    That's how I discovered this. The only libsota code that is being used is a handler event. Other than that, my testing was with the new ShroudOnMouseClick event and UI elements that only consist of the new functions. So the only ui function I call is ui.handler.invoke(). Which is why it being a libsota issue still seems odd.
     
  8. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,823
    Trophy Points:
    93
    Location:
    Iowa, USA
    i was mistaken about libsota. based on @Archer comment i noticed that the events were duplicated 1 time for each .lua file i had in the root lua folder that did not have the new event functions. i added the events to the bottom of each file and the issue was cleared up. thank you @Archer! never would have thought that was the issue.

    Code:
    function ShroudOnMouseClick(objectID, objectKind) end
    function ShroudOnMouseOver(objectID, objectKind) end
    function ShroudOnMouseOut(objectID, objectKind) end
    
     
  9. tervalas

    tervalas Avatar

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    8
    Grr....silliness from SOTA.
     
  10. Archer

    Archer Avatar

    Messages:
    285
    Likes Received:
    196
    Trophy Points:
    40
    Location:
    UK, EU, Terra
    Hopefully, @DavidDC can get that issue fixed eventually. As the available functionality grows, it will become a greater and greater problem; with every old script causing problems until new events are added to them.
     
  11. DavidDC

    DavidDC Programmer Moderator SOTA Developer

    Messages:
    1,532
    Likes Received:
    3,236
    Trophy Points:
    113
    Gender:
    Male
    hmm though that would be fixed, ill check it out
     
    Anpu likes this.
  12. tervalas

    tervalas Avatar

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    8
    Not sure it CatweazleX is planning on updating this, but I wanted to start thinking about how to evolve libsota to use the new UI system. Thoughts I was having:

    Obviously move anything involved with handling display of the elements out of ShroudOnGUI. I was thinking ShroudOnUpdate, and using ShroudShowObject and ShroudHideObject to control the display.

    guiObjects....what items to add/keep in the object list and which to return in the object itself. visible, showInScene, showInLoadScreen are still usable. I at first was thinking about getting rid of rect until I realized that some functions would be helpful to keep this info (thoughts?). Not sure if zIndex is needed, though I begin to wonder how we would control which items are in front. Maybe make this the basis for draw list sorting (I may need to test more but if someone has looked at this already would be good to hear).

    For the object itself, I do not believe there is any need to maintain Draw functions since the function to create the object supersedes this and display can be controlled with ShroudShowObject and ShroudHideObject. The objectID and objectKind is basically a requirement, and rect goes back to my last paragraph.

    That leaves parent information. At first I thought maybe this would be info for the objectList entry. Now part of me thinks it would work better as part of the object. I do believe saving this info to make it easier to retrieve is very useful.

    As for the objects themselves, changing them to use the new functions is relatively simple as well as removing the draw functions. I would rename the texture object to image just to match up with the system. And not sure if this would work but change the onClick function for guiButtons to work along the lines of what I posted about before (click handler along with ui.onClick function).
     
  13. tervalas

    tervalas Avatar

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    8
    Took me until I was implementing more functions to realize they added functions for finding parents already so I may just remove that as a stored value.
     
  14. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,823
    Trophy Points:
    93
    Location:
    Iowa, USA
    ive been holding off for a bit waiting for DC to work out a final product. from discord channel i saw there were other things planned such as scrollable panels.

    still, i have been thinking about it. i didnt want to break the current libsota so my thoughts led to a new ui set of functions mimicking the current ui but separated completely. i havent really looked into it or done anything though. excited to see where you take it.
     
  15. tervalas

    tervalas Avatar

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    8
    These would be great.....especially because it doesn't seem like panels have any unique functional purpose at the moment.
     
  16. tervalas

    tervalas Avatar

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    8
    Thank you for being excited, though I'm not really doing a whole lot different.

    First testing of object creation and controlling display through ShroudOnUpdate seems to show that will work. Main thing to do is work on verifying everything works when it has a parent and modifying mouse click handling.

    Then I need to decide what to do with anchors and pivots for objects that do not have a parent. Apparently the UI doesn't like that so I think that the screen itself is not treated as some sort of base parent object by the internal code.
     
  17. Archer

    Archer Avatar

    Messages:
    285
    Likes Received:
    196
    Trophy Points:
    40
    Location:
    UK, EU, Terra
    I'm confused why you're using ShroudOnUpdate() for 'control'. Isn't the design goal of this new system to NOT need a specific event to handle these objects? Forcing them to be used in an event that will be called every frame, is only a small step up from ShroudOnGUI which was called multiple times per frame.

    IMO control should be a part of the object you are creating, using the provided functions for control.

    NOTE: I have put my UI work on hold as I ran into problems and I decided to improve the experience with my IDE by creating custom SotA auto-complete, syntax highlighting, etc. So my actual experience here is more theoretical than practical.
     
    Last edited: Nov 13, 2021
  18. Archer

    Archer Avatar

    Messages:
    285
    Likes Received:
    196
    Trophy Points:
    40
    Location:
    UK, EU, Terra
    That would make sense. In Unity's uGUI system, that is being used for this, the base object is a Canvas which does not connect to the screen. It appears that the canvas is not exposed to us.
    Anchors on the base object do not make sense, there is nothing to anchor to, as the object is free floating from our POV.
     
  19. tervalas

    tervalas Avatar

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    8
    For right now, I didn't want to change some things because I still need to determine how drawing order may be affected (in order to display one item over another at different times for example). This plan was a starting point. I never want to make anyone think my solution is the most efficient, but ShroudOnUpdate at least fires less than ShroudOnGui did. :)

    Yup, but I thinking about writing the code to check so that it doesn't even make the attempt. If you try it, the object doesn't display. I'd rather not have a mistake mess with some things.

    As an update, I managed to modify the old guiButton. onClick function to handle the new mouse click event. Was worried my theory about sticking a ui.onClick function inside another function would fail miserably but managed to do it.

    So this works so far:

    Code:
    local testLabel = ui.label.add("TEST LABEL", 16, 200,400,200,20)
    testLabel:visible(true)
    local testImage = ui.image.add(450, 400, 30,30, "/assets/next.png")
    testImage:visible(true)
    local testButton = ui.guiButton.add(550,400,30,30,"/assets/prev.png")
    testButton:visible(true)
    testButton:onClick(function(id, kind)
        print("TEST")
    end)
    testImage:draggable(true)
     
  20. DavidDC

    DavidDC Programmer Moderator SOTA Developer

    Messages:
    1,532
    Likes Received:
    3,236
    Trophy Points:
    113
    Gender:
    Male
    Creating UI element in Update will (unless there some bool or something that stop it from being created) just create a ton of element every frame (60 time each second) and will eventually end up freezing up the game.
    This new UI element are meant to be created once, then manipulated later. In my LuaDemo example script you can see i use update just for animating every frame.
     
    Archer likes this.
Thread Status:
Not open for further replies.