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/touch/conf.json
Normal file
7
computers/commands/touch/conf.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "touch",
|
||||
"license": "MIT",
|
||||
"version": 0.1,
|
||||
"engine": 0.4,
|
||||
"help": "creates a file in the current path"
|
||||
}
|
14
computers/commands/touch/init.lua
Normal file
14
computers/commands/touch/init.lua
Normal file
@ -0,0 +1,14 @@
|
||||
function touch(pos, input, data)
|
||||
local path = computers.devicepath .. "/" .. minetest.hash_node_position(pos) .. data.element.pwd
|
||||
--make dir to be safe
|
||||
minetest.mkdir(path)
|
||||
|
||||
if input and input ~= "" and not input:find("/") then
|
||||
minetest.safe_file_write(path .. "/" .. input, "")
|
||||
return "file " .. input .. " created"
|
||||
else
|
||||
return "invalid or missing input"
|
||||
end
|
||||
end
|
||||
|
||||
return touch
|
Reference in New Issue
Block a user