martyj Posted January 14, 2015 Share Posted January 14, 2015 I have been trying to integrate LUA and C++ in the same project and I keep running into roadblock that require more of my code to be re-written in C++. I was wondering if anyone has managed to get C++ and Lua to be able to do things like draw to the screen. From what I can see, everything is either written in all C++ or everything is all written in Lua with C++ just setting up an interpreter. Does anyone have any experience/examples/documentation on the Interpreter class? Quote Link to comment Share on other sites More sharing options...
shadmar Posted January 14, 2015 Share Posted January 14, 2015 You can still use per entity lua scipts even if you have a c++ project. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Guppy Posted January 14, 2015 Share Posted January 14, 2015 Does anyone have any experience/examples/documentation on the Interpreter class? What would you like to know? Here is an example of pushing data from C++ to lua; http://www.leadwerks.com/werkspace/blog/138/entry-1288-pushing-complex-lua-tables-from-c/ If your up to digging through C++ code there is some examples of going in both directions here https://bitbucket.org/guppy42/cppandluatest (be ware this project is semi-retired) Finally the c++ source code for the lua version is in the source folder of any lua project you create - you can take that and replace your app.h/c++ of your c++ project and it will work exactly like the lua project - except for any changes you make Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
catch22 Posted January 14, 2015 Share Posted January 14, 2015 You'll have to be more specific with an example. Are you trying to expose your C++ to lua, or something? Without some specifics, what do you really needs beyond the entity scripts? Quote Coding for Christ. Link to comment Share on other sites More sharing options...
martyj Posted January 15, 2015 Author Share Posted January 15, 2015 Guppy, you're my hero. Any idea how to pass a C++ context to Lua? I'd like to be able to draw in either C++ or Lua. Same with window. Quote Link to comment Share on other sites More sharing options...
beo6 Posted January 15, 2015 Share Posted January 15, 2015 the way you get your context in LUA does not change when you use a C++ project. You should be able to use http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/contextgetcurrent-r632 to get your current context and then just draw on it like normal. Edit: And actually you probably don't even need the above since the Script:PostRender(context) function already provides you with the context. Quote Link to comment Share on other sites More sharing options...
Guppy Posted January 15, 2015 Share Posted January 15, 2015 Guppy, you're my hero. Any idea how to pass a C++ context to Lua? I'd like to be able to draw in either C++ or Lua. Same with window. As already pointed You dont really want to pass those as getCurrent work in both cases, also passing anything other than simple types is error prone. Window:GetCurrent() http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/window/windowgetcurrent-r628 Context:GetCurrent() http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/contextgetcurrent-r632 The bitbucket link has examples of passing data in both directions as well as calling lua functions from C++ and vice versa, but as I said it will require some digging as it's a more or less complete gui Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 15, 2015 Share Posted January 15, 2015 Not sure if it implies to the topic (quick look). http://www.leadwerks.com/werkspace/topic/6887-communicating-from-lua-to-c/ Quote Link to comment Share on other sites More sharing options...
martyj Posted January 17, 2015 Author Share Posted January 17, 2015 I have all my answers. Thank you everyone. 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.