Jump to content

Recommended Posts

Posted

You have to make the bindings. This basically means exposing the C++ RakNet to Lua. I've done this before but have since lost the code as back before it was free the creator said I couldn't distribute the DLL but had to give the source instead. It's very doable and not all that hard. I've been meaning to do it again but just haven't found the time.

 

You don't have to expose all of RakNet, just create some high level functions that give you the functionality of sending/receiving data. I think I exposed like maybe 5 functions to Lua or something like that.

  • Upvote 1
Posted

So I would have to translate c++ functions from Raknet into lua by creating a dll?

 

I'd assume Rick used toLua++ to expose the C++ functions of Raknet to Lua, you can learn about toLua++ here:

How to use toLua

 

With a basic understanding of toLua this shouldn't take any amount of time to do. Good luck!

Posted

ToLua seems to make things a whole lot easier. So it looks like I have to make a VC++ project with both raknet and tolua, bind functions, then I compile a dll which allows me to use networking in Leadwerks.

Posted

When I did it some time ago I actually didn't use ToLua but just the old fashion way. I flattened the RakNet classes and made it more procedural. Had functions like: Connect(), Host(), CreateBitStream(), WriteBitStream(), ReadBitStream(), Send(), NetworkLoop(), BindEvent().

 

More like the top part of this: http://lua-users.org/wiki/BindingCodeToLua

 

So I had global RakNet variables in my DLL for the peer interface and such.

Posted

When I did it some time ago I actually didn't use ToLua but just the old fashion way. I flattened the RakNet classes and made it more procedural. Had functions like: Connect(), Host(), CreateBitStream(), WriteBitStream(), ReadBitStream(), Send(), NetworkLoop(), BindEvent().

 

More like the top part of this: http://lua-users.org/wiki/BindingCodeToLua

 

So I had global RakNet variables in my DLL for the peer interface and such.

 

Oh, well that'd work just fine but since LE3 uses LuaJit I'd strongly recommend using toLua. toLua is much faster and weighs in at like 1/10th the overhead.

Posted

I don't believe LuaJit and toLua are in any way related are they? I personally don't like messing around with the whole idea of "cleaned header files". I'm sure RakNet doesn't adhere to those rules and setting that up manually for all of RakNet would be a pain in the arse. I could do it for my own exposure but then again the need to mess around with that I don't feel is required when simple static C++ methods gets the job done. When I looked at that it seemed more trouble than it was worth, but that's just my take on it.

 

If someone had the time to expose all of RakNet using something like toLua then that would be great, but it would also take a long time and be error prone most likely, but very welcomed I'm sure by many people.

Posted

I don't believe LuaJit and toLua are in any way related are they? I personally don't like messing around with the whole idea of "cleaned header files". I'm sure RakNet doesn't adhere to those rules and setting that up manually for all of RakNet would be a pain in the arse. I could do it for my own exposure but then again the need to mess around with that I don't feel is required when simple static C++ methods gets the job done. When I looked at that it seemed more trouble than it was worth, but that's just my take on it.

 

If someone had the time to expose all of RakNet using something like toLua then that would be great, but it would also take a long time and be error prone most likely, but very welcomed I'm sure by many people.

 

Agreed but doing it through C++ would produce more overhead, however I do agree with you about toLua, I'm not a big fan of it, also I haven't used it much; I would much prefer the implementation of LuaJit's FFI api into Leadwerks, I think this is something that should be strongly considered in the future.

 

Edit: Nevermind, it looks like FFI is in Leadwerks. Perfect biggrin.png

I'd strongly recommend using FFI.

Posted

oh yes.

im looking for that , long time ago..

would be nice to use raknet.dll in LE3 lua.

 

, or to implement a multiPlayer functionality in LE3+

Posted

I've exposed the ENET library to Lua in my project. I'm considering making it open-source once my project matures a bit more. :) Standard Leadwerks edition is required though, unless Josh would allow me to distribute the customized binaries.

Posted

@Ywa: would u share ur ENET exp. ? src, etc?

 

 

I have a version that binds ENET using LuaJit's FFI api, I''m sure it'd work on Leadwerks Indie ediotion, although I'm not sharing it; however, I could help you create your own it's very simple and quick..

Posted

Thanks for confirming.

 

actually it was Marley who had shown me a working example of enet via ffi in the lua version a couple of months ago... but since he isn't around at the moment i will take his "likes" laugh.png

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Posted

 

That's handy, but its unnecessarily large and complex.my version is purely Lua and a total of about 50 lines in the main lua file, aside from the header and the enums.

 

It also produces nicer functions instead of enet.enet_initialize it'd be proper, like: enet.initialize

 

I'll find it on my old external harddrive later and post some snippets.

  • 2 weeks later...
Posted

That's handy, but its unnecessarily large and complex.my version is purely Lua and a total of about 50 lines in the main lua file, aside from the header and the enums.

 

It also produces nicer functions instead of enet.enet_initialize it'd be proper, like: enet.initialize

 

I'll find it on my old external harddrive later and post some snippets.

 

Still waiting to see this ...still waiting ..been 14 days now biggrin.png

Threadripper 2920X Gen2 CPU(AMD 12-core 24 thread) | 32Gigs DDR4 RAM | MSI Nvidia GeForce RTX 2070 Stock OCed | ASRock X399 Professional Gaming Motherboard | Triple M.2 500Gig SSD's in Raid0

Windows 10 Pro | Blender | Paint.NetWorld Machine | Shader Map 4 | Substance Designer | Substance Painter | Inkscape | Universal Sound FX | ProBuilder | 3D World Studio | Spacescape | OpenSky | CubeMapGen | Ecrett Music | Godot Engine | Krita | Kumoworks | GDScript | Lua | Python | C# | Leadworks Engine | Unity Engine

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...