|
| 11 Oct 2014 06:34 PM |
What I want to make is the Cantor line fractal
Which is a line removing its middle third and then moving the 2 new lines downward.
And since fractals are supposed to be recursive I knew kindof that this problem might occur.
So I went around that by putting the wait so long that each coroutine should have finished therefore no reentrancy.
APPARENTLY IT DOESN'T EVEN REENTER ONCE THEN IT CALLS ERROR .-.?
______________________________________________________________________________
m = Instance.new("Model") m.Parent = workspace remIterations = 15 --root is the first cantor line root = script.Parent prevGen = {root} newGen = {}
function drawNextLine(oldline) --length of the newlines section local oldlength = oldline.Size.x local newlength = oldlength/3 --configuring size and position local newlineA = oldline:Clone() newlineA.Size = Vector3.new(newlength,oldline.Size.Y,oldline.Size.Z) newlineA.CFrame = newlineA.CFrame * CFrame.new(newlineA.Size/2,0,5) local newlineB = oldline:Clone() newlineB.Size = Vector3.new(newlength,oldline.Size.Y,oldline.Size.Z) newlineB.CFrame = newlineB.CFrame * CFrame.new(-newlineB.Size/2,0,5) --Hello World! newlineA.Parent = m newlineB.Parent = m --Moves them into the newGeneration for processing table.insert(newGen,1, newlineA) table.insert(newGen,1, newlineB) end
function sendIntoRoutines() --Releases all prevGen into calculation for index, value in ipairs(prevGen) do local newThread = coroutine.wrap(function() drawNextLine(value) end) newThread() end end
function manageTables() --Deletes all members of prevGen for index, value in ipairs(prevGen) do table.remove(prevGen,index) end --Moves all members of newGen to prevGen --Deletes members of newGen for index, value in ipairs(newGen) do table.insert(prevGen,1,value) table.remove(newGen,index) end end
while remIterations > 0 do --This function launches every member of prevGen into drawNextLine sendIntoRoutines() wait(5) --Now after they are finished, delete prevGen and move newGen into prevGen manageTables() --Decrease Iterations remIterations = remIterations - 1 end
|
|
|
| Report Abuse |
|
|
| 11 Oct 2014 06:37 PM |
Would it be more or less efficient to have a script that
1. Creates the 2 new lines 2. Places them 3. Reproduces this script into the 2 new lines 4. Deactivate the original script.
And is it possible for each script to have its own iteration counter or would it be better to have the counter as a seperate value in workspace? |
|
|
| Report Abuse |
|
|
| 11 Oct 2014 08:34 PM |
Seeing as nobody would help me
Figured out the trick an hour ago.
The trick is to have a script in the original brick do its job
Then it would reproduce into the new bricks
Finally it would kill itself.
http://www.roblox.com/Cantors-Progression-Between-Infinities-place?id=158751282
Take the model too, its a good framework for making fractals.
|
|
|
| Report Abuse |
|