From 4f0d311df745203f69b40efded6977c00409dde9 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Fri, 14 May 2021 18:06:51 +0100 Subject: [PATCH] Add example to turtle.inspect A pretty common but non-trivial API, so worth having something. Even if not perfect. --- .../computercraft/shared/turtle/apis/TurtleAPI.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 78d56ad6c..aeecf1d52 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java +++ b/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java @@ -661,6 +661,18 @@ public final MethodResult equipRight() * @return The turtle command result. * @cc.treturn boolean Whether there is a block in front of the turtle. * @cc.treturn table|string Information about the block in front, or a message explaining that there is no block. + * @cc.usage
{@code
+     * local has_block, data = turtle.inspect()
+     * if has_block then
+     *   print(textutils.serialize(data))
+     *   -- {
+     *   --   name = "minecraft:oak_log",
+     *   --   state = { axis = "x" },
+     *   --   tags = { ["minecraft:logs"] = true, ... },
+     *   -- }
+     * else
+     *   print("No block in front of the turtle")
+     * end}
*/ @LuaFunction public final MethodResult inspect()