wburton72 Posted October 1, 2014 Share Posted October 1, 2014 Does Rakknet work with lua? I'm hoping on making a multiplayer game in the indie version of LW. Quote Link to comment Share on other sites More sharing options...
Rick Posted October 1, 2014 Share Posted October 1, 2014 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. 1 Quote Link to comment Share on other sites More sharing options...
wburton72 Posted October 1, 2014 Author Share Posted October 1, 2014 So I would have to translate c++ functions from Raknet into lua by creating a dll? Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted October 1, 2014 Share Posted October 1, 2014 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! Quote Link to comment Share on other sites More sharing options...
wburton72 Posted October 1, 2014 Author Share Posted October 1, 2014 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. Quote Link to comment Share on other sites More sharing options...
Rick Posted October 1, 2014 Share Posted October 1, 2014 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. Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted October 1, 2014 Share Posted October 1, 2014 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. Quote Link to comment Share on other sites More sharing options...
Rick Posted October 1, 2014 Share Posted October 1, 2014 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. Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted October 2, 2014 Share Posted October 2, 2014 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 I'd strongly recommend using FFI. Quote Link to comment Share on other sites More sharing options...
dbk3r Posted October 2, 2014 Share Posted October 2, 2014 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+ Quote Link to comment Share on other sites More sharing options...
Ywa Posted October 2, 2014 Share Posted October 2, 2014 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. Quote Link to comment Share on other sites More sharing options...
dbk3r Posted October 2, 2014 Share Posted October 2, 2014 @Ywa: would u share ur ENET exp. ? src, etc? Quote Link to comment Share on other sites More sharing options...
Ywa Posted October 2, 2014 Share Posted October 2, 2014 @Ywa: would u share ur ENET exp. ? src, etc? Read my post again. Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted October 2, 2014 Share Posted October 2, 2014 @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.. Quote Link to comment Share on other sites More sharing options...
dbk3r Posted October 4, 2014 Share Posted October 4, 2014 thanx...will buy the standard edition, make many things a lot easier , i guess Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted October 4, 2014 Share Posted October 4, 2014 thanx...will buy the standard edition, make many things a lot easier , i guess I'd buy it regardless, but it'd be better to bind it using FFI: its instantaneous and would be like 0 overhead. Quote Link to comment Share on other sites More sharing options...
Rick Posted October 4, 2014 Share Posted October 4, 2014 I have a version that binds ENET using LuaJit's FFI api So FFI is working in LE's Lua version? Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted October 4, 2014 Share Posted October 4, 2014 So FFI is working in LE's Lua version? Yeah, works for me when I disable sandboxing. Edit: Then again I have Standard Edition as-well so I don't know for sure. Quote Link to comment Share on other sites More sharing options...
macklebee Posted October 5, 2014 Share Posted October 5, 2014 yes ffi is working in the lua only version as long as sandboxing is disabled. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Crazycarpet Posted October 5, 2014 Share Posted October 5, 2014 yes ffi is working in the lua only version as long as sandboxing is disabled. Thanks for confirming. Quote Link to comment Share on other sites More sharing options...
macklebee Posted October 5, 2014 Share Posted October 5, 2014 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" Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
dbk3r Posted October 5, 2014 Share Posted October 5, 2014 http://www.leadwerks.com/werkspace/blog/120/entry-1182-luajit-awesome-luajit-enet-loaded/ Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted October 5, 2014 Share Posted October 5, 2014 http://www.leadwerks.com/werkspace/blog/120/entry-1182-luajit-awesome-luajit-enet-loaded/ 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. Quote Link to comment Share on other sites More sharing options...
BES Posted October 19, 2014 Share Posted October 19, 2014 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 Quote 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.Net | World 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 Link to comment Share on other sites More sharing options...
dennis Posted October 20, 2014 Share Posted October 20, 2014 Is it also possible for the LE Standard users to add the raknet code inside the main.cpp or app.cpp and debug to use within a lua game ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.