Last active
August 29, 2015 14:18
-
-
Save Sleitnick/c2b9df8f150a48db7d65 to your computer and use it in GitHub Desktop.
Create and union Hexagon from ROBLOX Studio command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Instructions: | |
1) Set 'radius' and 'height' to non-zero positive numbers (x > 0) | |
2) Copy & Paste this code into Command Bar | |
3) Press Enter | |
--]] | |
local radius = 4 | |
local height = 10 | |
-- Load Stravant's PolyDraw module: | |
local tri = require(game.InsertService:LoadAsset(165651825):WaitForChild("PolyDraw")).Tri | |
local hex = Instance.new("Model", game.Workspace) | |
hex.Name = "Hexagon" | |
-- Set 'origin' 10 studs in front of camera: | |
local origin = game.Workspace.CurrentCamera.CoordinateFrame.p + (game.Workspace.CurrentCamera.CoordinateFrame.lookVector * 10) | |
local points = {} | |
local lastPoint, firstPoint | |
-- Create points and draw triangles: | |
for i = 1,6 do | |
local theta = math.rad(i * 60) | |
local x = radius * math.cos(theta) | |
local y = radius * math.sin(theta) | |
local point = origin + Vector3.new(x, 0, y) | |
if (lastPoint) then | |
tri.new(hex, point, lastPoint, origin) | |
end | |
lastPoint = point | |
if (not firstPoint) then | |
firstPoint = point | |
end | |
end | |
tri.new(hex, lastPoint, firstPoint, origin) | |
-- Set height: | |
for _,v in pairs(hex:GetChildren()) do | |
local c = v.CFrame | |
v.Size = Vector3.new(height, v.Size.Y, v.Size.Z) | |
v.CFrame = c | |
end | |
game:GetService("ChangeHistoryService"):SetWaypoint("CreateHexagon") | |
-- Attempt to union the hexagon: | |
local union = PluginManager():CreatePlugin():Union(hex:GetChildren()) | |
if (union) then | |
union.Parent = game.Workspace | |
union.UsePartColor = true | |
union.CanCollide = true | |
hex.Parent = nil | |
hex = union | |
game:GetService("ChangeHistoryService"):SetWaypoint("UnionHexagon") | |
end | |
game.Selection:Set{hex} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment