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

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

Started by ScruffyRules, 10 December 2012 - 04:18 PM
ScruffyRules #1
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
Kingdaro #2
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]))
ScruffyRules #3
Posted 10 December 2012 - 05:29 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]))
but the
for i = 1,tArgs[1] do
worked tho
Thank you that worked! :P/>
ScruffyRules #4
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 on 10 December 2012 - 04:35 PM