_k's Curvegen
To Use:
1) Copy this code and save it as curve.levelgen in your levels folder.
2) Modify the variables in the header and resave.
3) Go to LEVEL PARAMETERS in the editor and type curve.levelgen where it says Levegen Script:
4) From the editor, press Ctrl-R to run the script and then Ctrl-I to insert the barrier, goalzone, or loadoutzone.
As a bonus, by setting PercentofCircle to 1, you can use a low Resolution number to produce regular polygons!
1) Copy this code and save it as curve.levelgen in your levels folder.
2) Modify the variables in the header and resave.
3) Go to LEVEL PARAMETERS in the editor and type curve.levelgen where it says Levegen Script:
4) From the editor, press Ctrl-R to run the script and then Ctrl-I to insert the barrier, goalzone, or loadoutzone.
As a bonus, by setting PercentofCircle to 1, you can use a low Resolution number to produce regular polygons!
- Code:
- --Adjust the following variables to modify your Circle or Curve.
--To run this levelgen in your level, press Ctrl-R in the Editor.
--To add the created curve to your level, press Ctrl-I after running.
--Item Type
--Choose "BarrierMaker" or "GoalZone" or "LoadoutZone" or "PolyWall"
ItemType = "BarrierMaker"
--Barrier Width of Circle
BarrierWidth = 50
--X Coordinate of Center of Circle
CenterX = 0
--Y Coordinate of Center of Circle
CenterY = 0
--Radius in X Direction of Circle (Keep XRadius and YRadius the same for Circles. Make them different for elipses.)
XRadius = 1
--Radius in Y Direction of Circle (Keep XRadius and YRadius the same for Circles. Make them different for elipses.)
YRadius = 1
--Percent of Circle you want to Draw
--Use 1 for 100% of circle, .75 for 75%, etc.
--You may have to use .51 for 50%.
PercentofCircle = 1
--Where you want point 0 of the curve to be
--Use 0 to Start at (1,0)
--Use .5 * math.pi to Start at (0,-1)
--Use math.pi to Start at (-1,0)
--Use 1.5 * math.pi to Start at (0,1)
StartPoint = 0
--For Higher Resolution Curves, use a higher number.
--Some values might produce curves with too many points to plot.
--if PercentofCircle = 1, lower values will produce regular polygons.
--Suggested Resolutions: 30 or 60
Resolution = 30
-----------------------------------
--Do not edit the following code.--
-----------------------------------
if(ItemType=="BarrierMaker") then
Curve = ItemType .. " " .. BarrierWidth .. " "
elseif(ItemType=="PolyWall") then
Curve = ItemType .. " "
else
Curve = ItemType .. " 0 "
end
Destination = PercentofCircle * 2 * math.pi + StartPoint
for x = StartPoint, Destination, 2 * math.pi / Resolution do
Curve = Curve .. XRadius * math.cos(x) + CenterX .. " " .. YRadius * math.sin(x) - CenterY .. " "
end
if(PercentofCircle == 1) then
Curve = Curve .. XRadius * math.cos(StartPoint) + CenterX .. " " .. YRadius * math.sin(StartPoint) - CenterY .. " "
end
levelgen:addLevelLine(Curve)