Lua for循环

local BossID = {100,200}

local WorldBossHurt = {
	[100] = {},
	[200] = {}
}
for i=1,10,1 do
	local RoleList = {nRoleID = 20000,nHurt = 40}
	RoleList.nRoleID = RoleList.nRoleID+i
	RoleList.nHurt = RoleList.nHurt+i
	table.insert(WorldBossHurt[100],RoleList)
	table.insert(WorldBossHurt[200],RoleList)
	print(RoleList.nRoleID,RoleList.nHurt)
end

for key,value in ipairs(BossID) do
	for key,value in ipairs(WorldBossHurt[value]) do
		print(key,value.nRoleID,value.nHurt)
	end
end


 

posted @ 2012-12-27 16:12  byfei  阅读(182)  评论(0编辑  收藏  举报