1

The data variable is a parameter in a function. sheeple is an instantiated table. I printed out the type of id and data which printed "number" and then "string" respectively. However, upon the execution of sheeple[id]=data, I get the error "index expected, got function." Thank you for any help.

    local id = 0
    local tmp  = data:sub(8)
    tmp = tmp:sub(1,tmp:find("[^0-9]")-1)
    id = tonumber(tmp) 
    queue(id)
    print(type(id))
    print(type(data))
    sheeple[id]=data
3
  • Could you provide some more info? Is there any other value called id, which is a function(just a guess)? Do you have a backtrace? Commented Jul 17, 2018 at 1:29
  • There are no other variables by the name of id at all. I am not sure what a backtrace is. Commented Jul 17, 2018 at 1:31
  • 1
    It seems that sheeple is doing something especial with indexing. Look at its metatable, especially the __index and __newindex methods. Commented Jul 17, 2018 at 1:34

1 Answer 1

1

Upon further review of my code. Embarrassingly, sheeple was also the name of the function that the code segment was in.

Sign up to request clarification or add additional context in comments.

2 Comments

Can a moderator close this question? I am not able to accept my own answer after two days.
I thought so as well, but upon capitalizing the table value's name the error went away.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.