整理table扩展模块代码
This commit is contained in:
@@ -28,11 +28,11 @@ function TABLE.copy(org)
|
||||
end
|
||||
|
||||
--For all things in G if same type in base, push to base
|
||||
function TABLE.add(G,base)
|
||||
function TABLE.update(G,base)
|
||||
for k,v in next,G do
|
||||
if type(v)==type(base[k])then
|
||||
if type(v)=="table"then
|
||||
TABLE.add(v,base[k])
|
||||
TABLE.update(v,base[k])
|
||||
else
|
||||
base[k]=v
|
||||
end
|
||||
@@ -40,13 +40,6 @@ function TABLE.add(G,base)
|
||||
end
|
||||
end
|
||||
|
||||
--Clear the table
|
||||
function TABLE.clear(G)
|
||||
for k in next,G do
|
||||
G[k]=nil
|
||||
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
|
||||
@@ -58,6 +51,20 @@ function TABLE.complete(G,base)
|
||||
end
|
||||
end
|
||||
|
||||
--Remove positive integer index of table
|
||||
function TABLE.cut(G)
|
||||
for i=#G,1,-1 do
|
||||
G[i]=nil
|
||||
end
|
||||
end
|
||||
|
||||
--Clear table
|
||||
function TABLE.clear(G)
|
||||
for k in next,G do
|
||||
G[k]=nil
|
||||
end
|
||||
end
|
||||
|
||||
--Re-index string value of a table
|
||||
function TABLE.reIndex(org)
|
||||
for k,v in next,org do
|
||||
|
||||
@@ -299,7 +299,7 @@ SETTING={--Settings
|
||||
VKAlpha=.3,
|
||||
}
|
||||
local S=FILE.load("conf/settings")
|
||||
if S then TABLE.add(S,SETTING)end
|
||||
if S then TABLE.update(S,SETTING)end
|
||||
S=FILE.load("conf/data")
|
||||
if S then--Statistics
|
||||
STAT=S
|
||||
|
||||
@@ -49,7 +49,7 @@ scene.widgetList={
|
||||
WIDGET.newButton{name="importUnlock", x=190,y=300,w=280,h=100,color="lBlue",font=25,code=function()
|
||||
local D=parseCB()
|
||||
if D then
|
||||
TABLE.add(D,RANKS)
|
||||
TABLE.update(D,RANKS)
|
||||
FILE.save(RANKS,"conf/unlock")
|
||||
LOG.print(text.importSuccess,"message")
|
||||
else
|
||||
@@ -59,7 +59,7 @@ scene.widgetList={
|
||||
WIDGET.newButton{name="importData", x=490,y=300,w=280,h=100,color="lBlue",font=25,code=function()
|
||||
local D=parseCB()
|
||||
if D and D.version==STAT.version then
|
||||
TABLE.add(D,STAT)
|
||||
TABLE.update(D,STAT)
|
||||
FILE.save(STAT,"conf/data")
|
||||
LOG.print(text.importSuccess,"message")
|
||||
else
|
||||
@@ -69,7 +69,7 @@ scene.widgetList={
|
||||
WIDGET.newButton{name="importSetting", x=790,y=300,w=280,h=100,color="lBlue",font=25,code=function()
|
||||
local D=parseCB()
|
||||
if D then
|
||||
TABLE.add(D,SETTING)
|
||||
TABLE.update(D,SETTING)
|
||||
FILE.save(SETTING,"conf/settings")
|
||||
LOG.print(text.importSuccess,"message")
|
||||
else
|
||||
@@ -79,7 +79,7 @@ scene.widgetList={
|
||||
WIDGET.newButton{name="importVK", x=1090,y=300,w=280,h=100,color="lBlue",font=25,code=function()
|
||||
local D=parseCB()
|
||||
if D then
|
||||
TABLE.add(D,VK_org)
|
||||
TABLE.update(D,VK_org)
|
||||
FILE.save(VK_org,"conf/virtualkey")
|
||||
LOG.print(text.importSuccess,"message")
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user