This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
knoxy5467's profile picture

knoxy's variadic arguments question [SOLVED]

Started by knoxy5467, 27 January 2013 - 08:21 AM
knoxy5467 #1
Posted 27 January 2013 - 09:21 AM
hi i need help with something that most of you will probably think is elementary.
most of you know that when you use excavate you have to put a num after it for it to work


i want to make a program that digs rings and when i say dig 4 it would dig a 4x4 ring i want to know how to pass a variable like that.

i have seen things like tArgs = {…} but that doesnt seem to work…
Lyqyd #2
Posted 27 January 2013 - 09:41 AM
Split. No title was requested, so a title was provided. Feel free to edit your title by editing the first post and using the full editor.
LBPHacker #3
Posted 27 January 2013 - 10:01 AM

local tArgs = {...} -- and now tArgs contains the arguments
for i = 1, #tArgs do print(tArgs[i]) end -- this will print every arguments passed
remiX #4
Posted 27 January 2013 - 10:07 AM

args = {...}

length = tonumber(args[1])

if not length then
    print("No length specified")
    return
end

for i = 1, length do
-- code here to use the length
end
knoxy5467 #5
Posted 27 January 2013 - 06:01 PM
thank you you have saved me