lua - 公民:/scripting/resource_init.lua:17:'then'附近的意外符号
问题描述
我的 FiveM 服务器的代码,当我尝试启动 yo thr 服务器时,我得到一个错误,上面写着“citizen:/scripting/resource_init.lua:17: 'then' 附近的意外符号”有人可以帮我吗?
return function(chunk)
local addMetaData = AddMetaData
setmetatable(_G end
__index = function(t, k)
local raw = rawget(t, k)
end
if raw then
return raw
return function(value)
local newK = k
if type(value) == 'table' then
-- remove any 's' at the end (client_scripts, ...)
if k:sub(-1) == then
newK = k:sub(1, -2)
-- add metadata for each table entry
for _, v in ipairs(value) do
addMetaData(newK, v)
end
else
addMetaData(k, value)
end
-- for compatibility with legacy things
return function(v2)
addMetaData(newK .. '_extra', json.encode(v2))
end
end
end
})
-- execute the chunk
chunk()
-- and reset the metatable
setmetatable(_G, nil)
end
解决方案
您的代码中有很多错误,标题中的错误不是您运行此代码时当前出现的错误。
第一个错误::4: ')' expected near 'end'
第 4 行是:
setmetatable(_G end
应该
setmetatable(_G, {
该错误非常不清楚,因为这是一个相当奇怪的错误,我不确定为什么要end
放在那里。
第二个错误::9: '}' expected (to close '{' at line 4) near 'if'
第 8 行有一个错位end
,应该在第 11 行。这个错误是预期}
的,因为第end
8 行完成了从第 6 行开始的函数定义。
第三个错误:18: unexpected symbol near 'then'
第 18 行是:
if k:sub(-1) == then
应该是这样的:
if k:sub(-1) == "s" then
你需要第二个操作数==
第四错误::36: 'end' expected (to close 'function' at line 6) near '}'
在第 32 行和第 33 行之间丢失end
。这一个非常明显的错误,值得说明的是缩进最终变得不稳定,这会使看到丢失end
的 ' 有点困难
推荐阅读
- ios - 我需要设置哪个 iOS 目标以避免将 Swift 运行时库与我的 iOS 应用程序捆绑在一起?
- azure - 查询本地数据网关连接 Azure 分析服务的使用情况
- r - Find cumulative sum values in R / Error: Problem with `mutate()` column
- javascript - .toggleClass() 函数在快速点击时无法正常工作
- flutter - Flutter - 在完成输入后识别用户何时触摸 Textformfield 之外
- opencart - 将 opencart 主题期刊 2 升级到期刊 3
- python - Python同时为顶级字典和嵌套字典创建键
- sql - SSRS 报告为 Join 表达式提供错误
- javascript - react-hooks-helper,TypeError:无法读取未定义的属性“名称”
- java - Spring Boot 测试 - 使用测试 application.yaml 时 @Value 为空