mirror of
https://github.com/mt-mods/home_workshop_modpack.git
synced 2025-07-01 16:00:41 +02:00
add filesystem
This commit is contained in:
7
computers/commands/cd/conf.json
Normal file
7
computers/commands/cd/conf.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "cd",
|
||||
"license": "MIT",
|
||||
"version": 0.1,
|
||||
"engine": 0.4,
|
||||
"help": "move in and out of folders"
|
||||
}
|
25
computers/commands/cd/init.lua
Normal file
25
computers/commands/cd/init.lua
Normal file
@ -0,0 +1,25 @@
|
||||
function cd(pos, input, data)
|
||||
local path = computers.devicepath .. "/" .. minetest.hash_node_position(pos) .. data.element.pwd
|
||||
|
||||
if input and input ~= "" and not input:find("/") then
|
||||
if input == ".." then
|
||||
local uri = data.element.pwd:split("/")
|
||||
uri[#uri] = nil
|
||||
data.element.pwd = "/" .. table.concat(uri, "/")
|
||||
if data.element.pwd == "/" then data.element.pwd = "" end
|
||||
return "sucess"
|
||||
else
|
||||
for _, folder in pairs(minetest.get_dir_list(path, true)) do
|
||||
if folder == input then
|
||||
data.element.pwd = data.element.pwd .. "/" .. input
|
||||
return "sucess"
|
||||
end
|
||||
end
|
||||
return "ERROR: path not found"
|
||||
end
|
||||
else
|
||||
return "invalid or missing input"
|
||||
end
|
||||
end
|
||||
|
||||
return cd
|
Reference in New Issue
Block a user