ROBLOX LUA(u) 传递 table = nil 的参数(尝试将 nil 与字符串连接)
ROBLOX LUA(u) passing argument of table = nil (attempt to concatenate nil with string)
我正在尝试制作一个数据库,仍处于测试阶段,但是:
如您所见,它基本上是解包 table 给我们“nil”。
这是一个我无法修复的奇怪错误。
正在测试 ServerScriptService 脚本:
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Greenwich = require(ServerStorage:WaitForChild("Greenwich"))
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message == "t" then
local ServerName = script.Name
print("T has been recognized by "..ServerName)
print(Greenwich:GetDB("salvage"))
warn(Greenwich:GetDB("salvage"):Set("MyKey", "MyValue"))
print("Finalized.")
end
end)
end)
模块脚本:
--Variables
local dss = game:GetService("DataStoreService")
local db = dss:GetDataStore("greenwich")
-- Tables
local greenwich = {}
local dbFunctions = {}
--Functions
function greenwich:GetDB(name)
local new = {}
coroutine.resume(coroutine.create(function()
for k, v in pairs(dbFunctions) do
new[k] = function(...)
local args = { ... }
return v(name, unpack(args))
end
end
end))
return new
end
function dbFunctions:Set(save_key, key, value)
save_key = unpack(save_key)
db:SetAsync(
save_key..
key,
value)
return value
end
--Returning everything.
return greenwich
提前致谢。
save_key
与 table 与 new
相同
save_key = unpack(save_key)
将 nil
分配给 save_key
unpack(save_key)
returns nil
因为 save_key
不是序列。
unpack (list [, i [, j]])
等同于 return list[i], list[i+1],..,list[j]
在哪里
i
和 j
默认为 1
和 #list
new
中唯一的字段是 new["Set"]
。
我正在尝试制作一个数据库,仍处于测试阶段,但是: 如您所见,它基本上是解包 table 给我们“nil”。
这是一个我无法修复的奇怪错误。
正在测试 ServerScriptService 脚本:
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Greenwich = require(ServerStorage:WaitForChild("Greenwich"))
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message == "t" then
local ServerName = script.Name
print("T has been recognized by "..ServerName)
print(Greenwich:GetDB("salvage"))
warn(Greenwich:GetDB("salvage"):Set("MyKey", "MyValue"))
print("Finalized.")
end
end)
end)
模块脚本:
--Variables
local dss = game:GetService("DataStoreService")
local db = dss:GetDataStore("greenwich")
-- Tables
local greenwich = {}
local dbFunctions = {}
--Functions
function greenwich:GetDB(name)
local new = {}
coroutine.resume(coroutine.create(function()
for k, v in pairs(dbFunctions) do
new[k] = function(...)
local args = { ... }
return v(name, unpack(args))
end
end
end))
return new
end
function dbFunctions:Set(save_key, key, value)
save_key = unpack(save_key)
db:SetAsync(
save_key..
key,
value)
return value
end
--Returning everything.
return greenwich
提前致谢。
save_key
与 table 与 new
save_key = unpack(save_key)
将 nil
分配给 save_key
unpack(save_key)
returns nil
因为 save_key
不是序列。
unpack (list [, i [, j]])
等同于 return list[i], list[i+1],..,list[j]
在哪里
i
和 j
默认为 1
和 #list
new
中唯一的字段是 new["Set"]
。