🔒 Locked
Lua and C++
Advertisement
Original Post
Look on the LUA home page for Luna.
I've never used it, but it sounds like what you're after.
Tom
[edited by - krumms on December 19, 2002 9:43:52 PM]
I've never used it, but it sounds like what you're after.
Tom
[edited by - krumms on December 19, 2002 9:43:52 PM]
Had me all excited =P
What Im trying to do is allow the scripter to define an action for a button (which is created inside a C++ class). So, upon creation of the button, a Lua function is passed to the button, so it knows what to execute when it''s clicked.
Now.. getting it to call the function is what Im stuck on
What Im trying to do is allow the scripter to define an action for a button (which is created inside a C++ class). So, upon creation of the button, a Lua function is passed to the button, so it knows what to execute when it''s clicked.
Now.. getting it to call the function is what Im stuck on
hmm what you''re saying doesn''t quite make sense, but I think I get what you''re talking about.
So when you CLICK the button, you want an Lua function to be called?
I''ve done this before, it''s not too hard so far as I can remember *sound of shuffling through manuals*
Okays here''s what you''ve got to do:
1. Compile your Lua script using lua_dofile (after initialising an lua_State of course)
2. Call the lua function. lua_call does this. You''ll need to push any arguments onto the lua stack before doing this. The first parameter is the name of the function you wish to call. If your Lua function takes not arguments, however, pass 0 as the second parameter. You''ll need to tell it how many results will be on the stack after the call too.
And that''s it. Easy huh?
Tom L
So when you CLICK the button, you want an Lua function to be called?
I''ve done this before, it''s not too hard so far as I can remember *sound of shuffling through manuals*
Okays here''s what you''ve got to do:
1. Compile your Lua script using lua_dofile (after initialising an lua_State of course)
2. Call the lua function. lua_call does this. You''ll need to push any arguments onto the lua stack before doing this. The first parameter is the name of the function you wish to call. If your Lua function takes not arguments, however, pass 0 as the second parameter. You''ll need to tell it how many results will be on the stack after the call too.
And that''s it. Easy huh?
Tom L
Be careful when saying "passing to a C++ class" - you can''t really pass anything to a C++ object, and strictly speaking you certainly can''t pass anything to a class! 
What you can do is pass things to C++ methods, or functions. Make sure you distinguish, it will be confusing to understand your questions/statements otherwise.
Tom L
What you can do is pass things to C++ methods, or functions. Make sure you distinguish, it will be confusing to understand your questions/statements otherwise.
Tom L
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement