Commit Graph

224 Commits

Author SHA1 Message Date
Christopher Head 6d79272ed4
Implement VoxelManipulator-based transactions.
Rather than calling out through the Lua-to-C API for each node that
needs to be read or written, a group of map reads (and optionally
writes) can be grouped into a transaction. Access to map data within the
transaction is provided at high speed by means of VoxelManipulators.
Once the reads and writes are finished, the transaction can be committed
or aborted.
2016-08-24 00:42:38 -07:00
Christopher Head 564cee346a
Use VoxelManipulators for get_node_force.
A VoxelManipulator, when asked to read a mapblock, in addition to making
that mapblock available to the caller, also pulls it into the server’s
map cache, thus making get_node calls in the immediate future succeed.

This has the dual advantages that not every mapblock containing a
Mesecons circuit need remain loaded at all times (rather mapblocks can
be loaded on demand as signals are sent), and that the server need not
bother running ABMs and ticking entities within those mapblocks that are
loaded due to Mesecons signalling.
2016-08-24 00:41:47 -07:00
Carter Kolwey 912f17f335 Split wires into their own mod, introduce autoconnect hooks
The update_autoconnect function had to be abstracted away from the
default wires, any kind of wire can now register autoconnect hooks,
which should make having multiple different wire types much easier.

mesecons_mvps, mesecons_receiver and mesecons_random made use of
update_autoconnect, their code was also adapted. This also fixes a
receiver bug: If a receiver was placed with a onstate receptor next
to it (but not the wall lever / button that caused the receiver to
appear) the receiver didn't turn on in the past.

Also move documentation for mesecon wire into mesecons_wire.
2016-08-23 11:08:53 +02:00
Carter Kolwey 4816dee396 Move shared textures into base mod (fixes a few LuaC issues) 2016-08-23 11:02:12 +02:00
Jeija 778ee427f4 Fix bug introduced in previous commit that broke all logic blocks
turnon / turnoff were calling activate / deactivate on nodes even though
their rules didn't link

Fixes #278, thanks to @darkfeels
2016-07-31 22:26:33 +02:00
Jeija 7c7595fd7d Fix #276: Fix bugs in block forceloading in turnon / turnoff
Thanks to @Hawk777 for reporting this problem
2016-07-25 10:01:43 +02:00
Carter Kolwey acd41b5773 Don't bother checking if a node can overheat before cooling it 2016-07-09 11:17:08 +02:00
Samuel Sieb 4b9039266e Fix crash due to force loading changes. 2016-02-22 15:47:18 -08:00
Jeija c7428d8135 Remove unused VERSION file
and remove debug output
2016-02-19 12:20:52 +01:00
Jeija cfd4f7c287 Force-load areas with mesecon usage
This is a major speedup for large mesecon machines / structures.
Force-loaded areas are stored in a file to be persistent over server
reboots. By default, areas are unloaded after 10 minutes (600s) without
usage, this can be customized with the mesecon.forceload_timeout
setting. Please turn max_forceloaded_blocks up for better performance.
2016-02-19 12:11:38 +01:00
Jeija 7b84105512 Consistently use UNIX line endings (LF instead of CR LF) 2016-02-15 23:05:21 +01:00
Jeija 7865d42834 Always use minetest.set_node instead of minetest.add_node for consistency 2016-02-14 21:00:37 +01:00
Jeija 809192f353 Use vector helper functions instead of old builtin cmpPos and addPosRule functions 2016-02-14 20:55:50 +01:00
Jeija 0ec771bf7d Major change: Documentation is now included with mesecons, the website just extracts the documentation in a more readable format
This makes development of new features easier, as documentation can automatically be updated on the website without modifying the website's code!
Every mod that has nodes in the mesecons modpack has a "doc" folder that contains subfolders with recipe, description and preview of the block. The website will discover which documentation is available
by reading the documentation.json file.
2015-11-20 20:14:50 +01:00
Jeija 97f7b5745f Remove trailing whitespace 2015-10-04 13:30:34 +02:00
Jeija 24958e253b Revert "Do not send action_off signal when newly placing nodes"
This caused #238, reverting that commit fixes #238.

