I have a system of chunks and folders. I use the folders for storing data and using their names to store a position. Examples of the names are below:
1. 0, 0.045, 0
2. 0, 2.045, 0
3. 1, 5.676, 10
Now here is what I currently have:
Module.GetHighestGrassBrick = function(X, Z) -- Used for trees currently local RegionX, RegionZ = LocateRegion(Vector3.new(X, 0, Z)) local Region = RegionData:findFirstChild("Region"..RegionX.."-"..RegionZ) local CurrentHeight = 0 for Number, BrickFolder in pairs(Region:GetChildren()) do if BrickFolder:IsA("Folder") then local XX, YY, ZZ = GiveCoords(BrickFolder) if XX == X and ZZ == Z and YY > CurrentHeight and (BrickFolder:GetChildren())[1].Name == "Grass" then CurrentHeight = YY end end if Number%4096*8 then wait() end end return CurrentHeight end
Due to the nature of this, it takes roughly 5 seconds of sorting through 131,072 folders and checking the x and z coordinates, then comparing the height with the current highest spot. Of course nothing will move until it's done.
The regionX is the chunk's X and the regionZ is the chunk's Z, those aren't needed for you guys. I need a mroe efficent way to do this, I can redo the folder structure, but if possible this is a better structure for my purposes.
Keep in mind, 5 seconds of nothing moving is fine and all, but it does this 10 times....