v2.1.0 - Optimized ComboZone helpers, data option for zones, and fixed potentially major bug
Well, a useful feature request and a possibly severe bug led to what some may say is a "swift" schedule between 2.0 and 2.1. There's also one breaking change, so listen up!
This release adds:
- Data option on all zones
- You can give a
data
option to any zone that is a table that can store arbitrary additional info about your zone you want to keep on it. See here for more info
- You can give a
- /pzlast now asks for a name, or you can leave it empty to use the last created zone's name
- This replaces the logic of always using the last zone's name, which I figured isn't always what people would want
- Added
isPointInsideExhaustive()
,onPointInOutExhaustive()
, andonPlayerInOutExhaustive()
to ComboZone- This replaces the
exhaustive
parameter on those functions, and was done to fix a bug and optimize the non-exhaustive version of these functions. - What this breaks:
- If you are already using the regular versions of these functions, you'll need to replace the
true
you input for theexhaustive
parameter, to using one of these functions instead.
combo:isPointInside(point, true)
turns tocombo:isPointInsideExhaustive(point)
combo:onPlayerInOut(function(isPointInside, point, insideZones) end, 500, true)
turns tocombo:onPlayerInOutExhaustive(function(isPointInside, point, insideZones) end)
- On the non-exhaustive versions of these functions, they no longer pass/return a table of zones consisting of the one the point is inside, but instead just that zone (shown below).
- If you are already using the regular versions of these functions, you'll need to replace the
- This replaces the
-- old
combo:onPlayerInOut(function(isPointInside, point, insideZones)
-- insideZones here is a table of the zones you are currently in
-- This is probably how you are using it currently
if #insideZones > 0 then
doSomething(insideZones[1].name)
end
end)
-- new
combo:onPlayerInOut(function(isPointInside, point, zone)
-- if isPointInside is true, zone is the zone the player just entered
-- if isPointInside is false, zone is the last zone the player entered (aka the one the player is just leaving)
-- NOTE: If the player STARTS outside of the zone, this will trigger once with isPointInside=false and zone=nil,
-- so you should always check to make sure zone exists (not nil) if you are going to use it
-- The code above would now be just
if zone then
doSomething(zone.name)
end
end)
This new way of doing things also increases performance and avoids memory churn on non-exhaustive ComboZones. See here for more info about how these functions work now and how to use the exhaustive versions.
The resource itself can be found in PolyZone.zip
. You can grab an example resource from the last release (2.0.0).