[英]How to fix this error: attempt to index a number value in Lua Script
I'm learning Lua but I got this error attempt to index a number value when compiler reach this piece of code我正在学习 Lua 但是当编译器到达这段代码时我尝试索引一个数字值时出现这个错误
if a() == -1 then
return code
end
Console Error控制台错误
i tried to change the type of return from number to boolean but i got the same error我试图将返回类型从数字更改为 boolean 但我得到了同样的错误
Boolean console error Boolean 控制台错误
function a()
local message = developer:historicalMessage(22)
if message == nil or message[1] == nil then return nil end
message = message[1]
if message.subs == 0 then
global:printMessage("Here !")
return -1
end
end
function Notif()
if a() == -1 then
return code
end
end
You haven't told us the line, but there are only a few indexing operations:你没有告诉我们线路,但只有几个索引操作:
developer:historicalMessage(...)
and global:printMessage(...)
are presumably not the cause. developer:historicalMessage(...)
和global:printMessage(...)
大概不是原因。 If developer
and global
were numbers, they could be however.如果developer
和global
是数字,那么它们可能是。 That seems unlikely to me as they are being used as "method tables" though (probably with metatables).这对我来说似乎不太可能,因为它们被用作“方法表”(可能与元表一起使用)。message.subs
might be indexing the number message
if developer:historicalMessage(22)[1]
is a number.如果developer:historicalMessage(22)[1]
是一个数字, message.subs
可能正在索引数字message
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.