mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-27 20:07:39 +00:00
Merge branch 'mc-1.14.x' into mc-1.15.x
This commit is contained in:
@@ -797,6 +797,12 @@ function fs.complete(sPath, sLocation, bIncludeFiles, bIncludeDirs)
|
||||
return tEmpty
|
||||
end
|
||||
|
||||
function fs.isDriveRoot(sPath)
|
||||
expect(1, sPath, "string")
|
||||
-- Force the root directory to be a mount.
|
||||
return fs.getDir(sPath) == ".." or fs.getDrive(sPath) ~= fs.getDrive(fs.getDir(sPath))
|
||||
end
|
||||
|
||||
-- Load APIs
|
||||
local bAPIError = false
|
||||
local tApis = fs.list("rom/apis")
|
||||
@@ -932,6 +938,11 @@ settings.define("motd.path", {
|
||||
description = [[The path to load random messages from. Should be a colon (":") separated string of file paths.]],
|
||||
type = "string",
|
||||
})
|
||||
settings.define("lua.warn_against_use_of_local", {
|
||||
default = true,
|
||||
description = [[Print a message when input in the Lua REPL starts with the word 'local'. Local variables defined in the Lua REPL are be inaccessable on the next input.]],
|
||||
type = "boolean",
|
||||
})
|
||||
if term.isColour() then
|
||||
settings.define("bios.use_multishell", {
|
||||
default = true,
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
-- [mc]: https://minecraft.gamepedia.com/Commands
|
||||
--
|
||||
-- @module commands
|
||||
-- @usage Set the block above this computer to stone:
|
||||
--
|
||||
-- commands.setblock("~", "~1", "~", "minecraft:stone")
|
||||
|
||||
if not commands then
|
||||
error("Cannot load command API on normal computer", 2)
|
||||
@@ -97,4 +100,13 @@ for _, sCommandName in ipairs(native.list()) do
|
||||
tAsync[sCommandName] = mk_command({ sCommandName }, bJSONIsNBT, native.execAsync)
|
||||
end
|
||||
end
|
||||
|
||||
--- A table containing asynchronous wrappers for all commands.
|
||||
--
|
||||
-- As with @{commands.execAsync}, this returns the "task id" of the enqueued
|
||||
-- command.
|
||||
-- @see execAsync
|
||||
-- @usage Asynchronously sets the block above the computer to stone.
|
||||
--
|
||||
-- commands.async.setblock("~", "~1", "~", "minecraft:stone")
|
||||
env.async = tAsync
|
||||
|
||||
@@ -75,7 +75,10 @@ handleMetatable = {
|
||||
if not handle.read then return nil, "file is not readable" end
|
||||
|
||||
local args = table.pack(...)
|
||||
return function() return checkResult(self, self:read(table.unpack(args, 1, args.n))) end
|
||||
return function()
|
||||
if self._closed then error("file is already closed", 2) end
|
||||
return checkResult(self, self:read(table.unpack(args, 1, args.n)))
|
||||
end
|
||||
end,
|
||||
|
||||
read = function(self, ...)
|
||||
@@ -259,12 +262,13 @@ end
|
||||
-- instead. In this case, the handle is not used.
|
||||
--
|
||||
-- @tparam[opt] string filename The name of the file to extract lines from
|
||||
-- @param ... The argument to pass to @{Handle:read} for each line.
|
||||
-- @treturn function():string|nil The line iterator.
|
||||
-- @throws If the file cannot be opened for reading
|
||||
--
|
||||
-- @see Handle:lines
|
||||
-- @see io.input
|
||||
function lines(filename)
|
||||
function lines(filename, ...)
|
||||
expect(1, filename, "string", "nil")
|
||||
if filename then
|
||||
local ok, err = open(filename, "rb")
|
||||
@@ -273,9 +277,9 @@ function lines(filename)
|
||||
-- We set this magic flag to mark this file as being opened by io.lines and so should be
|
||||
-- closed automatically
|
||||
ok._autoclose = true
|
||||
return ok:lines()
|
||||
return ok:lines(...)
|
||||
else
|
||||
return currentInput:lines()
|
||||
return currentInput:lines(...)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -313,7 +317,7 @@ end
|
||||
-- @throws If the provided filename cannot be opened for writing.
|
||||
function output(file)
|
||||
if type_of(file) == "string" then
|
||||
local res, err = open(file, "w")
|
||||
local res, err = open(file, "wb")
|
||||
if not res then error(err, 2) end
|
||||
currentOutput = res
|
||||
elseif type_of(file) == "table" and getmetatable(file) == handleMetatable then
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
# New features in CC: Tweaked 1.88.0
|
||||
|
||||
* Computers and turtles now preserve their ID when broken.
|
||||
* Add `peripheral.getName` - returns the name of a wrapped peripheral.
|
||||
* Reduce network overhead of monitors and terminals.
|
||||
* Add a TBO backend for monitors, with a significant performance boost.
|
||||
* The Lua REPL warns when declaring locals (lupus590, exerro)
|
||||
* Add config to allow using command computers in survival.
|
||||
* Add fs.isDriveRoot - checks if a path is the root of a drive.
|
||||
|
||||
And several bug fixes:
|
||||
* Fix io.lines not accepting arguments.
|
||||
* Fix settings.load using an unknown global (MCJack123).
|
||||
|
||||
# New features in CC: Tweaked 1.87.1
|
||||
|
||||
* Fix blocks not dropping items in survival.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
ComputerCraft was created by Daniel "dan200" Ratcliffe, with additional code by Aaron "Cloudy" Mills.
|
||||
Thanks to nitrogenfingers, GopherATL and RamiLego for program contributions.
|
||||
Thanks to Mojang, the Forge team, and the MCP team.
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
New features in CC: Tweaked 1.87.1
|
||||
New features in CC: Tweaked 1.88.0
|
||||
|
||||
* Fix blocks not dropping items in survival.
|
||||
* Computers and turtles now preserve their ID when broken.
|
||||
* Add `peripheral.getName` - returns the name of a wrapped peripheral.
|
||||
* Reduce network overhead of monitors and terminals.
|
||||
* Add a TBO backend for monitors, with a significant performance boost.
|
||||
* The Lua REPL warns when declaring locals (lupus590, exerro)
|
||||
* Add config to allow using command computers in survival.
|
||||
* Add fs.isDriveRoot - checks if a path is the root of a drive.
|
||||
|
||||
And several bug fixes:
|
||||
* Fix io.lines not accepting arguments.
|
||||
* Fix settings.load using an unknown global (MCJack123).
|
||||
|
||||
Type "help changelog" to see the full version history.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
if not shell.openTab then
|
||||
printError("Requires multishell")
|
||||
return
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
if not shell.openTab then
|
||||
printError("Requires multishell")
|
||||
return
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local tArgs = { ... }
|
||||
if #tArgs > 2 then
|
||||
print("Usage: alias <alias> <program>")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local tApis = {}
|
||||
for k, v in pairs(_G) do
|
||||
if type(k) == "string" and type(v) == "table" and k ~= "_G" then
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local tArgs = { ... }
|
||||
if #tArgs < 1 then
|
||||
print("Usage: cd <path>")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
if not commands then
|
||||
printError("Requires a Command Computer.")
|
||||
return
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local tArgs = { ... }
|
||||
if not commands then
|
||||
printError("Requires a Command Computer.")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local tArgs = { ... }
|
||||
if #tArgs < 2 then
|
||||
print("Usage: cp <source> <destination>")
|
||||
|
||||
@@ -9,9 +9,18 @@ for i = 1, args.n do
|
||||
local files = fs.find(shell.resolve(args[i]))
|
||||
if #files > 0 then
|
||||
for _, file in ipairs(files) do
|
||||
local ok, err = pcall(fs.delete, file)
|
||||
if not ok then
|
||||
printError((err:gsub("^pcall: ", "")))
|
||||
if fs.isReadOnly(file) then
|
||||
printError("Cannot delete read-only file /" .. file)
|
||||
elseif fs.isDriveRoot(file) then
|
||||
printError("Cannot delete mount /" .. file)
|
||||
if fs.isDir(file) then
|
||||
print("To delete its contents run rm /" .. fs.combine(file, "*"))
|
||||
end
|
||||
else
|
||||
local ok, err = pcall(fs.delete, file)
|
||||
if not ok then
|
||||
printError((err:gsub("^pcall: ", "")))
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
-- Get arguments
|
||||
local tArgs = { ... }
|
||||
if #tArgs == 0 then
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local tBiomes = {
|
||||
"in a forest",
|
||||
"in a pine forest",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
-- Display the start screen
|
||||
local w, h = term.getSize()
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local function printUsage()
|
||||
print("Usages:")
|
||||
print("gps host")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local function printUsage()
|
||||
print("Usages:")
|
||||
print("pastebin put <filename>")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local function printUsage()
|
||||
print("Usage:")
|
||||
print("wget <url> [filename]")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local sDrive = nil
|
||||
local tArgs = { ... }
|
||||
if #tArgs > 0 then
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local function printUsage()
|
||||
print("Usages:")
|
||||
print("label get")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local tArgs = { ... }
|
||||
|
||||
-- Get all the files in the directory
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local tArgs = { ... }
|
||||
if #tArgs > 0 then
|
||||
print("This is an interactive Lua prompt.")
|
||||
@@ -67,6 +66,13 @@ while bRunning do
|
||||
if s:match("%S") and tCommandHistory[#tCommandHistory] ~= s then
|
||||
table.insert(tCommandHistory, s)
|
||||
end
|
||||
if settings.get("lua.warn_against_use_of_local") and s:match("^%s*local%s+") then
|
||||
if term.isColour() then
|
||||
term.setTextColour(colours.yellow)
|
||||
end
|
||||
print("To access local variables in later inputs, remove the local keyword.")
|
||||
term.setTextColour(colours.white)
|
||||
end
|
||||
|
||||
local nForcePrint = 0
|
||||
local func, e = load(s, "=lua", "t", tEnv)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local tArgs = { ... }
|
||||
if #tArgs < 2 then
|
||||
print("Usage: mv <source> <destination>")
|
||||
@@ -8,12 +7,35 @@ end
|
||||
local sSource = shell.resolve(tArgs[1])
|
||||
local sDest = shell.resolve(tArgs[2])
|
||||
local tFiles = fs.find(sSource)
|
||||
|
||||
local function sanity_checks(source, dest)
|
||||
if fs.exists(dest) then
|
||||
printError("Destination exists")
|
||||
return false
|
||||
elseif fs.isReadOnly(dest) then
|
||||
printError("Destination is read-only")
|
||||
return false
|
||||
elseif fs.isDriveRoot(source) then
|
||||
printError("Cannot move mount /" .. source)
|
||||
return false
|
||||
elseif fs.isReadOnly(source) then
|
||||
printError("Cannot move read-only file /" .. source)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
if #tFiles > 0 then
|
||||
for _, sFile in ipairs(tFiles) do
|
||||
if fs.isDir(sDest) then
|
||||
fs.move(sFile, fs.combine(sDest, fs.getName(sFile)))
|
||||
local dest = fs.combine(sDest, fs.getName(sFile))
|
||||
if sanity_checks(sFile, dest) then
|
||||
fs.move(sFile, dest)
|
||||
end
|
||||
elseif #tFiles == 1 then
|
||||
fs.move(sFile, sDest)
|
||||
if sanity_checks(sFile, sDest) then
|
||||
fs.move(sFile, sDest)
|
||||
end
|
||||
else
|
||||
printError("Cannot overwrite file multiple times")
|
||||
return
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local bAll = false
|
||||
local tArgs = { ... }
|
||||
if #tArgs > 0 and tArgs[1] == "all" then
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local tArgs = { ... }
|
||||
|
||||
local function printUsage()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
-- Find modems
|
||||
local tModems = {}
|
||||
for _, sModem in ipairs(peripheral.getNames()) do
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local tArgs = { ... }
|
||||
|
||||
local function printUsage()
|
||||
|
||||
@@ -10,6 +10,12 @@ local sDest = shell.resolve(tArgs[2])
|
||||
if not fs.exists(sSource) then
|
||||
printError("No matching files")
|
||||
return
|
||||
elseif fs.isDriveRoot(sSource) then
|
||||
printError("Can't rename mounts")
|
||||
return
|
||||
elseif fs.isReadOnly(sSource) then
|
||||
printError("Source is read-only")
|
||||
return
|
||||
elseif fs.exists(sDest) then
|
||||
printError("Destination exists")
|
||||
return
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
local tArgs = { ... }
|
||||
if #tArgs < 1 then
|
||||
print("Usage: type <path>")
|
||||
@@ -15,4 +14,3 @@ if fs.exists(sPath) then
|
||||
else
|
||||
print("No such path")
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user