mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-29 16:47:56 +00:00
Add documentation for peripherals
No clue how we're going to do this for the dynamic peripheral system if/when that ships, but this is a good first stage. Like the Java APIs, this relies on stub files, so we can't link to the implementation which is a bit of a shame. However, it's a good first step.
This commit is contained in:
27
doc/stub/computer.lua
Normal file
27
doc/stub/computer.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
--- A computer or turtle wrapped as a peripheral.
|
||||
--
|
||||
-- This allows for basic interaction with adjacent computers. Computers wrapped
|
||||
-- as peripherals will have the type `computer` while turtles will be `turtle`.
|
||||
--
|
||||
-- @module[kind=peripheral] computer
|
||||
|
||||
function turnOn() end --- Turn the other computer on.
|
||||
function shutdown() end --- Shutdown the other computer.
|
||||
function reboot() end --- Reboot or turn on the other computer.
|
||||
|
||||
--- Get the other computer's ID.
|
||||
--
|
||||
-- @treturn number The computer's ID.
|
||||
-- @see os.getComputerID To get your computer ID.
|
||||
function getID() end
|
||||
|
||||
--- Determine if the other computer is on.
|
||||
--
|
||||
-- @treturn boolean If the computer is on.
|
||||
function isOn() end
|
||||
|
||||
--- Get the other computer's label.
|
||||
--
|
||||
-- @treturn string|nil The computer's label.
|
||||
-- @see os.getComputerLabel To get your label.
|
||||
function getLabel() end
|
12
doc/stub/drive.lua
Normal file
12
doc/stub/drive.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
--- @module[kind=peripheral] drive
|
||||
|
||||
function isDiskPresent() end
|
||||
function getDiskLabel() end
|
||||
function setDiskLabel(label) end
|
||||
function hasData() end
|
||||
function getMountPath() end
|
||||
function hasAudio() end
|
||||
function getAudioTitle() end
|
||||
function playAudio() end
|
||||
function ejectDisk() end
|
||||
function getDiskID() end
|
73
doc/stub/modem.lua
Normal file
73
doc/stub/modem.lua
Normal file
@@ -0,0 +1,73 @@
|
||||
--- @module[kind=peripheral] modem
|
||||
|
||||
function open(channel) end
|
||||
function isOpen(channel) end
|
||||
function close(channel) end
|
||||
|
||||
--- Close all open channels.
|
||||
function closeAll() end
|
||||
|
||||
function transmit(channel, replyChannel, payload) end
|
||||
|
||||
--- Determine if this is a wired or wireless modem.
|
||||
--
|
||||
-- Some methods (namely those dealing with wired networks and remote
|
||||
-- peripherals) are only available on wired modems.
|
||||
--
|
||||
-- @treturn boolean @{true} if this is a wireless modem.
|
||||
function isWireless() end
|
||||
|
||||
-- Wired modem only
|
||||
|
||||
--- List all remote peripherals on the wired network.
|
||||
--
|
||||
-- If this computer is attached to the network, it _will not_ be included in
|
||||
-- this list.
|
||||
--
|
||||
-- > **Important:** This function only appears on wired modems. Check
|
||||
-- > @{isWireless} returns false before calling it.
|
||||
--
|
||||
-- @treturn { string... } Remote peripheral names on the network.
|
||||
function getNamesRemote(name) end
|
||||
|
||||
--- Determine if a peripheral is available on this wired network.
|
||||
--
|
||||
-- > **Important:** This function only appears on wired modems. Check
|
||||
-- > @{isWireless} returns false before calling it.
|
||||
--
|
||||
-- @tparam string name The peripheral's name.
|
||||
-- @treturn boolean If a peripheral is present with the given name.
|
||||
-- @see peripheral.isPresent
|
||||
function isPresentRemote(name) end
|
||||
|
||||
--- Get the type of a peripheral is available on this wired network.
|
||||
--
|
||||
-- > **Important:** This function only appears on wired modems. Check
|
||||
-- > @{isWireless} returns false before calling it.
|
||||
--
|
||||
-- @tparam string name The peripheral's name.
|
||||
-- @treturn string|nil The peripheral's type, or `nil` if it is not present.
|
||||
-- @see peripheral.getType
|
||||
function getTypeRemote(name) end
|
||||
|
||||
--- Call a method on a peripheral on this wired network.
|
||||
--
|
||||
-- > **Important:** This function only appears on wired modems. Check
|
||||
-- > @{isWireless} returns false before calling it.
|
||||
--
|
||||
-- @tparam string remoteName The name of the peripheral to invoke the method on.
|
||||
-- @tparam string method The name of the method
|
||||
-- @param ... Additional arguments to pass to the method
|
||||
-- @return The return values of the peripheral method.
|
||||
-- @see peripheral.call
|
||||
function callRemote(remoteName, method, ...) end
|
||||
|
||||
--- Returns the network name of the current computer, if the modem is on. This
|
||||
-- may be used by other computers on the network to wrap this computer as a
|
||||
-- peripheral.
|
||||
--
|
||||
-- > **Important:** This function only appears on wired modems. Check
|
||||
-- > @{isWireless} returns false before calling it.
|
||||
--
|
||||
-- @treturn string|nil The current computer's name on the wired network.
|
||||
function getNameLocal() end
|
32
doc/stub/monitor.lua
Normal file
32
doc/stub/monitor.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
--[[- Monitors are a block which act as a terminal, displaying information on
|
||||
one side. This allows them to be read and interacted with in-world without
|
||||
opening a GUI.
|
||||
|
||||
Monitors act as @{term.Redirect|terminal redirects} and so expose the same
|
||||
methods, as well as several additional ones, which are documented below.
|
||||
|
||||
Like computers, monitors come in both normal (no colour) and advanced (colour)
|
||||
varieties.
|
||||
|
||||
@module[kind=peripheral] monitor
|
||||
@usage Write "Hello, world!" to an adjacent monitor:
|
||||
|
||||
local monitor = peripheral.find("monitor")
|
||||
monitor.setCursorPos(1, 1)
|
||||
monitor.write("Hello, world!")
|
||||
]]
|
||||
|
||||
|
||||
--- Set the scale of this monitor. A larger scale will result in the monitor
|
||||
-- having a lower resolution, but display text much larger.
|
||||
--
|
||||
-- @tparam number scale The monitor's scale. This must be a multiple of 0.5
|
||||
-- between 0.5 and 5.
|
||||
-- @throws If the scale is out of range.
|
||||
-- @see getTextScale
|
||||
function setTextScale(scale) end
|
||||
|
||||
--- Get the monitor's current text scale.
|
||||
--
|
||||
-- @treturn number The monitor's current scale.
|
||||
function getTextScale() end
|
11
doc/stub/printer.lua
Normal file
11
doc/stub/printer.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
--- @module[kind=peripheral] printer
|
||||
|
||||
function write(text) end
|
||||
function getCursorPos() end
|
||||
function setCursorPos(x, y) end
|
||||
function getPageSize() end
|
||||
function newPage() end
|
||||
function endPage() end
|
||||
function setPageTitle(title) end
|
||||
function getInkLevel() end
|
||||
function getPaperLevel() end
|
Reference in New Issue
Block a user