-- initialise Lua bindings for PLplot examples.
--[[
The Lua 5.0 stanza below was temporarily tested for Lua 5.2 by
changing "Lua 5.0" to Lua 5.2 and converting all loadlib calls to
package.loadlib.  That test was a success (as was a test for the
non-Lua-5.0 stanza below when these temporary changes were removed)
when WRITEABLE_TARGET was non-null (which occurs when the user
uses the -DUSE_WRITEABLE_TARGET_TEST_PREFIX=ON option).  So
likely a real Lua 5.0 environment will work, but that has not
been explicitly tested.
--]]
if string.sub(_VERSION,1,7)=='Lua 5.0' then
	lib=
	          loadlib('/usr/lib/lua/plplot/plplotluac.so','luaopen_plplotluac') or
                  loadlib('/usr/lib/lua/plplot/plplotluac.dll','luaopen_plplotluac') or
                  loadlib('/usr/lib/lua/plplot/plplotluac.dylib','luaopen_plplotluac')
	assert(lib)()
else
	package.cpath = '/usr/lib/lua/plplot/?.so;' ..
                  '/usr/lib/lua/plplot/?.dll;' ..
                  '/usr/lib/lua/plplot/?.dylib;' ..package.cpath
	require('plplotluac')
end
