Hello People,
I’ve been wondering how to do this for a while, is it possible to create variables with loops? like
[lua] for i = 1, 10 do
local ball…i…isAvail = false
end [/lua]
My problem is that I am re-applying linear impulses to balls, to make them move around, but if one gets removed, the impulses stop because it can’t detect the ball. My idea was to put a variable, and set it to true when the ball is spawned, and then only apply the impulse if the ball is available. Does anyone know if this is possible?
This is the code I’m using to re-apply the force.
[lua]
local function boost (e)
for i = 1, 10 do
ball[i]:setLinearVelocity(math.random(-100,100),math.random(-100,100))
end
end
timer.performWithDelay(1000, boost, 0)[/lua]
This is what I want to use:
[lua]local function boost (e)
for i = 1, 10 do
if ball…i…isAvailable = true then
ball[i]:setLinearVelocity(math.random(-100,100),math.random(-100,100))
end
end
end
timer.performWithDelay(1000, boost, 0) [/lua]
Any help would be much appreciated.
Ollie [import]uid: 67534 topic_id: 25358 reply_id: 325358[/import]
[import]uid: 52491 topic_id: 25358 reply_id: 102667[/import]