一、文件读存:
复制代码 代码如下:
-- 似乎不支持大文件(不能超过9k"c:\\in.lua", "r");
assert(file);
local data = file:read("*a"); -- 读取所有内容
file:close();
file = io.open("c:\\out.lua", "w");
assert(file);
file:write(data);
file:close();
end
FileSaveLoad();
二、非循环表格处理:
复制代码 代码如下:
HERO = 1;
MONSTER = 2;
BUILDING = 3;
SUMUNIT = 4;
cha = {};
cha[1] =
{
basic =
{
Name = "农民", --NPC名字
cha_type = HERO, --NPC模型
},
combat =
{
acquire = 600.00, --主动攻击范围
basic_def = 10, --基础防御
},
};
function SaveTableContent(file, obj)
local szType = type(obj);
print(szType);
if szType == "number" then
file:write(obj);
elseif szType == "string" then
file:write(string.format("%q", obj));
elseif szType == "table" then
--把table的内容格式化写入文件
file:write("{\n");
for i, v in pairs(obj) do
file:write("[");
SaveTableContent(file, i);
file:write("]=\n");
SaveTableContent(file, v);
file:write(", \n");
end
file:write("}\n");
else
error("can't serialize a "..szType);
end
end
function SaveTable()
local file = io.open("e:\\00_00_00_海外组_学习\\写入.txt", "w");
assert(file);
file:write("cha = {}\n");
file:write("cha[1] = \n");
SaveTableContent(file, cha[1]);
file:write("}\n");
file:close();
end
SaveTable();
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]