Skip to content

Instantly share code, notes, and snippets.

@CoderPuppy
Created November 18, 2014 14:47
Show Gist options
  • Select an option

  • Save CoderPuppy/d55913f953153d45322f to your computer and use it in GitHub Desktop.

Select an option

Save CoderPuppy/d55913f953153d45322f to your computer and use it in GitHub Desktop.
My main post on computercraft.info/forums2
[size=5][b]Programs[/b][/size]
[spoiler]
[size=5][b]Sitdown[/b][/size]
[spoiler]
Multi file downloader
It can download an entire directory structure from an HTTP server with one command.
[url="http://pastebin.com/3tqG4Vg8"]Pastebin[/url]: pastebin get 3tqG4Vg8 sitdown
Instructions:
[spoiler]
[list=1]
[*]Create files list [spoiler]Sitdown uses a .files file to determine what files it need to download. Each line in it represents a file or directory. If it's a directory the the directory has to have .files file in it. You can generate one by running "sitdown sit test" replacing test with what directory you want to generate the files list for. It will generate a files list in the directory listing all the files in the directory.[/spoiler]
[*]Upload directory to server
[*]Download [spoiler]Run "sitdown down [url="http://example.com"]http://example.com[/url] example". Replace example.com with where the directory is located on the server and example with were to download it to. If you don't specify were to download it to it will attempt to figure it out. Eg: "sitdown down [url="http://coderpuppy.koding.com/sitdown-test"]http://coderpuppy.ko...om/sitdown-test[/url]" would download to "sitdown-test" [/spoiler]
[/list]
[/spoiler]
[/spoiler]
[size=5][b]Chat System[/b][/size]
[spoiler]
Better chat for ComputerCraft, features include colors (using text escapes) and bot support
[b]Server:[/b]
[url="http://pastebin.com/4s5XemYx"]Pastebin[/url]: pastebin get 4s5XemYx chatd
[url="https://gist.github.com/CoderPuppy/10176291"]Gist[/url]: 10176291
[b]Client:[/b]
Requires the chatbot API and my textEscapes API
[url="http://pastebin.com/dgJadwuS"]Pastebin[/url]: pastebin get dgJadwuS chatc
[url="https://gist.github.com/CoderPuppy/10176089"]Gist[/url]: 10176089
[b]Chat Bot API:[/b]
[url="http://pastebin.com/iw3J1Fgg"]Pastebin[/url]: pastebin get iw3J1Fgg chatbot
[url="https://gist.github.com/CoderPuppy/10158696"]Gist[/url]: 10158696
API:
[spoiler]
[list]
[*]createBot(hostname, username) -- Create a bot and connect to a server.
Bot: [spoiler]
[list]
[*]id -- Random identifier, hopefully unique to the bot
[*]handle(ev) -- Handle an event (ev must be in the form { event name, event parameters... })
[*]send(msg) -- Send a message
[*]logout(reason = 'Quit') -- Logout with an optional reason
[/list]
[/spoiler]
Events: [spoiler]
[list]
[*] bot_user_message -- Fired when anyone says anything, params: bot.id, username, msg, userid
[*] bot_user_action -- Fired when anyone uses /me, params: bot.id, username, action, userid
[*] bot_user_nickchange -- Fired when anyone changes their nick, params: bot.id, oldusername, newusername, userid
[*] bot_user_join -- Fired when anyone joins, params: bot.id, username, userid
[*] bot_user_leave -- Fired when anyone says leaves, params: bot.id, username, reason, userid
[*] bot_user_action -- Fired when anyone says anything, params: bot.id, username, action, userid
[*] bot_quit -- Fired when the bot disconnects for any reason, params: bot.id, reason
[/list]
[/spoiler]
[/list]
[/spoiler]
[/spoiler]
[/spoiler]
[size=5][b]APIS[/b][/size]
[spoiler]
[size=5][b]Text Escapes[/b][/size]
[spoiler]
textEscapes lets you print strings with escape codes to, for example, change the text color in the middle of a string.
[url="http://pastebin.com/F7hL1ite"]Pastebin[/url]: pastebin get F7hL1ite textEscapes
[url="https://gist.github.com/CoderPuppy/9906482"]Gist[/url]: 9906482
Examples:
[code]
-- Print "Hello World!" in lime
textEscapes.print(textEscapes.textLime .. "Hello World!" .. textEscapes.textWhite)
-- Print "HI!!!" in grey with a yellow background
textEscapes.print(textEscapes.textGrey .. textEscapes.backYellow .. "HI!!!" .. textEscapes.reset)
[/code]
API:
[spoiler]
[list]
[*]write(text, opts) -- Like normal write except uses' escapes, Options: [spoiler]
[list]
[*]textColor -- Whether text color escapes work
[*]backColor -- Whether background color escapes work
[*]moveCursor -- Whether cursor escapes work
[*]scroll -- Whether scroll escapes work
[*]blink -- Whether blink escapes work
[*]clear -- Whether clear escapes work
[*]clearLine -- Whether clearLine escapes work
[/list]
[/spoiler]
[*]print(text, opts) -- Like normal print except uses' escapes
[*]text[i]`Color`[/i] -- Escape code for changing the text color to [i]`color`[/i]
[*]back[i]`Color`[/i] -- Escape code for changing the background color to [i]`color`[/i]
[*]reset -- Escape code for changing the text color to white and the background color to black
[*]clear -- Escape code for clearing the screen
[*]clearLine -- Escape code for clearing the line (see term.clearLine)
[*]blinkOn -- Escape code for turning blink on
[*]blinkOff -- Escape code for turning blink off
[*]textColor(color) -- Get the escape code for changing the text color to `color`
[*]backColor(color) -- Get the escape code for changing the background color to `color`
[*]moveCursor(x, y) -- Get the escape code for moving the cursor to `x`, `y`
[*]scroll(n) -- Get the escape code for scrolling `n` rows
[*]hexColor(color) -- Get `color` in hexadecimal
[/list]
[/spoiler]
[/spoiler]
[/spoiler]
[size=5]TODO:[/size]
[list]
[*][size=4]Documentation[/size]
[*][size=4]Drop-in single file config function -- Saves the config in the same file[/size]
[/list]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment