I have a spawn function that spawns enemies that move from the left side of the screen to the right at random y values, 100-900 for example. How do I separate this range into smaller ranges, say 100-200, 400-500, and 800-900 for example? I don’t want to just use 3 separate spawns, as this creates a different effect than what I want.
Here is my spawn:
{"_com.ClassCommand",0,0,0,{ type = "spawn", params = { chars = {"ClassEnemy1"}, ranges = { interval = {200,300}, x = {-50,-50}, y = {100,900}, speedX = {"time",3.5,4}, }, } }},[/code]Here is the spawn function within my ClassCommand file:o.spawnObject = function() local p = o.params.params; --local char = p.chars[math.random(#p.chars)]; local char = p.chars[math.random(#p.chars)]; local speedX = math.random () * ( p.ranges.speedX[3] - p.ranges.speedX[2]) + p.ranges.speedX[2]; local x,y,seed,collisionDetectObj,collisionDetectObjX; local object = require(_G.charClass.."."..char).new(); for i=1, 1 do x = math.random (p.ranges.x[1], p.ranges.x[2]); y = math.random (p.ranges.y[1], p.ranges.y[2]); object.x = x; object.y = y; object.speed = speedX; object.isBodyActive = o.isBodiesActive; end return true; end[/code]Any help would be greatly appreciated.Much thanks,Steven [import]uid: 79394 topic_id: 33949 reply_id: 333949[/import]