1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-27 16:02:17 +00:00

Allow strings or numbers in textutils.*tabulate

Allow strings or numbers in textutils.*tabulate

A little dubious, but apparently CC used to support it. This means we're
consistent with methods like io.write or string.len which accept strings
or numbers.

Fixes #591
This commit is contained in:
Merith-TK 2021-05-07 11:26:24 -07:00
parent f8a58dbcb1
commit 717686d855
2 changed files with 16 additions and 3 deletions

View File

@ -362,3 +362,15 @@ Remove extra space (#586)
Fixed length check on function name in `expect` (#589)
```
```
04f9644ae75dafc72da4c4790f334d2e90b03e6f
Allow strings or numbers in textutils.*tabulate
A little dubious, but apparently CC used to support it. This means we're
consistent with methods like io.write or string.len which accept strings
or numbers.
Fixes #591
```

View File

@ -163,10 +163,11 @@ local function tabulateCommon(bPaged, ...)
for n, t in ipairs(tAll) do
if type(t) == "table" then
for nu, sItem in pairs(t) do
if type(sItem) ~= "string" then
error("bad argument #" .. n .. "." .. nu .. " (expected string, got " .. type(sItem) .. ")", 3)
local ty = type(sItem)
if ty ~= "string" and ty ~= "number" then
error("bad argument #" .. n .. "." .. nu .. " (expected string, got " .. ty .. ")", 3)
end
nMaxLen = math.max(#sItem + 1, nMaxLen)
nMaxLen = math.max(#tostring(sItem) + 1, nMaxLen)
end
end
end