From adbb888fe40757dbcda4d87d9079317ddbfab9cd Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 13 May 2021 00:49:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DnetPlayer=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/modes/netBattle.lua | 2 +- parts/netPlayer.lua | 28 +++++++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/parts/modes/netBattle.lua b/parts/modes/netBattle.lua index cddb352e..c781e1e2 100644 --- a/parts/modes/netBattle.lua +++ b/parts/modes/netBattle.lua @@ -20,7 +20,7 @@ return{ PLY.newPlayer(1) PLAYERS[1].sid=netPLY.getSID(USER.uid) for i=2,netPLY.getCount()do - PLY.newRemotePlayer(i,false,netPLY.getPLY(i)) + PLY.newRemotePlayer(i,false,netPLY.rawgetPLY(i)) end end, } \ No newline at end of file diff --git a/parts/netPlayer.lua b/parts/netPlayer.lua index 9dcf8761..316e48a9 100644 --- a/parts/netPlayer.lua +++ b/parts/netPlayer.lua @@ -61,18 +61,16 @@ local posLists={ } local posList -local PLY=setmetatable({},{ - __index=function(self,uid) - for _,p in next,self do - if p.uid==uid then - return p - end +local netPLY={list={}} +local PLY=netPLY.list + +local function getPLY(uid) + for i=1,#PLY do + if PLY[i].uid==uid then + return PLY[i] end end -}) - -local netPLY={list=PLY} - +end local function freshPosList() if #PLY<=5 then posList=posLists[1] @@ -99,13 +97,13 @@ function netPLY.freshPos() end function netPLY.getCount()return #PLY end -function netPLY.getPLY(i)return PLY[i]end -function netPLY.getUsername(uid)return PLY[uid].username end -function netPLY.getSID(uid)return PLY[uid].sid end +function netPLY.rawgetPLY(i)return PLY[i]end +function netPLY.getUsername(uid)return getPLY(uid).username end +function netPLY.getSID(uid)return getPLY(uid).sid end function netPLY.getSelfReady()return PLY[1].ready end -function netPLY.setPlayerObj(ply,p) ply.p=p end -function netPLY.setConf(uid,config)PLY[uid].config=config end +function netPLY.setPlayerObj(ply,p)ply.p=p end +function netPLY.setConf(uid,config)getPLY(uid).config=config end function netPLY.setReady(uid,ready) for i,p in next,PLY do if p.uid==uid then