Jump to content




Help With Targs In A Loop


  • You cannot reply to this topic
2 replies to this topic

#1 adencraft2000

  • Members
  • 43 posts

Posted 22 August 2013 - 02:42 AM

Hi, I have this program, http://pastebin.com/xwS2x1ab and I have this kind of loop
for i=1,5 do
--something
end
This loops 5 times.

I want it to accept an argument (for example "programName 10" will loop it 10 times

Thanks in advance,
Aden :)

#2 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 22 August 2013 - 02:48 AM

local sTimes = ...
local timesToRepeat = tonumber(sTimes)

if timesToRepeat == nil then
 print("That isn't a number")
 error()
end

for i = 1, timesToRepeat do
-- Do something
end

Untested, written in browser.

BTW, it doesn't need to be called tArgs, it is just "t" for table, then "Args" for arguments. It's used by the CC devs.

#3 adencraft2000

  • Members
  • 43 posts

Posted 22 August 2013 - 04:32 AM

Thanks, Check out my pastebin for all my codes I wrote (Talked to someone who is very good at lua expecting to be told they are bad but was told they are quite good)
pastebin.com/u/ADENCRAFT20000

I recommend you install my scripts via my installer by running
pastebin get 68JHikjS installer
then running
installer






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users