lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



Hi

> I really think I am rambling now, so I will stop.
	
	No, not a bit. I am very glad to share your experience . more or
less there are something like between us. I am developing a MMORPG now, As
imporing more and more lua to my project , I also find something exciting.
	1. As most of Game to do, use lua on GUI, Game task, 
	2. Use lua in fight compute then let the designer to do it as free
as their wish, I know it is slow, and I will translate them back to c++ when
publish.
	3. Use lua on test. it is much more better than cppuit for ---- no
need complile, it is can be easily managed by files. for example my test
folder is like
	test
		test_fight		
		test_npcai
		test_item
			test_equip.lua
			test_medical.lua
	and test suite is like RunScriptFolder('test_item')
	4. It is very diffcult what a test invoke both client and server,
but use lua coroutine can easily handle it.
	for example, on client	
		function main()
			StartThread('thread') -- will call lua_newthread and
resume function thread
		end
	
		function thread()
			connecttoserver()  -- when connected will call back
here.
			SendCmd(cmd_login,"Login('test')") -- net send a
comand, when login ok or not , will call back here
			-- do your test ... 
		end
	and I even use lua to write robot on pressure test
	5. It is very easy to write npc with special behaviour by coroutine 
	like
	function Behaviour()
		while(true)
			walkto(A)
			Say('hello')
			walkto(B)
			Say('I am hungry')
			...
		end
	end

	BUT most headache is I don't know how to end a luathread , there
just a function lua_newthread but not a function lua_endthread, why ?
	as my prev mail said I do it like:

	lua_State* m_L = lua_newthread(L);
	int refKey = luaL_ref(L, LUA_REGISTRYINDEX);

	NPC->L = L
	NPC->m_L = m_L
	NPC->refKey = refKey

	and 
	NPC::~NPC(){
		if (L){
		luaL_unref(L,LUA_REGISTRYINDEX,refKey );
		}
	}

	and I still have no confidence about that .