Uhh… That may have sounded confusing.
So, I have an attack that looks like the attack you’ll see in 0:11 to 0:14 of this video:
https://www.youtube.com/watch?v=8tBjWfofCqM
And here is the code for that attack:
local lifetime = 50000 local attack = {} function attack.horizontalAttack(blockadeNumber, spaceApart, speed, change) local function moveBlockades(self) if( autoIgnore( "enterFrame", self ) ) then return end if self.x + 15 \> 0 then self.x = self.x - speed end end local function removeBlockades(self) ignore("enterFrame", self) display.remove(self) end for i = 1, blockadeNumber do local blockadeBottom = ssk.display.newRect( nil, right + (i \* spaceApart), bottom, { w = 15, h = 200 + (i \* change), enterFrame = moveBlockades, anchorY = 1, fill = { 0.56, 0.13, 0.94 } }, { isSensor = true } ) local blockadeTop = ssk.display.newRect( nil, blockadeBottom.x, top, { w = 15, h = 200 - (i \* change), enterFrame = moveBlockades, anchorY = 0, fill = { 0.56, 0.13, 0.94 } }, { isSensor = true } ) blockadeTop.timer = removeBlockades timer.performWithDelay(lifetime, blockadeTop) blockadeBottom.timer = removeBlockades timer.performWithDelay(lifetime, blockadeBottom) end end return attack
So, lets say I have a table of tables in a module and I have “required” it at the top of my file. I would want it to do something like this:
for i, blockadeNumber do count = count + 1 --and then in this line: local blockadeBottom = ssk.display.newRect( nil, right + (i \* spaceApart), bottom, --\> { w = 15, h = 200 + table[math.random(1, 10)][count], enterFrame = moveBlockades, anchorY = 1, fill = { 0.56, 0.13, 0.94 } }, { isSensor = true } ) end
Would this work? I haven’t tried this yet, and I am wondering if there is a better way of doing this. If not, please inform me if this would work. Thank you.