PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Help with scripts => Topic started by: Hamachi on 04 December, 2010, 22:38:21

Title: require("pxlfs") AND linux Debian not work !
Post by: Hamachi on 04 December, 2010, 22:38:21
Hey i have som problems whit scripts whit require("pxlfs") on my linux server some there can help ?

Have install pack:
sudo apt-get install liblua5.1-0 liblua5.1-0-dev lua5.1 liblua5.1-filesystem0 liblua5.1-socket2 liblua5.1-sql-mysql-2 liblua5.1-sql-sqlite3-2 zlib1g-dev make g++

Thanks :)
Title: Re: require("pxlfs") AND linux Debian not work !
Post by: mariner on 05 December, 2010, 00:04:18
Replace require("pxlfs") with require("lfs")
Title: Re: require("pxlfs") AND linux Debian not work !
Post by: Hamachi on 05 December, 2010, 12:31:05
Thanks

Have try it before but it not work, but it work now :D

Are there a command so i can see the hub run on Linux or Win ?
Title: Re: require("pxlfs") AND linux Debian not work !
Post by: PPK on 05 December, 2010, 17:45:37
/stats
QuoteVersion: PtokaX DC Hub 0.4.1.2c x64 built on Jul  9 2010 01:17:01
OS: Windows 7
QuoteVersion: PtokaX DC Hub 0.4.1.2c built on Oct 30 2010 23:06:42
OS: Linux 2.6.32.22 (x86_64)
Title: Re: require("pxlfs") AND linux Debian not work !
Post by: Hamachi on 05 December, 2010, 21:18:52
hmm

where can i use that !

it is for somfing like this:

if os.px == linux then
   require("lfs") -- LINUX
else
   require("pxlfs") -- WIN
end
Title: Re: require("pxlfs") AND linux Debian not work !
Post by: PPK on 06 December, 2010, 11:09:43
Lua API don't have call to check what on what OS PtokaX is running, simply because it is hard to do ::) Many systems returning crazy OS identification (for example wtf is SunOS 5.11 (i86pc) ?) :-X
You can use Core.GetPtokaXPath() to check if is running on Unix like system (path will start with /)  8)
Title: Re: require("pxlfs") AND linux Debian not work !
Post by: mariner on 06 December, 2010, 18:40:11
Use this code
path,selfname = debug.getinfo(1).source:match("^@?(.+[/\\]).-[/\\](.-)$")
path = path:gsub("\\","/")

if path:find("^/") then -- OS detection
require "lfs" -- Linux
else
require"pxlfs" -- Windows
end
Title: Re: require("pxlfs") AND linux Debian not work !
Post by: mariner on 07 December, 2010, 16:38:10
Hm, I copied this code from the working script.