From 01ddb2b4e436d5931159c25c15eafdfe33f64de1 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Thu, 5 Aug 2021 18:23:13 +0000 Subject: [PATCH] A couple of documentation improvements - Add some missing to the turtle API docs - Version history for peripheral and redstone. I /think/ this is complete. --- .../java/dan200/computercraft/core/apis/RedstoneAPI.java | 4 ++++ .../dan200/computercraft/shared/turtle/apis/TurtleAPI.java | 4 ++-- .../data/computercraft/lua/rom/apis/peripheral.lua | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/dan200/computercraft/core/apis/RedstoneAPI.java b/src/main/java/dan200/computercraft/core/apis/RedstoneAPI.java index 186199302..8437916bf 100644 --- a/src/main/java/dan200/computercraft/core/apis/RedstoneAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/RedstoneAPI.java @@ -72,6 +72,7 @@ public class RedstoneAPI implements ILuaAPI * "back". * * @return A table of valid sides. + * @cc.since 1.2 */ @LuaFunction public final String[] getSides() @@ -122,6 +123,7 @@ public class RedstoneAPI implements ILuaAPI * @param side The side to set. * @param value The signal strength between 0 and 15. * @throws LuaException If {@code value} is not betwene 0 and 15. + * @cc.since 1.51 */ @LuaFunction( { "setAnalogOutput", "setAnalogueOutput" } ) public final void setAnalogOutput( ComputerSide side, int value ) throws LuaException @@ -136,6 +138,7 @@ public class RedstoneAPI implements ILuaAPI * @param side The side to get. * @return The output signal strength, between 0 and 15. * @see #setAnalogOutput + * @cc.since 1.51 */ @LuaFunction( { "getAnalogOutput", "getAnalogueOutput" } ) public final int getAnalogOutput( ComputerSide side ) @@ -148,6 +151,7 @@ public class RedstoneAPI implements ILuaAPI * * @param side The side to get. * @return The input signal strength, between 0 and 15. + * @cc.since 1.51 */ @LuaFunction( { "getAnalogInput", "getAnalogueInput" } ) public final int getAnalogInput( ComputerSide side ) diff --git a/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java b/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java index be0415416..9b58d6322 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java +++ b/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java @@ -515,8 +515,8 @@ public class TurtleAPI implements ILuaAPI /** * Refuel this turtle. * - * While most actions a turtle can perform (such as digging or placing blocks), moving consumes fuel from the - * turtle's internal buffer. If a turtle has no fuel, it will not move. + * While most actions a turtle can perform (such as digging or placing blocks) are free, moving consumes fuel from + * the turtle's internal buffer. If a turtle has no fuel, it will not move. * * {@link #refuel} refuels the turtle, consuming fuel items (such as coal or lava buckets) from the currently * selected slot and converting them into energy. This finishes once the turtle is fully refuelled or all items have diff --git a/src/main/resources/data/computercraft/lua/rom/apis/peripheral.lua b/src/main/resources/data/computercraft/lua/rom/apis/peripheral.lua index 75f581a4c..5266678e7 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/peripheral.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/peripheral.lua @@ -11,6 +11,8 @@ -- Peripheral functions are called *methods*, a term borrowed from Java. -- -- @module peripheral +-- @since 1.3 +-- @changed 1.51 Add support for wired modems. local expect = dofile("rom/modules/main/cc/expect.lua").expect @@ -24,6 +26,7 @@ local sides = rs.getSides() -- Modem, then it'll be reported according to its name on the wired network. -- -- @treturn { string... } A list of the names of all attached peripherals. +-- @since 1.51 function getNames() local results = {} for n = 1, #sides do @@ -69,6 +72,7 @@ end -- @tparam string|table peripheral The name of the peripheral to find, or a -- wrapped peripheral instance. -- @treturn string|nil The peripheral's type, or `nil` if it is not present. +-- @changed 1.88.0 Accepts a wrapped peripheral as an argument. function getType(peripheral) expect(1, peripheral, "string", "table") if type(peripheral) == "string" then -- Peripheral name passed @@ -118,6 +122,7 @@ end -- -- @tparam table peripheral The peripheral to get the name of. -- @treturn string The name of the given peripheral. +-- @since 1.88.0 function getName(peripheral) expect(1, peripheral, "table") local mt = getmetatable(peripheral) @@ -209,6 +214,7 @@ and returns if it should be included in the result. @usage This abuses the `filter` argument to call @{rednet.open} on every modem. peripheral.find("modem", rednet.open) +@since 1.6 ]] function find(ty, filter) expect(1, ty, "string")