我有一个使用 NLua 编写脚本的游戏引擎。但是,我似乎无法访问Command
数组中的元素:
-- Basic direction detection. This allows forward and backward to cancel each other out if both are active.
function DetectXHoldDirection()
directionDetect = 0
if self.MainBuffer.Hold[0].Directions:HasFlag(Direction.Forward) then
directionDetect = directionDetect + 1
end
if self.MainBuffer.Hold[0].Directions:HasFlag(Direction.Back) then
directionDetect = directionDetect - 1
end
end
MainBuffer
是一个类型为 的对象BufferedCommand
,其中包含Command
结构数组,称为“Hold”、“Release”和“Press”。该Command
结构包含两个枚举属性,按钮,类型Button
(一个标志枚举)和Directions
类型Direction
(另一个标志枚举)。
当我尝试运行此脚本时,标题中出现错误。为什么它试图投射到System.Object[]
?有没有办法解决这个问题?