Best way to pass information between C++ and Lua when doing callback?

Hi,

I’ve got a problem regarding passing information to lua functions from c++ when doing executeCallFunc*.
It’s all fine when I have to pass integers, as I can use CCNode and tag for example.
The trouble starts when I have to pass a string for example.
So I’ve tried using userData on CCNode to pass this information [that’s a hack, I know, but I couldn’t find any other way to do so], but all I get in Lua is userdata :confused:

CCNode *tempNode = CCNode::node();
tempNode->setUserData((void*)notificationLayer->getString().c_str());
CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->executeCallFuncN(functionNameOk.c_str(), tempNode);

and in Lua:

function testString(node)
  ogsLog("node:", node)
  ogsLog("wooohoooo string passed!", node:getUserData())
end

I get:

Cocos2d: node:      userdata: 0xeb49e94     
Cocos2d: wooohoooo string passed!       userdata: 0xeb40e8c 

Damn :confused:

I would appreciate if someone could point me in right direction :confused: I’m sure I’m missing something obvious.

Hi,

Is there a way to pass some data from c*+ to the lua script?
For example, there is a object in c*+ named SomeDataForLua with int fields someData1 and someData2.
Is it possible to send this to the lua script from c++?