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