Page 1 of 1

[solved] - how to compile Cel 1.6 with luasocket?

Posted: 11.02.2009, 08:38
by Stuffer
Hey,

I've got a problem with customizing celestia. I did it like described in the wiki and it worked fine as it was mentioned there.
But how can I include new functions or libraries?

I need to have the functions of the luasocket library which I assume are not yet included into 1.6. So I downloaded luasocket 1.4 where there was a lua.c and luasocket.c source file and a luasocket.h header file. How do I include them into the source code of celestia 1.6 I downloaded from SVN?

I also looked for the newer luasocket 2.0 but then I only found a package called 'luasocket-2.0.2-lua-5.1.2-Win32-vc8.zip' with an .exe-file and some lua source code files. Do I not need a .c/.cpp and .h/.hpp?

Do I just have to put them into the source folder? Change entries in a makefile? include the headerfile in some existing .cpp's?

I would appreciate some help here 'cause I'm really stuck at the moment.

Thanks in advance.

Re: how to compile Cel 1.6 with luasocket?

Posted: 11.02.2009, 14:52
by chris
(I got your PM, but am responding here so that anyone else interested in using luasocket with Celestia will also benefit...)

You don't need to include luasocket with the Celestia source code. You just need to copy the files from luasocket into the appropriate places (and unfortunately, it's not obvious how to do this...)

The Lua socket binary package for windows contains five items:
- lua5.1.dll - not needed, as Celestia is already built with Lua support built in
- lua5.1.exe - not needed (this is just a standalone Lua interpreter)
- lua folder - copy this folder into Celestia's extras folder
- socket (contains the single file core.dll) - copy this folder into the main Celestia folder (i.e. the one with celestia.exe)
- mime (contains the single file core.dll) - copy this folder into the main Celestia folder too

That should be all that you need to do to install Lua socket.

Do make sure that ScriptSystemAccessPolicy is set to "allow" in celestia.cfg. Otherwise scripts won't be able to use DLLs. Once that's done, try writing a simple script to test whether the luasocket library can be found. It should begin with something like:

local socket = require("socket")

If there's a problem, you'll see an error dialog pop up.

--Chris


--Chris

Re: how to compile Cel 1.6 with luasocket?

Posted: 11.02.2009, 15:57
by Stuffer
Chris,

thanks a lot.

unfortuantely it didn't work as you mentioned.

if I start as you proposed or having a script like this:

Code: Select all

require "socket"

celestia:flash("Hallo")


error message is in the picture

Hope this can be solved.

Stuffer

Re: how to compile Cel 1.6 with luasocket?

Posted: 11.02.2009, 16:49
by chris
I think I messed up one step. Try moving the lua folder from extras into the main Celestia folder...

--Chris

Re: how to compile Cel 1.6 with luasocket?

Posted: 11.02.2009, 21:18
by Stuffer
Chris,

thanks again. Now it seems to work fine.

Re: how to compile Cel 1.6 with luasocket?

Posted: 23.02.2009, 22:17
by phoenix
i was also trying to get this to work but am stuck now on this error:

Code: Select all

Fatal Error: extras/luatest/luatest.lua:7: attempt to index local 'http' (a boolean value)


after the error celestia loads up as normal.
i have all the files (core.dll an socket.lua etc.) in place but whatever small test-script i try to run with sockets it gives me an error.

maybe i'm not getting lua itself and there is a stupid error i'm not seeing.
the luatest.lua looks like this:

Code: Select all

local http = require("http")

-- Requests information about a document, without downloading it.
-- Useful, for example, if you want to display a download gauge and need
-- to know the size of the document in advance

r, c, h = http.request {
   method = "HEAD",
   url = "http://orpheus.purebytes.de/command.php"
   }


any help is appreciated ;)

Re: how to compile Cel 1.6 with luasocket?

Posted: 23.02.2009, 22:47
by selden
The lua manual states that "requre" returns either true or false, depending on whether or not the specified Lua module was successfully loaded. It does not return a table of functions. See the Lua manual at http://www.lua.org/manual/5.1/manual.html#pdf-require

You need to define the table http within the Lua code which you have "required".

Re: how to compile Cel 1.6 with luasocket?

Posted: 24.02.2009, 12:05
by phoenix
i downloaded the package from here:
http://www.inf.puc-rio.br/~brunoos/luasec/

just the "luasocket-2.0.2-lua-5.1-win32-dll9.zip".
i tried with and without require("socket") but always get this error.
doesn't the require include the proper http.lua file in that directory?

if it's just a lua error i should probably test this with lua only before i run it in celestia ;)

Re: how to compile Cel 1.6 with luasocket?

Posted: 24.02.2009, 17:25
by selden
The url
http://www.inf.puc-rio.br/~brunoos/luasec/
is for a Lua SSL implementation.

I assume you mean the Lua socket library which is mentioned on the SSL page and which is available at
http://luaforge.net/projects/luasocket/

I'm not sure what you mean by "this error". The Lua code you provided above doesn't reference the socket library. Also, the code above can't work because it isn't written correctly.