3929 Commits

Author SHA1 Message Date
Florian Nücke
a7d21190be r-tree for wireless networks; type in time formatter; label abstraction for more flexible label editing (e.g. for computercraft disks); allow mounting computercraft disks in disk drive; dependencies on mods for apis 2013-11-09 20:56:21 +01:00
Florian Nücke
1c34cdbe67 sending wireless network messages now costs power based on the used signal strength and range per power is configurable, as is the power buffer size of wireless network cards 2013-11-08 20:45:31 +01:00
Florian Nücke
35d8e07fc4 computer no longer uses power based on cpu time, since this caused massive power spikes when loading (and possible when the world lagged a lot), because the worker thread runs on low priority and could therefore be stalled by the host os for a while if something else takes priority; managed item environments now get their container passed along (usually the tile entity with the inventory they reside in), used by redstone card from now on to determine the block to read/write from/to (instead of the message sender, which should always be that same block, but it's clearer like this). also used for the new wireless network cards so they know where they are; added wireless network cards. they act as an upgrade to normal network cards, i.e. they still send "normal" network messages in addition to looking for receivers in range. the signal strength for sending can be adjusted via the api, the higher the further we look for receivers, but the more power it will cost (this isn't in, yet). in addition we sample a few blocks between sender and receiver to check if the signal may have been blocked. 2013-11-08 19:19:57 +01:00
Florian Nücke
bccee0c5a0 added basic "ownership" implementation: computers now have a list of users, and only users can perform direct operations on the computer, such as typing, changing the inventory and breaking the computer block. this does not apply to operators or in single player mode; added a new network message for computers computer.checked_signal, which expects an EntityPlayer as the first parameter and checks if the player is a user before pushing the signal. used by the keyboard for now; finally added custom implementation of 'mergeItemStack' that properly respects a slot's item validity (Slot.isItemValid) so shift clicking now inserts components into the right slots for computers; some small changes to Lua shell lib; added -b option to redstone Lua program to allow reading/setting bundled input and output; added programs to manage users from the shell 2013-11-08 14:08:01 +01:00
Florian Nücke
9098d00cac moved key tracking to keyboard companion object 2013-11-07 17:53:52 +01:00
Florian Nücke
99488799e9 tracking pressed keys on server to send key up signals when a player disconnects / changes dimension / dies 2013-11-07 17:50:51 +01:00
Florian Nücke
2a48cb28d9 fixed timers firing continuously after setting the time to a future date; fixed date stuff after realizing /time set sets world time absolutely (too used to nei by far...); added proper os.date implementation; 2013-11-07 17:02:25 +01:00
Florian Nücke
eb3a8e1ff8 added bundled redstone support, only support for immibis' RedLogic mod for now 2013-11-07 03:30:17 +01:00
Florian Nücke
bb7684acb7 cleaned up included apis some, removing all the unnecessary interfaces; made carriage component completely async; reworked state logic in computer some, probably broke something along the way; made startup delay after loading a setting; 2013-11-07 00:25:46 +01:00
Florian Nücke
ce69b1c7dd removed some unnecessary api stuff and unused jnlua classes 2013-11-05 19:25:46 +01:00
Florian Nücke
8395814e36 added @Optional for ic2, bc and cc interfaces 2013-11-05 19:08:54 +01:00
Florian Nücke
e9bc0888bc upgraded forge version and added API annotation to api package 2013-11-05 15:50:58 +01:00
Florian Nücke
59ab8767a2 minor cleanup 2013-11-05 14:00:54 +01:00
Florian Nücke
2a2785e077 cleaned up RIM reflection into a helper singleton; cleaned up and extended RIM component a bit; extended arguments class with type testing methods; documented arguments class; linearly increasing screen buffer size per tier (copy would fail for advanced screens...) 2013-11-05 13:23:11 +01:00
Florian Nücke
43d9365c17 renamed LuaCallback.asynchronous to LuaCallback.direct 2013-11-05 03:00:51 +01:00
Florian Nücke
7d907fdccc checking direction validity in carriage.move synchronously 2013-11-05 02:56:23 +01:00
Florian Nücke
ed458f9bbb added driver for RIM's carriage controller block and fixed some issues with blocks being moved 2013-11-05 02:32:10 +01:00
Florian Nücke
e99eebf6fb fixed lighting bug in dynamic inventory renderer 2013-11-04 21:05:20 +01:00
Florian Nücke
ab785eb3ac forbid access to string metatable for sandbox; minor restructuring of libraries (mostly sorting by name); saving managed environments attached to an adapter. this is not very reliable, sadly, since there are way too many ways neighbors can change outside our control (chunks only partially loaded, types removed across games due to other mod changes, mods that move blocks such as RIM, ...); making some effort to re-attach peripherals using their previous address; removed connection code on chunk load in network manager, since this is also handled by the check in the tile entities' update function 2013-11-04 20:53:31 +01:00
Florian Nücke
fcdb75e4bc rudimentary driver for computercraft peripherals: it emulates a computer that is the whole network and does not provide a lua context which may cause nullpointers. good enough to allow accessing cc disk drives and read/write floppies in them. 2013-11-04 17:49:42 +01:00
Florian Nücke
3c6d3f3b58 less nullpointers in buildcraft power logic; handling weird cases where the computer may not have run yet but we have to recompute the amount of memory and there is no ram; removed dead rotation logic from block activate, all handled via rotateblock; fixed computers possibly stopping after loading due to bad sleep value 2013-11-04 15:16:10 +01:00
Florian Nücke
1b5719347e made all the power stuff configurable; working around power spikes when loading computer blocks (waiting for world to settle for a second before continuing execution) 2013-11-04 13:53:43 +01:00
Florian Nücke
49ced36d5f computers need power to run (base level + elapsed cpu time); screens need power to change their display, different costs per operation, depends on number of 'pixels' changed; fixed distributors not balancing buffers if attached to existing network without distributor 2013-11-04 13:27:05 +01:00
Florian Nücke
301cec06d6 fixed adapter's network functionality. tested with latest CC and now it actually works. what a surprise. 2013-11-04 05:27:59 +01:00
Florian Nücke
59c953ec00 initializing network connections in tile entities' update function now (i.e. we call Network.joinOrCreateNetwork from there if we have a node and that node isn't in a network yet). this is because on block added is somewhat unreliable, in particular when other mods start getting involved - say, RIM. which is what I tested with right now, and it actually works, i.e. computers can be moved by carriages and keep running without fail. huzzah; also removed weak keys from screen renderer cache, the timeout is enough 2013-11-04 04:52:01 +01:00
Florian Nücke
60447a090e localizations for power supply 2013-11-04 02:23:40 +01:00
Florian Nücke
666ab55bb3 fixed rendering with multiple distributors in a single network 2013-11-04 02:21:52 +01:00
Florian Nücke
fd67e2457c added a simple power supply that generates power out of thin air for testing 2013-11-04 02:04:32 +01:00
Florian Nücke
f4641d59e8 better check for whether power redistribution is needed and reduced number of network packets generated for synchronizing average buffer fill (used for display, brightness of overlay on distributor) 2013-11-04 01:44:15 +01:00
Florian Nücke
521613f3f8 added option to make power optional; made it so that node creation is impossible for clients, since nodes are exclusively meant for server logic, this makes this more clear; underped buffer re-balancing computation and added check to stop if delta gets small 2013-11-04 01:33:29 +01:00
Florian Nücke
e420b0f8a2 moved node name from node to component, since that's where it belongs 2013-11-04 00:39:35 +01:00
Florian Nücke
734b1bd43f made the node factory stuff nicer to use. the backing code has become somewhat ugly, but that's just java's fault so whatever. it is now possible to write something along the lines of api.Network.newNode(host, name, visibility).withComponent().withConnector(bufferSize).create(), which reads pretty nicely; power is back, but with a few changes. for one, the "running cost" is gone, since that was really just confusing, and would have resulted in frequent updates once the buffers are full/empty anyway (once because we'd have to check whether to fill up or not, once to check if we have enough power or not). it's just much more intuitive to just have a buffer per powered entity that can be filled/emptied as needed. also, there's no differentiation between consumers and producers anymore. producers just fill up their buffers, while consumers empty their buffers. the power distributor now simply takes care of balancing the amount of energy in all buffers connected to the same network it is connected to. multiple distributors don't need any special logic this way, either, since the first one to update simply marks all processed buffers as clean (if they were dirty due to changes); renamed PowerSupply to PowerConverter 2013-11-04 00:26:56 +01:00
Florian Nücke
f9e6439704 using default pcall and xpcall again in sandbox, using a trick seen in corowatch (setting hook count to 1 on timeout) 2013-11-01 22:30:36 +01:00
Florian Nücke
d92257dde3 fixed network messaging; pulled persist logic completely to the scala side, doing away with the boot lua script; 2013-11-01 19:56:35 +01:00
Florian Nücke
5aad6d61cf cleaned up component visibility updating; some fixes 2013-11-01 04:30:07 +01:00
Florian Nücke
12081e5b31 some more "shortcut" functions in node interface, allows writing node.blah(..) instead of node.network.blah(node, ...), which, since normally a node reference is held, was way too common. 2013-11-01 02:01:14 +01:00
Florian Nücke
730c8f0ea4 restructuring network a bit, using messages more for "event like" stuff, thus removing the return values and simplifying the network manager in general quite a bit; removed "system messages", the manager now directly calls onConnect/onDisconnect in the nodes' environment, and said functions take now the relevant node as a parameter; component invoke is now directly called via component interface, not as a message anymore; stuff, i guess 2013-11-01 01:12:55 +01:00
Florian Nücke
fe446e9389 fixed nullpointer in disconnect of powered down computers; fixed components with a visibility lower than their reachability not being added to the list of visible components in a computer 2013-10-30 00:50:13 +01:00
Florian Nücke
d886527557 renamed event.wait to event.pull; removed event.fire, instead allowing generating/queuing signals from the Lua side, adding os.pushSignal and renaming os.signal to os.pullSignal. pullSignal now has no filtering capabilities, only a timeout, all filtering is done via event.pull 2013-10-29 23:49:28 +01:00
Florian Nücke
1fd375f17f screw it, events are now global, i.e. they will *not* automatically be cleaned up when the program that registered them dies. instead, resort to event pulling for most cases, the nice filtering in event.wait should make that feasible for most scenarios; on the upside, waits can now be canceled (customizable via event.shouldInterrupt, queried each time os.signal returns to event.wait, defaults to ctr+alt+c being pressed), event.wait will throw an "interrupted" error in that case. this means os.sleep is also interruptable since it just calls event.wait; also updated eris to latest version 2013-10-29 22:43:42 +01:00
Florian Nücke
d52a0995c5 less derpy environment "sandboxing" for shell.execute, instead tracking events per thread now, and removing those of dead threads; thus, programs are now run in their own coroutines, which also allows emulation of cc's yield behavior (pulling events = signals); no label = null instead of empty string now 2013-10-28 23:18:14 +01:00
Florian Nücke
7cf9fadd88 allow settings fs label on construction and added read-only flag (used to forbid label change on ro systems); forbid setting label on volatile systems (in particular tmpfs); added program to manipulate fs labels; added program to display disk usage 2013-10-28 15:16:55 +01:00
Florian Nücke
c51d55172f cleaned up lua stuff a bit; split off unicode stuff into extra table; some fixes (fs.exists for non-existent virtual objects, less program, other stuff i forgot); added mount and umount programs 2013-10-28 12:36:10 +01:00
Florian Nücke
30c2682105 cleaned up LuaCallbacks a bit, passing a context and argument wrapper instead of the message itself now 2013-10-27 16:23:54 +01:00
Florian Nücke
78a426c4fe metric ton of fixes. somehow the number of touches files feels too low... anyway, also added option to LuaCallback annotation to mark callbacks as asynchronous (meaning they will be called directly from the executor thread) and synchronized the sh*t out of the network manager in the hopes that not all will crumble to pieces due to sending messages around while someone meddles with the network (program calls sth while player places/breaks block e.g.); oh, and we now take the memory baseline after loading the libs, meaning 32k is enough to run a computer again. also, loading libs is done asynchronously now, since it's loaded from the rom and nobody else should be able to access that anyway, meaning fast boot-times; command line program to manipulate redstone output and read input 2013-10-27 15:06:21 +01:00
Florian Nücke
a7ec5c0ec0 things are slowly beginning to work again... it's still all a big mess, though 2013-10-27 05:33:33 +01:00
Florian Nücke
af286d17fa on the ever so painful path to refactoring the api... making nodes black boxes to be created via a factory and providing previous functionality to their "environment" (owning object) via other callbacks and stuff; pretty much *nothing* is working right now, yay! 2013-10-27 01:37:34 +02:00
Florian Nücke
24228a225a prepping for more api->java 2013-10-25 13:09:45 +02:00
Florian Nücke
c231f61ab5 javaified a lot of the api, which means a lot of the documentation will probably be slightly off now, and there may be new bugs (yay!). also, component networking stuff is slightly more fugly now since a lot of stuff has to be manually boxed. will rework that next, i guess 2013-10-25 02:33:08 +02:00
Florian Nücke
c556f4044e simplified redstone driver (just using the message source as the redstone input/output provider) 2013-10-25 00:47:15 +02:00