Game Development Reference
In-Depth Information
first one is the parent and the second the object. If the second is of type string , then it is position .
Otherwise, it is the x position.
function addObjectAtPosition(param1, param2, param3, param4, param5)
local lstPassed = {param1, param2, param3, param4, param5}
-- set the default values
local parent = nil -- or default value if you want to set any
local object = nil
local x =0
local y = 0
local position = "left"
local numPassed = #lstPassed
if numPassed == 1 then
object = lstPassed [1]
elseif numPassed == 2 then
if type(lstPassed[2])=="number" then
x = lstPassed[2]
object = lstPassed[1]
elseif type(lstPassed[2])=="string" then
position = lstPassed[2]
object = lstPassed[1]
elseif type(lstPassed[2])=="table" then
object = lstPassed[2]
parent = lstPassed[1]
end
elseif numPassed == 3 then
if type(lstPassed[2])=="number" then
object = lstPassed[1]
x = lstPassed[2]
y = lstPassed[3]
else
parent = lstPassed[1]
object = lstPassed[2]
x = lstPassed[3]
end
elseif numPassed == 4 then
if type(lstPassed[4])=="string" then
object = lstPassed[1]
x = lstPassed[2]
y = lstPassed[3]
position = lstpassed[4]
else
parent = lstPassed[1]
object = lstPassed[2]
x = lstPassed[3]
y = lstpassed[4]
end
else
parent = param1
object = param2
x = param3
Search WWH ::




Custom Search