整理代码,使用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
|
||||
|
||||
Reference in New Issue
Block a user