From 26c7c2871848bdb2d6b15986fdb9cc2fec753ff5 Mon Sep 17 00:00:00 2001 From: octacian Date: Tue, 12 Jul 2016 15:18:06 -0700 Subject: [PATCH] mod rename: digiterm -> digicompute --- api.lua | 66 +++++++++++++++++++++++++++---------------------------- data.lua | 6 ++--- init.lua | 16 +++++++------- nodes.lua | 2 +- os.lua | 20 ++++++++--------- 5 files changed, 55 insertions(+), 55 deletions(-) diff --git a/api.lua b/api.lua index 2f04afb..5e2613a 100644 --- a/api.lua +++ b/api.lua @@ -1,41 +1,41 @@ --- digiterm/api.lua +-- digicompute/api.lua -- SYSTEM FUNCTIONS -- turn on -function digiterm.on(pos, node) - minetest.swap_node({x = pos.x, y = pos.y, z = pos.z}, {name = "digiterm:"..node.."_bios"}) -- set node to bios +function digicompute.on(pos, node) + minetest.swap_node({x = pos.x, y = pos.y, z = pos.z}, {name = "digicompute:"..node.."_bios"}) -- set node to bios minetest.after(3.5, function(pos_) - minetest.swap_node({x = pos_.x, y = pos_.y, z = pos_.z}, {name = "digiterm:"..node.."_on"}) -- set node to on after 5 seconds + minetest.swap_node({x = pos_.x, y = pos_.y, z = pos_.z}, {name = "digicompute:"..node.."_on"}) -- set node to on after 5 seconds end, vector.new(pos)) local meta = minetest.get_meta(pos) -- get meta - meta:set_string("formspec", digiterm.formspec_normal("", "")) + meta:set_string("formspec", digicompute.formspec_normal("", "")) end -- turn off -function digiterm.off(pos, node) - minetest.swap_node({x = pos.x, y = pos.y, z = pos.z}, {name = "digiterm:"..node}) -- set node to off +function digicompute.off(pos, node) + minetest.swap_node({x = pos.x, y = pos.y, z = pos.z}, {name = "digicompute:"..node}) -- set node to off local meta = minetest.get_meta(pos) -- get meta meta:set_string("formspec", nil) -- clear formspec end -- reboot -function digiterm.reboot(pos, node) - digiterm.off(pos, node) - digiterm.on(pos, node) +function digicompute.reboot(pos, node) + digicompute.off(pos, node) + digicompute.on(pos, node) end -- clear -function digiterm.clear(field, pos) +function digicompute.clear(field, pos) local meta = minetest.get_meta(pos) -- get meta meta:set_string(field, "") -- clear value end -- /SYSTEM FUNCTIONS -function digiterm.register_terminal(termstring, desc) +function digicompute.register_terminal(termstring, desc) -- check os if not desc.os then desc.os = "bios" end - digiterm.os.load(desc.os) -- load os + digicompute.os.load(desc.os) -- load os -- off - minetest.register_node("digiterm:"..termstring, { + minetest.register_node("digicompute:"..termstring, { description = desc.description, tiles = desc.off_tiles, paramtype2 = "facedir", @@ -45,12 +45,12 @@ function digiterm.register_terminal(termstring, desc) receptor = {}, effector = { action = function(pos, node, channel, msg) - if digiterm.os.digiline ~= false then + if digicompute.os.digiline ~= false then local meta = minetest.get_meta(pos) -- get meta -- if channel is correct, turn on if channel == meta:get_string("channel") then - if msg.system == digiterm.os.digiline_on then - digiterm.on(pos, termstring) + if msg.system == digicompute.os.digiline_on then + digicompute.on(pos, termstring) end end end @@ -58,11 +58,11 @@ function digiterm.register_terminal(termstring, desc) }, }, on_rightclick = function(pos) - digiterm.on(pos, termstring) + digicompute.on(pos, termstring) end, }) -- bios - minetest.register_node("digiterm:"..termstring.."_bios", { + minetest.register_node("digicompute:"..termstring.."_bios", { description = desc.description, tiles = desc.bios_tiles, paramtype2 = "facedir", @@ -70,7 +70,7 @@ function digiterm.register_terminal(termstring, desc) sounds = default.node_sound_stone_defaults(), }) -- on - minetest.register_node("digiterm:"..termstring.."_on", { + minetest.register_node("digicompute:"..termstring.."_on", { description = desc.description, tiles = desc.on_tiles, paramtype2 = "facedir", @@ -80,14 +80,14 @@ function digiterm.register_terminal(termstring, desc) receptor = {}, effector = { action = function(pos, node, channel, msg) - if digiterm.os.digiline ~= false then + if digicompute.os.digiline ~= false then local meta = minetest.get_meta(pos) -- get meta if channel ~= meta:get_string("channel") then return end -- ignore if not proper channel if msg.system then - if msg.system == digiterm.os.clear then digiterm.clear("output", pos) -- clear output - elseif msg.system == digiterm.os.off then digiterm.off(pos, termstring) -- turn off - elseif msg.system == digiterm.os.reboot then digiterm.reboot(pos, termstring) -- reboot - else digiterm.os.proc_digiline({x = pos.x, y = pos.y, z = pos.z}, fields.input) end -- else, hand over to OS + if msg.system == digicompute.os.clear then digicompute.clear("output", pos) -- clear output + elseif msg.system == digicompute.os.off then digicompute.off(pos, termstring) -- turn off + elseif msg.system == digicompute.os.reboot then digicompute.reboot(pos, termstring) -- reboot + else digicompute.os.proc_digiline({x = pos.x, y = pos.y, z = pos.z}, fields.input) end -- else, hand over to OS end end end @@ -99,26 +99,26 @@ function digiterm.register_terminal(termstring, desc) meta:set_string("input", "") -- input buffer local name = meta:get_string("name") -- get computer name if not name then name = "" end -- if name nil, set to blank - meta:set_string("formspec", digiterm.formspec_name(name)) -- computer name formspec + meta:set_string("formspec", digicompute.formspec_name(name)) -- computer name formspec end, on_receive_fields = function(pos, formname, fields, sender) -- precess formdata local meta = minetest.get_meta(pos) -- get meta -- if name received, set if fields.name then meta:set_string("name", fields.name) -- set name - meta:set_string("formspec", digiterm.formspec_normal(meta:get_string("input"), meta:get_string("output"))) -- refresh formspec + meta:set_string("formspec", digicompute.formspec_normal(meta:get_string("input"), meta:get_string("output"))) -- refresh formspec return end -- if submit, check for keywords and process according to os if fields.submit then - if fields.input == digiterm.os.clear then digiterm.clear("output", pos) -- clear output - elseif fields.input == digiterm.os.off then digiterm.off(pos, termstring) -- turn off - elseif fields.input == digiterm.os.reboot then digiterm.reboot(pos, termstring) -- reboot - else digiterm.os.proc_input({x = pos.x, y = pos.y, z = pos.z}, fields.input) end -- else, hand over to OS - digiterm.clear("input", pos) -- clear input field + if fields.input == digicompute.os.clear then digicompute.clear("output", pos) -- clear output + elseif fields.input == digicompute.os.off then digicompute.off(pos, termstring) -- turn off + elseif fields.input == digicompute.os.reboot then digicompute.reboot(pos, termstring) -- reboot + else digicompute.os.proc_input({x = pos.x, y = pos.y, z = pos.z}, fields.input) end -- else, hand over to OS + digicompute.clear("input", pos) -- clear input field else meta:set_string("input", fields.input) end -- else, keep input -- refresh formspec - meta:set_string("formspec", digiterm.formspec_normal(meta:get_string("input"), meta:get_string("output"))) + meta:set_string("formspec", digicompute.formspec_normal(meta:get_string("input"), meta:get_string("output"))) end, }) end diff --git a/data.lua b/data.lua index 0015516..bb9c038 100644 --- a/data.lua +++ b/data.lua @@ -5,13 +5,13 @@ datalib.table = {} -- internal table global -- logger function datalib.log(content, log_type) if log_type == nil then log_type = "action" end - minetest.log(log_type, "[digiterm:datalib] "..content) + minetest.log(log_type, "[digicompute:datalib] "..content) end -- global path variables -datalib.modpath = minetest.get_modpath("digiterm") -- modpath +datalib.modpath = minetest.get_modpath("digicompute") -- modpath datalib.worldpath = minetest.get_worldpath() -- worldpath -datalib.datapath = datalib.worldpath.."/digiterm" -- path for general datalib storage +datalib.datapath = datalib.worldpath.."/digicompute" -- path for general datalib storage -- local path variables local modpath = datalib.modpath local worldpath = datalib.worldpath diff --git a/init.lua b/init.lua index 12ca98a..1ebe709 100644 --- a/init.lua +++ b/init.lua @@ -1,18 +1,18 @@ --- digiterm/init.lua -digiterm = {} +-- digicompute/init.lua +digicompute = {} -- variables -digiterm.modpath = minetest.get_modpath("digiterm") -- modpath -local modpath = digiterm.modpath -- modpath pointer +digicompute.modpath = minetest.get_modpath("digicompute") -- modpath +local modpath = digicompute.modpath -- modpath pointer -- logger -function digiterm.log(content, log_type) +function digicompute.log(content, log_type) if log_type == nil then log_type = "action" end - minetest.log(log_type, "[digiterm] "..content) + minetest.log(log_type, "[digicompute] "..content) end -- FORMSPECS -- normal -function digiterm.formspec_normal(input, output) +function digicompute.formspec_normal(input, output) if not output then local output = "" end if not input then local input = "" end -- formspec @@ -26,7 +26,7 @@ function digiterm.formspec_normal(input, output) return formspec -- return formspec text end -- set channel (currently unused) -function digiterm.formspec_name(computer) +function digicompute.formspec_name(computer) if not computer then local computer = "" end -- use blank channel is none specified local formspec = "size[6,1.7]".. diff --git a/nodes.lua b/nodes.lua index fe83b4e..f3fcdd6 100644 --- a/nodes.lua +++ b/nodes.lua @@ -1,4 +1,4 @@ --- digiterm/nodes.lua +-- digicompute/nodes.lua digiterm.register_terminal("basic", { description = "Basic Digiterm", diff --git a/os.lua b/os.lua index d11eaa5..187629c 100644 --- a/os.lua +++ b/os.lua @@ -1,34 +1,34 @@ --- digiterm/os.lua -digiterm.os = {} -- init os table -local modpath = digiterm.modpath -- modpath pointer -local path = digiterm.datapath -- datapath pointer +-- digicompute/os.lua +digicompute.os = {} -- init os table +local modpath = digicompute.modpath -- modpath pointer +local path = digicompute.datapath -- datapath pointer -- [function] load os -function digiterm.os.load(os_name) +function digicompute.os.load(os_name) if datalib.dofile(modpath.."/os/"..os_name..".lua") ~= true then if datalib.dofile(path.."/os/"..os_name.."/.lua") ~= true then -- print error - digiterm.log(os_name.." os could not be found. Please place the OS file in "..modpath.."/os/ or "..path.."/os/ with extension '.lua'.", "error") + digicompute.log(os_name.." os could not be found. Please place the OS file in "..modpath.."/os/ or "..path.."/os/ with extension '.lua'.", "error") end end end -- [function] set meta value -function digiterm.os.set(pos, key, value) +function digicompute.os.set(pos, key, value) local meta = minetest.get_meta({x = pos.x, y = pos.y, z = pos.z}) -- get meta meta:set_string(key, value) -- set value return true -- return true, successful end -- [function] get meta value -function digiterm.os.get(pos, key) +function digicompute.os.get(pos, key) local meta = minetest.get_meta({x = pos.x, y = pos.y, z = pos.z}) -- get meta local value = meta:get_string(key) -- get value return value -- return retrieved value end -- [function] refresh formspec -function digiterm.os.refresh(pos) +function digicompute.os.refresh(pos) local meta = minetest.get_meta(pos) -- get meta - meta:set_string("formspec", digiterm.formspec_normal(meta:get_string("input"), meta:get_string("output"))) + meta:set_string("formspec", digicompute.formspec_normal(meta:get_string("input"), meta:get_string("output"))) end