Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gridWorldSizeX = 2048;
- local gridWorldSizeY = 2048;
- local nodeRadius = .65;
- local nodeDiameter = nodeRadius * 2;
- local gridSizeX = math.ceil(gridWorldSizeX / nodeDiameter)
- local gridSizeY = math.ceil(gridWorldSizeY / nodeDiameter)
- local MaxSize = gridSizeX * gridSizeY;
- local WalkableMask = "Walkable"
- local NodeClass = require(game.ServerScriptService.Map.Node)
- local obstaclePromityPenalty = 1
- local part = workspace.Unwalkable.GridPart:Clone()
- local TerrainTypes = {
- {
- TerrainParentFolder = "Walkable",
- TerrainPenalty = 0,
- }
- }
- local walkableRegionList = {}
- function createFile(original)
- original.Parent = workspace.Exports
- return Instance.new("ModuleScript")
- end
- local makeGrid = true;
- local modulescript = Instance.new("ModuleScript")
- local worldBottomLeft = (Vector3.new(0,0,0) - Vector3.new(1,0, 0) * gridWorldSizeX / 2 - Vector3.new(0,0,1) * gridWorldSizeY / 2)
- local finalTable = {}
- local dataStuffTable = {}
- local Grid = {}
- if(makeGrid == true) then
- for x=1,gridSizeX, 1 do
- Grid[x] = {}
- for y=1,gridSizeY, 1 do
- local WorldPoint = worldBottomLeft + Vector3.new(1,0,0) * (x * nodeDiameter + nodeRadius) + Vector3.new(0,0,1) * (y * nodeDiameter + nodeRadius)
- local min = WorldPoint - (((nodeDiameter + nodeRadius)) * part.Size)
- local max = WorldPoint + (((nodeDiameter + nodeRadius)) * part.Size)
- local currentRegion = Region3.new(min, max)
- local notWalkableFound = false
- for _,Part in pairs(game.Workspace:FindPartsInRegion3(currentRegion,nil,5)) do
- if(Part.Parent.Name == "Unwalkable" == true) then
- notWalkableFound = true
- break;
- end
- end
- local walkable = true
- if(notWalkableFound == true) then
- walkable = false
- end
- local penalty = 1
- if(walkable == false) then
- penalty = penalty + obstaclePromityPenalty
- end
- if(string.len(modulescript.Source) > 197000) then
- modulescript = createFile(modulescript)
- end
- modulescript.Source = modulescript.Source.."\n".."GridStorage["..x.."]["..y.."] = NodeClass.new("..tostring(walkable)..", Vector3.new("..tostring(WorldPoint.X)..", 0, "..tostring(WorldPoint.Z).."), "..x..", "..y..", "..penalty..")"
- --Grid[x][y] = NodeClass.new(walkable, Vector3.new(WorldPoint.X, 0, WorldPoint.Z), x, y, penalty)--]]
- --wait()
- end
- wait()
- end
- else
- print("load from datastore.")
- end
- Grid.CompletedLoad = true
- repeat wait() until Grid.CompletedLoad == true
- --modulescript.Source = Grid
- modulescript.Parent = workspace.Exports
- --print("added to datastore.")
- --DrawBlocks()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement