Yeah, I also probably need to implement some sort of throttling, tomorrow maybe.
will simplezone in the future also be able to use meshes?
any any chance of a testing open source place with your next release ?
LessSimpleZone already supports that
Maybe.
hi, yes I know āLessSimpleZone already supports thatā ⦠was just asking if simplezone ever willā¦
You know what, maybe I will add it because it doesnāt require storing any additional data within the Zone
, stay tuned for another update
Update:
-
Added the
.fromParts()
constructor -
Will be adding some form of throttling soon⦠maybe frametime throttling?
-
Will also be adding some more small optimizations I have in mind soon
What am I doing wrong?
local Options = SZ.QueryOptions.new()
Options.FireMode = "Both"
local Zone = SZ.new(zonepart, Options)
Zone:BindToHeartbeat()
-- // Connections
Zone:ListenTo("Player", "Entered", function(Player : Player)
print("Player entered.")
end)
Zone:ListenTo("Player", "Exited", function(Player : Player)
print("Player left.")
end)
Try using .fromPart() instead of .new(), honestly I donāt know why but itās not very reliable
Oops found the issue
Wth is a Basedata
Will be fixed in the latest version
Is the latest version published already?
Hey this module works super well for my game but theres a small major issue with the model. Whenever the player resets/dies and then go into the zone again it wont fire. I made my own fix for it where I replaced the PlayerLookup module with this:
local Players = game:GetService('Players')
-- A lookup table to store the body parts of every player
local characterObjects = {}
-- A lookup table to store what bodyparts for a player are stored
-- in characterObjects
local playerOwned = {}
-- Fast player lookup table
local function updatePlayerCharacter(player, character)
if playerOwned[player] then
for _, part in playerOwned[player] do
characterObjects[part] = nil
end
end
local parts = {}
for _, part in character:GetDescendants() do
if part:IsA("BasePart") then
characterObjects[part] = player
table.insert(parts, part)
end
end
playerOwned[player] = parts
end
local function onPlayerAdded(player)
local character = player.Character or player.CharacterAdded:Wait()
updatePlayerCharacter(player, character)
player.CharacterAdded:Connect(function(newCharacter)
updatePlayerCharacter(player, newCharacter)
end)
end
local function onPlayerRemoving(player)
if playerOwned[player] then
for _, part in playerOwned[player] do
characterObjects[part] = nil
end
playerOwned[player] = nil
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)
for _, player in Players:GetPlayers() do
onPlayerAdded(player)
end
return characterObjects
Heres my place file for anyone that wants to test the zone
simple zone.rbxl (69.1 KB)
Yes it is
Summary
30charlimit
Ahh yes I completely forgot about that! Iāll merge this into the main package, thank you!
Hey. Great resource. But I have a couple of questions.
How would I update a bounding box zoneās CFrame/Size whenever the part that it inherited from changes those exact same properties.
(E.g: The part moving 1,000 studs from the side and the bounding box follows, or the part size changes and the bounding zone box size changes to that partās size)
local Zone = require(script.Parent.Zone);
local zonePart = script.Parent.Parent;
local queryOptions = Zone.QueryOptions.new();
queryOptions.TrackItemEnabled = false;
local boxes = ({
{cframe = zonePart.CFrame, size = Vector3.new(zonePart.Size.X, zonePart.Size.Y, zonePart.Size.Z)};
});
local zone = Zone.fromBoxes(boxes, queryOptions);
zone:BindToHeartbeat();
zone:ListenTo("Player", "Entered", function(Player : Player)
warn(Player.Name);
end);
The reason why I need this is because; I need zones that go over the 2048 part size limit while not being static at the same time.
More-so specifically I need this for tornadic windfields; for my storm-chasing game, this makes it much more performant and easier to manage than just manually making your own grid system for such large windfields.
I tried to get this to work but to no avail.
And also, is there a way to check the arrays of items, parts, and players in the zone similar to how ZonePlus has methods for that (e.g: zone:getPlayers
), I need this to constantly check for parts or players in the zone on a loop rather than just once when they entered.
I have tried looking for similar functions but couldnāt any on the documentation.
As far as I know the module isnāt able to do the stuff I mentioned, so consider this a suggestion, I guess if so.
Hmmm, yes I will consider adding this.
Yeah I understand
Yep, Definitely will add this. Thanks for the feedback, stay tuned for the next update.
Also, sorry for the late response, I got pretty ill and had to rest for a few days xd
UPDATE:
-
Added
Zone:GetItemsWhichAreA(class: string)
as well asSimpleZone.fromPartsUpdatable(...): (Zone, (parts: {BasePart}, updateThreshold: number?) -> boolean)
which passes an update function as the second return type. -
I also added 2 new fields to the
QueryOptions
object,AcceptMetadata: boolean
andStoreByClass: boolean
, the latter of which you need to set totrue
if you wish to useZone:GetItemsWhichAreA(...)
. -
I also added some comments in the
Zone:Update()
source code (felt like it needed some after all the changes) and also I made it so that a new metatable isnāt created everytime you construct a new zone
Update is available for anyone who already has the PackageLink
ed downloadable version, and is available on the marketplace.
Let me know if anyone encounters any bugs regarding these new changes
Was having trouble with ZonePlus, but SimpleZone ended up being the perfect solution, thanks!
Getting the following error after calling :Destroy()
cannot change a protected metatable
The solution is the following
local function zone_new(queryOp, queryFn)
assertQueryOp(queryOp)
return setmetatable({
_items = {},
_tracked = {},
_update = false,
_queryOptions = queryOp or queryop_new(),
ItemEntered = Signal.new(),
ItemExited = Signal.new(),
Query = queryFn
},{
__index = Zone,
})
end
Hello, the __metatable metamethod was removed a while ago, are you sure youāre using the most recent version?
If the package link isnt working, the marketplace link is up to date
just downloaded it today, so iād say so
Odd, well if you ever want to use some of the new features and optimizations I would try redownloading until youāre able to retrieve the latest version. Let me know if you still canāt get
it. Happy coding!