Skip to content
jijinlong edited this page Nov 23, 2016 · 3 revisions

Lang 使用 C++ 定制的扩展

class SceneNpc{
	public:
		int talk(Args *stub,Properties &propies)
		{
			stub->setNumber("index",1000);
			//printf("%s %s\n", "print",propies.getString("value").c_str());
			this->stub = *stub;
			return CodeState::NO;
		}
		void call()
		{
			stub.exec();
		}
	
		SceneNpc()
		{
		
		}
		int a;
};

LANG_SCRIPT(NPCLIB)
{
	BIND_FUNCTION(SceneNpc,talk);
	BIND_FIELD(int,SceneNpc,a);
	BIND_FUNCTION_NAME(SceneNpc,talk,"说话");
}

C++ 调用Lang脚本

   theLang.readFromFile("test.ai");
	   Args args;
	   SceneNpc *npc = new SceneNpc();
	   args.add("o",npc);
   	theLang.exec("start",&args);

Clone this wiki locally