The two recipes are pretty similar, so this allows us to substantially
simplify the code. This now introduces the additional requirement that
computers must be used to create turtles, rather than pocket computers
or another turtle.
This adds IComputerItem.withFamily(ItemStack, ComputerFamily) as well as
a ComputerFamilyRecipe class. Each type of computer (normal, turtle,
pocket) defines a recipe using this class, as they require a different
number of gold ingots to upgrade.
These act similarly to conventional wired modems, but with the advantage
that they are a full block. This means they can be attached to
peripherals which are not solid (such as chests). Further more, as they
do not have a direction, they allow wrapping peripherals on all 6 sides.
It's worth noting that wired modems do not require a cable - they will
automatically form connections to adjacent network elements when placed.
There are several important things to note here:
- The network element is associated with the cable, whilst the
peripheral (and so packet sender/receiver) is associated with the
modem. This allows us to have the main element be in the centre of
the cable block, whilst the modem is in the centre of the adjacent
computer.
- Cables will connect to any adjacent network element, not just
other cables.
- Rednet messages are now sent on the computer thread, rather than the
cable tick.
The API is composed of three primary classes:
- IWiredElement: Represents some physical entity in the network. This
will generally be a block (such as a cable or modem), but it is not
required to be.
Each element can provide a series of peripherals, which will be
exposed to other elements on the network.
- IWiredNode: Every wired element has a unique wired node. This acts
as a thread-safe proxy for communicating with the rest of the
network (such as sending packets). Each node is also its own packet
network.
- IWiredNetwork: This is responsible for keeping track of nodes and
peripherals in the network. It provides methods for forming and
breaking connections, correctly joining and splitting networks where
needed.
Tiles which wish to be part of a wired network should implement
IWiredElementTile or register a custom IWiredProvider. When loaded into
the world, it should connect to adjacent nodes. Similarly, when removed
(either due to being broken or chunk unloads), it should break those
connections.
There is no method to query the layout of the network, as that offers
greater flexibility in changing or extending the implementation later
on.
This provides a mechanism for peripherals to see what else a computer is
connected to - and then interact with those peripherals.
We also add the ability to query what block or tile a peripheral
targets. This allows one to interact with the original block of adjacent
peripherals instead.
Mostly intended for those people who don't like .inspect() or
.getItemDetail(), but could allow modpacks to block equipping upgrades,
placing blocks, etc...
The main aim of this is to allow for greater extensibility for other
mods. For instance, you can now prevent turtles placing dirt blocks, or
turning when on gravel.
As of #458, BlockPeripheral will act as a full/opaque block for some
peripherals and a transparent one for others. However, some Block
methods use the default state rather than the current one. This means
modems report being a full block when they are not, leading to
suffocating entities and lighting glitches.
As of #458, BlockPeripheral will act as a full/opaque block for some
peripherals and a transparent one for others. However, some Block
methods use the default state rather than the current one. This means
modems report being a full block when they are not, leading to
suffocating entities and lighting glitches.
This restructures monitor in order to make it thread-safe: namely
removing any world interaction from the computer thread.
Instead of each monitor having their own terminal, resize flag, etc...
we use a monitor "multiblock" object. This is constructed on the origin
monitor and propagated to other monitors when required.
We attempt to construct the multiblock object (and so the corresponding
terminal) as lazily as posible. Consequently, we only create the
terminal when fetching the peripheral (not when attaching, as that is
done on the computer thread).
If a monitor is resized (say due to placing/breaking a monitor) then we
will invalidate all references to the multiblock object, construct a new
one if required, and propagate it to all component monitors.
This commit also fixes several instances of glLists not being deleted
after use. It is not a comprehensive fix, but that is outside the scope
of this commit.
- Ensure usage is consistent
- Allow computer selectors to return multiple values
- Fix commands being marked as usable when it isn't
- Add /computercraft turn-on, a counter to /computercraft shutdown
As tiles outside the world border are not ticked, turtles are rendered
entirely useless. Furthermore, the turtle animation will never progress
resulting in visual glitches.
In order to avoid this, we ensure the target position is within the
world border when moving to it.
When a player places a turtle, they are marked as its owner. Any actions
they perform (such as breaking blocks, moving, etc...) are performed
using this player's game profile.
This allows turtles to work correctly with various permissions mods.
Previously you would have to whitelist all turtles in order for them to
function within a claim.
This means one can call .getFamily() in a thread-safe manner, ensuring
turtle.getFuelLimit() does not cause issues. As we use a specialist
TE class for each family this does not require any specialist caching.
This adds several commands which may be useful for server owners. It'd
be nice to integrate this into ComputerCraft itself, but the associated
command framework is quite large so we'd have to think about it.
This migrates TurtleMultiModel's current vertex transformation system
into something more powerful and "correct". Namely, it has the following
improvements:
- Handles all position formats (float, byte, etc...)
- Correctly translates normals of quads
- Reorders faces if the winding order is reversed
ILuaAPI has been moved to dan200.computercraft.api.lua. One creates
a new API by registering an instance of ILuaAPIFactory. This takes an
instance of IComputerSystem and returns such an API.
IComputerSystem is an extension of IComputerAccess, with methods to
access additional information about the the computer, such as its label
and filesystem.
- ComputerThread constructs multiple threads instead of just one,
depending on a config options.
- The synchronized blocks of PeripheralAPI.PeripheralWrapper have been
shifted a little to ensure no deadlocks occur.
Whilst I'm pretty sure this is safe for general use, I'm disabling this
by default for now. I may consider enabling it in the future if no
issues are found.
This uses Netty's websocket functionality, meaning we do not have to
depend on another library.
As websockets do not fit neatly into the standard polling socket model,
the API is significantly more event based than CCTweaks's. One uses
http.websocket to connect, which will wait until a connection is
established and then returns the connection object (an async variant is
available).
Once you have a websocket object, you can use .send(msg) to transmit a
message. Incoming messages will fire a "websocket_message" event, with
the URL and content as arguments. A convenience method (.receive())
exists to aid waiting for valid messages.
- Ensure pocket computers and turtles are distinguished by upgrades and
computer family.
- Ensure disks are distinguished by colour.
- Hide treasure disks from the list
This splits the computer state (blinking, label, etc...) and terminal
state into two separate packets. When a computer changes, the computer
state is sent to all players and the terminal state is sent to players
who are curerntly using the computer.
This reduces network usage by a substantial amount.
When printing on top of an already printed page, the previous contents
should be preserved. However, this did not occur as the stack had been
shrunk and so the item was no longer considered a printout.
ClosesSquidDev-CC/ComputerCraft#2
- Cable and modem can be broken individually
- Ray tracing will go through "holes" in the cable.
- Pick block will determine which part you are looking at.
- Selection box will only highlight the region you are looking at:
modem or cable.
We know turtle can't be null in any of these places, since in preceding code,
we called methods on it, so we would have gotten a NullPointerException then
and never gotten here if it were null.
This meant one could perform various illogical actions to
non-full-blocks, such as connecting fences and placing paitings.
We also modify the behaviour of isOpaqueCube and isFullCube for
peripherals, only returning false for the case of modems and cables.
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.
Breaking a disk drive was not stopping the record being played as the
block event never reached the client. Instead, we send a custom packet
which starts/stops music at a given location.
We also remove all the plumbing for eventReceived/sendBlockEvent from
the generic block/tile classes, as they are no longer used.
Closes#443
This makes a couple of significant changes to the original system, to
reduce the number of threads created and allow for multiple threads in
the future. There are several notable changes from the original
implementation:
- A blocking queue is used for the main task queue queue. This removes
the need for the "monitor" variable and allows for multiple threads
polling this queue in the future.
- The thread used to execute tasks is "cached" between tasks,
significantly reducing the number of threads which need to be
created. If a task needs to be stopped then the thread is then
terminated and a new one constructed, though this rarely happens.
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.
- Path containing '/' or '\' are resolved relative to the current
directory, rather than using the path. Paths starting with '/' still
resolve relative to the root directory.
- Shell completion will also include sub-directories of the current
directory.
Closes#219
Changes all equal or longer then 3 multidots setups to be treated as .
This removes other potentialy dangerus situations and brings it closer to windows in how it treats said dots.
If fs.open() failed, it will return nil and a a error message like "No such file" or "Out of space". This PR make, that io.open() returned this error too.
- Convert most recipes to JSON
- Add JSON factories for impostor and turtle recipes.
- Several mappings changes
- Migrate to Forge's new registry system
While the check (most likely) wouldn't break anything, it's better to fix it and not worry then to not fix it and find out it breaks image loading. Also fixes how files are loaded.
- textutils.serializeJSON now takes a table/string/number/boolean instead of just a string as the t argument, and checks for nil in the tNBTStyle argument, so the parameter becomes optional again, as described in the wiki.
- textutils.slowWrite and textutils.slowPrint now checks if the rate
parameter is a number, if not nil.
Computer now delegates to IComputerEnvironment which, by default, looks
in the following locations:
- Resouce pack files
- The "debug" folder
- The original ComputerCraft jar
- Adds a 1px margin around every glyph. This is generally empty,
with the exception of teletext characters where it continues their
pattern.
- Uses GL_CLAMP with the font texture.
Closes#300
edit currently deletes the previous 4 spaces when pressing backspace,
wherever you are on the line. This can be frustrating when you are
trying to align text in comments or strings.
This changes edit to only delete 4 spaces if all preceding characters
are whitespace, otherwise it only deletes a single character.
Attempting to use pastebin with plain HTTP results in a 301 redirect to the HTTPS version. This PR (and associated commit) makes the pastebin command work again.
Reduces amount of string operations and write calls inside writeHighlighted function by switching it to blit and using the 3rd argument in string.match.
Remove drawPixelInternal / drawLineHorizontal. At runtime they're both just excess calls.
Localise high-use term functions.
Arg-related function errors reflect that "colour" parameter is optional.
Add saveImage(tImage, sPath).
Use term.blit for images.
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.
This makes use of new pocket computer light access peripherals have and adds said functionality to speaker. If noisy pocket has made sound the pocket computer light will turn dark blue for a second.
- 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.
This uses a new utility class ArgumentHelper, which provides convenience
methods for parsing arguments from an array of Objects.
The format of error messages has also changed. It now follows a format
similar to Lua's native error messages - including the invalid argument
index, the expected type and the type actually received.