【发布时间】:2014-12-17 05:29:23
【问题描述】:
我有一个使用多个 lua 脚本的 HTML 项目,我在理解一个函数的功能时遇到了很大的问题(我是 lua 新手):
.......................
所有要求都已完成,路径也已定义
local fs = require "lfs"
local const = {}
for num = 1, 14 do
const[num] = assert(
dofile (const_path .. mkfilename(num)),
"Failed to load constant configuration ".. num ..".")
end
local function file_number() --this is the function that causes me a headach
local ci, co, num = ipairs(const)-- when I print num is 0 and ci,co are nil
local vi, vo, _ = fs.dir(virt_path)-- what does _ mean here ?
local function vix(o)
local file = vi(o)
if file == nil then return nil end
local number = file:match("^(%d+).lua$")
if number == nil then return vix(o) end
return tonumber(number)
end
local function iter(o, num)
return ci(o.co, num) or vix(o.vo, num)---where is ci defined or impplemented
end
return iter, {co=co, vo=vo}, num-- what 's the return value here ?
end
该功能有效,但我仍然不明白为什么以及如何,我会很高兴有任何提示。
【问题讨论】: