-
Notifications
You must be signed in to change notification settings - Fork 0
The #use directive
The #use directive imports other scripts as modules.
Module file: mymod.neil
module MyModule()
Void Hello()
Print("Hello World!")
End
End
Main file
#use "mymod"
Init
mymod.Hello()
End
#use is dependent on the underlying system, and can also be quite some trouble to set up right. By default it just looks up the file by default and loads it. Now Neil also supports that #use is being used in a full application or a game where all scripts are being packed in the way you decide. If that's the case, you should define the readfile method
function Neil.ReadFile(filename)
return << the full content for the file as a string >>
#use can also find a directory with the module name as a directory with the extension "NeilBundle". Inside it will at first try to look for the module with the same name with .neil, if not found Neil must be able to scan the entire directory, and by default Neil cannot do that. This is because Lua doesn't support it (Lua was written in plain C, had to work on all C compilers, and there's no standard directory read-out library for C, that's why). So in order to properly use bundles you should create a readdir method:
function Neil.ReadDir(directoryname)
return << all files within the directory returned as a table containing all file names as strings >>
Depending on how how Neil.ReadFile is defined it might be required for Neil.ReadDir to return all filenames with full path names.