1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-24 22:23:21 +00:00
Commit Graph

123 Commits

Author SHA1 Message Date
SquidDev
86e0330100 Lint bios and the rom (#321)
We now use illuaminate[1]'s linting facilities to check the rom and
bios.lua for a couple of common bugs and other problems.

Right now this doesn't detect any especially important bugs, though it
has caught lots of small things (unused variables, some noisy code). In
the future, the linter will grow in scope and features, which should
allow us to be stricter and catch most issues.

As a fun aside, we started off with ~150 bugs, and illuaminate was able
to fix all but 30 of them, which is pretty neat.

[1]: https://github.com/SquidDev/illuaminate
2019-12-03 23:26:13 +00:00
SquidDev
49c37857d4 Window.reposition now allow changing the redirect buffer
See #270
2019-09-13 20:55:20 +01:00
SquidDev
93310850d2 Use the "cc" module namespace instead of "craftos"
This is what we actually discussed in the issue, and I failed to
remember.
2019-07-27 11:34:59 +01:00
SquidDev
4ae77261fa Petty changes because I'm petty 2019-07-13 08:29:28 +01:00
liquid
85b740f484 Added term.getLine and window.getLine 2019-07-12 22:54:37 -05:00
SquidDev
bafab1ac07
Expose expect as a module (#267)
This moves expect from the bios into a new craftos.expect module,
removing the internal _G["~expect"] definition. Apparently people were
using this irrespective of the "don't use this" comment, so we need to
find another solution.

While this does introduce some ugliness (having to load the module in
weird ways for programs, duplicating the expect function in memory), it
does allow people to use the function in a supported way, and removes
the global ugliness.
2019-07-09 08:04:49 +01:00
SquidDev
d4b8650d21 Use select('#', ...) instead of ipairs on varargs
This means we don't discard any value after nil, meaning that
calls such as colors.combine(nil, 1, 2, 3) will error, rather
than returning 0.
2019-06-01 10:12:10 +01:00
SquidDev
17645a79f0 Fix type check on rednet.lookup
Fixes #224
2019-06-01 09:23:18 +01:00
SquidDev
e839ef54af Forbid mutating empty_json_array
It's definitely still possible (rawset), but should prevent people
accidentally trying to modify it when they shouldn't.
2019-05-30 20:01:09 +01:00
hydraz
9048deeb95 Add a function for type-checking arguments (#207)
- Define an expect(index, actual_value, types...) helper function which
   takes an argument index, value and list of permissable types and
   ensures the value is of one of those types.
   If not, it will produce an error message with the expected and actual
   type, as well as the argument number and (if available) the function
   name.
 - Expose expect in the global scope as _G["~expect"], hopefully making
   it clear it is internal.
 - Replace most manual type checks with this helper method.
 - Write tests to ensure this argument validation works as expected

Also fix a couple of bugs exposed by this refactor and the subsequent
tests:
 - Make rednet checks a little more strict - rednet.close(false) is no
   longer valid.
 - Error when attempting to redirect the terminal to itself 
   (term.redirect(term)).
2019-05-30 19:36:28 +01:00
Luca S
390575ab4d rednet.send now returns if the message was send (#164)
This makes use of the "sent" variable, which would otherwise go unused. It also makes rednet.send compliant to the behaviour specified in the Wiki: http://www.computercraft.info/wiki/Rednet.send
2019-04-01 19:31:21 +01:00
SquidDev
f1d10809d5 Make commands.collapseArgs a little more sane
We now generate a table and concatinate the elements together. This has
several benefits:
 - We no longer emit emit trailing spaces, which caused issues on 1.13's
   command system.
 - We no longer need the error level variable, nor have the weird
   recursion system - it's just easier to understand.
2019-02-26 08:40:48 +00:00
SquidDev
1fb3d16b89 Fix colours.*RGB methods working with 8 bit values
They should have been using 0-1s instead. I'm a moron for not noting
this earlier, and not testing this.
2019-02-23 23:20:46 +00:00
Lignum
af01b9514b Split colours.rgb8 into colours.packRGB and colours.unpackRGB 2019-02-19 09:51:01 +00:00
Lignum
070fd1f2ff Add term.nativePaletteColo(u)r 2019-02-19 09:50:57 +00:00
SquidDev
4c7ac50dd8 Fix a rather silly typo
I wonder if it'd be possible to extend LuaCheck to detect such cases?
2018-12-27 09:10:06 +00:00
SquidDev
86569533e9 The big massive reformat
- Normalise all line endings to be LF rather than CLRF
 - Trim all trailing whitespace
 - Remove any tabs
2018-12-17 18:09:31 +00:00
SquidDev
7e334bd4a5 Fix a couple of other bugs with the fs rewrite
- Fix stdin not being considered a "readable" input
 - Return an unsigned byte rather than a signed one for no-args .read()
2018-10-28 08:39:44 +00:00
SquidDev
e555f9f7f0 Merge pull request #575 from SquidDev-CC/ComputerCraft/feature/file-seeking
Rewrite file systems to use ByteChannels
2018-10-24 12:20:53 +01:00
SquidDev
33fad2da15 Merge pull request #577 from SquidDev-CC/ComputerCraft/feature/get-blink
Add .getCursorBlink to monitors and terminals
2018-09-28 16:23:00 +01:00
SquidDev
518eefbe10 Rewrite file systems to use ByteChannels
This replaces the existing IMount openFor* method with openChannelFor*
ones, which return an appropriate byte channel instead.

As channels are not correctly closed when GCed, we introduce a
FileSystemWrapper. We store a weak reference to this, and when it is
GCed or the file closed, we will remove it from our "open file" set and
ensure any underlying buffers are closed.

While this change may seem a little odd, it does introduce some
benefits:

 - We can replace JarMount with a more general FileSystemMount. This
   does assume a read-only file system, but could technically be used
   for other sources.

 - Add support for seekable (binary) handles. We can now look for
   instances of SeekableByteChannel and dynamically add it. This works
   for all binary filesystem and HTTP streams.

 - Rewrite the io library to more accurately emulate PUC Lua's
   implementation. We do not correctly implement some elements (most
   noticably "*n", but it's a definite improvement.
2018-09-26 10:00:17 +01:00
SquidDev
1ba73454c1 Add .getCursorBlink to monitors and terminals
Closes #576
2018-09-23 09:34:28 +01:00
SquidDev
1774f1a079 Merge pull request #566 from SquidDev-CC/ComputerCraft/feature/tiny-lua-wins
A couple of small improvements to CraftOS
2018-08-12 15:49:19 +01:00
SquidDev
de1307913b A couple of small improvements to CraftOS
- Make window.reposition's argument validation a little more strict.
   Previously it would accept `window.reposition(x, y, width)` (no
   height argument), just not act upon it.
 - Use select instead of table.unpack within `pastebin run`.
 - Use `parallel.waitForAny` instead of `waitForAll` within the dance
   program.
 - Pipe the entire help file into `textutils.pagedPrint`, rather than
   doing it line by line.
 - Remove bytecode loading disabling from bios.lua. This never worked
   correctly, and serves little purpose as LuaJ is not vulnerable to
   such exploits.
2018-08-12 08:23:17 +01:00
hugeblank
e4164ee9a1 amend additional typo in keys.lua
- fixed circumflex typo: you can now cîrcûmflêx on all your friends
- added comment making it clearer that the following lines are intended for backwards compatibility.
2018-05-14 15:54:06 +01:00
SquidDev
8775052dee Merge pull request #543 from hugeblank/ComputerCraft/patch-1
amend typo in keys.lua
2018-05-08 09:46:14 +01:00
hugeblank
c0c5d57e10
amend typo in keys.lua
The most important commit that CC has ever seen.
2018-05-08 01:10:45 -07:00
Daniel Ratcliffe
3e265c27ff
Merge pull request #455 from Wilma456/fileread
Add read() to Filehandle
2018-01-13 00:58:19 +00:00
Daniel Ratcliffe
8d356f50c4
Merge pull request #440 from Wilma456/iomulti
Make io.write() accept multiple args
2018-01-13 00:48:07 +00:00
SquidDev
d7301ff15e Merge pull request #412 from Wilma456/ComputerCraft-1/textfix
Add Check to textutils.tabulate/pagedTabulate
2017-11-15 16:58:13 +00:00
SquidDev
6c29b44c3c Merge pull request #440 from Wilma456/ComputerCraft-1/iomulti
Make io.write() accept multiple args
2017-11-15 11:47:33 +00:00
SquidDev
66f683d9c9 Merge pull request #475 from Wilma456/ComputerCraft-1/ioline
Fix io.lines()
2017-11-14 23:53:50 +00:00
Wilma456
bcf79165f9 Merge pull request #455 from Wilma456/ComputerCraft-1/fileread
Add read() to Filehandle
2017-11-14 23:48:38 +00:00
Wilma456 (Jakob0815)
999351e667 Fix io.lines() 2017-10-04 18:51:48 +02:00
Wilma456 (Jakob0815)
f8193a4d23 Set errorlevel for "Unsupported format" to 2 2017-09-16 16:11:36 +02:00
Wilma456
5be2202b2e Add read() to Filehandle 2017-09-16 16:06:27 +02:00
Daniel Ratcliffe
1c8480a329 Merge pull request #441 from SquidDev-CC/hotfix/paintutils-read
Fix a non-existent method being used in paintutils
2017-09-13 17:10:07 +01:00
Wilma456 (Jakob0815)
282aa804f8 Changes sugested by dan200 2017-09-12 19:42:08 +02:00
Bomb Bloke
70c6f3498b Correct minor typo in rednet.receive
Caused attempts to set a time-out value to throw "expected number, got number".
2017-09-13 01:06:59 +10:00
Wilma456 (Jakob0815)
92f5860de6 Use select() 2017-09-12 15:27:09 +02:00
SquidDev
12abd4292e Fixes a non-existent method being used in paintutils 2017-09-12 09:52:21 +01:00
Wilma456 (Jakob0815)
0115bc8dca Make io.write() accept multiple args
This is just to bring the io API from CC close the the io API from normal lua, which accept multiple args for io.write().
2017-09-11 15:47:30 +02:00
Daniel Ratcliffe
1fdfcdb5f2 Merge pull request #378 from MineRobber9000/patch-3
Add ability to load raw data from a string [paintutils]
2017-09-11 13:28:27 +01:00
Daniel Ratcliffe
51644e32ed Merge pull request #415 from Wilma456/palletecheck
Add valid check to term.setPaletteColor/getPaletteColor
2017-09-10 00:12:46 +01:00
Wilma456 (Jakob0815)
a5bbed528d Make mode from io.open() accept nil 2017-09-06 18:53:44 +02:00
Wilma456 (Jakob0815)
369be7c32c Fix io API
While adding checks to the io API in #424, I had forgot that the io API has his own type() function who overwrite the default one. This PR fix this. Sorry for that.
2017-08-27 17:08:40 +02:00
Daniel Ratcliffe
0de3a42808 Merge pull request #424 from Wilma456/newcheck
Add more Checks
2017-08-27 12:26:58 +01:00
Wilma456
4f9de6b02c Update Checks 2017-08-24 20:17:31 +02:00
Wilma456
e9cea7d0f5 Add more Checks 2017-08-21 15:20:32 +02:00
Wilma456 (Jakob0815)
30b55d966b Add valid check to term.setPaletteColor/getPaletteColor 2017-08-11 15:38:02 +02:00