【问题标题】:ERROR: [string "LuaVM"]:219: attempt to index a nil value (global 'math')错误:[字符串“LuaVM”]:219:尝试索引零值(全局“数学”)
【发布时间】:2020-12-20 23:21:08
【问题描述】:

我在下面的脚本中遇到错误。我在脚本下写了错误代码和行。请帮助某人。我已经收到这个错误好几天了。

这些是有错误的行

[string "LuaVM"]:219: 尝试索引一个 nil 值(全局'math')

function convert_sens(unconvertedSens) 
return 0.002 * math.pow(10, unconvertedSens / 50)
end

function calc_sens_scale(sensitivity)
return convert_sens(sensitivity)/convert_sens(50)
end

【问题讨论】:

标签: lua logitech logitech-gaming-software


【解决方案1】:

您使用的 Lua 解释器似乎没有预加载 math 库。您可以尝试在脚本开头添加local math = require "math" 语句,但如果这不起作用,您需要提供有关您的 Lua 环境的更多详细信息。可能未提供对 math 库的访问权限。

【讨论】:

  • require 在 OP 使用的 Lua 环境中不存在(由于沙盒)。
  • 然后先检查math 和assert:assert(math,'math is absent') - math 在package.loaded 中吗?
  • @koyaanisqatsi - 在 OP 使用的 Lua 环境中,整个 package 表不存在(由于沙盒)。
猜你喜欢
  • 1970-01-01
  • 2020-11-03
  • 1970-01-01
  • 2018-11-11
  • 2015-04-09
  • 2014-01-26
  • 2013-06-07
  • 2020-03-08
  • 2013-09-04
相关资源
最近更新 更多