Jump to content




[Error][Lua] Try to make a loop program


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

#1 ScruffyRules

  • Members
  • 98 posts

Posted 10 December 2012 - 05:18 PM

I am trying to make a loop program eg. Loop Hello 10 2
here is the usage "Loop <Program> <Number> <Sleep>"
since im a derp i get the Error "bios:133: Expected number"
Code:
local tArgs = {...}
if #tArgs < 3 then
  print("Usage: Loop <Program> <Number> <Sleep>")
  end
for i = 1,tArgs[2] do
  shell.run(tArgs[1])
  os.sleep(tArgs[3])
  end


#2 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 10 December 2012 - 05:27 PM

The arguments come in as strings. You need to convert them to numbers.

for i = 1, tonumber(tArgs[2]) do
  shell.run(tArgs[1])
  os.sleep(tonumber(tArgs[3]))


#3 ScruffyRules

  • Members
  • 98 posts

Posted 10 December 2012 - 05:29 PM

View PostKingdaro, on 10 December 2012 - 05:27 PM, said:

The arguments come in as strings. You need to convert them to numbers.

for i = 1, tonumber(tArgs[2]) do
  shell.run(tArgs[1])
  os.sleep(tonumber(tArgs[3]))
but the
for i = 1,tArgs[1] do
worked tho
Thank you that worked! :P

#4 ScruffyRules

  • Members
  • 98 posts

Posted 10 December 2012 - 05:31 PM

also 1.5 wouldn't work (for <sleep>) how would you get it to?
Edit: IM A Script Kiddie YAY!

Edited by ScruffyRules, 10 December 2012 - 05:35 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users