Can't require the rotlove library

I’m trying to require a library I got from Github into my project, but am getting an error message I can’t seem to figure out. The directory structure for the library module from the root is:
lib/rotlove/rot.lua

In addition there is another folder:
lib/rotlove/rot
that contains more modules that the rot.lua module requires under the hood.

Peeking into the code of rot.lua I can see that it is doing this when I get my error message:
local ROTLOVE_PATH = (...) .. '.'
local Class = require (ROTLOVE_PATH .. 'class')

and when the second line is run I get the following error
ERROR:SCRIPT: /lib/rotlove/rot.lua:2: module 'lib.rotlove.rot.class' not found: no file 'lib.rotlove.rot.class' stack traceback:
[C]:-1: in function require /lib/rotlove/rot.lua:2: in main chunk
[C]:-1: in function require /prefabs/level/level.script:4: in main chunk

I double checked and class.lua is indeed under /lib/rotlove/rot/ so I’m not sure why I’m getting this error message. Can someone either help me figure out how to properly modify the require for the library so I can get it to load, or tell me if this is some kind of engine bug?

I had a similar issue a while back, though it was working for me locally and was only an issue for some end users.

What I ended up doing was re-writing all the requires to remove the dynamic portion (ROTLOVE_PATH in your case).

So for you, this:
local Class = require (ROTLOVE_PATH .. 'class')

Would become (I think):
local Class = require "lib.rotlove.rot.class"

With regards to rot.lua, perhaps it’s an issue that the file is named the same as a subfolder? In which case I’d just try to rename rot.lua.

Hope this helps.

1 Like