Posts | ||
---|---|---|
[Source ] Adding Lua | Locked | |
Thread Options | 1 2 | |
Jun 30 2009 Anchor | ||
Hi! greetz, |
||
Jun 30 2009 Anchor | ||
There is a new tutorial for adding lua up on the wiki it uses a newer version of lua if I am not mistaken and doesn't use luabind. I recommend you check that out. |
||
|
Jun 30 2009 Anchor | |
Jun 30 2009 Anchor | ||
Ok, i tried it, but couldn't get that interface thingy to work. Could you help me alittle? |
||
|
Jun 30 2009 Anchor | |
Jul 2 2009 Anchor | ||
Well, may problem's a little more generic. It's just that the description "Now you can make a lua interface" is alittle vague. I mean, what is implemented and what do i have to implement? |
||
Jul 2 2009 Anchor | ||
I've also been using the "Adding Lua" tutorial and have been having some trouble with it. Firstly, I'm very greatful you put up a tutorial on Lua. Thanks But I'd like to request some additions: You say "You will need to make your own class that inherets from LuaHandle ..." and "And thus you will need to define this functions in another file". Would it be possible to instead include complete examples of these files in the wiki as you did with the ge_luamanager files? That would be really helpful. Thanks |
||
|
Jul 2 2009 Anchor | |
The reason i dont include complete versions of these is because they will be dependent on what you want to do. So the first thing you need to do is make a new class that inherits from LuaHandle
Next thing to do is make a constructor and the 4 functions you need to override
Now you need to make sure your constuctor calls Register so in a cpp file start the class def:
and implment the other functions like on the wiki. So what you have to do is dependent on what you want to do. You have to provide the mapping between c++ and lua in the form of functions (lua calls into c++) and callbacks (c++ calls into lua). If you tell me what your trying to do i could help a bit better. Edited by: lodle |
||
Jul 2 2009 Anchor | ||
Omg! Epic post! please add to wiki! Add an example of how to have lua register a C++ func and You're perfecx! |
||
|
Jul 2 2009 Anchor | |
This is on the wiki all ready plus that as well! Look at the 4 functions i have there and read the text! Edited by: lodle |
||
Jul 2 2009 Anchor | ||
kk, guess that be my bad. Well, then I'll be on programming a lua base Edited by: Drake25 |
||
Jul 2 2009 Anchor | ||
When I get this all working, I'll update the wiki page a little. I got it all to compile, now I just need to have Lua functions called in C++ and C++ functions called in Lua. Two quick questions before I go off and try that. In the init function, you call a lua file like so:
1. What location is this looking for the file? SourceMods/MyMod? p.s. For other guys who haven't been able to get it to compile, here's my stuff so far: myluamanager.h
myluamanager.cpp (I added in a Msg call to see if it reached that far. You can remove that when you're sure it's running)
I added them both in server/source files Edited by: SecretiveLoon |
||
|
Jul 2 2009 Anchor | |
You dont need to have lua_State *pL; in your class as this is part of LuaHandle (use GetLua() to get the lua handle) but besides that it looks fine. Here is an example script we use for ges: Wiki.goldeneyesource.net and yeah that will look for the file in your mod folder. |
||
Jul 3 2009 Anchor | ||
Wait, I'm missing something. Do i now have to make sepperate Lua functions in C++ or are they already their? (Before i continue programming to death) |
||
Jul 3 2009 Anchor | ||
It looks like the ones that already have global scope (such as Msg) just have to use the REG_FUNCTION define. Trying to access something in a class like GetMotor in ai_basenpc.cpp seems to require making a new function ... which seems to defeat the purpose a little to me. I'm hoping my understanding of Lua is just flawed here. I can't figure out how else folks could get Lua to do anything useful in non-open source games like DoW or WoW. I hope to God I'm wrong. |
||
|
Jul 3 2009 Anchor | |
Jul 3 2009 Anchor | ||
Great. ok, then I'm on trying my best to connect.... |
||
|
Jul 3 2009 Anchor | |
Jul 6 2009 Anchor | ||
Hey Lodle, I've been getting errors when trying to compile with your tutorial.
Any ideas? I compiled the LUA 5.1 Lib and added it to the project and followed the rest of the tutorial. -- Jordan Nolan |
||
|
Jul 6 2009 Anchor | |
Jul 6 2009 Anchor | ||
That fixed those errors, but when I compile again I get more. Its never ending :P 1>LIBCMT.lib(crtheap.obj) : error LNK2005: __calloc_crt already defined in memoverride.obj -- Jordan Nolan |
||
|
Jul 7 2009 Anchor | |
Jul 13 2009 Anchor | ||
Hello, when i try to compile, i get this error: C:\\?????\src\dlls\myluahandle.h(7) : fatal error C1083: Cannot open include file: 'ge_luamanager.h': No such file or directory ge_luamanager.cpp C:\\?????\adding lua to mod\ge_luamanager.h(20) : fatal error C1083: Cannot open include file: 'lua.h': No such file or directory Any help would be appreciated |
||
Jul 13 2009 Anchor | ||
Where did you put your ge_luamanager and did you include the lua5.1 include folder? -- Jordan Nolan |
||
Jul 26 2009 Anchor | ||
I have added ge_luamanager but also i've added lua.h to the same folder but i still get errors that it cant find it. |
Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.