This reverts commit 30468b09cf.
2015-10-04 12:30:04 +02:00
Jeija d0354d0dab Fix #234 2015-07-27 11:51:02 +02:00
Phil Hagelberg 52ea2c3c66 Don't refer to LIGHT_MAX global; use default.
The LIGHT_MAX global is created in the legacy.lua file in the default
mod; it states that it's there for backwards compatibility, but it would
be better to reference the proper value inside the default table.
2015-05-11 11:28:56 +07:00
Jeija a6d0a523ba Add support for sticky blocks for pistons and a a sample sticky block 2015-02-28 13:42:39 +01:00
Jeija 30468b09cf Do not send action_off signal when newly placing nodes, this didn't
cause any bugs, but unneccessary sounds (experimental change)
2015-02-03 20:07:58 +01:00
Jeija dca4706c7f Fix #197, doesn't remove the legacy code that triggered it though 2015-01-03 10:12:12 +01:00
Jeija 011543a782 Fix #196, removes soft-depend on commonlib 2014-12-20 10:11:12 +01:00
Jeija c326dc221a Rewrite Logic Gates: Makes it super-easy to add new gates and cleans up code
Fix bugs in the Luacontroller (when placing, false input pin values were given) and fix variables
leaking into the global environment in pistons.
2014-11-29 15:08:37 +01:00
Jeija d2373eb605 Don't trigger an "off" event to itself when luacontroller turns a port off
I hope this doesn't break anyone's setup.
2014-11-29 10:56:09 +01:00
Jeija 4bd9d2a9ec Merge branch 'improve-luacontroller'
However, without the print_count limiting functionality

Conflicts:
	mesecons_luacontroller/init.lua
2014-11-25 17:36:52 +01:00
Jeija fb695e9c1c Fix #189, clean code and update documentation 2014-11-23 09:43:24 +01:00
Jeija fc4d675b84 Fix crafting with the default mesecon wire 2014-11-22 23:20:29 +01:00
Jeija 0e3aa57ed3 Merge branch 'improve-luacontroller' of https://github.com/ShadowNinja/minetest-mod-mesecons into ShadowNinja-improve-luacontroller
Conflicts:
	mesecons/legacy.lua
	mesecons_luacontroller/init.lua
	mesecons_microcontroller/init.lua
2014-11-22 23:04:34 +01:00
Jeija f977ac821a Re-implement settings system:
Settings can now be retrieved by mesecon.setting(<name>, <default>) and can be modified without
editing the source code by adding the setting to minetest.conf
For instance, you can add mesecon.blinky_plant_interval = 0.5 to minetest.conf in order to
increase the blinking speed.
Rewrite the blinky plant with nodetimers.
Fixes #161
2014-11-22 22:09:26 +01:00
Jeija 80d136125e Fix bug in mesecon.find_receptor that caused false turnoffs and rewrite lever +
switch
2014-11-22 20:49:54 +01:00
Jeija a550323fea Fix compatibility with not yet updated mods that use mesecon:receptor_* 2014-11-22 20:05:36 +01:00
Jeija d19e975955 Use iterative algorithm for mesecon.find_receptor_on, major performance improvement for large
circuits.
This also fixes a crash introduced with the previous commit that occured when placing a wire
crossing.
2014-11-22 17:12:48 +01:00
Jeija 29dc50057c Fix bug in mesecon.mergetable that caused false rules 2014-11-22 16:00:49 +01:00
Jeija 5be179bf11 Replace mesecon:<some_function> with mesecon.<some_function> for greater
flexibility and because it was never inteded to be OOP in the first
place.

mesecon.receptor_on and mesecon.receptor_off are provided by wrappers
(mesecon:receptor_on/off) for compatibility, but will be removed. Mod
programmers that use mesecons: Please update!

