My table:
我的桌子:
local Cache = {
SurvivalGameFramework = {
parent = game.ServerStorage
}
}
As you can probably tell, this table is not an empty value or "nil" but according to ROBLOX studio, Cache[1]
is nil, and I've tried literally everything to figure out what is wrong with this engine.
正如您可能知道的,这个表不是空值或“nil”,但根据Roblox Studio的说法,缓存[1]为零,我几乎已经尝试了所有方法来找出这个引擎的问题所在。
print(Cache[1])
will return nil and so will Cache.SurvivalGameFramework[1]
.
Print(缓存[1])将返回nil,Cache.SurvivalGameFrame[1]也将返回nil。
更多回答
优秀答案推荐
Cache[1]
being nil
is correct: The only key used in your Cache
table is SurvivalGameFramework
. Cache.SurvivalGameFramework
in turn only has a parent
key, so Cache.SurvivalGameFramework[1]
is nil
as well. Cache.SurvivalGameFramework.parent
on the other hand would be game.ServerStorage
.
缓存[1]为空是正确的:缓存表中使用的唯一键是SurvivalGameFrame。反过来,Cache.SurvivalGameFramework只有一个父键,因此Cache.SurvivalGameFrame[1]也是空的。另一方面,Cache.SurvivalGameFramework.parent将是game.ServerStorage。
A table t = {42}
or t = {[1] = 42}
would have t[1] == 42
. A table t2 = {k = 42}
or t2 = {["k"] = 42}
has t2.k == 42
and t2["k"] == 42
. Absent keys have nil
values in Lua, so t2[1]
is nil
.
表t={42}或t={[1]=42}的t[1]==42。表T2={k=42}或T2={[“k”]=42}具有t2.k==42和t2[“k”]==42。缺少的关键点在Lua中的值为零,因此T2[1]为零。
更多回答
我是一名优秀的程序员,十分优秀!