From c8db07a8c89841a8888a350745b7325a568839a8 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Wed, 28 Apr 2021 17:22:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4table=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/tableExtend.lua | 26 +++++++++++++------------- parts/ai.lua | 2 +- parts/gametoolfunc.lua | 2 +- parts/net.lua | 2 +- parts/player/player.lua | 2 +- parts/scenes/dict.lua | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Zframework/tableExtend.lua b/Zframework/tableExtend.lua index 8cce81a6..6904673f 100644 --- a/Zframework/tableExtend.lua +++ b/Zframework/tableExtend.lua @@ -1,7 +1,7 @@ local next,type=next,type local TABLE={} ---Copy [1~#] elements +--Get a copy of [1~#] elements function TABLE.shift(org) local L={} for i=1,#org do @@ -14,7 +14,7 @@ function TABLE.shift(org) return L end ---Copy all elements +--Get a full copy of a table function TABLE.copy(org) local L={} for k,v in next,org do @@ -28,25 +28,25 @@ function TABLE.copy(org) end --For all things in G if same type in base, push to base -function TABLE.update(G,base) - for k,v in next,G do - if type(v)==type(base[k])then +function TABLE.update(new,old) + for k,v in next,new do + if type(v)==type(old[k])then if type(v)=="table"then - TABLE.update(v,base[k]) + TABLE.update(v,old[k]) else - base[k]=v + old[k]=v end end end end --For all things in G if no val in base, push to base -function TABLE.complete(G,base) - for k,v in next,G do - if base[k]==nil then - base[k]=v - elseif type(v)=="table"and type(base[k])=="table"then - TABLE.complete(v,base[k]) +function TABLE.complete(new,old) + for k,v in next,new do + if old[k]==nil then + old[k]=v + elseif type(v)=="table"and type(old[k])=="table"then + TABLE.complete(v,old[k]) end end end diff --git a/parts/ai.lua b/parts/ai.lua index ef806ad5..4ab88032 100644 --- a/parts/ai.lua +++ b/parts/ai.lua @@ -71,7 +71,7 @@ if type(_CC)=="table"then end CC.updateField(P) - TABLE.clear(P.holdQueue) + TABLE.cut(P.holdQueue) P.holdTime=P.gameEnv.holdCount P.cur=rem(P.nextQueue,1) diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 4f6525cd..f0a0e100 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -180,7 +180,7 @@ function destroyPlayers()--Destroy all player objects, restore freerows and free end PLAYERS[i]=nil end - TABLE.clear(PLY_ALIVE) + TABLE.cut(PLY_ALIVE) collectgarbage() end function pauseGame() diff --git a/parts/net.lua b/parts/net.lua index bd2163bf..55ee0d77 100644 --- a/parts/net.lua +++ b/parts/net.lua @@ -351,7 +351,7 @@ function NET.updateWS_play() elseif res.action==2 then--Player join if res.type=="Self"then --Create room - TABLE.clear(PLY_NET) + TABLE.cut(PLY_NET) if d.players then for _,p in next,d.players do ins(PLY_NET,p.uid==USER.uid and 1 or #PLY_NET+1,{ diff --git a/parts/player/player.lua b/parts/player/player.lua index 4846383f..e4e0196d 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -1748,7 +1748,7 @@ function Player:lose(force) if self.AI_mode=="CC"then CC.destroy(self.AI_bot) - TABLE.clear(self.holdQueue) + TABLE.cut(self.holdQueue) self:loadAI(self.AIdata) end diff --git a/parts/scenes/dict.lua b/parts/scenes/dict.lua index 287aa465..71f6d14e 100644 --- a/parts/scenes/dict.lua +++ b/parts/scenes/dict.lua @@ -31,7 +31,7 @@ local typeColor={ } local function getList()return result[1]and result or dict end local function clearResult() - TABLE.clear(result) + TABLE.cut(result) selected,scrollPos=1,0 waiting,lastSearch=0,false end