My Code is:
Target = {}
Target.__index = Target
function Target.new(isfound,distance,azimuth_angle,elevation_angle,time_since_detected)
local instance = setmetatable({},Target)
instance.isfound = isfound
instance.distance = distance
instance.azimuth_angle = azimuth_angle
instance.elevation_angle = elevation_angle
instance.time_since_detected = time_since_detected
return instance
end
function Target:CalculateXY(maxDistance,radius,radarAngle)
distancePx = (self.distance/maxDistance)*radius
x2 = w / 2 + distancePx * math.cos(1.58+radarAngle)
y2 = h / 2 + distancePx * math.sin(1.58+radarAngle)
data = {x = x2, y= y2}
return data
end
function Target:GetIsFound()
return self.isfound
end
The error message is:
Exception has occurred: attempt to call a nil value (global 'setmetatable')
It is triggered on the Line:
local instance = setmetatable({},Target)
I am Using VS Code with the lua version:
Name: Lua
Id: sumneko.lua
Description: Lua Language Server coded by Lua
Version: 3.5.6
Publisher: sumneko
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=sumneko.lua
What could be the issue?