- UID
- 3528696
- 主题
- 2
- 阅读权限
- 20
- 帖子
- 122
- 精华
- 0
- 积分
- 63
- 金钱
- 2248
- 荣誉
- 0
- 人气
- 21
- 在线时间
- 2142 小时
- 评议
- 0
- 帖子
- 122
- 精华
- 0
- 积分
- 63
- 金钱
- 2248
- 荣誉
- 0
- 人气
- 21
- 评议
- 0
|
本帖最后由 LopezMagic 于 2017-3-25 03:38 编辑
keyneslin 发表于 2017-3-25 01:51
成功存入,但讀不回來
.\script\DIY.lua:14: in function 'load_GoodsKeep_from_file' 這行的內容 ...
您可能发现了 JSON4Lua 的bug
可以去下面地址提交issue了
不过也说不定是啥时候我乱改的导致的
-- JSON4Lua: JSON encoding / decoding support for the Lua language.
-- json Module.
-- Author: Craig Mason-Jones
-- Homepage: http://github.com/craigmj/json4lua/
目前我改的如下(就是增加了一行变量声明),经测试可以用
用于测试的函数如下:
local function load_GoodsKeep_from_file()
local fileName = CC.CrossSaves_Filename
local fileExist = help.file.is_file_exists(fileName)
if fileExist then
local content = help.file.readfile_allcontent(fileName)
if content ~= nil then
help.util.debug("[load_GoodsKeep_from_file] load_file_size="..string.len(content))
local load_data = json.decode(content)
local tmpGoodsKeep = load_data["HHH_GOODS_KEEP"]
local tmpCC_AwglwKF = load_data["CC_AwglwKF"]
if tmpCC_AwglwKF ~= nil then
for iii = 1, #tmpCC_AwglwKF do
if tmpCC_AwglwKF[iii] ~= nil then
for jjj = 1, #tmpCC_AwglwKF[iii] do
local test = tmpCC_AwglwKF[iii][jjj]
help.util.debug("[CC_AwglwKF] ["..iii.."]["..jjj.."]=["..tostring(test).."]")
end
end
end
end
HHH_GOODS_KEEP = tmpGoodsKeep
if HHH_GOODS_KEEP == nil then
HHH_GOODS_KEEP = {}
end
end
end
end
local function store_GoodsKeep_to_file()
local fileName = CC.CrossSaves_Filename
local CC_AwglwKF = {
{0, 777},
{1, 666},
{2, 233}
}
local save_data = {}
save_data["HHH_GOODS_KEEP"] = HHH_GOODS_KEEP
save_data["CC_AwglwKF"] = CC_AwglwKF
local content = json.encode(save_data)
if fileName ~= nil and content ~= nil then
help.file.writefile(fileName, content)
help.util.debug("[store_GoodsKeep_to_file] store_file_size="..string.len(content))
end
end
|
附件: 你需要登录才可以下载或查看附件。没有帐号?注册
-
总评分: 人气 + 1
查看全部评分
|