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

Error antivirus:8: expected number, number

Started by badass114, 14 March 2015 - 02:56 PM
badass114 #1
Posted 14 March 2015 - 03:56 PM
So im new to computer craft and im making an antivirus already made an working virus but it gives me this error and i need help
error : Error antivirus:8: expected number, number
Can you help me dont understand what i did wrong and thats a fake ip xD
Code :
[html]textutils.slowPrint("Antivirus is being runned please wait")
textutils.slowPrint("One virus found")
print("Name:FakeShell.run")
print("Ip:198.0.249.2")
print("Maker:Madara")
textutils.slowPrint("Disabling all virus,please wait . . .")
sleep(1)
term.setCursorPos("18, 1")
print("Progress Bar")
term.setCursorPos("18, 2")
textutils.slowPrint("#")
sleep(2)
term.setCursorPos("18, 2")
textutils.slowPrint("##")
sleep(2)
term.setCursorPos("18, 2")
textutils.slowPrint("###")
sleep(1)
term.setCursorPos("18, 2")
textutils.slowPrint("########")
sleep(4)
term.setCursorPos("18, 2")
textutils.slowPrint("###############")
sleep(10)
[/html]
Anavrins #2
Posted 14 March 2015 - 06:35 PM
term.setCursorPos("18, 1")
You're giving it a string argument "18, 1", this function only accepts two number.
You have to put setCursorPos(18, 1) instead.

Btw, is your antivirus doing anything good?
It looks like it's just wasting a good minute printing #'s
Edited on 14 March 2015 - 05:37 PM
HPWebcamAble #3
Posted 14 March 2015 - 06:52 PM
Obviously, this is just for fun, since it doesn't DO anything, but that's why we have Computer Craft :D/>

Like anavrins mentioned, term.setCursorPos() only accepts two NUMBERS, not STRINGS
Numbers are just, well numbers, strings have quotes around them ""


term.setCursorPos("1,1") --# Wrong

term.setCursorPos(1,1) --# Right

Also, each time you redraw the progress bar, it's reprinting things it's already printed
(Sorry if that was confusing sentence.. couldn't think of a good way to word it)


It won't error, but it isn't very efficient.

You could do this instead:

term.setCursorPos(18,1)

for i = 1, 8 do --# Repeats 8 times. 'i' isn't used by our program, but it needs to be there for syntax
  term.write("#")
  sleep(1)
end
This will print 8 '#', waiting a second in between