General Lua Scripting/Error Questions

Discussion in 'Lua Discussions' started by tervalas, Nov 19, 2021.

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

    tervalas Avatar

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    8
    Not sure if a topic like this could get pinned or anything, but always good to have one thread for people to get help.

    This was started based off my post in another thread....

     
  2. tervalas

    tervalas Avatar

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    8
    So I think I've narrowed it down with an issue on calling the caption function. I changed that to:
    Code:
    caption = function(label, caption)
        if caption ~= nil then
            ShroudModifyText(label.objId, caption)
            label.caption = caption
        end
        return label.caption
    end,
    Test code:
    Code:
    clock.label = createLabel("THIS IS A TEST", 20, 5, 0,200,30)
    print(clock.label:caption())
    Gives the same lua error as before. And what is irritating is that it doesn't seem to even make it into the caption function code.
     
  3. tervalas

    tervalas Avatar

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    8
    Solved it. Guess lua didn't like me naming the function caption while also referencing a table value called caption. So it may have been interpreting clock.label:caption() as caption(clock.label.caption, nil).

    It's a really weird thing with how Lua calls functions that took a while to find an answer to.
     
    Drake Aedus likes this.
Thread Status:
Not open for further replies.