I have a game engine that uses NLua for scripting. However, I can't seem to access elements in my Command
array:
-- 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
is an object of type BufferedCommand
, which contains arrays of Command
structs, called "Hold," "Release," and "Press." The Command
struct contains two enum properties, Buttons, of type Button
(a flags enum), and Directions
of type Direction
(another flags enum).
When I try running this script, I get the error in the title. Why is it trying to cast to System.Object[]
? Is there any way to get around that?