SimpleZone | A simple, fast and new Zone module!

Yeah, I also probably need to implement some sort of throttling, tomorrow maybe.

1 Like

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…

1 Like

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 :wink:

1 Like

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? :sob:

External Media
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)
1 Like

Try using .fromPart() instead of .new(), honestly I don’t know why but it’s not very reliable

Oops found the issue
image

Wth is a Basedata :sob:
Will be fixed in the latest version

1 Like

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)

2 Likes

Yes it is

Summary

30charlimit

Ahh yes I completely forgot about that! I’ll merge this into the main package, thank you! :heart:

1 Like

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.

1 Like

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 as SimpleZone.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 and StoreByClass: boolean, the latter of which you need to set to true if you wish to use Zone: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 PackageLinked downloadable version, and is available on the marketplace.
Let me know if anyone encounters any bugs regarding these new changes :slight_smile:

Was having trouble with ZonePlus, but SimpleZone ended up being the perfect solution, thanks!

1 Like

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
1 Like

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 :slight_smile:

1 Like

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!

1 Like