Skip to main content
gamedev.net
🔒 Locked

Luabind function parameters, problems

Started by Minnek Mar 6, 2009 at 3:27 AM 0 replies 600+ views
Original Post
Minnek
Minnek
I'm having issues with a short bit of code that I can't seem to make sense of. I'm new to Luabind (and embedding scripting languages in general) so this is all new to me. My issues lie in the following two functions:

class LuaScript {
public:
...
void Textbox(const irr::core::stringc&);
void Test() { m_logger->log("Test."); }
}
When I call Test() from my Lua script (as "lscript:Test()") it outputs "Test." as expected. However, when I call Textbox() (as 'lscript:Textbox("Hi!")') it won't run the script; my luaL_dofile() returns a 1. Here's the code where I register the modules and put lscript into the globals:

LuaScript() {
	m_state = lua_open();
	luaL_openlibs(m_state);
	luabind::open(m_state);
	luabind::module(m_state)
		[
			luabind::class_<LuaScript>("LuaScript")
			.def("Textbox",&LuaScript::Textbox)
			.def("Test",&LuaScript::Test)
		];
	luabind::globals(m_state)["lscript"] = this;
}
I'm guessing it's because my parameter is a stringc from Irrlicht; is there something different I should use for strings? const char*? Or is there a way to somehow make the stringc work with luabind? The whole affair has me muddled. Any pointers in the right direction would be great, and I'll happily provide any more information needed. Thanks, everyone. :) Edit: After some more work, I found that it works with const char* as the parameter instead. So the question is now, is there any way to make stringc work? This is now more out of curiosity than need, but if I run into this problem again with my own class, I'll end up asking again anyway. Thanks again, all. [Edited by - Minnek on March 6, 2009 3:43:01 AM]

Topic Locked

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

Sign in to reply to this topic.