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

[Solved] I made a script that took me forever looking through all the help and such, but it doesnt work PLZ HALP!

Started by 11516, 21 January 2016 - 10:50 AM
11516 #1
Posted 21 January 2016 - 11:50 AM
okay, well I spent a long time making an "anti-virus" for computercraft, and well long story short is doesn't work, so here's the script.
oh! one more thing, when i run the script it gives me this error bios.lua :14: [string ".temp" :7: 'then' expected

term.clear()
term.setCursorPos(1,1)
term.setTextColor( colors.lime )
print ("Anti-Virus 1.0")
term.setTextColor( colors.white)
sleep(1)
if fs.exists("startup") = = true then
term.setCursorPos(1,2)
print ("Restoring Computer. . .")
fs.delete("startup")
fs.copy("disk/Restorer","startup")
sleep(2)
print ("Restord Computer! Rebooting. . .")
sleep(2)
disk.eject("left")
disk.eject("right")
disk.eject("back")
disk.eject("top")
disk.eject("bottom")
os.reboot()
else
term.setCursorPos(1,1)
print ("Anti-Virus 1.0")
sleep(1)
term.setCursorPos(1,2)
print ("No Restoring Needed")
end

(restorer file, if your wondering)


term.clear()
term.setCursorPos(1,1)
term.setTextColor( colors.lime )
print ("Anti-Virus 1.0")
term.setTextColor( colors.white )
sleep(1)
print ("Thank you for using 11516's Anti-Virus")
Edited on 22 January 2016 - 11:32 PM
Bomb Bloke #2
Posted 21 January 2016 - 01:16 PM
Line 7:

if fs.exists("startup") = = true then

You've got a space in between your == there.

Mind you, the "== true" bit isn't needed at all: fs.exists() already returns either true or false, which is what the "if" statement is looking for. This is perfectly valid:

if fs.exists("startup") then
TheOddByte #3
Posted 21 January 2016 - 06:24 PM
Mind you, the "== true" bit isn't needed at all: fs.exists() already returns either true or false, which is what the "if" statement is looking for. This is perfectly valid:

if fs.exists("startup") then
And to add further on this you can do the same thing when checking if a statement is false using the keyword not

if not fs.exists( "startup" ) then
this is ofcourse the same thing as doing this

if fs.exists( "startup" ) == false then

Another suggestion is to learn how to use code tags, as it will be useful when asking further questions. Simply add [.code] code between these tags [./code] and remove the dots, or you can use the button that looks like this <> to insert code tags aswell. If you don't want to use any of these you can alternatively use Pastebin to share your code.
11516 #4
Posted 21 January 2016 - 10:22 PM
:D/>/> it works now, thanks!

urm
its supposed to copy my restorer file to the startup file of the computer… but it isn't… any help?
HPWebcamAble #5
Posted 22 January 2016 - 12:57 AM
its supposed to copy my restorer file to the startup file of the computer… but it isn't… any help?

Is it printing this line?

print ("Restord Computer! Rebooting. . .")

Make sure you have a startup file before you run the program, since you made it only set the new startup file when there's an existing one.