Posted 17 December 2012 - 10:44 PM
In my code I tried to pass all variables as function parameters rather than relying on global variables, since I feel this is cleaner.
But the more variables I add the more I regret doing this :)/> Right now I have functions like the next one:
My question is: What do you think is the best option for me?
But the more variables I add the more I regret doing this :)/> Right now I have functions like the next one:
function excavateAllShafts(num, interval, offset, radius, components, minFuel, fuelSuckDir, fuelDropDir, itemDropDir)
local torchSlot=0
if placeTorches then
torchSlot=1
end
if tunSkip<4 then
for i=1, tunSkip do
moveToNextTunnel(radius, fuelSuckDir, fuelDropDir, components+1+torchSlot)
end
excavateShafts(num-shSkip, interval, (offset+(shSkip*(interval+1))), radius, components, minFuel, fuelSuckDir, fuelDropDir, itemDropDir)
moveToNextTunnel(radius, fuelSuckDir, fuelDropDir, components+1+torchSlot)
for i=(tunSkip+2),4 do
excavateShafts(num, interval, offset, radius, components, minFuel, fuelSuckDir, fuelDropDir, itemDropDir)
moveToNextTunnel(radius, fuelSuckDir, fuelDropDir, components+1+torchSlot)
end
end
end
My question is: What do you think is the best option for me?
- Individual function parameters
- Global variables
- grouped function parameters (example: configuration[1] = fuelSuckDir, configuration[2] = fuelDropDir, … and passing configuration to all functions)