Multiplayer using RakNet/Löve with Lua C API

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
olle
Prole
Posts: 5
Joined: Sat Dec 25, 2010 3:40 pm

Multiplayer using RakNet/Löve with Lua C API

Post by olle »

Hello, everybody!

I'm quite new to Löve. I'm using it right know for prototyping our game project (info here: https://sites.google.com/site/anakhagame/).

I will use Raknet to program the network stuff, thus I need to export functions to Lua, I think. How do I use the Lua C API with Löve? I think that will be necessary, or is there any other way to program network with Löve?

Regards
Olle
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Multiplayer using RakNet/Löve with Lua C API

Post by vrld »

Welcome to the world of LÖVE, you will not regret entering it! :awesome:
olle wrote:I will use Raknet to program the network stuff, thus I need to export functions to Lua, I think. How do I use the Lua C API with Löve?
Well, normally you don't. But you can build modules using the C api and require them in your game. But this will likely break portability - you have to provide the compiled module for every platform you wish to support.
olle wrote:I think that will be necessary, or is there any other way to program network with Löve?
LuaSocket is bundled with LÖVE, and it is awesome. Apart from rather low level socket programming it offers a nice high level concept called LTN12.
There is also LUBE which was developed by bartbes specifically for the use with LÖVE.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
olle
Prole
Posts: 5
Joined: Sat Dec 25, 2010 3:40 pm

Re: Multiplayer using RakNet/Löve with Lua C API

Post by olle »

Well, normally you don't. But you can build modules using the C api and require them in your game.
Wouldn't that require that I start a separate Lua state from C? I can't use C functions in Lua without having a C executable running, right? Is it possible to start Löve from C?
But this will likely break portability - you have to provide the compiled module for every platform you wish to support.
Breaking portability is no biggy in this state.

EDIT: Ok, found link http://lua-users.org/wiki/BuildingModules, I think that's what I need. Thanks!!

EDIT2: I'd still like to know if it's possible to start Löve from C, though...
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Multiplayer using RakNet/Löve with Lua C API

Post by Robin »

Welcome!
olle wrote:EDIT2: I'd still like to know if it's possible to start Löve from C, though...
LÖVE is written as an application, and although there has been some action to make it usable as a library, but AFAIK only from the Lua side.

Is there a special reason to use RakNet instead of LuaSocket, though?
Help us help you: attach a .love.
olle
Prole
Posts: 5
Joined: Sat Dec 25, 2010 3:40 pm

Re: Multiplayer using RakNet/Löve with Lua C API

Post by olle »

Robin wrote:Welcome!
Thank you! :)
LÖVE is written as an application, and although there has been some action to make it usable as a library, but AFAIK only from the Lua side.
Using Löve as a library could work too. In that case I could use the regular C API and start up LÖVE from my own Lua state. Is there information available on this?
Is there a special reason to use RakNet instead of LuaSocket, though?
Performance, I suppose. Also, the chief of the project don't know about LuaSocket (well, not yet, anyway). LÖVE will not be used in the final produc.

If any one is interested, this is the network algorithm we will try to implement: http://www.gamasutra.com/view/feature/3 ... twork_.php

Our ambition is to make it peer-to-peer, though. Eventually.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Multiplayer using RakNet/Löve with Lua C API

Post by Robin »

olle wrote:Using Löve as a library could work too. In that case I could use the regular C API and start up LÖVE from my own Lua state. Is there information available on this?
Not that I know of.
olle wrote:
Is there a special reason to use RakNet instead of LuaSocket, though?
Performance, I suppose.
I doubt performance will be affected by this. The core part of LuaSocket is implemented in C. And even if it were implemented completely in Lua, network lag poses a much larger performance issue. If you won't use LÖVE in the final product, why use RakNet in the prototype?
Help us help you: attach a .love.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Multiplayer using RakNet/Löve with Lua C API

Post by vrld »

RakNet is rather high level. Implementing the network functionality with luasocket in the prototype would mean to reinvent the whole thing later. Plus you'd have to learn luasocket in addition to RakNet.
That said, it is possibly easier to make a lua module out of RakNet than to make a module out of LÖVE...
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
olle
Prole
Posts: 5
Joined: Sat Dec 25, 2010 3:40 pm

Re: Multiplayer using RakNet/Löve with Lua C API

Post by olle »

If you won't use LÖVE in the final product, why use RakNet in the prototype?
Because I can. ;) It will save time, too, of course.

A good question is which functions in the network routine should be exported to Lua.

I think I will do like this:
1. Make a module that works on Ubuntu, with RakNet etc and LÖVE.
2. When LÖVE no longer is needed, start my own Lua state and export the functions in the former module.

Thank you for your time!
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 77 guests