整理代码,使用TABLE.find
This commit is contained in:
@@ -273,12 +273,10 @@ function love.joystickadded(JS)
|
||||
joysticks[#joysticks+1]=JS
|
||||
end
|
||||
function love.joystickremoved(JS)
|
||||
for i=1,#joysticks do
|
||||
if joysticks[i]==JS then
|
||||
rem(joysticks,i)
|
||||
LOG.print("Joystick removed",COLOR.Y)
|
||||
return
|
||||
end
|
||||
local i=TABLE.find(joysticks,JS)
|
||||
if i then
|
||||
rem(joysticks,i)
|
||||
LOG.print("Joystick removed",COLOR.Y)
|
||||
end
|
||||
end
|
||||
local keyMirror={
|
||||
|
||||
@@ -589,17 +589,15 @@ local selector={
|
||||
}
|
||||
function selector:reset()
|
||||
self.ATV=0
|
||||
local V=self.disp()
|
||||
local L=self.list
|
||||
for i=1,#L do
|
||||
if L[i]==V then
|
||||
self.select=i
|
||||
self.selText=self.list[i]
|
||||
return
|
||||
end
|
||||
local V,L=self.disp(),self.list
|
||||
local i=TABLE.find(L,V)
|
||||
if i then
|
||||
self.select=i
|
||||
self.selText=self.list[i]
|
||||
else
|
||||
self.hide=true
|
||||
LOG.print("Selector "..self.name.." dead, disp= "..tostring(V),'warn')
|
||||
end
|
||||
self.hide=true
|
||||
LOG.print("Selector "..self.name.." dead, disp= "..tostring(V),'warn')
|
||||
end
|
||||
function selector:isAbove(x,y)
|
||||
return
|
||||
|
||||
@@ -399,6 +399,7 @@ function NET.updateWS_play()
|
||||
SCN.back()
|
||||
else
|
||||
netPLY.remove(d.sid)
|
||||
--TODO
|
||||
for i=1,#PLAYERS do
|
||||
if PLAYERS[i].sid==d.sid then
|
||||
rem(PLAYERS,i)
|
||||
|
||||
@@ -427,12 +427,8 @@ function Player:changeAtk(R)
|
||||
-- if self.type~='human'then R=PLAYERS[1]end--1vALL mode?
|
||||
if self.atking then
|
||||
local K=self.atking.atker
|
||||
for i=1,#K do
|
||||
if K[i]==self then
|
||||
rem(K,i)
|
||||
break
|
||||
end
|
||||
end
|
||||
local i=TABLE.find(K,self)
|
||||
if i then rem(K,i)end
|
||||
end
|
||||
if R then
|
||||
self.atking=R
|
||||
@@ -1717,12 +1713,8 @@ function Player:lose(force)
|
||||
return
|
||||
end
|
||||
self:die()
|
||||
for i=1,#PLY_ALIVE do
|
||||
if PLY_ALIVE[i]==self then
|
||||
rem(PLY_ALIVE,i)
|
||||
break
|
||||
end
|
||||
end
|
||||
local i=TABLE.find(PLY_ALIVE,self)
|
||||
if i then rem(PLY_ALIVE,i)end
|
||||
self.result='lose'
|
||||
if GAME.modeEnv.royaleMode then
|
||||
self:changeAtk()
|
||||
|
||||
@@ -585,13 +585,12 @@ do--commands.applet(name)
|
||||
log(appList[i]..": "..appDescription[i])
|
||||
end
|
||||
elseif name~=""then
|
||||
for i=1,#appList do
|
||||
if appList[i]==name then
|
||||
SCN.go(appScene[i])
|
||||
return
|
||||
end
|
||||
local i=TABLE.find(appList,name)
|
||||
if i then
|
||||
SCN.go(appScene[i])
|
||||
else
|
||||
log{C.aqua,"No this applet"}
|
||||
end
|
||||
log{C.aqua,"No this applet"}
|
||||
else
|
||||
log{C.aqua,"Usage:"}
|
||||
log{C.aqua,"applet -list"}
|
||||
@@ -766,9 +765,7 @@ function scene.keyDown(k)
|
||||
if #res>1 then
|
||||
log(">Commands start with '"..str.."' :")
|
||||
table.sort(res)
|
||||
for i=1,#res do
|
||||
log{COLOR.lH,res[i]}
|
||||
end
|
||||
for i=1,#res do log{COLOR.lH,res[i]}end
|
||||
elseif #res==1 then
|
||||
inputBox.value=res[1]
|
||||
end
|
||||
|
||||
@@ -61,9 +61,7 @@ function scene.keyDown(key)
|
||||
end
|
||||
elseif key=="delete"then
|
||||
if sure>20 then
|
||||
for _=1,#MISSION do
|
||||
rem(MISSION)
|
||||
end
|
||||
TABLE.cut(MISSION)
|
||||
cur=0
|
||||
sure=0
|
||||
SFX.play('finesseError',.7)
|
||||
|
||||
@@ -65,9 +65,7 @@ function scene.keyDown(key)
|
||||
end
|
||||
elseif key=="delete"then
|
||||
if sure>20 then
|
||||
for _=1,#BAG do
|
||||
rem(BAG)
|
||||
end
|
||||
TABLE.cut(BAG)
|
||||
cur=0
|
||||
sure=0
|
||||
SFX.play('finesseError',.7)
|
||||
|
||||
@@ -6,12 +6,8 @@ local function modComp(a,b)
|
||||
return a.no<b.no
|
||||
end
|
||||
local function remMod(M)
|
||||
for i=1,#GAME.mod do
|
||||
if GAME.mod[i]==M then
|
||||
rem(GAME.mod,i)
|
||||
return
|
||||
end
|
||||
end
|
||||
local i=TABLE.find(GAME.mod,M)
|
||||
if i then rem(GAME.mod,i)end
|
||||
end
|
||||
local function toggleMod(M,back)
|
||||
if M.sel==0 then
|
||||
|
||||
@@ -12,19 +12,9 @@ local scene={}
|
||||
local selected--Music selected
|
||||
|
||||
local bgmList=BGM.getList()
|
||||
if #bgmList==0 then
|
||||
bgmList={"[NO BGM]"}
|
||||
end
|
||||
if #bgmList==0 then bgmList={"[NO BGM]"}end
|
||||
function scene.sceneInit()
|
||||
if BGM.nowPlay then
|
||||
for i=1,BGM.getCount()do
|
||||
if bgmList[i]==BGM.nowPlay then
|
||||
selected=i
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
selected=1
|
||||
selected=TABLE.find(bgmList,BGM.nowPlay)or 1
|
||||
end
|
||||
|
||||
function scene.wheelMoved(_,y)
|
||||
@@ -33,7 +23,7 @@ end
|
||||
function scene.keyDown(key)
|
||||
local S=selected
|
||||
if key=="down"then
|
||||
if S<BGM.getCount()then
|
||||
if S<#bgmList then
|
||||
selected=S+1
|
||||
SFX.play('move',.7)
|
||||
end
|
||||
|
||||
@@ -42,7 +42,9 @@ return STRING.split([=[
|
||||
取消软件锁功能
|
||||
控制台支持滚轮和键盘导航
|
||||
代码:
|
||||
场景模块支持拖拽文件事件
|
||||
场景模块支持拖拽文件(夹)事件
|
||||
允许模式给每个玩家初始化多个任务
|
||||
升级table扩展模块
|
||||
修复:
|
||||
本地混战模式ai死亡时报错
|
||||
hold会让锁延刷新次数超出上限
|
||||
|
||||
Reference in New Issue
Block a user