From 319b7dd484f548dd4e5f25f9d827280c1470e9f2 Mon Sep 17 00:00:00 2001 From: Emojigit <55009343+Emojigit@users.noreply.github.com> Date: Mon, 3 May 2021 13:02:39 +0800 Subject: [PATCH] import steps: rename items --- builtin.luaR | 143 +++++++++++++++++++++++++++++++++++++ builtin.luaRr | 143 +++++++++++++++++++++++++++++++++++++ builtin.luar | 143 +++++++++++++++++++++++++++++++++++++ depends.txtR | 1 + depends.txtRr | 1 + depends.txtr | 1 + description.txtR | 3 + description.txtRr | 3 + description.txtr | 3 + doc/computers/api.md | 2 +- modules/computers/api.lua | 16 ++--- modules/computers/gui.lua | 2 +- modules/computers/init.lua | 4 +- 13 files changed, 453 insertions(+), 12 deletions(-) create mode 100644 builtin.luaR create mode 100644 builtin.luaRr create mode 100644 builtin.luar create mode 100755 depends.txtR create mode 100755 depends.txtRr create mode 100755 depends.txtr create mode 100644 description.txtR create mode 100644 description.txtRr create mode 100644 description.txtr diff --git a/builtin.luaR b/builtin.luaR new file mode 100644 index 0000000..4e7551b --- /dev/null +++ b/builtin.luaR @@ -0,0 +1,143 @@ +-- digicompute/builtin.lua + +digicompute.builtin = {} +local builtin = digicompute.builtin + +-- [function] check if file exists +function builtin.exists(path) + if io.open(path, "r") then return true end +end + +-- [function] list contents +function builtin.list(path) + local files = minetest.get_dir_list(path, false) + local subdirs = minetest.get_dir_list(path, true) + + local retval = { + files = files, + subdirs = subdirs, + } + + if not files and not subdirs then + retval = nil + end + + return retval +end + +-- [function] create file +function builtin.create(path) + local f = io.open(path, "w") -- create file + f:close() -- close file + return true +end + +-- [function] write to file +function builtin.write(path, data, mode) + if mode ~= "w" and mode ~= "a" then + mode = "w" + end + local f = io.open(path, mode) -- open file for writing + f:write(data) -- write data + f:close() -- close file + return true +end + +-- [function] read file +function builtin.read(path) + local f = io.open(path, "r") -- open file for reading + if f then + local data = f:read("*all") -- read and store all data + f:close() -- Close file + return data -- return file contents + end +end + +-- [function] copy file +function builtin.copy(original, new) + original = builtin.read(original) -- read + if original then + builtin.write(new, original) -- write + return true + end +end + +-- [function] create directory +function builtin.mkdir(path) + if not io.open(path) then + if minetest.mkdir then + minetest.mkdir(path) -- create directory if minetest.mkdir is available + elseif os.execute then + os.execute('mkdir "'..path..'"') -- create directory with os mkdir command + else + return false + end + return true + end +end + +-- [function] remove directory +function builtin.rmdir(path) + if builtin.list(path) then + -- [local function] remove files + local function rm_files(ppath, files) + for _, f in ipairs(files) do + os.remove(ppath.."/"..f) + end + end + + -- [local function] check and rm dir + local function rm_dir(dpath) + local files = minetest.get_dir_list(dpath, false) + local subdirs = minetest.get_dir_list(dpath, true) + rm_files(dpath, files) + if subdirs then + for _, d in ipairs(subdirs) do + rm_dir(dpath.."/"..d) + end + end + + local ok = os.remove(dpath) -- TODO: TEST + if not ok then + if os.execute then + os.execute("rmdir "..dpath) + end + end + end + + local len = path:len() + + if path:sub(len, len) == "/" then + path = path:sub(1, -2) + end + + rm_dir(path) + return true + end +end + +-- [function] copy directory +function builtin.cpdir(original, new) + if builtin.list(original) then + -- [local function] copy files + local function copy_files(opath, npath, files) + for _, f in ipairs(files) do + builtin.copy(opath.."/"..f, npath.."/"..f) + end + end + + -- [local function] check and copy dir + local function copy_dir(opath, npath) + builtin.mkdir(npath) + local files = minetest.get_dir_list(opath, false) + local subdirs = minetest.get_dir_list(opath, true) + copy_files(opath, npath, files) + for _, d in ipairs(subdirs) do + copy_dir(opath.."/"..d, npath.."/"..d) + end + end + + copy_dir(original, new) + return true + end +end diff --git a/builtin.luaRr b/builtin.luaRr new file mode 100644 index 0000000..4e7551b --- /dev/null +++ b/builtin.luaRr @@ -0,0 +1,143 @@ +-- digicompute/builtin.lua + +digicompute.builtin = {} +local builtin = digicompute.builtin + +-- [function] check if file exists +function builtin.exists(path) + if io.open(path, "r") then return true end +end + +-- [function] list contents +function builtin.list(path) + local files = minetest.get_dir_list(path, false) + local subdirs = minetest.get_dir_list(path, true) + + local retval = { + files = files, + subdirs = subdirs, + } + + if not files and not subdirs then + retval = nil + end + + return retval +end + +-- [function] create file +function builtin.create(path) + local f = io.open(path, "w") -- create file + f:close() -- close file + return true +end + +-- [function] write to file +function builtin.write(path, data, mode) + if mode ~= "w" and mode ~= "a" then + mode = "w" + end + local f = io.open(path, mode) -- open file for writing + f:write(data) -- write data + f:close() -- close file + return true +end + +-- [function] read file +function builtin.read(path) + local f = io.open(path, "r") -- open file for reading + if f then + local data = f:read("*all") -- read and store all data + f:close() -- Close file + return data -- return file contents + end +end + +-- [function] copy file +function builtin.copy(original, new) + original = builtin.read(original) -- read + if original then + builtin.write(new, original) -- write + return true + end +end + +-- [function] create directory +function builtin.mkdir(path) + if not io.open(path) then + if minetest.mkdir then + minetest.mkdir(path) -- create directory if minetest.mkdir is available + elseif os.execute then + os.execute('mkdir "'..path..'"') -- create directory with os mkdir command + else + return false + end + return true + end +end + +-- [function] remove directory +function builtin.rmdir(path) + if builtin.list(path) then + -- [local function] remove files + local function rm_files(ppath, files) + for _, f in ipairs(files) do + os.remove(ppath.."/"..f) + end + end + + -- [local function] check and rm dir + local function rm_dir(dpath) + local files = minetest.get_dir_list(dpath, false) + local subdirs = minetest.get_dir_list(dpath, true) + rm_files(dpath, files) + if subdirs then + for _, d in ipairs(subdirs) do + rm_dir(dpath.."/"..d) + end + end + + local ok = os.remove(dpath) -- TODO: TEST + if not ok then + if os.execute then + os.execute("rmdir "..dpath) + end + end + end + + local len = path:len() + + if path:sub(len, len) == "/" then + path = path:sub(1, -2) + end + + rm_dir(path) + return true + end +end + +-- [function] copy directory +function builtin.cpdir(original, new) + if builtin.list(original) then + -- [local function] copy files + local function copy_files(opath, npath, files) + for _, f in ipairs(files) do + builtin.copy(opath.."/"..f, npath.."/"..f) + end + end + + -- [local function] check and copy dir + local function copy_dir(opath, npath) + builtin.mkdir(npath) + local files = minetest.get_dir_list(opath, false) + local subdirs = minetest.get_dir_list(opath, true) + copy_files(opath, npath, files) + for _, d in ipairs(subdirs) do + copy_dir(opath.."/"..d, npath.."/"..d) + end + end + + copy_dir(original, new) + return true + end +end diff --git a/builtin.luar b/builtin.luar new file mode 100644 index 0000000..4e7551b --- /dev/null +++ b/builtin.luar @@ -0,0 +1,143 @@ +-- digicompute/builtin.lua + +digicompute.builtin = {} +local builtin = digicompute.builtin + +-- [function] check if file exists +function builtin.exists(path) + if io.open(path, "r") then return true end +end + +-- [function] list contents +function builtin.list(path) + local files = minetest.get_dir_list(path, false) + local subdirs = minetest.get_dir_list(path, true) + + local retval = { + files = files, + subdirs = subdirs, + } + + if not files and not subdirs then + retval = nil + end + + return retval +end + +-- [function] create file +function builtin.create(path) + local f = io.open(path, "w") -- create file + f:close() -- close file + return true +end + +-- [function] write to file +function builtin.write(path, data, mode) + if mode ~= "w" and mode ~= "a" then + mode = "w" + end + local f = io.open(path, mode) -- open file for writing + f:write(data) -- write data + f:close() -- close file + return true +end + +-- [function] read file +function builtin.read(path) + local f = io.open(path, "r") -- open file for reading + if f then + local data = f:read("*all") -- read and store all data + f:close() -- Close file + return data -- return file contents + end +end + +-- [function] copy file +function builtin.copy(original, new) + original = builtin.read(original) -- read + if original then + builtin.write(new, original) -- write + return true + end +end + +-- [function] create directory +function builtin.mkdir(path) + if not io.open(path) then + if minetest.mkdir then + minetest.mkdir(path) -- create directory if minetest.mkdir is available + elseif os.execute then + os.execute('mkdir "'..path..'"') -- create directory with os mkdir command + else + return false + end + return true + end +end + +-- [function] remove directory +function builtin.rmdir(path) + if builtin.list(path) then + -- [local function] remove files + local function rm_files(ppath, files) + for _, f in ipairs(files) do + os.remove(ppath.."/"..f) + end + end + + -- [local function] check and rm dir + local function rm_dir(dpath) + local files = minetest.get_dir_list(dpath, false) + local subdirs = minetest.get_dir_list(dpath, true) + rm_files(dpath, files) + if subdirs then + for _, d in ipairs(subdirs) do + rm_dir(dpath.."/"..d) + end + end + + local ok = os.remove(dpath) -- TODO: TEST + if not ok then + if os.execute then + os.execute("rmdir "..dpath) + end + end + end + + local len = path:len() + + if path:sub(len, len) == "/" then + path = path:sub(1, -2) + end + + rm_dir(path) + return true + end +end + +-- [function] copy directory +function builtin.cpdir(original, new) + if builtin.list(original) then + -- [local function] copy files + local function copy_files(opath, npath, files) + for _, f in ipairs(files) do + builtin.copy(opath.."/"..f, npath.."/"..f) + end + end + + -- [local function] check and copy dir + local function copy_dir(opath, npath) + builtin.mkdir(npath) + local files = minetest.get_dir_list(opath, false) + local subdirs = minetest.get_dir_list(opath, true) + copy_files(opath, npath, files) + for _, d in ipairs(subdirs) do + copy_dir(opath.."/"..d, npath.."/"..d) + end + end + + copy_dir(original, new) + return true + end +end diff --git a/depends.txtR b/depends.txtR new file mode 100755 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txtR @@ -0,0 +1 @@ +default diff --git a/depends.txtRr b/depends.txtRr new file mode 100755 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txtRr @@ -0,0 +1 @@ +default diff --git a/depends.txtr b/depends.txtr new file mode 100755 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txtr @@ -0,0 +1 @@ +default diff --git a/description.txtR b/description.txtR new file mode 100644 index 0000000..008f7b4 --- /dev/null +++ b/description.txtR @@ -0,0 +1,3 @@ +This, is the first mod ever to attempt to provide fully functional computer and networking devices to the Minetest players. +Originally inspired by digiterm, the mod has begun to take an entirely new direction. Computers are completely stand +alone. They require no other mods to function, and can run alone or as a group. diff --git a/description.txtRr b/description.txtRr new file mode 100644 index 0000000..008f7b4 --- /dev/null +++ b/description.txtRr @@ -0,0 +1,3 @@ +This, is the first mod ever to attempt to provide fully functional computer and networking devices to the Minetest players. +Originally inspired by digiterm, the mod has begun to take an entirely new direction. Computers are completely stand +alone. They require no other mods to function, and can run alone or as a group. diff --git a/description.txtr b/description.txtr new file mode 100644 index 0000000..008f7b4 --- /dev/null +++ b/description.txtr @@ -0,0 +1,3 @@ +This, is the first mod ever to attempt to provide fully functional computer and networking devices to the Minetest players. +Originally inspired by digiterm, the mod has begun to take an entirely new direction. Computers are completely stand +alone. They require no other mods to function, and can run alone or as a group. diff --git a/doc/computers/api.md b/doc/computers/api.md index fb84703..e25e8d3 100644 --- a/doc/computers/api.md +++ b/doc/computers/api.md @@ -15,7 +15,7 @@ digicompute.register_computer("", { }) ``` -The definition is formed just like that of a normal node definition, except digicompute uses it to do a lot of groundwork rather than requiring you to do it manually. **Note:** do not put a modname in the computer string, `digicompute:` is automatically inserted. +The definition is formed just like that of a normal node definition, except digicompute uses it to do a lot of groundwork rather than requiring you to do it manually. **Note:** do not put a modname in the computer string, `digicompute_redo:` is automatically inserted. **Example:** ```lua diff --git a/modules/computers/api.lua b/modules/computers/api.lua index c41868a..b1149f2 100644 --- a/modules/computers/api.lua +++ b/modules/computers/api.lua @@ -25,7 +25,7 @@ local check_booting = coroutine.create(function() local temp = get_node(c.pos) local ddef = minetest.registered_nodes[temp.name].digicompute if ddef.state == "off" or ddef.state == "bios" then - local name, param2 = "digicompute:"..ddef.base, temp.param2 + local name, param2 = "digicompute_redo:"..ddef.base, temp.param2 digicompute.c:complete_boot(c.pos, id, name, param2) else c.booting = nil @@ -158,7 +158,7 @@ end -- [function] turn computer off function digicompute.c:off(pos, player) local temp = minetest.get_node(pos) -- Get basic node information - local offname = "digicompute:"..minetest.registered_nodes[temp.name].digicompute.base + local offname = "digicompute_redo:"..minetest.registered_nodes[temp.name].digicompute.base local meta = minetest.get_meta(pos) -- Swap node to off minetest.swap_node({x = pos.x, y = pos.y, z = pos.z}, {name = offname, param2 = temp.param2}) @@ -190,7 +190,7 @@ end function digicompute.register_computer(itemstring, def) -- off - minetest.register_node("digicompute:"..itemstring, { + minetest.register_node("digicompute_redo:"..itemstring, { digicompute = { state = "off", base = itemstring, @@ -201,7 +201,7 @@ function digicompute.register_computer(itemstring, def) paramtype = "light", paramtype2 = "facedir", groups = {cracky = 2}, - drop = "digicompute:"..itemstring, + drop = "digicompute_redo:"..itemstring, sounds = default.node_sound_stone_defaults(), node_box = def.node_box, after_place_node = function(pos, player) @@ -230,7 +230,7 @@ function digicompute.register_computer(itemstring, def) end, }) -- bios - minetest.register_node("digicompute:"..itemstring.."_bios", { + minetest.register_node("digicompute_redo:"..itemstring.."_bios", { light_source = def.light_source or 7, digicompute = { state = "bios", @@ -242,7 +242,7 @@ function digicompute.register_computer(itemstring, def) paramtype = "light", paramtype2 = "facedir", groups = {cracky = 2, not_in_creative_inventory = 1}, - drop = "digicompute:"..itemstring, + drop = "digicompute_redo:"..itemstring, sounds = default.node_sound_stone_defaults(), node_box = def.node_box, on_destruct = function(pos) @@ -252,7 +252,7 @@ function digicompute.register_computer(itemstring, def) end, }) -- on - minetest.register_node("digicompute:"..itemstring.."_on", { + minetest.register_node("digicompute_redo:"..itemstring.."_on", { light_source = def.light_source or 7, digicompute = { state = "on", @@ -264,7 +264,7 @@ function digicompute.register_computer(itemstring, def) paramtype = "light", paramtype2 = "facedir", groups = {cracky = 2, not_in_creative_inventory = 1}, - drop = "digicompute:"..itemstring, + drop = "digicompute_redo:"..itemstring, sounds = default.node_sound_stone_defaults(), node_box = def.node_box, on_rightclick = function(pos, node, player) diff --git a/modules/computers/gui.lua b/modules/computers/gui.lua index 435d841..4c1d3c8 100644 --- a/modules/computers/gui.lua +++ b/modules/computers/gui.lua @@ -282,7 +282,7 @@ function digicompute.c:open(pos, player, formname) digicompute.c:set_user(pos, name) computer_contexts[name] = minetest.get_meta(pos):get_string("id") - minetest.show_formspec(name, "digicompute:"..formname, form.get(pos, player)) + minetest.show_formspec(name, "digicompute_redo:"..formname, form.get(pos, player)) return true end else diff --git a/modules/computers/init.lua b/modules/computers/init.lua index 74d4f92..8ca72ad 100644 --- a/modules/computers/init.lua +++ b/modules/computers/init.lua @@ -34,7 +34,7 @@ function digicompute.c:set_user(pos, name) local formname = meta:get_string("formname") -- if formname is defined, close that formspec if formname ~= "" then - minetest.close_formspec(current_user, "digicompute:"..formname) + minetest.close_formspec(current_user, "digicompute_redo:"..formname) end -- Remove from current users current_users[current_user] = nil @@ -56,7 +56,7 @@ function digicompute.c:unset_user(pos, name) local formname = meta:get_string("formname") -- if formname is defined, close that formspec if formname ~= "" then - minetest.close_formspec(name, "digicompute:"..formname) + minetest.close_formspec(name, "digicompute_redo:"..formname) end end end