Jump to content

Combining C++ and Lua


Clackdor
 Share

Recommended Posts

So, how do I go about utilizing objects with Lua scripts that I place inside the editor? I've figured out that I can access entities using FindChild(); This lets me position the entities and manipulate them in that manner. How would I associate them with a controller or access the animations written in the .lua file associated with the .gmf.

 

Specifically, I am talking about zaphos' skeleton models. They are my favorite toy right now. It's the first truely complex model I've incorporated into my game. Until now, I have been using the editor to carve out a static scene and then adding all of my dynamic content via C++. This has the unfortunate drawback of making me re-write all of the code in C++ that was already written in Lua. Any other models I've imported, I've had to write code for anyway, so I did it in C++.

Link to comment
Share on other sites

BP lua = GetLuaState();
lua_pushobject(lua, fw);
lua_setglobal(lua, "fw");
lua_pop(lua,1);

 

and so if there is an object that you load in C++ that you want to access in LUA you need to set it as global

 

SetGlobalObject(object);

 

Now all your LUA code should work when you load the model in c++ or via LoadScene().

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...