User talk:Sduke524/SumoBots/Rings: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>NXTBoy
Created page with "==Suggested replacement== {{lua|= function new(obj, f) obj = Instance.new(obj) return f and f(obj) or obj end function range(t) local to, from = t[1] or t[0], t[1] and t[0]..."
 
>NXTBoy
Line 1: Line 1:
==Suggested replacement==
==Suggested replacement==
{{lua|=
{{lua|=
function new(obj, f) obj = Instance.new(obj) return f and f(obj) or obj end
function with(obj, f) return f and f(obj) or obj end
function new(obj, f) return with(Instance.new(obj), f) end


function range(t)
function range(t)
Line 19: Line 20:
local position = CFrame.new(0, 0.2, 0)
local position = CFrame.new(0, 0.2, 0)
local radius = 40
local radius = 40
local cleanPart = new("Part", function(p)
p.Anchored = true
p.TopSurface = "Smooth"
p.BottomSurface = "Smooth"
p.formFactor = "Custom"
p.BrickColor = BrickColor.new("White")
end)


new("Model", function(ring)
new("Model", function(ring)
ring.Name = "Ring"
ring.Name = "Ring"


new("Part", function(center)
with(cleanPart:clone(), function(center)
center.Name = "Center"
center.Name = "Center"
center.Anchored = true
center.BrickColor = BrickColor.new("White")
center.TopSurface = "Smooth"
center.BottomSurface = "Smooth"
center.formFactor = "Custom"
center.Size  = Vector3.new(20, 0.31, 20)
center.Size  = Vector3.new(20, 0.31, 20)
center.CFrame = position
center.CFrame = position
Line 38: Line 42:
local cf = position * CFrame.Angles(0, angle, 0)
local cf = position * CFrame.Angles(0, angle, 0)


new("Part", function(inner)
with(cleanPart:clone(), function(inner)
inner.Name = "Inner"
inner.Name = "Inner"
inner.Anchored = true
inner.BrickColor = BrickColor.new("Really black")
inner.BrickColor = BrickColor.new("Really black")
inner.TopSurface = "Smooth"
inner.BottomSurface = "Smooth"
inner.formFactor = "Custom"
inner.Size = Vector3.new(10.1, 0.3, radius)
inner.Size = Vector3.new(10.1, 0.3, radius)
inner.CFrame = cf * CFrame.new(0, 0, radius / 2)
inner.CFrame = cf * CFrame.new(0, 0, radius / 2)
end).Parent = ring
end).Parent = ring


new("Part", function(outer)
with(cleanPart:clone(), function(outer)
outer.Name = "Outer"
outer.Name = "Outer"
outer.Anchored = true
outer.BrickColor = BrickColor.new("White")
outer.TopSurface = "Smooth"
outer.BottomSurface = "Smooth"
outer.formFactor = "Custom"
outer.Size = Vector3.new(11, 0.3, 2)
outer.Size = Vector3.new(11, 0.3, 2)
outer.CFrame = cf * CFrame.new(0, 0, radius + 1)
outer.CFrame = cf * CFrame.new(0, 0, radius + 1)
Line 62: Line 57:
end).Parent = workspace
end).Parent = workspace
}}
}}
{{User:NXTBoy/sig|date=22:37, 18 March 2012 (UTC)}}

Revision as of 22:37, 18 March 2012

Suggested replacement

function with(obj, f) return f and f(obj) or obj end
function new(obj, f) return with(Instance.new(obj), f) end

function range(t)
	local to, from = t[1] or t[0],  t[1] and t[0] or 0
	local span, i = to - from, 0
	local steps = t.steps or span / t.step
	return function()
		if i < steps then
			local n = from + span * i/steps
			i = i + 1
			return n
		end
	end
end

local itr = 25
local position = CFrame.new(0, 0.2, 0)
local radius = 40

local cleanPart = new("Part", function(p)
	p.Anchored = true
	p.TopSurface = "Smooth"
	p.BottomSurface = "Smooth"
	p.formFactor = "Custom"
	p.BrickColor = BrickColor.new("White")
end)

new("Model", function(ring)
	ring.Name = "Ring"

	with(cleanPart:clone(), function(center)
		center.Name = "Center"
		center.Size  = Vector3.new(20, 0.31, 20)
		center.CFrame = position
		new("CylinderMesh").Parent = center
	end).Parent = ring

	for angle in range{2*math.pi, steps = itr} do
		local cf = position * CFrame.Angles(0, angle, 0)

		with(cleanPart:clone(), function(inner)
			inner.Name = "Inner"
			inner.BrickColor = BrickColor.new("Really black")
			inner.Size = Vector3.new(10.1, 0.3, radius)
			inner.CFrame = cf * CFrame.new(0, 0, radius / 2)
		end).Parent = ring

		with(cleanPart:clone(), function(outer)
			outer.Name = "Outer"
			outer.Size = Vector3.new(11, 0.3, 2)
			outer.CFrame = cf * CFrame.new(0, 0, radius + 1)
		end).Parent = ring
	end
end).Parent = workspace
22:37, 18 March 2012 (UTC)