Skip to content

Commit

Permalink
mod rename: digiterm -> digicompute
Browse files Browse the repository at this point in the history
  • Loading branch information
octacian committed Jul 12, 2016
1 parent 855b4c0 commit 26c7c28
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 55 deletions.
66 changes: 33 additions & 33 deletions api.lua
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -45,32 +45,32 @@ 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
end
},
},
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",
groups = {cracky = 2},
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",
Expand All @@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions init.lua
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]"..
Expand Down
2 changes: 1 addition & 1 deletion nodes.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- digiterm/nodes.lua
-- digicompute/nodes.lua

digiterm.register_terminal("basic", {
description = "Basic Digiterm",
Expand Down
20 changes: 10 additions & 10 deletions os.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 26c7c28

Please sign in to comment.