Author Topic: require() doesn't work with lua scripts  (Read 3324 times)

0 Members and 1 Guest are viewing this topic.

Offline ATAG

  • Scripter
  • Double Ace
  • ******
  • Posts: 111
  • Karma: +14/-0
  • secret things
    • Metin2 Hungarian Forum
require() doesn't work with lua scripts
« on: 24 July, 2009, 19:01:16 »
When i try to load a lua module (written in lua) i get this error:
Quote
24.07.2009 18:49:16 - error loading module 'vhsql' from file '/home/atag/.PtokaX/libs/vhsql.lua':

   /home/atag/.PtokaX/libs/vhsql.lua: invalid ELF header

This is only PtokaX related problem, in lua commandline it works like a charm.

I can' use dofile() because this module uses a global sqlite db for all scripts :(

Version: PtokaX DC Hub 0.4.1.1 built on Jul 24 2009 18:40:37
OS: Linux 2.6.28-14-generic (i686) -> (Ubuntu 9.04)
« Last Edit: 24 July, 2009, 19:04:33 by ATAG »

PtokaX forum

require() doesn't work with lua scripts
« on: 24 July, 2009, 19:01:16 »

Offline PPK

  • Administrator
  • Emperor
  • *****
  • Posts: 1 480
  • Karma: +209/-22
  • PtokaX developer
Re: require() doesn't work with lua scripts
« Reply #1 on: 24 July, 2009, 23:21:19 »
PtokaX on unix not contains lua and not change any default lua functions :o
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

Offline ATAG

  • Scripter
  • Double Ace
  • ******
  • Posts: 111
  • Karma: +14/-0
  • secret things
    • Metin2 Hungarian Forum
Re: require() doesn't work with lua scripts
« Reply #2 on: 26 July, 2009, 16:56:40 »
Hmm.. i tried to compile PX with lua-5.1.4 (from source) but i got this:
Quote
/usr/local/lib/liblua.a(loadlib.o): In function `ll_loadfunc':
loadlib.c:(.text+0xa31): undefined reference to `dlsym'
loadlib.c:(.text+0xa7c): undefined reference to `dlopen'
loadlib.c:(.text+0xa89): undefined reference to `dlerror'
loadlib.c:(.text+0xaa1): undefined reference to `dlerror'
/usr/local/lib/liblua.a(loadlib.o): In function `gctm':
loadlib.c:(.text+0x109e): undefined reference to `dlclose'
collect2: ld returned 1 exit status
make: *** [PtokaX] Error 1
atag@server:~/PtokaX$
Any idea? :(



Sorry, i've found the solution here.

Now i get the "ivalid ELF header" error in commandline too :D



Ok, finally i found the problem. We have to add libs folder to package.path TOO
Code: [Select]
if not string.find(package.path, Core.GetPtokaXPath().."libs/?.lua", 1, 1) then
package.path = package.path..";"..Core.GetPtokaXPath().."libs/?.lua"
end
« Last Edit: 26 July, 2009, 17:32:26 by ATAG »

Offline PPK

  • Administrator
  • Emperor
  • *****
  • Posts: 1 480
  • Karma: +209/-22
  • PtokaX developer
Re: require() doesn't work with lua scripts
« Reply #3 on: 26 July, 2009, 20:06:49 »
Good, nice to see that you fixed it yourself  8)
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

PtokaX forum

Re: require() doesn't work with lua scripts
« Reply #3 on: 26 July, 2009, 20:06:49 »