So, from what I am understanding this "should" work but I keep getting the the following error: attempt to index local 'test' (a function value) error.
here is the "test" (main) file
local test = require("testAPI")
local term = require("term")
term.write("This is NOT from the api!")
test.fred("And this is!")
And here is the "testAPI.lua" file:
local term = require("term")
function fred(text)
term.write(text)
end
function george()
term.write("should not see this unless george was called!")
end
and when I run it I get:
/# test
This is NOT from the API!
/test:5: attempt to index local 'test' (a function value)
stack traceback:
/test:5: in main chunk
(...tail calls...)
Basically, I would like to create an API/Library with various functions in them so I can call the separate functions as needed. What am I doing wrong to prevent this error?
p.s., I did look at this tutorial and tried to use a table with a different error altogether.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
So, from what I am understanding this "should" work but I keep getting the the following error: attempt to index local 'test' (a function value) error.
here is the "test" (main) file
And here is the "testAPI.lua" file:
and when I run it I get:
Basically, I would like to create an API/Library with various functions in them so I can call the separate functions as needed. What am I doing wrong to prevent this error?
p.s., I did look at this tutorial and tried to use a table with a different error altogether.
Link to post
Share on other sites