Last active
August 29, 2015 14:01
-
-
Save awstanley/061765914e55f6a06d4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[------------------------------------------------------------------- | |
-- Platform detecting Lua initialisation code | |
-- Copyright (c) 2014 A.W. Stanley <[email protected]> | |
-- Released under the new BSD License | |
-------------------------------------------------------------------]]-- | |
local lua_dir = "lua" | |
local lua_init = "lua/server.lua" | |
-- Pull the first directory | |
local rpath = package.path:gmatch("([^;]+)(;)")() | |
rpath = rpath:gsub("\\","/") | |
rpath = rpath:sub(0,#rpath-9) .. lua_dir .. "/?" | |
-- Operating system detection | |
local _, w32count = package.cpath:gsub(".dll",".dll") | |
if(w32count > 0) then | |
os.platform = "win32" | |
os.platform_ext = ".dll" | |
end | |
if os.platform == nil then | |
local _, osxcount = package.cpath:gsub(".dylib",".dylib") | |
if(osxcount > 0) then | |
os.platform = "osx" | |
os.platform_ext = ".dylib" | |
else | |
if(osxcount > 0) then | |
os.platform = "posix" | |
os.platform_ext = ".so" | |
end | |
end | |
end | |
package.cpath = package.cpath .. ";" .. rpath .. os.platform_ext | |
-- Your init call (this is mine) | |
dofile(lua_init) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment