Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function makeNodeGrid(x, y)
- local nodesInRow = math.floor(x/3)
- local nodesInLength = math.floor(y/3)
- local totalNodes = nodesInRow * nodesInLength
- local nodes = {}
- local model = Instance.new("Model")
- model.Parent = workspace
- local node = Instance.new("Part")
- node.Shape = "Ball"
- node.Anchored = true
- for i=1,totalNodes+1 do
- local newNode = node:Clone()
- newNode.Parent = model
- newNode.Size = Vector3.new(0.5,0.5,0.5)
- table.insert(nodes, newNode)
- end
- local origin = nodes[1].Position
- local previousPoint = nodes[1].Position
- for i,v in pairs(nodes) do
- if math.fmod(i, nodesInRow) == 0 then
- v.Position = origin + Vector3.new(0,2,0)
- origin = v.Position
- previousPoint = origin
- else
- v.Position = previousPoint + Vector3.new(0,0,2)
- previousPoint = v.Position
- end
- end
- local A1 = Instance.new("Attachment")
- A1.Name = "Attachment1"
- local A2 = Instance.new("Attachment")
- A2.Name = "Attachment2"
- for i,v in pairs(nodes) do
- local A1 = Instance.new("Attachment")
- A1.Name = "Attachment1"
- local A2 = Instance.new("Attachment")
- A2.Name = "Attachment2"
- local A3 = Instance.new("Attachment")
- A3.Name = "Attachment3"
- local A4 = Instance.new("Attachment")
- A4.Name = "Attachment4"
- A1.Parent = v
- A2.Parent = v
- if nodes[i+1] ~= nil then
- A3.Parent = nodes[i+1]
- end
- if nodes[i+nodesInRow] ~= nil then
- A4.Parent = nodes[i+nodesInRow]
- end
- if nodes[i+1] ~= nil then
- if (nodes[i+1].Position - v.Position).magnitude <= 2 then
- local rope1 = Instance.new("RopeConstraint")
- rope1.Color = BrickColor.new("White")
- rope1.Visible = true
- rope1.Parent = v
- rope1.Length = 2.3
- rope1.Attachment0 = A1
- rope1.Attachment1 = A3
- end
- end
- local rope2 = Instance.new("RopeConstraint")
- rope2.Color = BrickColor.new("White")
- rope2.Visible = true
- rope2.Parent = v
- rope2.Length = 2.3
- rope2.Attachment0 = A2
- rope2.Attachment1 = A4
- end
- end
- makeNodeGrid(55, 25)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement