Skip to main content
gamedev.net
🔒 Locked

Scripting

Started by Skuld Apr 8, 2002 at 12:39 AM 5 replies 200+ views
Original Post
Skuld
Skuld
OK, so how do I integrate a scripting language, such as LUA, to my game engine? would i need to modify the engine, and in what way? Could somebody give me a sample of this? I have a hard time learning from tutorials, etc. i need to see the code firsthand (which is how i learn).
cpp boy
cpp boy
The best way to integret a scripting engine to your game is to create one. But if you cant do that then i would go to use the thing you said or an other scripting language.

Kevin
Kevin
Null and Void
Null and Void
The Lua reference has plenty of information on integrating it into C (since that''s what it was designed for in the first place). Look at the lua_do* functions to execute code and lua_register to register your own functions with Lua.

Taulin
Taulin
Can you register class functions? I always thought a function pointer was the same as the next, but I have read some scripting languages do not allow it.
Null and Void
Null and Void
quote:
Original post by Taulin
Can you register class functions? I always thought a function pointer was the same as the next, but I have read some scripting languages do not allow it.

A "class function" has both a function pointer and a this pointer. You can register them with Lua, but it takes a little trickery . I personally only have Lua call one type of class''s methods (gScriptFunc), which has a single virtual function. I simply register my function "gtwCall" with Lua, then pass it a gScriptFunc pointer (which I registered as a global variable, of type user data, with Lua) and my gtwCall function calls the virtual function of the pointer passed. It works for me, but you may want to use a different solution.

Skuld
Skuld
ok, so it''s better to use another scripting language like lua, but how do you install it on a windows system? i''ve tried the lua mailing lists, but they keep saying the same thing: copy all .h .c and compile the project file. how do you specifically install it on MSVC++ 6?
Null and Void
Null and Void
quote:
Original post by Skuld
ok, so it''s better to use another scripting language like lua, but how do you install it on a windows system? i''ve tried the lua mailing lists, but they keep saying the same thing: copy all .h .c and compile the project file. how do you specifically install it on MSVC++ 6?

Have you checked if there are any Win32 binaries already available? If so, just put the libraries in your lib directory and the headers in your include directory. Lua''s one and only implementation is 100% ANSI C, so it should be easy to compile your own version too. When I get home (I''m about to head off to HS, I have to go early for some meeting dealy ) I''ll boot Windows and install it again (I don''t remember what I did last time) if you haven''t figured it out yet.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.