lua:90: 尝试对字段“?”(值为空)进行索引。
2014-3-3 13:47:19
收藏:0
阅读:144
评论:1
当我调用它时,我的二维变量无法被正确识别。当我打印它时,它似乎可以正常工作,但是当我尝试从函数内部调用它时,它就变得毫无头绪了。
这是我的代码:
math.randomseed(os.time())
math.random(); math.random(); math.random()
-- init
local t = ""
-- t == type
local year = 2014
-- year is placeholder with no real value.
local i = 1
local x = 0
local y = 0
local z = 0
local o = 0
--
local l = 0
local l1 = 0
local l2 = 0
--
local h = 1
-- Junk Variables
local month = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}
local days = {0, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
-- Days linked to months, weeks come as calculated
local m = 1
-- "m" is the real month value to be used within the code as the literal value.
fd = {} -- create the matrix
for y=1,5 do
fd[y] = {} -- create a new row
for z=1,5 do
fd[y][z] = 0
end
end
-- fd = Family/Day
na = {1, 2, 3, 4 ,5}
-- numbers not allocated for the day
fv = {}
--[12][days[m]][5]
-- final value to be printed literally into string of txt file.
local s = ""
-- string variable
io.write("Please enter a month (ONLY USE NUMBERS)")
io.flush()
m=io.read()
io.write("Please enter a chore creation type (daily, weekly, monthly [Case sensitive])")
t=io.read()
--
m = tonumber(m)
--
for y=1,12 do
fv[y] = {}
for z=1,days[m] do
fv[y][z] = {}
for o=1,5 do
fv[y][z][o] = 0
end
end
end
--
if t == "daily" then
local f,err = io.open("ChoreDaily.txt","w")
if not f then return print(err) end
f:write("")
--
repeat
i = 0
y = 0
print(">>")
repeat
if h <= days[m] then
--
repeat
if h <= days[m] then
--
os.execute("cls")
l1 = math.random(1,2)
l2 = math.random(3,4)
l = math.random(l1,l2)
repeat
o = math.random(1,5)
l = l-1
until l == 0
--
if y == 0 then
--
if na[o] > 0 then
if x < 4 then
s = s .. tostring(na[o]) .. ", "
elseif x >= 4 then
s = s .. tostring(na[o])
end
fd[x][y] = na[o] -- this is the problem.
na[o] = 0
x = x+1
print("!")
end
--
我认为我的总体目标相当明显,但这是一个家务清单的创建器。非常基本,我希望我可以全部自己完成,但是不幸的是,如果我无法利用二维变量,我就无法有更多的进展了。
有一些未使用的变量和其他东西挂在那里。我打算稍后把它们清除。
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法
x的初始值为0,在尝试访问fd[x][y]之前不会更改。但是,表格fd的有效索引为1到5,这意味着在这里fd[x]是nil,您无法访问fd[x][y]。