Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
--[[ ------------------------ Originally made by 'Engineer' on the ComputerCraft forums http://www.computercraft.info/forums2/index.php?/topic/11484-/ Edited by DeliciousJaffa to fix bugs, add documentation and add a whole load of new functionality http://twitter.com/DeliciousJaffa ------------------------ Current version: 1.0.1.3 Documentation: 1. Installation Run the following commands: pastebin get JW4uj2Jw startup reboot 2. Usage "startup auto list" - This command will list all auto updating programs "startup auto add <paste bin code> <program>" - This command will add a program to check for updates from a pastebin page "startup auto remove <program>" - This will remove a program from the auto update list by it's name (also known as it's command) "startup auto reset" - This will reset the auto update list to the current defaults "startup set <program>" - This command will set a program to be launcher after update checking when the computer restarts (or when the chunk becomes loaded again) "startup unset" - This will wipe the startup so that no program is ran automatically. "startup update" - This command will check if the code at the specified pastebin id is different from the named program, if it is, it'll automatically download the update before anything else 3. Preinstalled programs This auto-updater installs 2 programs by default. - "EpicMine" by Princetommen http://pastebin.com/6qmBBLpz Mines out tunnels or an area - "Attack" by DeliciousJaffa http://pastebin.com/vNNYrHUp Attacks mobs forever and drops items ------------------------ ]] local tArgs = { ... } local autoFile = "/startup-updatelist" local prefFile = "/startup-prefs" local defaultsPbinCode = "B2jBQTU2" function usage() print( "Usage:" ) print( "- startup auto list" ) print( "- startup auto add <pastebin code> <program>" ) print( "- startup auto remove <program>" ) print( "- startup auto reset" ) print( "- startup set <program>" ) print( "- startup unset" ) print( "- startup update" ) print( "See the documentation for more information") end function getPastebin( code ) local response = http.get( "http://pastebin.com/raw.php?i=" .. textutils.urlEncode( code ) ) if response then local contents = response.readAll() local file = fs.open( code, "w" ) file.write( contents ) file.close() return true, contents else return false end end function setDefaults() if fs.exists( autoFile ) then fs.delete( autoFile ) end local file = fs.open( autoFile, "w" ) local condition, raw = getPastebin(defaultsPbinCode) fs.delete(defaultsPbinCode) local default = textutils.unserialize(raw) local tPrograms = {} if condition == true then tPrograms = default file.write( textutils.serialize(tPrograms)) file.close() print("Default autoupdate list installed") else print("Failed to obtain the default update list") end end function update() if fs.exists( autoFile ) then local file = fs.open( autoFile, "r" ) local handler = file.readAll() file.close() local tPrograms = textutils.unserialize( handler ) if type( tPrograms ) == "table" then for i = 1, #tPrograms do local condition, content = getPastebin( tPrograms[i][1] ) if condition then local reader = "needsupdateornot" if fs.exists(tPrograms[i][2]) then local installed = fs.open(tPrograms[i][2], "r") reader = installed.readAll() installed.close() end if reader ~= content then fs.delete( tPrograms[i][2] ) fs.move( tPrograms[i][1], tPrograms[i][2] ) print( "Updated " .. tPrograms[i][2] .. " succesfully!" ) else print( "No update needed for: "..tPrograms[i][2] ) fs.delete( tPrograms[i][1] ) end else print( "Update for " .. tPrograms[i][2] .. " unsuccesfull!" ) end end end end print("Update check completed") end if not fs.exists( autoFile ) then setDefaults() end local sCommand = "noCommand" if #tArgs == 0 then update() print("See documentation for commands (pastebin page)") if turtle then if os.getComputerLabel() then print(os.getComputerLabel() .. " reporting for duty with " .. turtle.getFuelLevel() .. " fuel") else print("Reporting for duty with " .. turtle.getFuelLevel() .. " fuel") end else if os.getComputerLabel() then print(os.getComputerLabel() .. " reporting for duty!") end end if fs.exists( prefFile ) then local file = fs.open( prefFile, "r" ) local startupname = file.readAll() if fs.exists(startupname) then print("Launching startup program") shell.run(startupname) else print("Startup program could not be found.") end end elseif #tArgs > 4 then usage() else if string.lower( tArgs[1] ) == "manual" and tArgs[3] then sCommand = "manual" elseif string.lower(tArgs[1]) == "auto" then if string.lower( tArgs[2] ) == "remove" and tArgs[3] then sCommand = "auto_getoff" elseif string.lower( tArgs[2] ) == "add" and tArgs[4] then sCommand = "auto_add" elseif string.lower( tArgs[2] ) == "list" then sCommand = "auto_list" elseif string.lower( tArgs[2] ) == "reset" then setDefaults() else usage() end elseif string.lower(tArgs[1]) == "set" then sCommand = "setstartup" elseif string.lower(tArgs[1]) == "unset" then sCommand = "delstartup" elseif string.lower(tArgs[1]) == "update" then update() else usage() end end if not http then print( "HTTP not enabled" ) print( "Enable this in the config" ) error() end if sCommand == "manual" then local sFile = tArgs[3] local sCode = tArgs[2] if not fs.exists( sFile ) then local rAnswer, download term.clear() term.setCursorPos( 1,1 ) print( "File doesn't exist!\nStill download " .. sCode .. " to "..sFile.." ? (Y/N)" ) while true do local evt, key = os.pullEvent("char") if key == "y" then download = true break elseif key == "n" then download = false break end end if download then if getPastebin( sCode ) then fs.move( sCode, sFile ) print( "Succesfully downloaded " .. sCode .. " as " .. sFile ) elseif not getPastebin( sCode, sFile ) then print( "Could not download " .. sCode .. " from pastebin.com" ) end end else if getPastebin( sCode ) then fs.delete( sFile ) fs.move( sCode, sFile ) print( "Succesfully updated " .. sFile ) elseif not getPastebin( sCode ) then print( "Could not update " .. sFile .. " with " .. sCode ) end end elseif sCommand == "auto_list" then if not fs.exists( autoFile ) then print( "Nothing is added yet" ) else local file = fs.open( autoFile, "r" ) local reader = file.readAll() file.close() local tPrograms = textutils.unserialize( reader ) term.clear() term.setCursorPos( 1,1 ) print( "Pastebin Code: Program Name:" ) if type( tPrograms ) == "table" then for i = 1, #tPrograms do term.setCursorPos( 1, i + 2 ) write( tPrograms[i][1] ) term.setCursorPos( 19, i + 2 ) write( tPrograms[i][2] ) term.setCursorPos( 1, i + 3 ) end else print( "None None") end end elseif sCommand == "auto_add" then local sCode = tArgs[3] local sFile = tArgs[4] if sFile and getPastebin( sCode ) then fs.delete( sCode ) local file = fs.open( autoFile, "r" ) local handler = file.readAll() file.close() local tPrograms = textutils.unserialize( handler ) if type( tPrograms ) ~= "table" then local file = fs.open( autoFile, "w" ) tPrograms = {} file.write( textutils.serialize( tPrograms ) ) file.close() end local codeintable = false for i = 1, #tPrograms do if tPrograms[i][2] == sFile then codeintable = true end end if codeintable == false then table.insert( tPrograms, { sCode, sFile } ) end fs.delete( autoFile ) file = fs.open( autoFile, "w" ) file.write( textutils.serialize( tPrograms )) file.close() if codeintable == false then print("Succesfully added " .. sFile .. " to the update list." ) else print("Please remove " .. sFile .. " from the list before adding a new code for it") end update() elseif not getPastebin( sCode ) then print( "Your pastebin code is invalid" ) end elseif sCommand == "auto_getoff" then local sFile = tArgs[3] local file = fs.open( autoFile, "r" ) local handler = file.readAll() file.close() local tPrograms = textutils.unserialize( handler ) for i = 1, #tPrograms do if tPrograms[i][2] == sFile then table.remove( tPrograms, i) table.remove( tPrograms, i) break end end fs.delete( autoFile ) file = fs.open( autoFile, "w" ) file.write( textutils.serialize( tPrograms ) ) file.close() print( "Succesfully removed " .. sFile .. " from the auto update list." ) elseif sCommand == "setstartup" then local file = fs.open( prefFile, "w" ) file.write( tArgs[2] ) file.close() print("" .. tArgs[2] .. " will now open on startup") elseif sCommand == "delstartup" then if fs.exists(prefFile) then fs.delete(prefFile) print("This computer will no longer auto launch a program on startup") end print("Error: No launch program set") end
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
웹 보안 - HTML & JavaScript 기초
6 hours ago | 6.45 KB
Trevor-powershell
6 hours ago | 0.15 KB
Halo Evolutions 21
13 hours ago | 1.25 KB
EU Defense Stocks
1 day ago | 0.06 KB
Halo Evolutions 19
1 day ago | 0.42 KB
Halo Evolutions 17
1 day ago | 0.43 KB
Halo Evolutions 16
1 day ago | 0.20 KB
gen5
1 day ago | 0.75 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!