import steps: rename items
parent
c77b42d6b3
commit
319b7dd484
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -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.
|
|
@ -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.
|
|
@ -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.
|
|
@ -15,7 +15,7 @@ digicompute.register_computer("<computer_string>", {
|
|||
})
|
||||
```
|
||||
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue