--[[ asteroid field generator generates asteroid field posX, posY, posZ - position in space minSize, maxSize - size boundaries of each asteroid radius - size of the cube around position in space count - number of asteroids --]] function asteroidField(posX, posY, posZ, minSize, maxSize, radius, count) for i = 1, count, 1 do size = (math.random() * (maxSize - minSize)) + minSize pX = (2 * math.random() * radius) - radius + posX pY = (2 * math.random() * radius) - radius + posY pZ = (2 * math.random() * radius) - radius + posZ print("") print(" ") print(" ") print(" ") print("") end end --[[ asteroid belt generator generates asteroid belt posX, posY, posZ - position in space yaw, pitch - rotation minSize, maxSize - size boundaries of each asteroid radius0, radius1 - inner/outer radius count - number of asteroids --]] function asteroidBelt(centerX, centerY, centerZ, yaw, pitch, segments, minSize, maxSize, radius0, radius1, count) dPhi = (2 * math.pi) / segments width = math.abs(radius1 - radius0) radius = (radius1 + radius0) / 2 segmentCount = count / segments print("") print("") for i = 0, segments - 1, 1 do asteroidField((radius * math.cos(i * dPhi)), (radius * math.sin(i * dPhi)), 0, minSize, maxSize, width,segmentCount) end print("") print("") end