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

[ASAP][Lua]require function

Started by Mads, 30 March 2012 - 05:20 PM
Mads #1
Posted 30 March 2012 - 07:20 PM
Hi! I think it would be awesome, if we could use require <filename>, just like normal.
This would open alot of new possibilities, and make life a whole lot easier for many people. :o/>/>
Hope a developer of CC sees this xD
Advert #2
Posted 30 March 2012 - 07:23 PM
require() was actually removed.

You can use loadfile().
Mads #3
Posted 30 March 2012 - 07:33 PM
Are they 100% identical?
Advert #4
Posted 30 March 2012 - 07:37 PM
Do they HAVE to be?

You can create your own require() if you really want it that much.
bonobot #5
Posted 08 April 2012 - 01:09 AM
Why not return a pseudo-object (table) with dofile?
Xfel #6
Posted 08 April 2012 - 11:17 AM
dofile should behave as specified in the lua api.

but a cc require function could look through a library path and than load the searched api. Currently, APIs are loaded on startup only, and to load it later you have to know the full path. A package library inplementation would be definetely a good thing. it could also search in local paths if the library isn't found in the rom path.