From c46ec76c635538b6834b18ae2786aabe93b49b85 Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Sun, 20 Feb 2022 20:28:41 -0500 Subject: [PATCH] meow --- computers/commands/cat/conf.json | 7 +++++++ computers/commands/cat/init.lua | 15 +++++++++++++++ computers/init.lua | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 computers/commands/cat/conf.json create mode 100644 computers/commands/cat/init.lua diff --git a/computers/commands/cat/conf.json b/computers/commands/cat/conf.json new file mode 100644 index 0000000..e05c428 --- /dev/null +++ b/computers/commands/cat/conf.json @@ -0,0 +1,7 @@ +{ + "name": "cat", + "license": "MIT", + "version": 0.1, + "engine": 0.44, + "help": "output file to the terminal" +} \ No newline at end of file diff --git a/computers/commands/cat/init.lua b/computers/commands/cat/init.lua new file mode 100644 index 0000000..8d3d252 --- /dev/null +++ b/computers/commands/cat/init.lua @@ -0,0 +1,15 @@ +function cat(pos, input, data) + local path = computers.devicepath .. "/" .. minetest.hash_node_position(pos) .. data.element.pwd + local files = computers.api.get_dir_keyed_list(path, false) + + if files[input] then + local f = io.open(path .. "/" .. input) + local fdata = f:read("*all") + f:close() + return fdata + else + return "file not found" + end +end + +return cat \ No newline at end of file diff --git a/computers/init.lua b/computers/init.lua index 440e45a..70cd691 100644 --- a/computers/init.lua +++ b/computers/init.lua @@ -8,7 +8,7 @@ minetest.mkdir(computers.devicepath) --make sure it exists minetest.mkdir(computers.networkpath) --make sure it exists computers.os = { - version = 0.43, + version = 0.44, name = "kuto", authors = {"wsor", "luk3yx"}, license = "MIT",