From 0a5690bf94b67274f3c5dfeb38759937541c2813 Mon Sep 17 00:00:00 2001 From: Zachary Vance Date: Tue, 16 Jun 2015 03:25:52 -0700 Subject: [PATCH] Update computercraft --- cheatsheet.css | 13 ++- computercraft_reference.html | 156 ++++++++++++++++++++++++++++++++++- 2 files changed, 161 insertions(+), 8 deletions(-) diff --git a/cheatsheet.css b/cheatsheet.css index f8d0509..784efcd 100644 --- a/cheatsheet.css +++ b/cheatsheet.css @@ -1,12 +1,9 @@ -div#layout { +.cheatsheet { column-width: 400px; -webkit-column-width: 400px; -moz-column-width: 400px; } -body { -} - section { display: inline-block; vertical-align: top; @@ -37,6 +34,10 @@ section > div { .note:before { content: "("; } .note:after { content: ")"; } +.cheatsheet .boring { + display: none; +} + .shortcut { background: lightgrey; display: inline-block; @@ -46,6 +47,10 @@ section > div { padding: 2px; } +.event-name { + font-weight: bold; +} + .returns { display: block; margin-left: 10px; diff --git a/computercraft_reference.html b/computercraft_reference.html index 321f399..897c998 100644 --- a/computercraft_reference.html +++ b/computercraft_reference.html @@ -3,14 +3,13 @@ - -
+
Shortcuts
Ctrl-S Shutdown computer
Ctrl-R Reboot computer
Ctrl-T Terminate running program
-
startup -> disk, then
+
Boot sequence: disk/startup, startup
Turtle Api @@ -34,6 +33,52 @@
getFuelLevel() / getFuelLimit()
transferTo(slot, [quantity])
+
+ Coroutine Api +
create(function)
+
resume(resume)
+
running()
+
status(coroutine)One of: running, suspended, normal, dead
+
wrap(coroutine)
+
yield(...)
+
+
+ Defaults +
Fuel limit (moves): 20,000 normal / 100,000 advanced
+
Modem distance, wired (blocks): 256 +
Modem distance, wireless (blocks): 64+ (16+ in thunderstorm)
+
Resolution (chars): 51x19 chars computer / 7x5 monitor
+
+
+ Disk Api +
isPresent(side) / hasData(side) / hasAudio(side)
+
setLabel(side, label) / getLabel(side) / getID(side)
+
getAudioTitle(side)
+
playAudio(side) / stopAudio(side)
+
eject(side)
+
+
+ File handles +
close()
+
readLine() / readAll()"r"
+
write / writeLine(data)"w" or "a"
+
flush() "w" or "a"
+
read() / write(byte)"rb" or "wb"
+
+
+ Fs Api +
open(path, mode)
+
+
+ Gps Api +
locate(timeout)
+
+
+ Help Api +
topics()
+
lookup(topic)
+
path() / setPath(path)
+
Http Api
get(url, [headers]) sync
@@ -41,13 +86,67 @@
request(url, [postData, [headers]) http_success or http_failure event sent later via os
+
+ Multishell Api +
getCurrent()
+
setTitle(tabID, title) / getTitle(tabID)
+
Os Api +
version()
+
computerID() / computerLabel() / setComputerLabel(label)
clock()
time() / day()
sleep(seconds)
setAlarm(time) / cancelAlarm(alarm)
setTimer(seconds) / cancelTime(timer)
+
pullEvent([target-event])
+
queueEvent(event, params...)
+
+
+ Native Os Events +
key: keycode
+
char: letter
+
timer / alarm: id
+
redstone Any redstone input changed
+
disk / disk_detach: side
+
rednet_message: senderID, message, protocol
+
modem_message: side, frequency, replyFrequency, message, distanceTravelled
+
peripheral / peripheral_detach: side
+
mouse_click: button, x, y
+
mouse_scroll: direction, x, y
+
mouse_drag: button, x, y
+
monitor_touch: side, x, y Right click on an advanced monitor
+
"term_resize"
+
"terminate"os.pullEventRaw only
+
turtle_inventory Inventory changes
+
+
+ Parallel Api +
+
+ Peripheral Api +
getType(side)
+
getMethods(side)
+
wrap(side) peripheral table
+ A wired modem can connect peripherals indirectly + +
+ Printer Peripheral +
newPage() / endPage()
+
write(text)
+
getPageSize() / getCursorPos() / setCursorPos(x, y)
+
getPaperLevel() / getInkLevel()
+
setPageTitle()
+
+
+ Rednet Api +
open / close / isOpen(side) for networking
+
send(receiverId, message, [protocol])
+
broadcast(message, [protocol])
+
receive([protocolFilter], [timeout])
+
host / unhost(protocol, hostname)
+
lookup(protocol, [hostname])
Redstone @@ -56,6 +155,56 @@
setOutput(side) / getOutput(side)
getAnalogInput(side) / setAnalogOutput(side)
+
+ Shell Api +
exit()
+
dir() / setDir(path)
+
path() / setPath(path)
+
resolve(localPath) / resolveProgram(name)
+
aliases() / setAlias(alias, program) / clearAlias(alias)
+
programs([showHidden])
+
getRunningProgram()
+
run(command, args...)
+
openTab(command, args...)
+
switchTab(tabID)
+
+
+ Term Api +
write(text)
+
clear() / clearLine()
+
getCursorPos() / setCursorPos(x, y)
+
setCursorBlink(shouldBlink)
+
isColor()
+
getSize()
+
scroll(n
+
redirect(target)
+
current() / native()
+
setTextColor(color) / setBackgroundColor(color)
+
setTextScale(scale) monitor only
+
window.setVisible(visible)
+
window.restoreCursor()
+
window.getPosition() (x,y) of top-left
+
window.reposition(x, y, [width, height])
+
+
+ Textutils Api +
formatTime(time, [twentyFourHour])
+
serialize(data) / unserialize(serializedData)
+
serializeJSON(data)
+
urlEncode(urlUnsafeString)
+
+
+ Vector Api +
new(x, y, z) +
v1:dot(v2) / v1:cross(v2)
+
v1:normalize() / v1:length()
+
v1:round()
+
v1:tostring()
+
+
+ Window Api +
create(parentTerm, x, y, width, height, [visible])
+
Lua Reference
if condition then block else block end
@@ -69,6 +218,5 @@
table.__index / table.__newindex
Example values: nil, True, False, {}, 3, "yes", {"yes", 3}, {a="a", b=3}
- -- 2.47.3