Also, fix microcontroller polluting the global namespace and remove some
deprecated stuff.
2014-11-22 15:42:22 +01:00
Jeija ffacbfde5a Use an iterative algorithm for turnon() and turnoff(), fixes #160
This may also bring some performance benefit.
2014-11-22 14:47:18 +01:00
Jeija b5cc933287 Pressure plates and the object detector will send power to vertical
wires 2 nodes below them, allows to hide circuitry powered by them.
Fixes #179
Rewrite pressure plates + vertical wires using mesecon.register_node.
2014-11-22 12:30:39 +01:00
Jeija 194155fff8 Rewrite mesecon wires. This should increase the efficiency and speed of
large machines.

It also makes the wires.lua code easier to understand and more
maintainable. In case any other mod depends on
mesecon:update_autoconnect, please update it to use
mesecon.update_autoconnect. This should also fix some other minor bugs.
Please report bugs if this commit creates new ones.

This commit changes wire looks and removes some unneccesary textures.
2014-11-22 11:40:58 +01:00
Jeija 1b9f1b8c13 Fix #182, bug when placing wire crossings next to a powered source
In case this fix creates new bugs, please report them.
2014-11-21 22:05:35 +01:00
Jeija dcf1f799c5 Fix #184, Fix #186, Fix #187
Just some minor issues like dead code.
2014-11-21 21:43:28 +01:00
ShadowNinja bd1766e448 Improve the LuaController
Changes:
  * Stops code after a certain number of instructions.
  * Allows functions, due to instruction counting.
  * Allows loops and goto with non-JIT Lua (LuaJIT doesn't count looping as an instruction, allowing infinite loops), due to instruction counting.
  * Removes string matching functions as they can be slow.
  * Adds some safe functions.
  * Limits the amount of printing that can be done (to prevent console flooding).
  * Code cleanup.
  * More...
2014-10-07 17:09:25 -04:00
Jeija e5896076fe Make sure #160 cannot be exploited to make servers crash.
This is not exactly a fix for the issue, because extremely
large circuits (3000+ conductors) still won't work with this applied.
This simply aborts any execution if there is the danger of a stack overflow.
2014-06-01 11:00:39 +02:00
Jeija 300abcb587 Fix #155 (option 2 used). Remove non-ActionQueue system. Enable overheat for more than 20 actions per second on lua- / microcontrollers and gates.
Fix a bug where a burnt luacontroller didn't have the correct pin-states as the burnt controller does not register any changes from outside.
2014-04-20 21:51:17 +02:00
Jeija 1852e967a9 Send changesignals for placed receptors when not powered, make on_placenode code more readable
with comments. Also fixes a bug of lua- / microcontrollers not being updated when pushed by a
piston.
This could cause some bugs, even though I haven't found any while testing as it is a very core part of mesecons.
2014-03-21 21:31:34 +01:00
Jeija 2cab6aa5ef Merge pull request #134 from Novatux/master
Fix a few bugs that caused effectors not to turn off sometimes
2014-03-20 09:28:03 +01:00
Jeija 37405e5a06 Fix #146 2014-03-19 15:13:23 +01:00
Jeija df6829e553 Remove timer() from LuaController and make interrupt() use the ActionQueue so that it will keep working when restarting the server 2014-03-19 10:20:43 +01:00
Jeija 8a71f51b26 Merge branch 'actionqueue'
This introduces the ActionQueue, a new kind of MESECONS_GLOBALSTEP.
Circuits using delayers will now resume when restarting the server.
Also, large circuits should automatically resume if parts of them are
in unloaded chunks.
Old circuits e.g. using gates will not resume when mesecons is updated,
which means you have to restart them once. But after that, it should work
just like it used to.
This will fix a lot of stuff but may also introduce some new bugs.
So please report them!
2014-01-19 13:59:22 +01:00
Jeija a632a8abc8 Fix delayers and disable resuming if not using MESECONS_GLOBALSTEP 2014-01-19 13:57:11 +01:00
Jeija a6bd955449 Merge pull request #144 from Novatux/gates-fix
Fix gates with serverstep code.
Let's give that a try.
2014-01-11 23:17:14 -08:00
Novatux fe50e87da1 Make receptor_on/off overwritable, fix a serious bug. 2014-01-11 20:12:22 +01:00
Jeija c8ef37f522 Actionqueue tweaks 2014-01-11 20:11:54 +01:00
Jeija 1a492feb7a Turnon/turnoff overwritable 2014-01-11 18:31:30 +01:00
Jeija d066b91632 Fix infinite priority bug in mesecon:turnoff, thanks to Novatux 2014-01-11 16:48:25 +01:00
Jeija 1083539e9b Resume turnon/off calls as soon as area is loaded in case turnon/off calls end in unloaded territory 2014-01-11 16:46:27 +01:00
Jeija 6afded8284 Fix unloaded area in receptor_off, yet it was only fixed in receptor_on 2014-01-11 16:18:35 +01:00
Jeija ff5e315325 Fix ActionQueue delays 2014-01-11 15:36:30 +01:00
Jeija f1211f7dae Add ActionQueue priority system
This makes effectors nearer to the source of the action (the receptor) update first.

This defines behaviour for this piston circuit: http://i.imgur.com/9Pp2Mzb.png
And defines, that this memory circuit does not work from this direction: http://i.imgur.com/jJn0aFh.png
But it will work when using the switch from the other side: http://i.imgur.com/nvw0oZB.png

Only if two effectors have the same distance, there is nothing we can do about it, behaviour is not defined.
"Distance" is determined by the stack size of recursions in turnon / turnoff.
Priorities are between 0 (lowest) and 1 (highest).
2014-01-11 14:57:56 +01:00
Jeija 93fb489bdb Fix the bugs spotted by Novatux - thanks for spotting them 2014-01-11 08:57:21 +01:00
Novatux f1ae54ed12 Try to fix gateswith serverstep code. 2014-01-11 07:24:42 +01:00
Jeija 2d004b19ea First draft of some kind of Action Queue (just like the globalstep queue in to_update), but more flexible and also including delay functionality (mesecon_delayer).
The queue is also saved to a file, so that when restarting mesecons, delayers resume to the state they had when the game shut down. Needs testing.
2014-01-10 22:33:40 +01:00
ShadowNinja de6dd30745 Move textures into their mods 2014-01-10 13:13:02 -05:00
Novatux 5e02b3beef Fix a few bugs that caused effectors not to turn off sometimes (rules_link is evil!) 2014-01-05 13:51:09 +01:00
Novatux 9c2a5c313c Use swap_node instead of add_node when replacing conductors. 2014-01-05 09:52:06 +01:00
Novatux fb417d45a7 Fix when there are several rules with different specials 2014-01-04 17:22:04 +01:00
Novatux b3f3692622 Fix crash if metarule not found 2014-01-04 16:51:52 +01:00
Novatux ae557d1cd4 Fixes with multi-conductors that have special connects 2014-01-04 15:52:52 +01:00
Novatux d5b39951a4 Fix bugs with multi-rules conductors (like crossing) that have param2 2014-01-04 14:15:41 +01:00
Uberi 16b4b79c51 Update code to standards of Minetest 0.4.8. 2013-11-30 22:13:00 -05:00
Uberi b4654cedb7 Compat shim for minetest.swap_node, lightstone conducts from the bottom. 2013-11-30 21:23:58 -05:00
Vanessa Ezekowitz f46bc329de Use minetest.swap_node() instead of mesecons' version, Minor code changes
here and there to facilitate this.
2013-11-30 20:34:55 -05:00
khonkhortisan 913e355a71 Merge pull request #112 from khonkhortisan/multi_rules
Multi rules
Merged for near-future textures to be merged cleanly.
2013-08-27 22:22:30 -07:00
Anthony Zhang 96011bc718 Audit code for possible nil value indexing with unregistered nodes. 2013-06-22 15:43:58 -04:00
khonkhortisan 885899cbaf Crossover 2013-06-20 09:30:26 -07:00
khonkhortisan 4f2604e01b mesecon:rules_link nil return rule
Fixes https://github.com/Jeija/minetest-mod-mesecons/issues/108
2013-06-10 18:29:40 -07:00
Novatux afad592783 Change mesecons signals so that they update effectors only after a globalstep, configurable to be on/off 2013-06-05 15:37:55 -04:00
Novatux edc10dac47 Add an ABM function which resets heat to 0, since gates/controllers won't be cooled normally if they are moved (piston, etc...) during the cooling delay. 2013-06-05 06:45:19 +02:00
RealBadAngel 255e363b04 Fix all crafting recipes to use modern style 2013-04-28 12:40:08 +02:00
Anthony Zhang 10bacdd7f4 Update selection boxes to make building easier. 2013-04-20 11:25:12 -04:00
Anthony Zhang 3b1afb1783 Fix invalid node name if node was changed in after_place_node callback (fixes #93). 2013-04-14 13:54:33 -04:00
Jeija 57e1547515 Make pistons and movestones move objects (push only yet) 2013-04-02 11:57:28 +02:00
Anthony Zhang 5f9e655c13 Add MOVESTONE_MAXIMUM_PUSH setting. 2013-03-15 19:53:09 -04:00
Jeija 10ea3c971b Merge branch 'master' into luacontroller 2013-02-11 08:03:08 +01:00
Anthony Zhang 5b5e919683 Make load times faster by avoiding inventorycube and wielditem creation in technical blocks such as active wires and various piston orientations. 2013-02-08 14:36:20 -05:00
Jeija ef087f2bb6 Fix Bug: Wrong usage of action_on/action_off instead of action_change 2013-01-19 23:37:03 +01:00
Jeija 841bc70b97 Fix a bug that occured when using a receptor placed directly next to a
gate.
We need to call a changesignal even if the gate/other effector is still
connected to a power source in a way.
2013-01-09 16:56:25 +01:00
Jeija ec07fc27d7 Merge branch 'nextgen'
Conflicts:
	mesecons/wires.lua
2012-12-31 18:32:46 +01:00
Vanessa Ezekowitz 5921f6d46c made tweaks to the way mese is converted to mesecons. If old mese paradigm is
in use, one default:mese crafts to 18 mesecons wires.  If new paradigm is in
use, cook one mese crystal fragment to get 2 wires, or cook one mese crystal to
get 18, or cook one mese block to get 162.  Avoids conflict with new default
recipe that crafts 9 crystals from one mese block.
2012-12-28 16:51:11 -05:00
Jeija 7e231b99a6 Make nr in rules rotation local in order not to pullute the holy global namespace 2012-12-28 07:33:16 +01:00
Jeija ac0fb91139 Minor cleanup of mesecno torch and add another rule to it (behind above) 2012-12-27 10:50:20 +01:00
Jeija 7fe4947056 Bugfix foes for pistons, delayyrs, gates and microcontrollers. Rework delayers. 2012-12-27 09:28:04 +01:00
Jeija d91e0b66cb Re-write pistons from scratch, propably fixes a lot of bugs and doesn't cause too many new ones. 2012-12-26 22:54:28 +01:00
Jeija 973a9c650f Add new crafting recipe for mesecons: Cook a mese crystal 2012-12-21 16:19:38 +01:00
Jeija 313b9adcd5 Should fix this bug: bit.ly/XEy94j 2012-12-18 15:59:23 +01:00
Jeija 5fb5df446c Bugfix, use param2 for conductors when turning them on/off 2012-12-15 21:23:38 +01:00
Jeija c0d3bd2abb Include experimental vertical wires (needs textures) 2012-12-13 18:42:45 +01:00
Jeija 23bebfc054 Merge branch 'master' into nextgen
Conflicts:
	mesecons/internal.lua
	mesecons/wires.lua
	mesecons_pistons/init.lua
2012-12-21 16:22:25 +01:00
Jeija 9019a4aff7 Bugfix, wires sometimes turned off for no reason 2012-12-21 16:04:19 +01:00
Jeija 6b1bfe6391 Add rule-name system. Every input rule can now have a name, that could help e.g. the microcontroller to know where a signal comes from. 2012-12-19 17:34:05 +01:00
Jeija 2c4a46a557 Minor cleanup, use addPosRule 2012-12-16 16:29:03 +01:00
Jeija c76c274cc0 Remove mesecons:updatenode 2012-12-16 12:00:11 +01:00