This is everything relating to zones whether it's polygon, box or 2d/3d circle zones
Register
This is how you register a zone this is best used if you need to check if a player has entered/exited a zone or whether they are contiously inside it
Core.Zones.Register("zoneIdentifier", {
Type = "poly", --## "circle", "poly", "box"
Zone = { --## "poly":table "circle":vec2(2d)/vec3(3d) "box":table {Width:2.0, Height:2.0, Pos:vector4(0,0,0,0)}
vector3(0,0,0),
vector3(0,0,0),
},
Radius = 2.5, --## "circle" ONLY
Draw = { --## OPTIONAL: Used to determine if you are drawing the zone and if so what colour etc
Enabled = false,
Col = {R = 255, G = 0, B = 100, A = 50},
},
onStayLoopTime = 500, --## OPTIONAL: WILL SEND YOUR onStay FUNCTION EVERY 500ms
onStay = function() --## OPTIONAL
end,
onEnter = function() --## OPTIONAL: Will be triggered when a player enters this zone
end,
onExit = function() --## OPTIONAL: Will be triggered when a player exits this zone
end
})
RemoveZone
Core.Zones.RemoveZone("zoneIdentifier")
ToggleDraw
Core.Zones.ToggleDraw("zoneIdentifier", true) --## true to draw, false to not draw...
EditColors
Core.Zones.EditColors("zoneIdentifier", {R = 155, G = 0, B = 0, A = 50})
CreatePolygon
This will allow you create a polygon in-game which then will be copied to your clipboard for easy pasting into your scripts etc
RegisterCommand("Dirk-Core:DrawPolygon", function(source,arg)
local polygon = Core.Zones.CreatePolygon()
Core.UI.Notify("Copied Polygon to Clipboard")
print(Core.UI.CopyToClipboard(json.encode(polygon)))
end)
--## This is a command built into dirk-core for quickly creating polyzones but you
--## could use this Core.Zones.CreatePolygon() anywhere you wanted...
IsPointInside
Could be used if you don't want to register polyzones for some reason and just want a one off check if a point is inside
local polygon = {
vector3(0,0,0),
vector3(0,0,0),
vector3(0,0,0),
}
local isInside = Core.Polygon.IsPointInside(vector3(0,0,0), polygon)
print("This point is inside this zone ", isInside)
plotPolygon
This will plot points within a polygon at seperation distances of your choosing aswell as the width of each cell
local polygon = {
vector3(0,0,0),
vector3(0,0,0),
vector3(0,0,0),
}
local pointWidth = 1.0 --## How big these points are
local pointSeperation = 0.5 --## How far apart the points are
local plottedPoints = Core.Polygon.plotPolygon(polygon, pointSeperation, pointWidth)
--## This will return a bunch of plotted points within the polygon with the settings
--## that you have chosen, I used this for spawning a bunch of random objects at random
--## points within a polygon.