Jump to content

Building zones from a table


Recommended Posts

Hey all, I have a simple function that will create a colShape and a radarArea from some definitions in a table. I've tried the code below, but get the following error:

  
[22:44:34] WARNING: Bad argument @ 'createColPolygon' (string-defined function) 
[22:44:34] WARNING: Bad argument @ 'createRadarArea' (string-defined function) 
[22:44:34] WARNING: Bad argument @ 'addEventHandler' (string-defined function) 
[22:44:34] WARNING: Bad argument @ 'addEventHandler' (string-defined function) 
  

  
--{x, y, width, height, red, green, blue, alpha} 
local zones = { 
    {1684, -2008, 200, 200, 0, 255, 0, 0}, 
    {0, 0, 200, 200, 0, 255, 0, 0}} 
function buildSafeZones() 
    for theKey, theZone in ipairs(zones) do 
        local x = tonumber(zones[1]) 
        local y = tonumber(zones[2]) 
        local width = tonumber(zones[3]) 
        local height = tonumber(zones[4]) 
        local red = tonumber(zones[5]) 
        local green = tonumber(zones[6]) 
        local blue = tonumber(zones[7]) 
        local alpha = tonumber(zones[8]) 
        createColRectangle ( X, Y, Width, Height ) 
        createRadarArea (X, Y, Width, Height, R, G, B, A) 
    end 
end 
  

tysm once again.

Link to comment

You are using invalid arguments...

--{x, y, width, height, red, green, blue, alpha} 
local zones = { 
    {1684, -2008, 200, 200, 0, 255, 0, 0}, 
    {0, 0, 200, 200, 0, 255, 0, 0} 
    } 
     
function buildSafeZones() 
    for theKey, theZone in ipairs(zones) do 
        local x = tostring(zones[1]) 
        local y = tostring(zones[2]) 
        local width = tostring(zones[3]) 
        local height = tostring(zones[4]) 
        local red = tostring(zones[5]) 
        local green = tostring(zones[6]) 
        local blue = tostring(zones[7]) 
        local alpha = tostring(zones[8]) 
        createColRectangle ( x, y, width, height ) 
        createRadarArea (x, y, width, height, red, green, blue, alpha) 
    end 
end 

X, Y doesn't exist, same with R, G, B, A

they are red, green, blue, alpha and x,yz

Edited by Guest
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...