A standards compatible implementation of require,
and part of the package library, as specified by the Lua Manual
Allows for compatability with many non-CC Lua programs and API.
Examples
Standards compatible:
local api = {}
function api.hello(what)
print("Hello, " .. what .. "!")
end
return api
The ComputerCraft way:
function hello(what)
print("Hello, " .. what .. "!")
end
The main difference is that with standard require, APIs return a table
containing the API, where as in ComputerCraft's os.loadAPI, the global
environment of the API file is put into _G[api_filename].
This implementation of require allows you to import either type API.
It will however not place it in the global environment.
-- API file: /lib/api.lua
local api = require("api")
api.hello("World")
-- API file: /lib/test/api.lua
local api = require("test.api")
api.hello("ComputerCraft")
The search paths, where require looks for the API, can be found at the top of require.lua
Contribute
Download and installation
Resource pack can be downloaded from the Bitbucket download section.
Put the downloaded zip into the directory resourcepacks/, innside your minecraft directory, creating it if needed.