I haven't worked with Lua in a while and recently my friends and I started a new modded game. I'm currently trying to require another file from another, and to my knowledge have done it to how the syntax describes. However, OpenOS is giving me an error stating the following:
However, when running the cd command it states that core.lua does indeed exist in the directory /home/
This is my code:
-- core.lua
functioncatch(inp)return inp[1]endfunctiontry(inp)
status, res = pcall(inp[1])ifnot status then
inp[2](res)endreturn res
end-- test.lua
function dir()local str = debug.getinfo(2,"S").source:sub(2)return str:match("(.*/)")end--thisiswhere it breaks:require(dir().."core.lua")local http
core.try{function()
http =require("socket.http")local body, code = http.request('https://raw.githubusercontent.com/rxi/json.lua/master/json.lua')local f =assert(io.open('modules/json.lua','wb'))
f:write(body)
f:close()print('Successfully downloaded json.lua module.')end, core.catch{function(err)print('Caught Error: '.. err)end}}
If someone could please explain to me what I am doing wrong and more specifically how to fix the issue it would be greatly appreciated.
Module can't be found but file exists at location?
in Programming
Posted
Hey,
I haven't worked with Lua in a while and recently my friends and I started a new modded game. I'm currently trying to require another file from another, and to my knowledge have done it to how the syntax describes. However, OpenOS is giving me an error stating the following:
However, when running the cd command it states that core.lua does indeed exist in the directory /home/
This is my code:
If someone could please explain to me what I am doing wrong and more specifically how to fix the issue it would be greatly appreciated.