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

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 15 years 11 months
Location: Stuttgart, Germany

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

Post #1by Stuffer » 11.02.2009, 08:38

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.
Last edited by Stuffer on 02.04.2009, 07:15, edited 1 time in total.
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: how to compile Cel 1.6 with luasocket?

Post #2by chris » 11.02.2009, 14:52

(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

Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 15 years 11 months
Location: Stuttgart, Germany

Re: how to compile Cel 1.6 with luasocket?

Post #3by Stuffer » 11.02.2009, 15:57

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
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: how to compile Cel 1.6 with luasocket?

Post #4by chris » 11.02.2009, 16:49

I think I messed up one step. Try moving the lua folder from extras into the main Celestia folder...

--Chris

Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 15 years 11 months
Location: Stuttgart, Germany

Re: how to compile Cel 1.6 with luasocket?

Post #5by Stuffer » 11.02.2009, 21:18

Chris,

thanks again. Now it seems to work fine.
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB

phoenix
Posts: 214
Joined: 18.06.2002
With us: 22 years 5 months
Location: Germany - Berlin

Re: how to compile Cel 1.6 with luasocket?

Post #6by phoenix » 23.02.2009, 22:17

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 ;)
most recent celestia win32-SVN-build - use at your own risk (copy over existing 1.5.1 release)

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Re: how to compile Cel 1.6 with luasocket?

Post #7by selden » 23.02.2009, 22:47

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".
Selden

phoenix
Posts: 214
Joined: 18.06.2002
With us: 22 years 5 months
Location: Germany - Berlin

Re: how to compile Cel 1.6 with luasocket?

Post #8by phoenix » 24.02.2009, 12:05

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 ;)
most recent celestia win32-SVN-build - use at your own risk (copy over existing 1.5.1 release)

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Re: how to compile Cel 1.6 with luasocket?

Post #9by selden » 24.02.2009, 17:25

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.
Selden


Return to “Development”