lua - 是否有可能为表内的所有内容创建一个带有字符串的变量?
问题描述
只是想知道,因为我没有找到解决方案。很确定,因为我是这个 c 的新手:感谢您的帮助。
编辑:为了解释,我会用代码解释一下。
local FileList = fs.list("") --Makes a Table with all the files and directories available (as strings) on the PC it's running on (Inside of a mod called computercraft for minecraft)
for _, file in ipairs(FileList) do
--Here I need a function which assigns every string from the table to a variable, just for the explanation I'll call it unknown.function
unknown.function
end
while true do
print(a) --a is for example one of the different variables made from the "unknown.function"
sleep(1)
end
解决方案
像这样?
AllFiles = {}
function Crazyfunction(file)
AllFiles[table.getn(AllFiles)+1] = file
end
local FileList = fs.list("")
for _, file in ipairs(FileList) do
Crazyfunction(file)
end
while true do
print(AllFiles[NUMBE_OF_FILE_HERE])
sleep(1)
end
推荐阅读
- python - 为什么 Cython 期望 0 维?
- amazon-cloudformation - ParameterOverrides 的 CloudFormation 语法
- r - 如何解决错误:在 r 上提供连续刻度的离散值
- php - PHP覆盖数组mysql查询?
- angular - 由于 null 错误,从服务调用组件方法失败
- find - 运行 Xargs 查找的结果以获取已找到项目的版本时出现问题
- angular - 带有模板变量引用的输入的Angular 8模板
- c++ - protobuf 嵌入式消息最佳实践
- java - 使用 Selenium WebDriver 和 Java 无法识别特定页面中的元素
- html - Vue CLI ESLint 将额外的空白注入到多行跨度中