-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mc-1.15.x' into mc-1.16.x
- Loading branch information
Showing
71 changed files
with
4,054 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
module: [kind=event] alarm | ||
see: os.setAlarm To start an alarm. | ||
--- | ||
|
||
The @{timer} event is fired when an alarm started with @{os.setAlarm} completes. | ||
|
||
## Return Values | ||
1. @{string}: The event name. | ||
2. @{number}: The ID of the alarm that finished. | ||
|
||
## Example | ||
Starts a timer and then prints its ID: | ||
```lua | ||
local alarmID = os.setAlarm(os.time() + 0.05) | ||
local event, id | ||
repeat | ||
event, id = os.pullEvent("alarm") | ||
until id == alarmID | ||
print("Alarm with ID " .. id .. " was fired") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
module: [kind=event] computer_command | ||
--- | ||
|
||
The @{computer_command} event is fired when the `/computercraft queue` command is run for the current computer. | ||
|
||
## Return Values | ||
1. @{string}: The event name. | ||
... @{string}: The arguments passed to the command. | ||
|
||
## Example | ||
Prints the contents of messages sent: | ||
```lua | ||
while true do | ||
local event = {os.pullEvent("computer_command")} | ||
print("Received message:", table.unpack(event, 2)) | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
module: [kind=event] disk | ||
see: disk_eject For the event sent when a disk is removed. | ||
--- | ||
|
||
The @{disk} event is fired when a disk is inserted into an adjacent or networked disk drive. | ||
|
||
## Return Values | ||
1. @{string}: The event name. | ||
2. @{string}: The side of the disk drive that had a disk inserted. | ||
|
||
## Example | ||
Prints a message when a disk is inserted: | ||
```lua | ||
while true do | ||
local event, side = os.pullEvent("disk") | ||
print("Inserted a disk on side " .. side) | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
module: [kind=event] disk_eject | ||
see: disk For the event sent when a disk is inserted. | ||
--- | ||
|
||
The @{disk_eject} event is fired when a disk is removed from an adjacent or networked disk drive. | ||
|
||
## Return Values | ||
1. @{string}: The event name. | ||
2. @{string}: The side of the disk drive that had a disk removed. | ||
|
||
## Example | ||
Prints a message when a disk is removed: | ||
```lua | ||
while true do | ||
local event, side = os.pullEvent("disk_eject") | ||
print("Removed a disk on side " .. side) | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
module: [kind=event] http_check | ||
see: http.checkURLAsync To check a URL asynchronously. | ||
--- | ||
|
||
The @{http_check} event is fired when a URL check finishes. | ||
|
||
This event is normally handled inside @{http.checkURL}, but it can still be seen when using @{http.checkURLAsync}. | ||
|
||
## Return Values | ||
1. @{string}: The event name. | ||
2. @{string}: The URL requested to be checked. | ||
3. @{boolean}: Whether the check succeeded. | ||
4. @{string|nil}: If the check failed, a reason explaining why the check failed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
module: [kind=event] http_failure | ||
see: http.request To send an HTTP request. | ||
--- | ||
|
||
The @{http_failure} event is fired when an HTTP request fails. | ||
|
||
This event is normally handled inside @{http.get} and @{http.post}, but it can still be seen when using @{http.request}. | ||
|
||
## Return Values | ||
1. @{string}: The event name. | ||
2. @{string}: The URL of the site requested. | ||
3. @{string}: An error describing the failure. | ||
4. @{http.Response|nil}: A response handle if the connection succeeded, but the server's response indicated failure. | ||
|
||
## Example | ||
Prints an error why the website cannot be contacted: | ||
```lua | ||
local myURL = "https://does.not.exist.tweaked.cc" | ||
http.request(myURL) | ||
local event, url, err | ||
repeat | ||
event, url, err = os.pullEvent("http_failure") | ||
until url == myURL | ||
print("The URL " .. url .. " could not be reached: " .. err) | ||
``` | ||
|
||
Prints the contents of a webpage that does not exist: | ||
```lua | ||
local myURL = "https://tweaked.cc/this/does/not/exist" | ||
http.request(myURL) | ||
local event, url, err, handle | ||
repeat | ||
event, url, err, handle = os.pullEvent("http_failure") | ||
until url == myURL | ||
print("The URL " .. url .. " could not be reached: " .. err) | ||
print(handle.getResponseCode()) | ||
handle.close() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
module: [kind=event] http_success | ||
see: http.request To make an HTTP request. | ||
--- | ||
|
||
The @{http_success} event is fired when an HTTP request returns successfully. | ||
|
||
This event is normally handled inside @{http.get} and @{http.post}, but it can still be seen when using @{http.request}. | ||
|
||
## Return Values | ||
1. @{string}: The event name. | ||
2. @{string}: The URL of the site requested. | ||
3. @{http.Response}: The handle for the response text. | ||
|
||
## Example | ||
Prints the content of a website (this may fail if the request fails): | ||
```lua | ||
local myURL = "https://tweaked.cc/" | ||
http.request(myURL) | ||
local event, url, handle | ||
repeat | ||
event, url, handle = os.pullEvent("http_success") | ||
until url == myURL | ||
print("Contents of " .. url .. ":") | ||
print(handle.readAll()) | ||
handle.close() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
module: [kind=event] modem_message | ||
--- | ||
|
||
The @{modem_message} event is fired when a message is received on an open channel on any modem. | ||
|
||
## Return Values | ||
1. @{string}: The event name. | ||
2. @{string}: The side of the modem that received the message. | ||
3. @{number}: The channel that the message was sent on. | ||
4. @{number}: The reply channel set by the sender. | ||
5. @{any}: The message as sent by the sender. | ||
6. @{number}: The distance between the sender and the receiver, in blocks (decimal). | ||
|
||
## Example | ||
Prints a message when one is sent: | ||
```lua | ||
while true do | ||
local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message") | ||
print(("Message received on side %s on channel %d (reply to %d) from %f blocks away with message %s"):format(side, channel, replyChannel, distance, tostring(message))) | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
module: [kind=event] monitor_resize | ||
--- | ||
|
||
The @{monitor_resize} event is fired when an adjacent or networked monitor's size is changed. | ||
|
||
## Return Values | ||
1. @{string}: The event name. | ||
2. @{string}: The side or network ID of the monitor that resized. | ||
|
||
## Example | ||
Prints a message when a monitor is resized: | ||
```lua | ||
while true do | ||
local event, side = os.pullEvent("monitor_resize") | ||
print("The monitor on side " .. side .. " was resized.") | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
module: [kind=event] monitor_touch | ||
--- | ||
|
||
The @{monitor_touch} event is fired when an adjacent or networked Advanced Monitor is right-clicked. | ||
|
||
## Return Values | ||
1. @{string}: The event name. | ||
2. @{string}: The side or network ID of the monitor that was touched. | ||
3. @{number}: The X coordinate of the touch, in characters. | ||
4. @{number}: The Y coordinate of the touch, in characters. | ||
|
||
## Example | ||
Prints a message when a monitor is touched: | ||
```lua | ||
while true do | ||
local event, side, x, y = os.pullEvent("monitor_touch") | ||
print("The monitor on side " .. side .. " was touched at (" .. x .. ", " .. y .. ")") | ||
end | ||
``` |
Oops, something went wrong.