1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-16 10:09:55 +00:00
Commit Graph

57 Commits

Author SHA1 Message Date
Jonathan Coates
2f42a4e85b
Add documentation for shell and multishell
Heh, one place we're more complete than cc.cc :p.
2020-04-22 14:39:39 +01:00
Jonathan Coates
1fc0214857
Some redesigning of the settings API (#408)
- The store is now split into two sections:
   - A list of possible options, with some metadata about them.
   - A list of values which have been changed.
 - settings.define can be used to register a new option. We have
   migrated all existing options over to use it. This can be used to
   define a default value, description, and a type the setting must have
   (such as `string` or `boolean).

 - settings.{set,unset,clear,load,store} operate using this value list.
   This means that only values which have been changed are stored to
   disk.
   Furthermore, clearing/unsetting will reset to the /default/ value,
   rather than removing entirely.

 - The set program will now display descriptions.

 - settings.{load,save} now default to `.settings` if no path is given.
2020-04-21 11:37:56 +01:00
SquidDev
865fc239a0 Reformat bracketed expressions in Lua
- Parenthesised expressions (function calls, arguments, etc...) should
   never have spaces in them.
 - Tables always will have spaces inside.
2020-04-18 10:09:40 +01:00
SquidDev
cb8135a0d1 Bump Cobalt version
- Remove stub for table.pack/table.unpack.
 - Remove Lua 5.3 bitlib stub. We're not on 5.3, there's no
   point emulating it.
 - Change peripheral.call to correctly adjust the error level. This is a
   terrible hack, but I believe the only good option.

It'd be good to remove load as well, but it's a little more complex due
to our injecting of _ENV.

Closes #363
2020-04-16 10:48:26 +01:00
Jonathan Coates
ef8da8054f
An initial stab at documentation generation (#360)
This adds documentation comments to many of CC's Lua APIs, and
a couple of the Java ones, through the use of stubs. We then
export these to HTML using illuaminate [1] and upload them to our
documentation site [2].

Uploads currently occur on pushes to master and any release/tag. The
site is entirely static - there is no way to switch between versions,
etc... but hopefully we can improve this in the future.

[1]: github.com/SquidDev/illuaminate/
[2]: https://tweaked.cc/
2020-04-10 10:27:53 +01:00
Jonathan Coates
68e6bc464b
Bump illuaminate version
For now, we just perform the minimal number of changes to get this
working. We'll switch to a more strict bracket handling system in the
future.
2020-04-09 22:15:06 +01:00
Jonathan Coates
1db3a14c54
Eta-reduce several calls to pcall 2020-01-15 09:29:11 +00:00
SquidDev
a48c3d0ba8 A couple of io fixes
- Use expect within io.write before calling the handle's write
   function. Closes #338
 - Coerce to string in write before doing any writing. Fixes #339
2020-01-01 09:01:00 +00:00
Jonathan Coates
03b6d2f1ab
Replace string.len with # 2019-12-10 18:55:11 +00:00
Jared Allard
b0397ed3c5 Add support for HTTP PATCH and TRACE (#324) 2019-12-08 17:10:58 +00:00
Jonathan Coates
fa70ebcac2
Fix spacing on all of the rom (#323) 2019-12-07 10:33:47 +00:00
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
0ae70fed13 Correctly implement mouse movement within read
Note to self: if you're going to modify the rom, make sure you test on a
computer which doesn't overwrite the rom with something else.
2019-11-29 20:15:58 +00:00
SquidDev
08cf55e55f Correct implementation of clamp
That's what I get for inlining definitions.
2019-11-23 14:36:43 +00:00
SquidDev
c4d18aa9ca Allow navigating read's input using the mouse 2019-11-23 13:21:07 +00: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
f9929cb27d Fix the signature of loadfile
Lua 5.2+ uses loadfile(filename, mode, env), not loadfile(filename,
env). While this is a minor incompatibility, it'd be nice to be
consistent as much as possible.

We try to handle the incorrect case too, as obviously we don't want to
break existing programs.
2019-07-12 22:04:28 +01: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
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
Wilma456 (Jakob0815)
ad33acd7d1 Add MOTD (#175) 2019-05-13 16:54:19 +01:00
SquidDev
5b942ff9c1 Some changes to Lua machines and string loading
- Share the ILuaContext across all method calls, as well as shifting it
   into an anonymous class.
 - Move the load/loadstring prefixing into bios.lua
 - Be less militant in prefixing chunk names:
   - load will no longer do any auto-prefixing.
   - loadstring will not prefix when there no chunk name is supplied.
     Before we would do `"=" .. supplied_program`, which made no sense.
2019-03-10 12:24:55 +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
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
SquidDev
5bf9f9e3c5 Allow multiple HTTP request methods
This implements an argument format similar to LuaReqeust, as described
in dan200/ComputerCraft#515. The Lua argument checking code is a little
verbose and repetitive, but I'm not sure how to avoid that - we should
look into improving it in the future.

Closes #21
2018-05-15 10:11:08 +01:00
SquidDev
4e9034f910 Make http.websocket call synchronous in bios.lua
I thought I'd done this already, but it's possible it got lost during a
rebase.
2017-12-06 09:28:38 +00:00
SquidDev
1cf10c5c47 Merge pull request #490 from zardyh/ComputerCraft/master
Propagate errors arising from API loading
2017-11-15 16:51:26 +00:00
hydraz
d766f8b34e Propagate errors arising from API loading 2017-11-15 14:22:36 -02:00
SquidDev
fe0f998c27 Merge pull request #448 from Wilma456/ComputerCraft-1/writecheck
Fix check of write()
2017-11-14 23:50:12 +00:00
SquidDev
540e2e25aa Merge pull request #163 from SquidDev-CC/ComputerCraft/feature/cobalt
Replace LuaJ with Cobalt
2017-11-14 21:48:47 +00:00
SquidDev
060fb21bdb Merge pull request #298 from SquidDev-CC/ComputerCraft/feature/luaj-bit32
Replace BitAPI with a LuaJ implementation of bit32
2017-11-14 21:32:19 +00:00
SquidDev
0bd0f4d313 Prefix all loaded strings with "="
Whilst this is not consistent with normal Lua, this is required in order
to remain compatible with LuaJ.
2017-11-14 18:41:01 +00:00
SquidDev
0420b6c831 Remove string metatable protection
The string metatable and environment are no longer shared, so this
sandboxing is no longer required.
2017-11-14 18:41:00 +00:00
Wilma456 (Jakob0815)
373b7ba293 Fix check of write()
if you call write(nil), you will get the error "bios.lua:229: bad argument: string expected, got nil", so nil is not a valid argument for write() and should be removed.
2017-09-12 17:17:58 +02:00
Daniel Ratcliffe
2f829a1413 Fixed load() not accepting function arguments 2017-08-27 13:34:33 +01:00
Wilma456
79697e37b0 Add Check to load() 2017-08-24 20:18:21 +02:00
Wilma456
e9cea7d0f5 Add more Checks 2017-08-21 15:20:32 +02:00
Daniel Ratcliffe
123a0158af Merge pull request #313 from SquidDev-CC/feature/http-blacklist
HTTP blacklist and IP address support
2017-06-28 22:36:14 +01:00
Wojbie
bf533dd00a Reverting requested changes. Take 1
Reverting rewrites to painutils, paint and edit - keept the paste logic change in edit.
Changed and removed misc parts as requested in PR.
2017-06-28 22:58:57 +02:00
Wojbie
6255314ba8 Fir error in http.request _post error cheacking code and add package.config to shell require code to support standard better. 2017-06-24 14:33:29 +02:00
Wojbie
fc93ee474f Merge branch 'master' into Mixed-lua-side-improvements 2017-06-24 14:29:19 +02:00
Wojbie
6df22235ae Add forgotten settings.set in bios. 2017-06-20 02:09:28 +02:00
Wilma456
c70acbb05a Add Checks to Bios 2017-06-18 17:48:07 +02:00
SquidDev
084bbe8480 Replace BitAPI with a LuaJ implementation of bit32 2017-06-17 21:39:12 +01:00
Wojbie
3acbdb2f90 Merge branch 'master' into Mixed-lua-side-improvements 2017-06-17 22:21:25 +02:00
Wilma456
2445a5b5d5 Add Default to read() 2017-06-15 14:50:47 +02:00
Wojbie
76a3562d58 Multiple fixes and feature fixes for lua side of CC
In no particular order:
bios.lua - added missing test for ensure turtle folder exists.
paintutils.lua - added drawLineHorizontal() to reduce most (not all) cases of running multiple writes on same horizontal line that can be solved with one write.
textutils.lua - Added exception to complete function - will not complete if provided with LuaKeyword - solves do->dofile problem and removes other LuaKeyword related ones in advance.
edit.lua - Changed logic in handling the paste event - if paste event is received when menu is open it automatically closed said menu and lets it paste - resolves ctrl+ctrl+v annoyance. Added Jump to Menu functions - allows for fast jump to needed line - must for bigger files and a nice feature to have.
set.lua - Switched set to use pagedPrint - this will ensure that even if there are more settings than lines on screen the set command will show you all of them.
startup.lua - Added autocompletition for turtle programs go, turn, equip, unequip and command program exec.
lua.lua - Changed return function to print returned stuff correctly -
will print all returned variables even if there are any nils in there.
2017-06-13 11:00:07 +02:00
SquidDev
585c769c2a Restructure the HTTP API
- Adds support for blacklisting domains
 - Adds support for blacklisting & whitelisting IP addresses and
   IP ranges.
 - Reuse threads for HTTP requests

AddressPredicate will parse a series of patterns and convert them into
regexes or CIDR ranges. When checking whether an address is accessible,
we first ensure the domain is whitelisted and isn't blacklisted.

If everything is OK, then we start create a new thread for the HTTP
request and resolve the IP, ensuring that is whitelisted & not
blacklisted. Then the normal HTTP request is continued.

However, http.checkURL also needs to resolve the IP address. In order to
avoid blocking the Lua thread, this method will return instantly and
create a new thread which will queue an event.

As both http.request and http.checkURL are now creating threads and
queuing events, some logic is abstracted into a separate HTTPTask class
- this allows us to share the thread creation, finishing and cancelling
logic.
2017-06-12 19:22:02 +01:00
Wilma456
07ae332c24 Add fileextension for Paint (#260)
* Add fileextension for Paint

* Change extension to .nfp

* Add setting
2017-05-29 14:05:19 +01:00
Wilma456
99b5534099 Add setting for .lua extension (#278)
* Add setting for .lua extension

* Feedback  from SquidDev

* Feedback from dan200

* All requested changes are done

* Better description

* Cleaner check
2017-05-29 13:21:27 +01:00