Difference between revisions of "Including simplelib in a Project"
m (→Intermediary Library Authors) |
m (→Dofile Call) |
||
Line 4: | Line 4: | ||
local sl = dofile(getinstalldir()..'/lib/simplelib.lua') | local sl = dofile(getinstalldir()..'/lib/simplelib.lua') | ||
− | That's all it takes to begin using simplelib. This initializes the library and assigns its interface to the local variable sl. In order to avoid usage errors, the interface is a special table which guards against user modification. Attempting to add new keys to the table or referencing non-existent keys will result in an error. | + | That's all it takes to begin using simplelib. This initializes the library and assigns its interface to the local variable sl. In order to avoid usage errors, the interface is a special table which guards against user modification. Attempting to add new keys to the table or referencing non-existent keys will result in an error. |
+ | |||
+ | == Version == | ||
+ | |||
+ | |||
+ | You can check the version of simplelib with the interface method [[slversion]](): | ||
+ | |||
+ | local v = sl.slversion() | ||
+ | |||
+ | Version will always be a monotonically increasing real number. | ||
== Intermediary Library Authors == | == Intermediary Library Authors == | ||
Calling dofile() on simplelib.lua multiple times is unnecessary but will cause no harm unless the global environment guard variable [[simple_lib_soliton__]] is overwritten. That's the only value/variable defined by simplelib in [[_G]] by default. Calling [[simple_lib_soliton__]] returns the unique interface table of simplelib. | Calling dofile() on simplelib.lua multiple times is unnecessary but will cause no harm unless the global environment guard variable [[simple_lib_soliton__]] is overwritten. That's the only value/variable defined by simplelib in [[_G]] by default. Calling [[simple_lib_soliton__]] returns the unique interface table of simplelib. |
Revision as of 15:12, 1 November 2010
Dofile Call
The simplelib.lua file belongs in the lib/ subdirectory of the openeuo root directory. To use simplelib, include the following line at the top of the dependent script:
local sl = dofile(getinstalldir()..'/lib/simplelib.lua')
That's all it takes to begin using simplelib. This initializes the library and assigns its interface to the local variable sl. In order to avoid usage errors, the interface is a special table which guards against user modification. Attempting to add new keys to the table or referencing non-existent keys will result in an error.
Version
You can check the version of simplelib with the interface method slversion():
local v = sl.slversion()
Version will always be a monotonically increasing real number.
Intermediary Library Authors
Calling dofile() on simplelib.lua multiple times is unnecessary but will cause no harm unless the global environment guard variable simple_lib_soliton__ is overwritten. That's the only value/variable defined by simplelib in _G by default. Calling simple_lib_soliton__ returns the unique interface table of simplelib.