mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-12 19:33:00 +00:00
Clean up some examples a little bit
Would be good if they didn't crash and burn on entry :).
This commit is contained in:
@@ -305,3 +305,9 @@ little more detail.
|
|||||||
[1] https://github.com/SquidDev-CC/CC-Tweaked/wiki/Monitor-texture-reference
|
[1] https://github.com/SquidDev-CC/CC-Tweaked/wiki/Monitor-texture-reference
|
||||||
```
|
```
|
||||||
|
|
||||||
|
7f90f2f7cadce0d5b9177b16626979591bce8137
|
||||||
|
```
|
||||||
|
Clean up some examples a little bit
|
||||||
|
|
||||||
|
Would be good if they didn't crash and burn on entry :).
|
||||||
|
```
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ end
|
|||||||
-- @treturn number The combined hexadecimal colour.
|
-- @treturn number The combined hexadecimal colour.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- ```lua
|
-- ```lua
|
||||||
-- colors.rgb(0.7, 0.2, 0.6)
|
-- colors.unpackRGB(0.7, 0.2, 0.6)
|
||||||
-- -- => 0xb23399
|
-- -- => 0xb23399
|
||||||
-- ```
|
-- ```
|
||||||
function packRGB(r, g, b)
|
function packRGB(r, g, b)
|
||||||
@@ -291,7 +291,7 @@ end
|
|||||||
-- @treturn number The blue channel, will be between 0 and 1.
|
-- @treturn number The blue channel, will be between 0 and 1.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- ```lua
|
-- ```lua
|
||||||
-- colors.rgb(0xb23399)
|
-- colors.unpackRGB(0xb23399)
|
||||||
-- -- => 0.7, 0.2, 0.6
|
-- -- => 0.7, 0.2, 0.6
|
||||||
-- ```
|
-- ```
|
||||||
-- @see colors.packRGB
|
-- @see colors.packRGB
|
||||||
@@ -317,12 +317,12 @@ end
|
|||||||
-- @deprecated Use @{packRGB} or @{unpackRGB} directly.
|
-- @deprecated Use @{packRGB} or @{unpackRGB} directly.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- ```lua
|
-- ```lua
|
||||||
-- colors.rgb(0xb23399)
|
-- colors.unpackRGB(0xb23399)
|
||||||
-- -- => 0.7, 0.2, 0.6
|
-- -- => 0.7, 0.2, 0.6
|
||||||
-- ```
|
-- ```
|
||||||
-- @usage
|
-- @usage
|
||||||
-- ```lua
|
-- ```lua
|
||||||
-- colors.rgb(0.7, 0.2, 0.6)
|
-- colors.unpackRGB(0.7, 0.2, 0.6)
|
||||||
-- -- => 0xb23399
|
-- -- => 0xb23399
|
||||||
-- ```
|
-- ```
|
||||||
function rgb8(r, g, b)
|
function rgb8(r, g, b)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ end
|
|||||||
--
|
--
|
||||||
-- @tparam string name The name of the disk drive.
|
-- @tparam string name The name of the disk drive.
|
||||||
-- @treturn boolean If something is in the disk drive.
|
-- @treturn boolean If something is in the disk drive.
|
||||||
-- @usage disk.isPresent(false)
|
-- @usage disk.isPresent("top")
|
||||||
function isPresent(name)
|
function isPresent(name)
|
||||||
if isDrive(name) then
|
if isDrive(name) then
|
||||||
return peripheral.call(name, "isDiskPresent")
|
return peripheral.call(name, "isDiskPresent")
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ end
|
|||||||
-- @tparam string topic The topic to find
|
-- @tparam string topic The topic to find
|
||||||
-- @treturn string|nil The path to the given topic's help file, or `nil` if it
|
-- @treturn string|nil The path to the given topic's help file, or `nil` if it
|
||||||
-- cannot be found.
|
-- cannot be found.
|
||||||
-- @usage print(help.lookup("disk"))
|
-- @usage help.lookup("disk")
|
||||||
function lookup(_sTopic)
|
function lookup(_sTopic)
|
||||||
expect(1, _sTopic, "string")
|
expect(1, _sTopic, "string")
|
||||||
-- Look on the path variable
|
-- Look on the path variable
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ keys.cimcumflex = keys.circumflex --- @local
|
|||||||
--
|
--
|
||||||
-- @tparam number code The key code to look up.
|
-- @tparam number code The key code to look up.
|
||||||
-- @treturn string|nil The name of the key, or `nil` if not a valid key code.
|
-- @treturn string|nil The name of the key, or `nil` if not a valid key code.
|
||||||
|
-- @usage keys.getName(keys.enter)
|
||||||
function getName(_nKey)
|
function getName(_nKey)
|
||||||
expect(1, _nKey, "number")
|
expect(1, _nKey, "number")
|
||||||
return tKeys[_nKey]
|
return tKeys[_nKey]
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ end
|
|||||||
-- filter function, which takes the peripheral's name and wrapped table
|
-- filter function, which takes the peripheral's name and wrapped table
|
||||||
-- and returns if it should be included in the result.
|
-- and returns if it should be included in the result.
|
||||||
-- @treturn table... 0 or more wrapped peripherals matching the given filters.
|
-- @treturn table... 0 or more wrapped peripherals matching the given filters.
|
||||||
-- @usage local monitors = { peripheral.find("monitor") }
|
-- @usage { peripheral.find("monitor") }
|
||||||
-- @usage peripheral.find("modem", rednet.open)
|
-- @usage peripheral.find("modem", rednet.open)
|
||||||
function find(ty, filter)
|
function find(ty, filter)
|
||||||
expect(1, ty, "string")
|
expect(1, ty, "string")
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ local expect, field = expect.expect, expect.field
|
|||||||
--- Slowly writes string text at current cursor position,
|
--- Slowly writes string text at current cursor position,
|
||||||
-- character-by-character.
|
-- character-by-character.
|
||||||
--
|
--
|
||||||
-- Like @{write}, this does not insert a newline at the end.
|
-- Like @{_G.write}, this does not insert a newline at the end.
|
||||||
--
|
--
|
||||||
-- @tparam string sText The the text to write to the screen
|
-- @tparam string sText The the text to write to the screen
|
||||||
-- @tparam[opt] number nRate The number of characters to write each second,
|
-- @tparam[opt] number nRate The number of characters to write each second,
|
||||||
@@ -119,8 +119,8 @@ end
|
|||||||
-- displayed before prompting.
|
-- displayed before prompting.
|
||||||
-- @treturn number The number of lines printed.
|
-- @treturn number The number of lines printed.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- local width, height = term.getSize()
|
-- local width, height = term.getSize()
|
||||||
-- textutils.pagedPrint(("This is a rather verbose dose of repetition.\n"):rep(30), height - 2)
|
-- textutils.pagedPrint(("This is a rather verbose dose of repetition.\n"):rep(30), height - 2)
|
||||||
function pagedPrint(_sText, _nFreeLines)
|
function pagedPrint(_sText, _nFreeLines)
|
||||||
expect(2, _nFreeLines, "number", "nil")
|
expect(2, _nFreeLines, "number", "nil")
|
||||||
-- Setup a redirector
|
-- Setup a redirector
|
||||||
@@ -706,7 +706,7 @@ unserialiseJSON = unserialise_json
|
|||||||
--
|
--
|
||||||
-- @tparam string str The string to encode
|
-- @tparam string str The string to encode
|
||||||
-- @treturn string The encoded string.
|
-- @treturn string The encoded string.
|
||||||
-- @usage print("https://example.com/?view=" .. textutils.urlEncode(read()))
|
-- @usage print("https://example.com/?view=" .. textutils.urlEncode("some text&things"))
|
||||||
function urlEncode(str)
|
function urlEncode(str)
|
||||||
expect(1, str, "string")
|
expect(1, str, "string")
|
||||||
if str then
|
if str then
|
||||||
@@ -744,8 +744,8 @@ local tEmpty = {}
|
|||||||
--
|
--
|
||||||
-- @treturn { string... } The (possibly empty) list of completions.
|
-- @treturn { string... } The (possibly empty) list of completions.
|
||||||
-- @see shell.setCompletionFunction
|
-- @see shell.setCompletionFunction
|
||||||
-- @see read
|
-- @see _G.read
|
||||||
-- @usage textutils.complete( "pa", getfenv() )
|
-- @usage textutils.complete( "pa", _ENV )
|
||||||
function complete(sSearchText, tSearchTable)
|
function complete(sSearchText, tSearchTable)
|
||||||
expect(1, sSearchText, "string")
|
expect(1, sSearchText, "string")
|
||||||
expect(2, tSearchTable, "table", "nil")
|
expect(2, tSearchTable, "table", "nil")
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
--- A collection of helper methods for working with input completion, such
|
--- A collection of helper methods for working with input completion, such
|
||||||
-- as that require by @{read}.
|
-- as that require by @{_G.read}.
|
||||||
--
|
--
|
||||||
-- @module cc.completion
|
-- @module cc.completion
|
||||||
-- @see cc.shell.completion For additional helpers to use with
|
-- @see cc.shell.completion For additional helpers to use with
|
||||||
@@ -29,7 +29,7 @@ end
|
|||||||
-- @tparam { string... } choices The list of choices to complete from.
|
-- @tparam { string... } choices The list of choices to complete from.
|
||||||
-- @tparam[opt] boolean add_space Whether to add a space after the completed item.
|
-- @tparam[opt] boolean add_space Whether to add a space after the completed item.
|
||||||
-- @treturn { string... } A list of suffixes of matching strings.
|
-- @treturn { string... } A list of suffixes of matching strings.
|
||||||
-- @usage Call @{read}, completing the names of various animals.
|
-- @usage Call @{_G.read}, completing the names of various animals.
|
||||||
--
|
--
|
||||||
-- local animals = { "dog", "cat", "lion", "unicorn" }
|
-- local animals = { "dog", "cat", "lion", "unicorn" }
|
||||||
-- read(nil, nil, function(text) return choice(text, animals) end)
|
-- read(nil, nil, function(text) return choice(text, animals) end)
|
||||||
|
|||||||
@@ -13,11 +13,11 @@
|
|||||||
-- @module cc.pretty
|
-- @module cc.pretty
|
||||||
-- @usage Print a table to the terminal
|
-- @usage Print a table to the terminal
|
||||||
-- local pretty = require "cc.pretty"
|
-- local pretty = require "cc.pretty"
|
||||||
-- pretty.write(pretty.pretty({ 1, 2, 3 }))
|
-- pretty.print(pretty.pretty({ 1, 2, 3 }))
|
||||||
--
|
--
|
||||||
-- @usage Build a custom document and display it
|
-- @usage Build a custom document and display it
|
||||||
-- local pretty = require "cc.pretty"
|
-- local pretty = require "cc.pretty"
|
||||||
-- pretty.write(pretty.group(pretty.text("hello") .. pretty.space_line .. pretty.text("world")))
|
-- pretty.print(pretty.group(pretty.text("hello") .. pretty.space_line .. pretty.text("world")))
|
||||||
|
|
||||||
local expect = require "cc.expect"
|
local expect = require "cc.expect"
|
||||||
local expect, field = expect.expect, expect.field
|
local expect, field = expect.expect, expect.field
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
-- wrap them using @{build}, or your own custom function.
|
-- wrap them using @{build}, or your own custom function.
|
||||||
--
|
--
|
||||||
-- @module cc.shell.completion
|
-- @module cc.shell.completion
|
||||||
-- @see cc.completion For more general helpers, suitable for use with @{read}.
|
-- @see cc.completion For more general helpers, suitable for use with @{_G.read}.
|
||||||
-- @see shell.setCompletionFunction
|
-- @see shell.setCompletionFunction
|
||||||
|
|
||||||
local expect = require "cc.expect".expect
|
local expect = require "cc.expect".expect
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ end
|
|||||||
--
|
--
|
||||||
-- @tparam string sLine The input to complete.
|
-- @tparam string sLine The input to complete.
|
||||||
-- @treturn { string }|nil The list of possible completions.
|
-- @treturn { string }|nil The list of possible completions.
|
||||||
-- @see read For more information about completion.
|
-- @see _G.read For more information about completion.
|
||||||
-- @see shell.completeProgram
|
-- @see shell.completeProgram
|
||||||
-- @see shell.setCompletionFunction
|
-- @see shell.setCompletionFunction
|
||||||
-- @see shell.getCompletionInfo
|
-- @see shell.getCompletionInfo
|
||||||
@@ -461,7 +461,7 @@ end
|
|||||||
-- The completion function.
|
-- The completion function.
|
||||||
-- @see cc.shell.completion Various utilities to help with writing completion functions.
|
-- @see cc.shell.completion Various utilities to help with writing completion functions.
|
||||||
-- @see shell.complete
|
-- @see shell.complete
|
||||||
-- @see read For more information about completion.
|
-- @see _G.read For more information about completion.
|
||||||
function shell.setCompletionFunction(program, complete)
|
function shell.setCompletionFunction(program, complete)
|
||||||
expect(1, program, "string")
|
expect(1, program, "string")
|
||||||
expect(2, complete, "function")
|
expect(2, complete, "function")
|
||||||
|
|||||||
Reference in New Issue
Block a user