Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
--[[ Setup Vars ]]-- timeUrl = "http://www.8bittrip.comli.com/time.php" splitOn = ":" --[[ Sides for hour/minute connected to terminal ]]-- hourSide = "left" minSide = "back" --[[ Set your colours here ]]-- tl = colors.lime t = colors.lightBlue tr = colors.black m = colors.orange bl = colors.red b = colors.white br = colors.pink tl2 = colors.lightGray t2 = colors.gray tr2 = colors.green m2 = colors.blue bl2 = colors.brown b2 = colors.cyan br2 = colors.yellow --[[ End Vars Setup ]]-- --[[ Code below here should not be altered ]]-- wordHE = tl + tr + m + bl + br + tl2 + t2 + m2 + bl2 + b2 wordLO = tl + bl + b + tl2 + t2 + tr2 + bl2 + b2 + br2 wordSY = tl + t + m + br + b + tl2 + m2 + tr2 + br2 + b2 wordNC = tl + bl + t + tr + br + bl2 + t2 + tl2 + b2 --[[ Standard function to split strings ]]-- function split(str, pat) local t = {} -- NOTE: use {n = 0} in Lua-5.0 local fpat = "(.-)" .. pat local last_end = 1 local s, e, cap = str:find(fpat, 1) while s do if s ~= 1 or cap ~= "" then table.insert(t,cap) end last_end = e+1 s, e, cap = str:find(fpat, last_end) end if last_end <= #str then cap = str:sub(last_end) table.insert(t, cap) end return t end --[[ Standard function (slightly modified) to get URL by Espen ]]-- function httpPullCheck(urlArg, fileArg) --[[ HttpTest by Espen v1.3 An example code to show how to use the ComputerCraft HTTP functions. Thanks to Advert for making me aware of the redundant call to http.get after http.request! --]] --[[ Setting up variables ]] -- local fileWriteOK local url = false local filename = false local function getHttpBody( url ) get( url ) while true do local event, urle, hBody = os.pullEvent() if event == "http_success" then print( "HTTP SUCCESS\nURL " ) return hBody else print( "HTTP FAILURE\nURL , retry in 1min" ) -- If the error is not catched, this will exit the program. return nil -- In case this function is called via pcall. end end end local function processHttpBody( hBody, filename ) local hFile if hBody then local body = hBody.readAll() -- Read the whole body. hFile = io.open( filename, "w" ) -- Open the provided filename for writing. hFile:write( body ) -- Write the body to the file. hFile:close() -- Save the changes and close the file. hBody.close() -- Do not know for sure if this is really necessary, but just in case. else print( "Sorry, no body to process." ) end end local function checkOverwrite( filename ) term.setCursorBlink( false ) print("\nWarning: File already exists. Overwrite? (Y/N)") while true do event, choice = os.pullEvent( "char" ) -- Only listen for "char" events. if string.lower( choice ) == "y" then return true end if string.lower( choice ) == "n" then return false end end end local function printUsage() print("Usage:") print("httptest <URL> <OUTPUT-FILENAME>") print("Example:") print("httptest http://www.google.com/ webout") print("\nThe response body will then be output into the file 'webout', line for line.") end --[[ ===== Execution Entry ===== ]] --[[ Processing arguments ]] if urlArg then url = urlArg end if fileArg then filename = fileArg end --[[ Making sure all necessary arguments were provided by the user ]] if not url or not filename then printUsage() --elseif not fs.exists( filename ) or checkOverwrite( filename ) then else processHttpBody( getHttpBody( url ), filename ) --If getHttpBody successfully returns a body, we continue with processing the body and saving it to a file. end end function setDoubleDigits(outputSide, digitsTotal) if digitsTotal < 10 then leftDigit = 0 else leftDigit = math.floor(digitsTotal/10) end if digitsTotal == 0 then rightDigit = 0 else rightDigit = digitsTotal%10 end --setDigits rs.setBundledOutput(outputSide, leftMixes[leftDigit] + rightMixes[rightDigit]) end --[[ Mixes of colours to get digits ]]-- rightMixes = { } rightMixes[0] = tl2 + t2 + tr2 + bl2 + b2 + br2 rightMixes[1] = tr2 + br2 rightMixes[2] = t2 + tr2 + m2 + bl2 + b2 rightMixes[3] = t2 + tr2 + m2 + br2 + b2 rightMixes[4] = tl2 + tr2 + m2 + br2 rightMixes[5] = t2 + tl2 + m2 + br2 + b2 rightMixes[6] = t2 + tl2 + m2 + br2 + bl2 + b2 rightMixes[7] = t2 + tr2 + br2 rightMixes[8] = t2 + tl2 + tr2 + m2 + br2 + bl2 + b2 rightMixes[9] = t2 + tl2 + tr2 + m2 + br2 + b2 leftMixes = { } leftMixes[0] = tl + t + tr + bl + b + br leftMixes[1] = tr + br leftMixes[2] = t + tr + m + bl + b leftMixes[3] = t + tr + m + br + b leftMixes[4] = tl + tr + m + br leftMixes[5] = t + tl + m + br + b leftMixes[6] = t + tl + m + br + bl + b leftMixes[7] = t + tr + br leftMixes[8] = t + tl + tr + m + br + bl + b leftMixes[9] = t + tl + tr + m + br + b --[[ Program starts here ]]-- firstRun = true lastSync = 0 splitTime = { } --[[ Display "HELO" and delay to ready HTTP API ]]-- print("System sync prep...") rs.setBundledOutput(hourSide, wordHE) rs.setBundledOutput(minSide, wordLO) sleep(10.0) --[[ Loop runs once every 60 secs, time updates once every hour ]]-- while true do --[[ Sync time every 60min/first run ]]-- if firstRun or lastSync >= 60 then rs.setBundledOutput(hourSide, wordSY) rs.setBundledOutput(minSide, wordNC) sleep(10.0) httpPullCheck(timeUrl,"time") if fs.exists( "time" ) then h = fs.open("time","r") newTime = h.readLine() h:close() lastSync = 0 firstRun = false end end --[[ Check that newTime exists, else print 00:00 ]]-- print(newTime) if lastSync == 0 and newTime then splitTime = split(newTime, splitOn) splitTime[1] = tonumber(splitTime[1]) splitTime[2] = tonumber(splitTime[2]) -1 elseif not newTime then splitTime[1] = 0 splitTime[2] = -1 end --[[ Increase minute by 1 ]]-- splitTime[2] = splitTime[2] + 1 --[ Increase hour if needed ]-- if splitTime[2] >= 60 then splitTime[2] = 0 if splitTime[1] == 23 then splitTime[1] = 0 else splitTime[1] = splitTime[1] + 1 end end --[[ Print time check and run digit set functions ]]-- print("Updating time to: "..splitTime[1]..":"..splitTime[2]) --Begin set hour setDoubleDigits(hourSide, splitTime[1]) --Begin set minute setDoubleDigits(minSide, splitTime[2]) print("Time set, last sync "..lastSync.."min ago.") --[[ Sleep for 1min before running again ]]-- os.sleep(60.0) lastSync = lastSync + 1 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
FED RESPONSE TEMPLATES: FED HTML Review Feedb...
8 hours ago | 0.79 KB
disable email per category (not fully tested)
11 hours ago | 0.82 KB
Neuromancer — The Construct Cut (Complete Una...
17 hours ago | 3.30 KB
GLUC6
17 hours ago | 1.56 KB
Mapscan v1.0 - Archeagus Grey Hack Series, Ep...
JavaScript | 22 hours ago | 3.33 KB
Untitled
23 hours ago | 17.15 KB
gpt2
Go | 1 day ago | 2.79 KB
gpt
GetText | 1 day ago | 1.07 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!