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