This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
bigflipperfish's profile picture

require()?

Started by bigflipperfish, 28 April 2017 - 12:45 AM
bigflipperfish #1
Posted 28 April 2017 - 02:45 AM
I wanted to use the require() function from lua to add a module to my code. I know about os.loadAPI() and dofile() and the such and I can make my code have the result that I want, but I was wondering if there was a particular reason that require() is not included in computercraft. I've been searching through the documentation and reading forum after forum with no clear answer. Can anyone help me out?
Exerro #2
Posted 28 April 2017 - 04:34 PM
Not sure of the reason it's not implemented, but there are Lua-based versions that do the same thing on the forums. Alternatively, `dofile` is pretty much identical except it doesn't cache the result.

See http://www.computercraft.info/forums2/index.php?/topic/24015-cc-require-standards-compatible-require-for-computercraft