Problem using the lua api
#1
I'm busy working on a channel manager right now to simplify handling custom packets encapsulated within what we call plugin messages. However, I am having trouble with the lua api.

My manual binding, which can be found here, checks to see if the third argument is a valid function, which it is and it passes the check fine. However, when cPlugin::Call tries to use the stored function ref, cLuaState::PushFunction(int a_FnRef) fails because it says it is not a function.

What am I doing wrong?
Programming Telekinetically
The practice of programming a computer without touching an input device of any kind, such as a keyboard or mouse. Easily confused with doing nothing at all.

Johnny might be sitting and staring at the computer, or he might be programming telekinetically.
Reply
Thanks given by:
#2
Nevermind. I fixed it. I was trying to grab the function directly instead of through LUA_REGISTRYINDEX.
Programming Telekinetically
The practice of programming a computer without touching an input device of any kind, such as a keyboard or mouse. Easily confused with doing nothing at all.

Johnny might be sitting and staring at the computer, or he might be programming telekinetically.
Reply
Thanks given by:
#3
That's why the cLuaState class has a cRef class, which is exactly what you should be using for storing function references.
Reply
Thanks given by:
#4
I tried using it, but I couldn't get it to work. Especially since there is no copy constructor for cRef.
Programming Telekinetically
The practice of programming a computer without touching an input device of any kind, such as a keyboard or mouse. Easily confused with doing nothing at all.

Johnny might be sitting and staring at the computer, or he might be programming telekinetically.
Reply
Thanks given by:
#5
It doesn't support copying (because it would be unnecessarily difficult to copy the value in Lua), you must std::move it.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)