206 Commits

Author SHA1 Message Date
7d8fd7a8df Fix issue #135 2014-01-05 19:55:45 +01:00
39361fb719 Merge pull request #133 from Novatux/master
Use swap_node instead of add_node when replacing conductors.
2014-01-05 01:01:53 -08:00
9c2a5c313c Use swap_node instead of add_node when replacing conductors. 2014-01-05 09:52:06 +01:00
fb417d45a7 Fix when there are several rules with different specials 2014-01-04 17:22:04 +01:00
b3f3692622 Fix crash if metarule not found 2014-01-04 16:51:52 +01:00
ae557d1cd4 Fixes with multi-conductors that have special connects 2014-01-04 15:52:52 +01:00
d5b39951a4 Fix bugs with multi-rules conductors (like crossing) that have param2 2014-01-04 14:15:41 +01:00
b0f81a8c62 Add mesecon:register_on_mvps_move, fix mesecon:mvps_pull_all 2014-01-03 11:04:19 +01:00
d9cc1d5aa1 Vertical wire update. 2013-12-18 15:14:03 -05:00
e8d31c3e5a Change field receipt handling to work properly with Minetest 0.4.8. 2013-12-18 14:54:46 -05:00
85f2f3f742 Merge pull request #126 from qwrwed/master
change on_punch to on_rightclick, make disabled blinky plants drop norma...
2013-12-02 10:43:10 -08:00
711c73a197 change on_punch to on_rightclick, make disabled blinky plants drop normal ones 2013-12-02 17:50:00 +00:00
16b4b79c51 Update code to standards of Minetest 0.4.8. 2013-11-30 22:13:00 -05:00
b4654cedb7 Compat shim for minetest.swap_node, lightstone conducts from the bottom. 2013-11-30 21:23:58 -05:00
3105ae7084 Merge branch 'master' of github.com:Jeija/minetest-mod-mesecons 2013-11-30 20:45:38 -05:00
f12206acc6 Remove "disabled" blinkyplant from inventory 2013-11-30 20:45:10 -05:00
f479dd27d5 Fix vertical wire drops. 2013-11-30 20:44:33 -05:00
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
669e3d0880 use 'wood' group for crafting pistons, pressure plates, and noteblocks 2013-11-30 19:07:12 -05:00
2d0ff5e2ac Merge pull request #124 from qwrwed/master
Make blinkyplants toggleable
2013-11-29 14:44:51 -08:00
33de6fad55 Make blinkyplants toggleable 2013-11-29 22:06:50 +00:00
9ab0d9deb2 Update Microcontroller Tutorial and add .odt source for the .pdf 2013-09-08 11:38:01 +02:00
c3082f6601 Add LICENSE.txt
LGPLv3 for code,
CC-BY-SA-3.0 for everything else
This should makes it easier for packagers of distributions
2013-09-07 23:20:17 +02:00
09be8af517 Upgrade CC-BY-SA License to 3.0
Permitted according to section 4b of CC-BY-SA-2.0:
"a later version of this License with the same License Elements as this License"
2013-09-07 23:15:21 +02:00
75ca00f51e Escape microcontroller code in formspec 2013-08-29 14:14:04 -07:00
d0fdefb5a6 Merge pull request #119 from VanessaE/master
Give crossing proper textures
2013-08-27 22:42:21 -07:00
5516ca58e9 Give crossing proper textures 2013-08-28 01:26:00 -04:00
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
96011bc718 Audit code for possible nil value indexing with unregistered nodes. 2013-06-22 15:43:58 -04:00
ec63bd3abf Merge remote-tracking branch 'refs/remotes/origin/master' 2013-06-22 15:39:01 -04:00
d15e3eedb0 Descend µ in comment 2013-06-22 09:11:06 -07:00
885899cbaf Crossover 2013-06-20 09:30:26 -07:00
6efe579f68 Fix pistons not updating the nodes when placing them again. 2013-06-15 19:15:43 +02:00
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
c87bc60635 Support cyclic references in luacontroller memory tables, prohibit usage of goto statement (bugs reported by Nore). 2013-06-10 16:40:34 -04:00
8ea71a9036 Fix bug where functions in Luacontroller EEPROM crashes the server (fixes #107). 2013-06-06 16:38:40 -04:00
367a41416b Fix README a little and add piston sounds by suzenako, contributed by jordan4ibanez. 2013-06-05 16:01:11 -04:00
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
9a9df6cabf Merge pull request #106 from Novatux/heat
Add an ABM function which resets heat to 0, ...
2013-06-05 10:35:36 -07:00
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
fa0cf15cd9 Add yellow lightstone 2013-06-01 11:17:38 +02:00
8be0d0e1d9 A ReadMe that is at least 2.84 times better than the old ones. 2013-05-26 18:40:48 -04:00
f9ce95154e Add license information (requested by kaeza). 2013-05-25 22:59:40 -04:00
24160d45ff Silly mistake, interrupts should work better now. 2013-05-21 17:57:25 -04:00
682cf34792 Add burnt luacontroller (so you don't lose your program after an overheat) and prevent interrupts from piling up (fixes #101, metadata trashing). Idea for burnt luacontroller comes from ShadowNinja. 2013-05-15 21:36:16 -04:00
6f83f4cf1e Merge pull request #100 from RealBadAngel/master
Update crafting recipes - pretty much all of Mesecons recipes still used an old, now deprecated syntax substantially of the form 'node "default:xxxx" 2'  (with two pairs of quotes).  All such recipes have been changed to use the current method, i.e. "default:xxxx 2" (with one pair of quotes encompassing the whole itemstack).
2013-04-28 04:18:37 -07:00
255e363b04 Fix all crafting recipes to use modern style 2013-04-28 12:40:08 +02:00
ac9a05df0b Merge pull request #98 from RealBadAngel/patch-3
Update init.lua
2013-04-28 02:21:05 -07:00
cc20b9ba47 Update init.lua
Remove old style flat inv images
2013-04-28 12:18:52 +03:00
163384f308 Merge remote-tracking branch 'refs/remotes/origin/master' 2013-04-27 16:52:17 -04:00
d4f18d08c0 Avoid prepending "Server -!- " to messages sent using the command block. 2013-04-27 16:51:00 -04:00
9299111900 Merge pull request #97 from RealBadAngel/patch-2
Update README

minetest-c55 --> minetest
2013-04-26 21:46:27 -07:00
13757ac854 Update README 2013-04-27 02:13:42 +03:00
0a9bcf26ca Merge pull request #96 from VanessaE/master
Texture tweaks for vertical wires with caps
2013-04-22 09:50:13 -07:00
b3fb406727 Minor tweak to allow vertical wires with caps to use the "vertical"
texture for the sides (still uses the "full" for the top/bottom of the
caps).
2013-04-21 22:16:17 -04:00
b0bef909a0 Fix pressure plate (onstate) nodebox 2013-04-21 08:16:43 +02:00
fc5245139d Merge pull request #95 from VanessaE/master
Pressure plate texturing tweaks
2013-04-20 23:07:14 -07:00
109d817df6 Make pressure plate texturing more flexible, improve appearance of existing textures 2013-04-21 01:00:31 -04:00
1a5b1b4691 Fix pressure plate wield image. 2013-04-20 21:22:43 -04:00
10bacdd7f4 Update selection boxes to make building easier. 2013-04-20 11:25:12 -04:00
8afc6abcd5 Merge pull request #94 from RealBadAngel/patch-1
Update mesecons_button/init.lua (change craft recipe format, no gameplay change)
2013-04-15 07:19:22 -07:00
e88e99b54f Update init.lua
change crafting recipe format
2013-04-15 09:21:41 +03:00
01d8c26b5b Merge remote-tracking branch 'refs/remotes/origin/master' 2013-04-14 13:58:31 -04:00
3b1afb1783 Fix invalid node name if node was changed in after_place_node callback (fixes #93). 2013-04-14 13:54:33 -04:00
6cfd12e63c Merge branch 'patch_#85'
Let's see if someone complains...
2013-04-13 21:14:46 +02:00
c08e868be2 Merge pull request #92 from khonkhortisan/lazypull
Round movestone position, don't forget last pull
2013-04-07 17:05:39 -07:00
f1a327ad16 Round movestone position, don't forget last pull 2013-04-07 14:27:31 -07:00
e45a2a511e Sanity checks for commandblock commands. 2013-04-02 17:15:38 -04:00
63a18f1a51 Don't push objects into walls and fix bug in previous commit 2013-04-02 12:13:25 +02:00
57e1547515 Make pistons and movestones move objects (push only yet) 2013-04-02 11:57:28 +02:00
3b38bbcaf2 Make pistons and movestones move objects (push only yet) 2013-04-02 11:56:37 +02:00
e789794c75 Experimental fix for issue #85 by removing ignored ports from the luacontroller 2013-04-01 22:24:01 +02:00
2cc38909a1 Add /tellme command to command block. 2013-03-27 21:21:44 -04:00
36bcce57b0 Add table.* to luacontroller sandbox 2013-03-26 15:12:56 +01:00
21550b3727 Explicit tables of luacontroller environment. 2013-03-23 18:41:44 -04:00
6983db6d82 Add math library to luacontroller, and make sure to copy stuff so code can't get out of the sandbox. 2013-03-23 17:49:25 -04:00
1ff437b7b0 Don't forget sticky movestones! 2013-03-16 21:18:36 -04:00
5f9e655c13 Add MOVESTONE_MAXIMUM_PUSH setting. 2013-03-15 19:53:09 -04:00
3c3e45c7ea Avoid corrupting metadata. 2013-03-15 17:46:59 -04:00
5fd1cf5c80 Use formspec_escape when available. 2013-03-15 17:21:16 -04:00
e1211729cc Avoid borking the luacontroller if the code uses square brackets. When the next stable MT is released, uncomment the formspec_escape call to take advantave of formspec escaping. 2013-03-15 17:07:15 -04:00
588e41c786 Up/down pistons should also have special rules excluding the pusher side (rotated versions of normal pistons). 2013-03-14 14:19:02 -04:00
79bb4a3433 Lots of bugs in movestones fixed:
* Movestones no longer eat nodes when running off the track.
* Movestones no longer eat nodes when colliding with an mvps stopper.
* Movestones no longer pass through mvps stoppers.
* Movestones do not eat nodes when they are suddenly placed in the entity's path.
2013-03-14 13:44:49 -04:00
e1577eba46 Revert additional piston rules. 2013-03-11 17:49:07 -04:00
4406654fa4 Support metadata in piston pushing (so that microcontrollers and such can be pushed), support pushing chests (not locked ones though), and add two missing rules for pistons (z- top and bottom, but not z- itself). This still avoids the piston pushing power source issue. 2013-03-11 17:37:50 -04:00
db90c1cb4b Add /hp command to set the HP of a given player, requires the ban privelege. 2013-03-07 16:47:32 -05:00
3792b692aa Digging and footstep sounds for everything that needs them! Plus, pushing buttons, punching switches, and flipping levers all make sounds. 2013-03-06 20:51:57 -05:00
84d5546df1 Merge pull request #82 from Jat15/patch-1
Fix bug texture in mesewire for 0.4 stable
2013-03-05 09:36:07 -08:00
Jat
629a52af11 Fix bug texture in mesewire for 0.4 stable 2013-03-04 19:56:43 +01:00
4c0988ceab Merge pull request #80 from khonkhortisan/master
Vertical piston selection boxes
2013-03-02 22:24:29 -08:00
ac23eb070a Make vertical piston pusher selection boxes match their horizontal
equivalents
2013-03-02 22:22:43 -08:00
e707afef1a Don't totally force deactivation of block two below the pressure plate if connected to a receptor 2013-02-24 19:09:07 +01:00
2848df007e Bugfix: Also deactivate the block two below when digging a pressure plate 2013-02-24 19:03:28 +01:00
c9e89189eb Improved object detector craft recipe, picture soon available on mesecons.net 2013-02-22 19:49:03 +01:00
36263d481a Add (shaped) craft recipe for vertical mesecons
* Craft them from three wires in a vertical row
* Craft them back into mesecons by just putting one of them in the grid
2013-02-22 19:37:05 +01:00
a0920104fc Object Detector, cleanup and different behaviour:
* Name to scan for can be specified by right-clicking it
* It can receive digiline signals that change the name to scan for
* A sign above it for the name doesn't work anymore (this features wasn't used often anyway)
2013-02-22 19:23:28 +01:00
cc41f136cc More distinguishable inventory image for the luacontroller (not wield
item, just top)
2013-02-19 16:58:17 +01:00
8827cfd66f Merge branch 'luacontroller' 2013-02-19 16:54:53 +01:00
d36dd865ad Fix onstate corner drop
I blame khonkhortisan
2013-02-19 16:42:33 +01:00
ad9dde706e Merge pull request #77 from khonkhortisan/master
mesecons_extrawires:insulated_off
2013-02-18 10:38:05 -08:00
09ac201bac Fix the nodename of a drop 2013-02-18 10:27:11 -08:00
1c4ab938ad Fix a dumb bug that conflicted with different things in the luacontroller 2013-02-12 10:58:29 +01:00
eeed4f148d Fix odd behaviour when using interrupts in the luacontroller 2013-02-12 10:25:24 +01:00
0e34696214 Make Mese conductive 2013-02-11 11:01:13 +01:00
10ea3c971b Merge branch 'master' into luacontroller 2013-02-11 08:03:08 +01:00
591e2d7cde LuaController: Queue setting the ports (wait for pending operations) 2013-02-10 23:10:22 +01:00
7cc803b0d7 Merge pull request #74 from khonkhortisan/eghoststone
Remove ghoststone_active shadow on_construct
2013-02-08 17:01:13 -08:00
536c77330b Fix sticky piston crafting recipe. 2013-02-08 19:50:20 -05:00
fb45ee1d77 Remove ghoststone shadow when active. 2013-02-08 16:49:27 -08:00
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
4714c908ac Fix #73 - receiver wire drops down one node when connected button is dug. 2013-02-08 14:18:42 -05:00
ccb3430540 Merge pull request #70 from khonkhortisan/eghoststone
Make ghoststone conductive
2013-02-07 08:49:24 -08:00
43cb258877 Make ghoststone conductive. 2013-02-07 08:30:15 -08:00
e3c9eded2a Merge branch 'master' of https://github.com/Jeija/minetest-mod-mesecons 2013-02-06 21:25:55 +01:00
74eefc270a Fix piston drops and craft recipe 2013-02-06 21:24:58 +01:00
a5a4f2b65c Merge pull request #69 from khonkhortisan/master
Keep vertical wire base from self-intersecting
2013-02-04 20:02:27 -08:00
c23295409b Keep vertical wire base from self-intersecting
on the bottom.
2013-02-04 15:25:36 -08:00
baba7de063 Fix door compatibility, update to latest version 2013-01-30 07:37:08 +01:00
59cd72191b Add tostring, tonumber, string to luacontroller, prohibit 'function' 2013-01-22 21:15:49 +01:00
2b30360da2 Bugfix for the luacontroller that occured when two events occur at the
same time (output connected to input).
The behaviour of the controller can now be described this way:
The luacontroller sets port A, then B, then C, then D; if it is
interrupted by another event during that time it stops and let the
second event do the job.
2013-01-22 18:26:27 +01:00
18da94006a Lots of bugfixes concerning the luacontroller
- Bug when using NOT-Gates
- Moved error label a little downwards
- On digiline event, msg and channel are now in event.*, not in
event.iid.*
2013-01-20 18:00:33 +01:00
5c2959826e Fix piston bug: up piston pushing sand won't drop the sand anymore 2013-01-20 13:01:40 +01:00
ef087f2bb6 Fix Bug: Wrong usage of action_on/action_off instead of action_change 2013-01-19 23:37:03 +01:00
62ddebaecb Add support in luacontroller for a not yet released mod called 'digilines' 2013-01-19 21:45:39 +01:00
fc384aedbb Remove unused variable 2013-01-19 12:04:10 +01:00
ec517becab Texture the LuaController formspec 2013-01-19 12:03:27 +01:00
0d44144421 Bugfixes and improved stability of the luacontroller 2013-01-14 17:58:14 +01:00
240fb83e8b Implement interrupt(time, iid): The whole code is called again after a
certain amount of time.
Whenever it is called, an event is set.
Possible events are: program, interrupt, on and off
It also contains additional information (on/off -> event.in; interrupt ->
event.iid)
iid must be an integer or string value, otherwise the interrupt is not active
2013-01-13 17:33:16 +01:00
e297a02ec2 Implement a memory for the controller (accesible via mem.) and cleanup code
Based on PilzAdam's code.
2013-01-13 11:08:13 +01:00
bd749ec4d4 Add luacontroller, a microcontroller that you can code in lua.
It still misses some functionality such as a persistent memory and a
timer, but that is subject to change. The code runs in a sandbox.
Speaking long term this will hopefully replace the old controller.
2013-01-13 00:18:25 +01:00
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
17579a6aa1 Fix gates drop bug reported by kaeza and Kacey, avoid polluting the global namespace. 2013-01-06 14:09:54 -05:00
ec07fc27d7 Merge branch 'nextgen'
Conflicts:
	mesecons/wires.lua
2012-12-31 18:32:46 +01:00
52ddd4bdc9 Add crafting recipe for the delayer (similar to redstone, but with cobble instead of stone) 2012-12-30 09:07:49 +01:00
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
7e231b99a6 Make nr in rules rotation local in order not to pullute the holy global namespace 2012-12-28 07:33:16 +01:00
ab1966f763 Fix server crash when using movestones 2012-12-27 22:33:09 +01:00
2bbc9dd4b7 Rework the next nodes: Pressure Plates 2012-12-27 22:28:39 +01:00
72d58d2018 Merge branch 'nextgen' of https://github.com/Jeija/minetest-mod-mesecons into nextgen 2012-12-27 20:39:04 +01:00
c062411fa1 Fix another two piston-related bugs 2012-12-27 20:38:12 +01:00
2a061362fb Merge branch 'nextgen' of github.com:Jeija/minetest-mod-mesecons into nextgen 2012-12-27 13:51:36 -05:00
92122379de added and tweaked textures to improve appearance and tiling of insulated
T-junctions.
2012-12-27 13:50:54 -05:00
c63afd49ec Merge branch 'nextgen' of https://github.com/Jeija/minetest-mod-mesecons into nextgen 2012-12-27 19:15:24 +01:00
2a8bd68c41 Fix very rare piston bug (needs testing) 2012-12-27 19:14:54 +01:00
84ad046533 Added a couple of needed textures for curved/corner wires and tweak code to
use them.  Also fixed the "on" state image for wire ends so that it works for
curved wires also.
2012-12-27 12:48:02 -05:00
cdd9a93da9 revamped textures for all pistons, tweaked thickness of piston pusher 2012-12-27 12:13:40 -05:00
d3b77b5be3 Compatibility with old pistons 2012-12-27 12:03:05 +01:00
ac0fb91139 Minor cleanup of mesecno torch and add another rule to it (behind above) 2012-12-27 10:50:20 +01:00
d1ace465c7 Add experimental 'corner' wire, an insulated bended wire (needs textures and maybe rename it) 2012-12-27 09:54:19 +01:00
7fe4947056 Bugfix foes for pistons, delayyrs, gates and microcontrollers. Rework delayers. 2012-12-27 09:28:04 +01:00
5a88a9715f Re-write pistons from scratch, propably fixes a lot of bugs and doesn't
cause too many new ones.
2012-12-26 22:56:31 +01:00
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
a9a2108d13 Implement /say and /tell commands to aid mapmakers using command blocks. 2012-12-25 14:26:03 -05:00
c508bfaea6 Merge branch 'nextgen' of https://github.com/Jeija/minetest-mod-mesecons into nextgen 2012-12-23 17:21:34 +01:00
af8fd75fa4 Fix sticky piston up 2012-12-23 17:20:59 +01:00
e2ec7b5b04 Fix pressure plates (forgot to add mesecons field to some of the nodedefs) 2012-12-22 23:39:17 +01:00
5e8e003b8c Merge pull request #65 from montyoso/nextgen
now the insulated wires change their color when are turned on
2012-12-21 21:21:39 -08:00
6fab716f3e Fix up piston retraction.
The node property is_sticky_piston was applied to piston_up_normal rather than piston_up_sticky.
2012-12-21 20:46:57 -05:00
34fa8a1167 now the insulated wires change their color when they are turn on 2012-12-21 20:24:43 -05:00
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
973a9c650f Add new crafting recipe for mesecons: Cook a mese crystal 2012-12-21 16:19:38 +01:00
9019a4aff7 Bugfix, wires sometimes turned off for no reason 2012-12-21 16:04:19 +01:00
f114cb8ddc Fix movestone crash bug 2012-12-20 20:16:07 +01:00
5aa0815ffb hopefully fix http://minetest.net/forum/viewtopic.php?pid=58093#p58093 2012-12-19 18:20:21 +01:00
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
f6ef7b005d Same for sticky piston 2012-12-18 16:21:41 +01:00
5cdf23fb00 Fix bug reported here: http://bit.ly/VOF35X 2012-12-18 16:20:24 +01:00
e9e1006656 Merge branch 'master' of https://github.com/Jeija/minetest-mod-mesecons 2012-12-18 16:14:47 +01:00
313b9adcd5 Should fix this bug: bit.ly/XEy94j 2012-12-18 15:59:23 +01:00
313a137675 Merge remote-tracking branch 'origin/master' 2012-12-16 15:13:03 -05:00
c50b68cf83 Use a simpler way of detecting up/down piston placement (thanks Jeija). 2012-12-16 15:12:24 -05:00
13befe3bba Fix #62 (Hopefully this time) 2012-12-16 19:03:46 +01:00
2c4a46a557 Minor cleanup, use addPosRule 2012-12-16 16:29:03 +01:00
0aab812487 Fix addPosRule without mesecon: in vertical wires (issue #62) 2012-12-16 13:02:05 +01:00
c76c274cc0 Remove mesecons:updatenode 2012-12-16 12:00:11 +01:00
a1852204fb Cleanup and improve piston code 2012-12-16 11:58:43 +01:00
ae4bd1e21c Merge branch 'master' into nextgen
Conflicts:
	mesecons_pistons/init.lua
2012-12-16 08:59:06 +01:00
9dee0c020c Fix placing while facing diagonally. 2012-12-15 19:16:59 -05:00
aab0d4d943 Place up/down pistons automatically depending on the player look direction, remove the craft recipes for up/down pistons, and unify all the pushing/pulling behaviors into mesecon:piston_push(pos) and mesecon:piston_pull(pos). 2012-12-15 19:12:20 -05:00
b5f5beeb3d Attempt to update the wire crossing. 2012-12-15 17:53:03 -05:00
5fb5df446c Bugfix, use param2 for conductors when turning them on/off 2012-12-15 21:23:38 +01:00
18731cbc8a Bugfix, param2 for conductors 2012-12-15 21:21:54 +01:00
44dc1a128c Upload cleaned up mesecons to nextgen branch 2012-12-15 18:45:51 +01:00
c0d3bd2abb Include experimental vertical wires (needs textures) 2012-12-13 18:42:45 +01:00
594d061d6d Fix sticky piston retraction not working 2012-12-12 03:14:57 +01:00
659060ddcd Fix a bug that occured when placing an effector next to a receptor 2012-12-11 19:54:53 +01:00
de46729b97 Merge branch 'mesecons_in_nodedef'
Conflicts:
	mesecons/internal.lua
2012-12-11 19:49:55 +01:00
5540fcbcb3 Fix a bug reported here: http://minetest.net/forum/viewtopic.php?pid=56152#p56152 2012-12-11 18:15:44 +01:00
a55874b5d2 Fix blinky plant bug (crash when placing mesecon next to it) 2012-12-10 22:05:13 +01:00
192b9eca4f Fix crash when digging unknown nodes 2012-12-10 21:14:03 +01:00
59a39204a9 Remove dead parts of the mod/dead textures/wireless mesecons 2012-12-10 20:55:13 +01:00
e9f2beb2c6 Slightly change wire look (may be reverted?) 2012-12-10 20:39:12 +01:00
5904abbd79 Port gates (finally) 2012-12-10 19:46:24 +01:00
d5825f9602 Fix insulated mesecon 2012-12-10 17:19:30 +01:00
05def1540a Fix microcontroller digging 2012-12-09 15:32:29 +01:00
961b955f2d Port door, fix button/lever bug, new visual style for receiver 2012-12-09 13:28:32 +01:00
31f3c99288 Fix microcontroller alias 2012-12-09 11:16:48 +01:00
a0a3328f7c Fix microcontroller alias 2012-12-09 11:13:32 +01:00
b37bdbf55c Port a lot more (basically everything apart from gates, pistons and extrawire crossing) to the new nodedef system. There are some problems with wall button and wall lever (in the way they visually connect to wires) 2012-12-09 00:42:30 +01:00
cf6080f723 Port more blocks to nodedef system: object detector, extrawires, water turbine, insulated wire 2012-12-08 22:28:46 +01:00
00e071b695 Cleanup, make and use util.lua, port command block and delayer to nodedef 2012-12-08 21:56:09 +01:00
8578fd89c8 Port lightstones (as reference for effectors) + blinky plant to the new nodedef system 2012-12-08 19:02:34 +01:00
472650f099 Finish new mesecon-in-nodedef for conductors and receptors. Make wires and switch use it for reference. 2012-12-08 17:50:25 +01:00
f28cf0af03 Fix major bug that often occured when using gates (caused by commit 64d109b) 2012-12-08 16:08:16 +01:00
e0aa5b1d3d New branch: Move mesecon to node definition instead of functions like register_conductor; first steps: move everything to legacy 2012-12-08 14:14:04 +01:00
12206ac190 Add support for the preinstalled wooden door in minetest_game 2012-12-08 12:13:45 +01:00
142 changed files with 5170 additions and 2983 deletions

532
LICENSE.txt Normal file
View File

@ -0,0 +1,532 @@
The LGPLv3 applies to all code in this project.
The CC-BY-SA-3.0 license applies to textures and any other content in this project which is not source code.
=================================================================
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
=================================================================
Creative Commons Legal Code
Attribution-ShareAlike 3.0 Unported
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
DAMAGES RESULTING FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and
other pre-existing works, such as a translation, adaptation,
derivative work, arrangement of music or other alterations of a
literary or artistic work, or phonogram or performance and includes
cinematographic adaptations or any other form in which the Work may be
recast, transformed, or adapted including in any form recognizably
derived from the original, except that a work that constitutes a
Collection will not be considered an Adaptation for the purpose of
this License. For the avoidance of doubt, where the Work is a musical
work, performance or phonogram, the synchronization of the Work in
timed-relation with a moving image ("synching") will be considered an
Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as
encyclopedias and anthologies, or performances, phonograms or
broadcasts, or other works or subject matter other than works listed
in Section 1(f) below, which, by reason of the selection and
arrangement of their contents, constitute intellectual creations, in
which the Work is included in its entirety in unmodified form along
with one or more other contributions, each constituting separate and
independent works in themselves, which together are assembled into a
collective whole. A work that constitutes a Collection will not be
considered an Adaptation (as defined below) for the purposes of this
License.
c. "Creative Commons Compatible License" means a license that is listed
at http://creativecommons.org/compatiblelicenses that has been
approved by Creative Commons as being essentially equivalent to this
License, including, at a minimum, because that license: (i) contains
terms that have the same purpose, meaning and effect as the License
Elements of this License; and, (ii) explicitly permits the relicensing
of adaptations of works made available under that license under this
License or a Creative Commons jurisdiction license with the same
License Elements as this License.
d. "Distribute" means to make available to the public the original and
copies of the Work or Adaptation, as appropriate, through sale or
other transfer of ownership.
e. "License Elements" means the following high-level license attributes
as selected by Licensor and indicated in the title of this License:
Attribution, ShareAlike.
f. "Licensor" means the individual, individuals, entity or entities that
offer(s) the Work under the terms of this License.
g. "Original Author" means, in the case of a literary or artistic work,
the individual, individuals, entity or entities who created the Work
or if no individual or entity can be identified, the publisher; and in
addition (i) in the case of a performance the actors, singers,
musicians, dancers, and other persons who act, sing, deliver, declaim,
play in, interpret or otherwise perform literary or artistic works or
expressions of folklore; (ii) in the case of a phonogram the producer
being the person or legal entity who first fixes the sounds of a
performance or other sounds; and, (iii) in the case of broadcasts, the
organization that transmits the broadcast.
h. "Work" means the literary and/or artistic work offered under the terms
of this License including without limitation any production in the
literary, scientific and artistic domain, whatever may be the mode or
form of its expression including digital form, such as a book,
pamphlet and other writing; a lecture, address, sermon or other work
of the same nature; a dramatic or dramatico-musical work; a
choreographic work or entertainment in dumb show; a musical
composition with or without words; a cinematographic work to which are
assimilated works expressed by a process analogous to cinematography;
a work of drawing, painting, architecture, sculpture, engraving or
lithography; a photographic work to which are assimilated works
expressed by a process analogous to photography; a work of applied
art; an illustration, map, plan, sketch or three-dimensional work
relative to geography, topography, architecture or science; a
performance; a broadcast; a phonogram; a compilation of data to the
extent it is protected as a copyrightable work; or a work performed by
a variety or circus performer to the extent it is not otherwise
considered a literary or artistic work.
i. "You" means an individual or entity exercising rights under this
License who has not previously violated the terms of this License with
respect to the Work, or who has received express permission from the
Licensor to exercise rights under this License despite a previous
violation.
j. "Publicly Perform" means to perform public recitations of the Work and
to communicate to the public those public recitations, by any means or
process, including by wire or wireless means or public digital
performances; to make available to the public Works in such a way that
members of the public may access these Works from a place and at a
place individually chosen by them; to perform the Work to the public
by any means or process and the communication to the public of the
performances of the Work, including by public digital performance; to
broadcast and rebroadcast the Work by any means including signs,
sounds or images.
k. "Reproduce" means to make copies of the Work by any means including
without limitation by sound or visual recordings and the right of
fixation and reproducing fixations of the Work, including storage of a
protected performance or phonogram in digital form or other electronic
medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
limit, or restrict any uses free from copyright or rights arising from
limitations or exceptions that are provided for in connection with the
copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License,
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
perpetual (for the duration of the applicable copyright) license to
exercise the rights in the Work as stated below:
a. to Reproduce the Work, to incorporate the Work into one or more
Collections, and to Reproduce the Work as incorporated in the
Collections;
b. to create and Reproduce Adaptations provided that any such Adaptation,
including any translation in any medium, takes reasonable steps to
clearly label, demarcate or otherwise identify that changes were made
to the original Work. For example, a translation could be marked "The
original work was translated from English to Spanish," or a
modification could indicate "The original work has been modified.";
c. to Distribute and Publicly Perform the Work including as incorporated
in Collections; and,
d. to Distribute and Publicly Perform Adaptations.
e. For the avoidance of doubt:
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme cannot be waived, the Licensor
reserves the exclusive right to collect such royalties for any
exercise by You of the rights granted under this License;
ii. Waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme can be waived, the Licensor waives the
exclusive right to collect such royalties for any exercise by You
of the rights granted under this License; and,
iii. Voluntary License Schemes. The Licensor waives the right to
collect royalties, whether individually or, in the event that the
Licensor is a member of a collecting society that administers
voluntary licensing schemes, via that society, from any exercise
by You of the rights granted under this License.
The above rights may be exercised in all media and formats whether now
known or hereafter devised. The above rights include the right to make
such modifications as are technically necessary to exercise the rights in
other media and formats. Subject to Section 8(f), all rights not expressly
granted by Licensor are hereby reserved.
4. Restrictions. The license granted in Section 3 above is expressly made
subject to and limited by the following restrictions:
a. You may Distribute or Publicly Perform the Work only under the terms
of this License. You must include a copy of, or the Uniform Resource
Identifier (URI) for, this License with every copy of the Work You
Distribute or Publicly Perform. You may not offer or impose any terms
on the Work that restrict the terms of this License or the ability of
the recipient of the Work to exercise the rights granted to that
recipient under the terms of the License. You may not sublicense the
Work. You must keep intact all notices that refer to this License and
to the disclaimer of warranties with every copy of the Work You
Distribute or Publicly Perform. When You Distribute or Publicly
Perform the Work, You may not impose any effective technological
measures on the Work that restrict the ability of a recipient of the
Work from You to exercise the rights granted to that recipient under
the terms of the License. This Section 4(a) applies to the Work as
incorporated in a Collection, but this does not require the Collection
apart from the Work itself to be made subject to the terms of this
License. If You create a Collection, upon notice from any Licensor You
must, to the extent practicable, remove from the Collection any credit
as required by Section 4(c), as requested. If You create an
Adaptation, upon notice from any Licensor You must, to the extent
practicable, remove from the Adaptation any credit as required by
Section 4(c), as requested.
b. You may Distribute or Publicly Perform an Adaptation only under the
terms of: (i) this License; (ii) a later version of this License with
the same License Elements as this License; (iii) a Creative Commons
jurisdiction license (either this or a later license version) that
contains the same License Elements as this License (e.g.,
Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible
License. If you license the Adaptation under one of the licenses
mentioned in (iv), you must comply with the terms of that license. If
you license the Adaptation under the terms of any of the licenses
mentioned in (i), (ii) or (iii) (the "Applicable License"), you must
comply with the terms of the Applicable License generally and the
following provisions: (I) You must include a copy of, or the URI for,
the Applicable License with every copy of each Adaptation You
Distribute or Publicly Perform; (II) You may not offer or impose any
terms on the Adaptation that restrict the terms of the Applicable
License or the ability of the recipient of the Adaptation to exercise
the rights granted to that recipient under the terms of the Applicable
License; (III) You must keep intact all notices that refer to the
Applicable License and to the disclaimer of warranties with every copy
of the Work as included in the Adaptation You Distribute or Publicly
Perform; (IV) when You Distribute or Publicly Perform the Adaptation,
You may not impose any effective technological measures on the
Adaptation that restrict the ability of a recipient of the Adaptation
from You to exercise the rights granted to that recipient under the
terms of the Applicable License. This Section 4(b) applies to the
Adaptation as incorporated in a Collection, but this does not require
the Collection apart from the Adaptation itself to be made subject to
the terms of the Applicable License.
c. If You Distribute, or Publicly Perform the Work or any Adaptations or
Collections, You must, unless a request has been made pursuant to
Section 4(a), keep intact all copyright notices for the Work and
provide, reasonable to the medium or means You are utilizing: (i) the
name of the Original Author (or pseudonym, if applicable) if supplied,
and/or if the Original Author and/or Licensor designate another party
or parties (e.g., a sponsor institute, publishing entity, journal) for
attribution ("Attribution Parties") in Licensor's copyright notice,
terms of service or by other reasonable means, the name of such party
or parties; (ii) the title of the Work if supplied; (iii) to the
extent reasonably practicable, the URI, if any, that Licensor
specifies to be associated with the Work, unless such URI does not
refer to the copyright notice or licensing information for the Work;
and (iv) , consistent with Ssection 3(b), in the case of an
Adaptation, a credit identifying the use of the Work in the Adaptation
(e.g., "French translation of the Work by Original Author," or
"Screenplay based on original Work by Original Author"). The credit
required by this Section 4(c) may be implemented in any reasonable
manner; provided, however, that in the case of a Adaptation or
Collection, at a minimum such credit will appear, if a credit for all
contributing authors of the Adaptation or Collection appears, then as
part of these credits and in a manner at least as prominent as the
credits for the other contributing authors. For the avoidance of
doubt, You may only use the credit required by this Section for the
purpose of attribution in the manner set out above and, by exercising
Your rights under this License, You may not implicitly or explicitly
assert or imply any connection with, sponsorship or endorsement by the
Original Author, Licensor and/or Attribution Parties, as appropriate,
of You or Your use of the Work, without the separate, express prior
written permission of the Original Author, Licensor and/or Attribution
Parties.
d. Except as otherwise agreed in writing by the Licensor or as may be
otherwise permitted by applicable law, if You Reproduce, Distribute or
Publicly Perform the Work either by itself or as part of any
Adaptations or Collections, You must not distort, mutilate, modify or
take other derogatory action in relation to the Work which would be
prejudicial to the Original Author's honor or reputation. Licensor
agrees that in those jurisdictions (e.g. Japan), in which any exercise
of the right granted in Section 3(b) of this License (the right to
make Adaptations) would be deemed to be a distortion, mutilation,
modification or other derogatory action prejudicial to the Original
Author's honor and reputation, the Licensor will waive or not assert,
as appropriate, this Section, to the fullest extent permitted by the
applicable national law, to enable You to reasonably exercise Your
right under Section 3(b) of this License (right to make Adaptations)
but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
a. This License and the rights granted hereunder will terminate
automatically upon any breach by You of the terms of this License.
Individuals or entities who have received Adaptations or Collections
from You under this License, however, will not have their licenses
terminated provided such individuals or entities remain in full
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
survive any termination of this License.
b. Subject to the above terms and conditions, the license granted here is
perpetual (for the duration of the applicable copyright in the Work).
Notwithstanding the above, Licensor reserves the right to release the
Work under different license terms or to stop distributing the Work at
any time; provided, however that any such election will not serve to
withdraw this License (or any other license that has been, or is
required to be, granted under the terms of this License), and this
License will continue in full force and effect unless terminated as
stated above.
8. Miscellaneous
a. Each time You Distribute or Publicly Perform the Work or a Collection,
the Licensor offers to the recipient a license to the Work on the same
terms and conditions as the license granted to You under this License.
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
offers to the recipient a license to the original Work on the same
terms and conditions as the license granted to You under this License.
c. If any provision of this License is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of
the remainder of the terms of this License, and without further action
by the parties to this agreement, such provision shall be reformed to
the minimum extent necessary to make such provision valid and
enforceable.
d. No term or provision of this License shall be deemed waived and no
breach consented to unless such waiver or consent shall be in writing
and signed by the party to be charged with such waiver or consent.
e. This License constitutes the entire agreement between the parties with
respect to the Work licensed here. There are no understandings,
agreements or representations with respect to the Work not specified
here. Licensor shall not be bound by any additional provisions that
may appear in any communication from You. This License may not be
modified without the mutual written agreement of the Licensor and You.
f. The rights granted under, and the subject matter referenced, in this
License were drafted utilizing the terminology of the Berne Convention
for the Protection of Literary and Artistic Works (as amended on
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
and the Universal Copyright Convention (as revised on July 24, 1971).
These rights and subject matter take effect in the relevant
jurisdiction in which the License terms are sought to be enforced
according to the corresponding provisions of the implementation of
those treaty provisions in the applicable national law. If the
standard suite of rights granted under applicable copyright law
includes additional rights not granted under this License, such
additional rights are deemed to be included in the License; this
License is not intended to restrict the license of any rights under
applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty
whatsoever in connection with the Work. Creative Commons will not be
liable to You or any party on any legal theory for any damages
whatsoever, including without limitation any general, special,
incidental or consequential damages arising in connection to this
license. Notwithstanding the foregoing two (2) sentences, if Creative
Commons has expressly identified itself as the Licensor hereunder, it
shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the
Work is licensed under the CCPL, Creative Commons does not authorize
the use by either party of the trademark "Creative Commons" or any
related trademark or logo of Creative Commons without the prior
written consent of Creative Commons. Any permitted use will be in
compliance with Creative Commons' then-current trademark usage
guidelines, as may be published on its website or otherwise made
available upon request from time to time. For the avoidance of doubt,
this trademark restriction does not form part of the License.
Creative Commons may be contacted at http://creativecommons.org/.

24
README
View File

@ -1,24 +0,0 @@
-- |\ /| ____ ____ ____ _____ ____ _____
-- | \ / | | | | | | | |\ | |
-- | \/ | |___ ____ |___ | | | | \ | |____
-- | | | | | | | | | \ | |
-- | | |___ ____| |___ |____ |____| | \| ____|
-- by Jeija and contributors
Credits:
Jeija: main developer
VanessaE: Awesome textures & design, coding
sfan5: coding, textures
temperest: coding, textures
Jordach: Sounds for the noteblock
minerd247: Some textures
...other contributors
This is a mod for minetest-c55.
Copy the minetest-mod-mesecons directory into you game's mod folder
(e.g. games/minetest_game/mods/minetest-mod-mesecons)
You can remove modules of this mod by deleting the mesecons_*
folders in the minetest-mod-mesecons directory.
Mod dependencies: none

78
README.md Normal file
View File

@ -0,0 +1,78 @@
########################################################################
## __ __ _____ _____ _____ _____ _____ _ _ _____ ##
## | \ / | | ___| | ___| | ___| | ___| | _ | | \ | | | ___| ##
## | \/ | | |___ | |___ | |___ | | | | | | | \| | | |___ ##
## | |\__/| | | ___| |___ | | ___| | | | | | | | | |___ | ##
## | | | | | |___ ___| | | |___ | |___ | |_| | | |\ | ___| | ##
## |_| |_| |_____| |_____| |_____| |_____| |_____| |_| \_| |_____| ##
## ##
########################################################################
MESECONS by Jeija and contributors
Mezzee-what?
------------
[Mesecons](http://mesecons.net/)! They're yellow, they're conductive, and they'll add a whole new dimension to Minetest's gameplay.
Mesecons is a mod for [Minetest](http://minetest.net/) that implements a ton of items related to digital circuitry, such as wires, buttons, lights, and even programmable controllers. Among other things, there are also pistons, solar panels, pressure plates, and note blocks.
Mesecons has a similar goal to Redstone in Minecraft, but works in its own way, with different rules and mechanics.
OK, I want in.
--------------
Go get it!
[DOWNLOADS PAGE](http://mesecons.net/downloads.php)
Now go ahead and install it like any other Minetest mod. Don't know how? Check out [the wonderful page about it](http://wiki.minetest.com/wiki/Mods) over at the Minetest Wiki. For your convenience, here's a quick summary:
1. If Mesecons is still in a ZIP file, extract the folder inside to somewhere on the computer.
2. Make sure that when you open the folder, you can directly find `README.md` in the listing. If you just see another folder, move that folder up one level and delete the old one.
3. Open up the Minetest mods folder - usually `/mods/`. If you see the `minetest` or folder inside of that, that is your mod folder instead.
4. Copy the Mesecons folder into the mods folder.
Don't like some parts of Mesecons? Open up the Mesecons folder and delete the subfolder containing the mod you don't want. If you didn't want movestones, for example, all you have to do is delete the `mesecons_movestones` folder and they will no longer be available.
There are no dependencies - it will work right after installing!
How do I use this thing?
------------------------
How about a [quick overview video](https://www.youtube.com/watch?v=6kmeQj6iW5k)?
Or maybe a [comprehensive reference](http://mesecons.net/items.php) is your style?
An overview for the very newest of new beginners? How does [this one](http://uberi.mesecons.net/projects/MeseconsBasics/index.html) look?
Want to get more into building? Why not check out the [Mesecons Laboratory](http://uberi.mesecons.net/), a website dedicated to advanced Mesecons builders?
Want to contribute to Mesecons itself? Check out the [source code](https://github.com/Jeija/minetest-mod-mesecons)!
Who wrote it anyways?
---------------------
These awesome people made Mesecons possible!
| Contributor | Contribution |
| --------------- | -------------------------------- |
| Jat15 | Various tweaks. |
| Jeija | **Main developer! Everything.** |
| Jordach | Noteblock sounds. |
| khonkhortistan | Code, recipes, textures. |
| Kotolegokot | Nodeboxes for items. |
| minerd247 | Textures. |
| Nore/Novatux | Code. |
| RealBadAngel | Fixes, improvements. |
| sfan5 | Code, recipes, textures. |
| suzenako | Piston sounds. |
| Uberi/Temperest | Code, textures, documentation. |
| VanessaE | Code, recipes, textures, design. |
| Whiskers75 | Logic gates implementation. |
There are also a whole bunch of other people helping with everything from code to testing and feedback. Mesecons would also not be possible without their help!
Alright, how can I use it?
--------------------------
All textures in this project are licensed under the CC-BY-SA 3.0 (Creative Commons Attribution-ShareAlike 3.0 Generic). That means you can distribute and remix them as much as you want to, under the condition that you give credit to the authors and the project, and that if you remix and release them, they must be under the same or similar license to this one.
All code in this project is licensed under the LGPL version 3 or later. That means you have unlimited freedom to distribute and modify the work however you see fit, provided that if you decide to distribute it or any modified versions of it, you must also use the same license. The LGPL also grants the additional freedom to write extensions for the software and distribute them without the extensions being subject to the terms of the LGPL, although the software itself retains its license.
No warranty is provided, express or implied, for any part of the project.

View File

@ -3,128 +3,154 @@
-- | \/ | |___ ____ |___ | | | | \ | |____ -- | \/ | |___ ____ |___ | | | | \ | |____
-- | | | | | | | | | \ | | -- | | | | | | | | | \ | |
-- | | |___ ____| |___ |____ |____| | \| ____| -- | | |___ ____| |___ |____ |____| | \| ____|
-- by Jeija and Minerd247 -- by Jeija, Uberi (Temperest), sfan5, VanessaE
-- --
-- --
-- --
-- This mod adds mesecons[=minecraft redstone] and different receptors/effectors to minetest. -- This mod adds mesecons[=minecraft redstone] and different receptors/effectors to minetest.
--
-- See the documentation on the forum for additional information, especially about crafting -- See the documentation on the forum for additional information, especially about crafting
-- --
-- For developer documentation see the Developers' section on mesecons.tk --
-- For developer documentation see the Developers' section on mesecons.TK
--
--
--
--Quick draft for the mesecons array in the node's definition
--mesecons =
--{
-- receptor =
-- {
-- state = mesecon.state.on/off
-- rules = rules/get_rules
-- },
-- effector =
-- {
-- action_on = function
-- action_off = function
-- action_change = function
-- rules = rules/get_rules
-- },
-- conductor =
-- {
-- state = mesecon.state.on/off
-- offstate = opposite state (for state = on only)
-- onstate = opposite state (for state = off only)
-- rules = rules/get_rules
-- }
--}
-- PUBLIC VARIABLES -- PUBLIC VARIABLES
mesecon={} -- contains all functions and all global variables mesecon={} -- contains all functions and all global variables
mesecon.actions_on={} -- Saves registered function callbacks for mesecon on mesecon.actions_on={} -- Saves registered function callbacks for mesecon on | DEPRECATED
mesecon.actions_off={} -- Saves registered function callbacks for mesecon off mesecon.actions_off={} -- Saves registered function callbacks for mesecon off | DEPRECATED
mesecon.actions_change={} -- Saves registered function callbacks for mesecon change mesecon.actions_change={} -- Saves registered function callbacks for mesecon change | DEPRECATED
mesecon.receptors={} mesecon.receptors={} -- saves all information about receptors | DEPRECATED
mesecon.effectors={} mesecon.effectors={} -- saves all information about effectors | DEPRECATED
mesecon.rules={} mesecon.conductors={} -- saves all information about conductors | DEPRECATED
mesecon.conductors={}
-- INCLUDE SETTINGS
dofile(minetest.get_modpath("mesecons").."/settings.lua")
--Internal API local wpath = minetest.get_worldpath()
dofile(minetest.get_modpath("mesecons").."/internal.lua"); local function read_file(fn)
local f = io.open(fn, "r")
-- API API API API API API API API API API API API API API API API API API if f==nil then return {} end
local t = f:read("*all")
function mesecon:register_receptor(onstate, offstate, rules, get_rules) f:close()
if get_rules == nil and rules == nil then if t=="" or t==nil then return {} end
rules = mesecon:get_rules("default") return minetest.deserialize(t)
end
table.insert(mesecon.receptors,
{onstate = onstate,
offstate = offstate,
rules = rules,
get_rules = get_rules})
end end
function mesecon:register_effector(onstate, offstate, input_rules, get_input_rules) local function write_file(fn, tbl)
if get_input_rules==nil and input_rules==nil then local f = io.open(fn, "w")
rules=mesecon:get_rules("default") f:write(minetest.serialize(tbl))
f:close()
end
mesecon.to_update = read_file(wpath.."/mesecon_to_update")
mesecon.r_to_update = read_file(wpath.."/mesecon_r_to_update")
minetest.register_on_shutdown(function()
write_file(wpath.."/mesecon_to_update",mesecon.to_update)
write_file(wpath.."/mesecon_r_to_update",mesecon.r_to_update)
end)
-- Settings
dofile(minetest.get_modpath("mesecons").."/settings.lua")
-- Presets (eg default rules)
dofile(minetest.get_modpath("mesecons").."/presets.lua");
-- Utilities like comparing positions,
-- adding positions and rules,
-- mostly things that make the source look cleaner
dofile(minetest.get_modpath("mesecons").."/util.lua");
-- Internal stuff
-- This is the most important file
-- it handles signal transmission and basically everything else
-- It is also responsible for managing the nodedef things,
-- like calling action_on/off/change
dofile(minetest.get_modpath("mesecons").."/internal.lua");
-- Deprecated stuff
-- To be removed in future releases
-- Currently there is nothing here
dofile(minetest.get_modpath("mesecons").."/legacy.lua");
-- API
-- these are the only functions you need to remember
function mesecon:receptor_on_i(pos, rules)
rules = rules or mesecon.rules.default
for _, rule in ipairs(mesecon:flattenrules(rules)) do
local np = mesecon:addPosRule(pos, rule)
local rulenames = mesecon:rules_link_rule_all(pos, rule)
for _, rulename in ipairs(rulenames) do
mesecon:turnon(np, rulename)
end
end end
table.insert(mesecon.effectors,
{onstate = onstate,
offstate = offstate,
input_rules = input_rules,
get_input_rules = get_input_rules})
end end
function mesecon:receptor_on(pos, rules) function mesecon:receptor_on(pos, rules)
if rules == nil then if MESECONS_GLOBALSTEP then
rules = mesecon:get_rules("default") rules = rules or mesecon.rules.default
mesecon.r_to_update[#mesecon.r_to_update+1]={pos=pos, rules=rules, action="on"}
else
mesecon:receptor_on_i(pos, rules)
end end
end
for i, rule in ipairs(rules) do function mesecon:receptor_off_i(pos, rules)
local np = { rules = rules or mesecon.rules.default
x = pos.x + rule.x, for _, rule in ipairs(mesecon:flattenrules(rules)) do
y = pos.y + rule.y, local np = mesecon:addPosRule(pos, rule)
z = pos.z + rule.z} local rulenames = mesecon:rules_link_rule_all(pos, rule)
if mesecon:rules_link(pos, np, rules) then for _, rulename in ipairs(rulenames) do
mesecon:turnon(np, pos) if not mesecon:connected_to_receptor(np, mesecon:invertRule(rule)) then
mesecon:turnoff(np, rulename)
else
mesecon:changesignal(np, minetest.get_node(np), rulename, mesecon.state.off)
end
end end
end end
end end
function mesecon:receptor_off(pos, rules) function mesecon:receptor_off(pos, rules)
if rules == nil then if MESECONS_GLOBALSTEP then
rules = mesecon:get_rules("default") rules = rules or mesecon.rules.default
end mesecon.r_to_update[#mesecon.r_to_update+1]={pos=pos, rules=rules, action="off"}
else
for i, rule in ipairs(rules) do mesecon:receptor_off_i(pos, rules)
local np = {
x = pos.x + rule.x,
y = pos.y + rule.y,
z = pos.z + rule.z}
if mesecon:rules_link(pos, np, rules) and not mesecon:connected_to_pw_src(np) then
mesecon:turnoff(np, pos)
end
end end
end end
function mesecon:register_on_signal_on(action)
table.insert(mesecon.actions_on, action)
end
function mesecon:register_on_signal_off(action) print("[OK] Mesecons")
table.insert(mesecon.actions_off, action)
end
function mesecon:register_on_signal_change(action)
table.insert(mesecon.actions_change, action)
end
function mesecon:register_conductor (onstate, offstate, rules, get_rules)
if rules == nil then
rules = mesecon:get_rules("default")
end
table.insert(mesecon.conductors, {onstate = onstate, offstate = offstate, rules = rules, get_rules = get_rules})
end
mesecon:add_rules("default",
{{x=0, y=0, z=-1},
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
{x=0, y=0, z=1},
{x=1, y=1, z=0},
{x=1, y=-1, z=0},
{x=-1, y=1, z=0},
{x=-1, y=-1, z=0},
{x=0, y=1, z=1},
{x=0, y=-1, z=1},
{x=0, y=1, z=-1},
{x=0, y=-1, z=-1}})
print("[MESEcons] Main mod Loaded!")
--The actual wires --The actual wires
dofile(minetest.get_modpath("mesecons").."/wires.lua"); dofile(minetest.get_modpath("mesecons").."/wires.lua");
--Services like turnoff receptor on dignode and so on --Services like turnoff receptor on dignode and so on
dofile(minetest.get_modpath("mesecons").."/services.lua"); dofile(minetest.get_modpath("mesecons").."/services.lua");
--Deprecated stuff
dofile(minetest.get_modpath("mesecons").."/legacy.lua");

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,5 @@
function mesecon:add_receptor_node(name, rules, get_rules) minetest.swap_node = minetest.swap_node or function(pos, node)
if get_rules==nil and rules==nil then local data = minetest.get_meta(pos):to_table()
rules=mesecon:get_rules("default") minetest.add_node(pos, node)
end minetest.get_meta(pos):from_table(data)
table.insert(mesecon.receptors, {onstate = name, rules = rules, get_rules = get_rules})
end
function mesecon:add_receptor_node_off(name, rules, get_rules)
if get_rules==nil and rules==nil then
rules=mesecon:get_rules("default")
end
table.insert(mesecon.receptors, {offstate = name, rules = rules, get_rules = get_rules})
end end

38
mesecons/oldwires.lua Normal file
View File

@ -0,0 +1,38 @@
minetest.register_node("mesecons:mesecon_off", {
drawtype = "raillike",
tiles = {"jeija_mesecon_off.png", "jeija_mesecon_curved_off.png", "jeija_mesecon_t_junction_off.png", "jeija_mesecon_crossing_off.png"},
inventory_image = "jeija_mesecon_off.png",
wield_image = "jeija_mesecon_off.png",
paramtype = "light",
is_ground_content = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
},
groups = {dig_immediate=3, mesecon=1, mesecon_conductor_craftable=1},
description="Mesecons",
mesecons = {conductor={
state = mesecon.state.off,
onstate = "mesecons:mesecon_on"
}}
})
minetest.register_node("mesecons:mesecon_on", {
drawtype = "raillike",
tiles = {"jeija_mesecon_on.png", "jeija_mesecon_curved_on.png", "jeija_mesecon_t_junction_on.png", "jeija_mesecon_crossing_on.png"},
paramtype = "light",
is_ground_content = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
},
groups = {dig_immediate=3, not_in_creaive_inventory=1, mesecon=1},
drop = "mesecons:mesecon_off 1",
light_source = LIGHT_MAX-11,
mesecons = {conductor={
state = mesecon.state.on,
offstate = "mesecons:mesecon_off"
}}
})

45
mesecons/presets.lua Normal file
View File

@ -0,0 +1,45 @@
mesecon.rules = {}
mesecon.state = {}
mesecon.rules.default =
{{x=0, y=0, z=-1},
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
{x=0, y=0, z=1},
{x=1, y=1, z=0},
{x=1, y=-1, z=0},
{x=-1, y=1, z=0},
{x=-1, y=-1, z=0},
{x=0, y=1, z=1},
{x=0, y=-1, z=1},
{x=0, y=1, z=-1},
{x=0, y=-1, z=-1}}
mesecon.rules.buttonlike =
{{x = 1, y = 0, z = 0},
{x = 1, y = 1, z = 0},
{x = 1, y =-1, z = 0},
{x = 1, y =-1, z = 1},
{x = 1, y =-1, z =-1},
{x = 2, y = 0, z = 0}}
mesecon.rules.flat =
{{x = 1, y = 0, z = 0},
{x =-1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z =-1}}
mesecon.rules.buttonlike_get = function(node)
local rules = mesecon.rules.buttonlike
if node.param2 == 2 then
rules=mesecon:rotate_rules_left(rules)
elseif node.param2 == 3 then
rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
elseif node.param2 == 0 then
rules=mesecon:rotate_rules_right(rules)
end
return rules
end
mesecon.state.on = "on"
mesecon.state.off = "off"

View File

@ -1,28 +1,38 @@
minetest.register_on_dignode( mesecon.on_placenode = function (pos, node)
function(pos, oldnode, digger) if mesecon:is_receptor_on(node.name) then
if mesecon:is_conductor_on(oldnode.name) then mesecon:receptor_on(pos, mesecon:receptor_get_rules(node))
mesecon:receptor_off(pos) elseif mesecon:is_powered(pos) then
end if mesecon:is_conductor(node.name) then
mesecon:turnon (pos)
if mesecon:is_receptor_node(oldnode.name) then --mesecon:receptor_on (pos, mesecon:conductor_get_rules(node))
mesecon:receptor_off(pos, mesecon:receptor_get_rules(oldnode)) else
mesecon:changesignal(pos, node, mesecon:effector_get_rules(node), "on")
mesecon:activate(pos, node)
end end
elseif mesecon:is_conductor_on(node) then
minetest.swap_node(pos, {name = mesecon:get_conductor_off(node)})
elseif mesecon:is_effector_on (node.name) then
mesecon:deactivate(pos, node)
end end
) end
minetest.register_on_placenode( mesecon.on_dignode = function (pos, node)
function (pos, node) if mesecon:is_conductor_on(node) then
if mesecon:is_receptor_node(node.name) then mesecon:receptor_off_i(pos, mesecon:conductor_get_rules(node))
mesecon:receptor_on(pos, mesecon:receptor_get_rules(node)) elseif mesecon:is_receptor_on(node.name) then
end mesecon:receptor_off(pos, mesecon:receptor_get_rules(node))
if mesecon:is_powered(pos) then
if mesecon:is_conductor_off(node.name) then
mesecon:turnon(pos)
else
mesecon:changesignal(pos)
mesecon:activate(pos)
end
end
end end
) end
minetest.register_abm({
nodenames = {"group:overheat"},
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
meta:set_int("heat",0)
end,
})
minetest.register_on_placenode(mesecon.on_placenode)
minetest.register_on_dignode(mesecon.on_dignode)

View File

@ -2,3 +2,8 @@
BLINKY_PLANT_INTERVAL = 3 BLINKY_PLANT_INTERVAL = 3
NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires
PRESSURE_PLATE_INTERVAL = 0.1 PRESSURE_PLATE_INTERVAL = 0.1
OBJECT_DETECTOR_RADIUS = 6
PISTON_MAXIMUM_PUSH = 15
MOVESTONE_MAXIMUM_PUSH = 100
MESECONS_GLOBALSTEP = true -- true = receptors/effectors won't be updated
-- until next globalstep, decreases server load

183
mesecons/util.lua Normal file
View File

@ -0,0 +1,183 @@
function mesecon:move_node(pos, newpos)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos):to_table()
minetest.remove_node(pos)
minetest.add_node(newpos, node)
minetest.get_meta(pos):from_table(meta)
end
--[[ new functions:
mesecon:flattenrules(allrules)
mesecon:rule2bit(findrule, allrules)
mesecon:rule2meta(findrule, allrules)
dec2bin(n)
mesecon:getstate(nodename, states)
mesecon:getbinstate(nodename, states)
mesecon:get_bit(binary, bit)
mesecon:set_bit(binary, bit, value)
mesecon:invertRule(r)
--]]
function mesecon:flattenrules(allrules)
--[[
{
{
{xyz},
{xyz},
},
{
{xyz},
{xyz},
},
}
--]]
if allrules[1] and
allrules[1].x then
return allrules
end
local shallowrules = {}
for _, metarule in ipairs( allrules) do
for _, rule in ipairs(metarule ) do
table.insert(shallowrules, rule)
end
end
return shallowrules
--[[
{
{xyz},
{xyz},
{xyz},
{xyz},
}
--]]
end
function mesecon:rule2bit(findrule, allrules)
--get the bit of the metarule the rule is in, or bit 1
if (allrules[1] and
allrules[1].x) or
not findrule then
return 1
end
for m,metarule in ipairs( allrules) do
for _, rule in ipairs(metarule ) do
if mesecon:cmpPos(findrule, rule) and mesecon:cmpSpecial(findrule, rule) then
return m
end
end
end
end
function mesecon:rule2metaindex(findrule, allrules)
--get the metarule the rule is in, or allrules
if allrules[1].x then
return nil
end
if not(findrule) then
return mesecon:flattenrules(allrules)
end
for m, metarule in ipairs( allrules) do
for _, rule in ipairs(metarule ) do
if mesecon:cmpPos(findrule, rule) and mesecon:cmpSpecial(findrule, rule) then
return m
end
end
end
end
function mesecon:rule2meta(findrule, allrules)
local index = mesecon:rule2metaindex(findrule, allrules)
if index == nil then
if allrules[1].x then
return allrules
else
return {}
end
end
return allrules[index]
end
if convert_base then
print(
"base2dec is tonumber(num,base1)\n"..
"commonlib needs dec2base(num,base2)\n"..
"and it needs base2base(num,base1,base2),\n"..
"which is dec2base(tonumber(num,base1),base2)"
)
else
function dec2bin(n)
local x, y = math.floor(n / 2), n % 2
if (n > 1) then
return dec2bin(x)..y
else
return ""..y
end
end
end
function mesecon:getstate(nodename, states)
for state, name in ipairs(states) do
if name == nodename then
return state
end
end
error(nodename.." doesn't mention itself in "..dump(states))
end
function mesecon:getbinstate(nodename, states)
return dec2bin(mesecon:getstate(nodename, states)-1)
end
function mesecon:get_bit(binary,bit)
bit = bit or 1
local c = binary:len()-(bit-1)
return binary:sub(c,c) == "1"
end
function mesecon:set_bit(binary,bit,value)
if value == "1" then
if not mesecon:get_bit(binary,bit) then
return dec2bin(tonumber(binary,2)+math.pow(2,bit-1))
end
elseif value == "0" then
if mesecon:get_bit(binary,bit) then
return dec2bin(tonumber(binary,2)-math.pow(2,bit-1))
end
end
return binary
end
function mesecon:invertRule(r)
return {x = -r.x, y = -r.y, z = -r.z, sx = r.sx, sy = r.sy, sz = r.sz}
end
function mesecon:addPosRule(p, r)
return {x = p.x + r.x, y = p.y + r.y, z = p.z + r.z}
end
function mesecon:cmpPos(p1, p2)
return (p1.x == p2.x and p1.y == p2.y and p1.z == p2.z)
end
function mesecon:cmpSpecial(r1, r2)
return (r1.sx == r2.sx and r1.sy == r2.sy and r1.sz == r2.sz)
end
function mesecon:tablecopy(table) -- deep table copy
local newtable = {}
for idx, item in pairs(table) do
if type(item) == "table" then
newtable[idx] = mesecon:tablecopy(item)
else
newtable[idx] = item
end
end
return newtable
end

View File

@ -1,39 +1,3 @@
-- Oldstyle wires:
if NEW_STYLE_WIRES == false then --old wires
minetest.register_node("mesecons:mesecon_off", {
drawtype = "raillike",
tiles = {"jeija_mesecon_off.png", "jeija_mesecon_curved_off.png", "jeija_mesecon_t_junction_off.png", "jeija_mesecon_crossing_off.png"},
inventory_image = "jeija_mesecon_off.png",
wield_image = "jeija_mesecon_off.png",
paramtype = "light",
is_ground_content = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
},
groups = {dig_immediate=3, mesecon=1, mesecon_conductor_craftable=1},
description="Mesecons",
})
minetest.register_node("mesecons:mesecon_on", {
drawtype = "raillike",
tiles = {"jeija_mesecon_on.png", "jeija_mesecon_curved_on.png", "jeija_mesecon_t_junction_on.png", "jeija_mesecon_crossing_on.png"},
paramtype = "light",
is_ground_content = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
},
groups = {dig_immediate=3, not_in_creaive_inventory=1, mesecon=1},
drop = '"mesecons:mesecon_off" 1',
light_source = LIGHT_MAX-11,
})
mesecon:register_conductor("mesecons:mesecon_on", "mesecons:mesecon_off")
else -- NEW STYLE WIRES
-- naming scheme: wire:(xp)(zp)(xm)(zm)_on/off -- naming scheme: wire:(xp)(zp)(xm)(zm)_on/off
-- The conditions in brackets define whether there is a mesecon at that place or not -- The conditions in brackets define whether there is a mesecon at that place or not
-- 1 = there is one; 0 = there is none -- 1 = there is one; 0 = there is none
@ -41,7 +5,6 @@ else -- NEW STYLE WIRES
box_center = {-1/16, -.5, -1/16, 1/16, -.5+1/16, 1/16} box_center = {-1/16, -.5, -1/16, 1/16, -.5+1/16, 1/16}
box_bump1 = { -2/16, -8/16, -2/16, 2/16, -13/32, 2/16 } box_bump1 = { -2/16, -8/16, -2/16, 2/16, -13/32, 2/16 }
box_bump2 = { -3/32, -13/32, -3/32, 3/32, -12/32, 3/32 }
box_xp = {1/16, -.5, -1/16, 8/16, -.5+1/16, 1/16} box_xp = {1/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
box_zp = {-1/16, -.5, 1/16, 1/16, -.5+1/16, 8/16} box_zp = {-1/16, -.5, 1/16, 1/16, -.5+1/16, 8/16}
@ -53,6 +16,8 @@ box_zpy = {-1/16, -.5+1/16, .5-1/16, 1/16, .4999+1/16, .5}
box_xmy = {-.5, -.5+1/16, -1/16, -.5+1/16, .4999+1/16, 1/16} box_xmy = {-.5, -.5+1/16, -1/16, -.5+1/16, .4999+1/16, 1/16}
box_zmy = {-1/16, -.5+1/16, -.5, 1/16, .4999+1/16, -.5+1/16} box_zmy = {-1/16, -.5+1/16, -.5, 1/16, .4999+1/16, -.5+1/16}
-- Registering the wires
for xp=0, 1 do for xp=0, 1 do
for zp=0, 1 do for zp=0, 1 do
for xm=0, 1 do for xm=0, 1 do
@ -69,10 +34,10 @@ for zmy=0, 1 do
tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy) tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy)
if nodeid == "00000000" then if nodeid == "00000000" then
groups = {dig_immediate = 3, mesecon = 2, mesecon_conductor_craftable=1} groups = {dig_immediate = 3, mesecon_conductor_craftable=1}
wiredesc = "Mesecon" wiredesc = "Mesecon"
else else
groups = {dig_immediate = 3, mesecon = 2, not_in_creative_inventory = 1} groups = {dig_immediate = 3, not_in_creative_inventory = 1}
wiredesc = "Mesecons Wire (ID: "..nodeid..")" wiredesc = "Mesecons Wire (ID: "..nodeid..")"
end end
@ -90,7 +55,6 @@ for zmy=0, 1 do
if adjx and adjz and (xp + zp + xm + zm > 2) then if adjx and adjz and (xp + zp + xm + zm > 2) then
table.insert(nodebox, box_bump1) table.insert(nodebox, box_bump1)
table.insert(nodebox, box_bump2)
tiles_off = { tiles_off = {
"wires_bump_off.png", "wires_bump_off.png",
"wires_bump_off.png", "wires_bump_off.png",
@ -144,7 +108,7 @@ for zmy=0, 1 do
sunlight_propagates = true, sunlight_propagates = true,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5} fixed = {-.5, -.5, -.5, .5, -.5+4/16, .5}
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -153,19 +117,27 @@ for zmy=0, 1 do
groups = groups, groups = groups,
walkable = false, walkable = false,
stack_max = 99, stack_max = 99,
drop = "mesecons:wire_00000000_off" drop = "mesecons:wire_00000000_off",
mesecons = {conductor={
state = mesecon.state.off,
onstate = "mesecons:wire_"..nodeid.."_on"
}}
}) })
minetest.register_node("mesecons:wire_"..nodeid.."_on", { minetest.register_node("mesecons:wire_"..nodeid.."_on", {
description = "Wire ID:"..nodeid, description = "Wire ID:"..nodeid,
drawtype = "nodebox", drawtype = "nodebox",
tiles = tiles_on, tiles = tiles_on,
-- inventory_image = "wires_inv.png",
-- wield_image = "wires_inv.png",
inventory_image = "jeija_mesecon_off.png",
wield_image = "jeija_mesecon_off.png",
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = true, sunlight_propagates = true,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5} fixed = {-.5, -.5, -.5, .5, -.5+4/16, .5}
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -174,9 +146,12 @@ for zmy=0, 1 do
groups = {dig_immediate = 3, mesecon = 2, not_in_creative_inventory = 1}, groups = {dig_immediate = 3, mesecon = 2, not_in_creative_inventory = 1},
walkable = false, walkable = false,
stack_max = 99, stack_max = 99,
drop = "mesecons:wire_00000000_off" drop = "mesecons:wire_00000000_off",
mesecons = {conductor={
state = mesecon.state.on,
offstate = "mesecons:wire_"..nodeid.."_off"
}}
}) })
mesecon:register_conductor("mesecons:wire_"..nodeid.."_on", "mesecons:wire_"..nodeid.."_off")
end end
end end
end end
@ -186,17 +161,18 @@ end
end end
end end
minetest.register_on_placenode(function(pos, node) -- Updating the wires:
if minetest.get_item_group(node.name, "mesecon") > 1 then -- Place the right connection wire
mesecon:update_autoconnect(pos)
end
end)
minetest.register_on_dignode(function(pos, node) local update_on_place_dig = function (pos, node)
if minetest.get_item_group(node.name, "mesecon") > 1 then if minetest.registered_nodes[node.name]
and minetest.registered_nodes[node.name].mesecons then
mesecon:update_autoconnect(pos) mesecon:update_autoconnect(pos)
end end
end) end
minetest.register_on_placenode(update_on_place_dig)
minetest.register_on_dignode(update_on_place_dig)
function mesecon:update_autoconnect(pos, secondcall, replace_old) function mesecon:update_autoconnect(pos, secondcall, replace_old)
local xppos = {x=pos.x+1, y=pos.y, z=pos.z} local xppos = {x=pos.x+1, y=pos.y, z=pos.z}
@ -231,68 +207,23 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old)
mesecon:update_autoconnect(zmympos, true) mesecon:update_autoconnect(zmympos, true)
end end
nodename = minetest.env:get_node(pos).name nodename = minetest.get_node(pos).name
if string.find(nodename, "mesecons:wire_") == nil and not replace_old then return nil end if string.find(nodename, "mesecons:wire_") == nil and not replace_old then return nil end
if mesecon:rules_link_anydir(pos, xppos) then xp = 1 else xp = 0 end
if mesecon:rules_link_anydir(pos, xmpos) then xm = 1 else xm = 0 end
if mesecon:rules_link_anydir(pos, zppos) then zp = 1 else zp = 0 end
if mesecon:rules_link_anydir(pos, zmpos) then zm = 1 else zm = 0 end
--if the groups mesecon == 1 then wires won't connect to it if mesecon:rules_link_anydir(pos, xpympos) then xp = 1 end
local zmg = minetest.get_item_group(minetest.env:get_node(zmpos ).name, "mesecon") if mesecon:rules_link_anydir(pos, xmympos) then xm = 1 end
local zmymg = minetest.get_item_group(minetest.env:get_node(zmympos).name, "mesecon") if mesecon:rules_link_anydir(pos, zpympos) then zp = 1 end
local xmg = minetest.get_item_group(minetest.env:get_node(xmpos ).name, "mesecon") if mesecon:rules_link_anydir(pos, zmympos) then zm = 1 end
local xmymg = minetest.get_item_group(minetest.env:get_node(xmympos).name, "mesecon")
local zpg = minetest.get_item_group(minetest.env:get_node(zppos ).name, "mesecon")
local zpymg = minetest.get_item_group(minetest.env:get_node(zpympos).name, "mesecon")
local xpg = minetest.get_item_group(minetest.env:get_node(xppos ).name, "mesecon")
local xpymg = minetest.get_item_group(minetest.env:get_node(xpympos).name, "mesecon")
if mesecon:rules_link_anydir(pos, xpypos) then xpy = 1 else xpy = 0 end
local xpyg = minetest.get_item_group(minetest.env:get_node(xpypos).name, "mesecon") if mesecon:rules_link_anydir(pos, zpypos) then zpy = 1 else zpy = 0 end
local zpyg = minetest.get_item_group(minetest.env:get_node(zpypos).name, "mesecon") if mesecon:rules_link_anydir(pos, xmypos) then xmy = 1 else xmy = 0 end
local xmyg = minetest.get_item_group(minetest.env:get_node(xmypos).name, "mesecon") if mesecon:rules_link_anydir(pos, zmypos) then zmy = 1 else zmy = 0 end
local zmyg = minetest.get_item_group(minetest.env:get_node(zmypos).name, "mesecon")
if ((zmg == 2) or (zmymg == 2)) == true then zm = 1 else zm = 0 end
if ((xmg == 2) or (xmymg == 2)) == true then xm = 1 else xm = 0 end
if ((zpg == 2) or (zpymg == 2)) == true then zp = 1 else zp = 0 end
if ((xpg == 2) or (xpymg == 2)) == true then xp = 1 else xp = 0 end
if xpyg == 2 then xpy = 1 else xpy = 0 end
if zpyg == 2 then zpy = 1 else zpy = 0 end
if xmyg == 2 then xmy = 1 else xmy = 0 end
if zmyg == 2 then zmy = 1 else zmy = 0 end
-- If group == 3 then the mesecon only connects to input and output ports
if xpg == 3 and mesecon:rules_link_bothdir(pos, xppos) then xp = 1 end
if xmg == 3 and mesecon:rules_link_bothdir(pos, xmpos) then xm = 1 end
if zpg == 3 and mesecon:rules_link_bothdir(pos, zppos) then zp = 1 end
if zmg == 3 and mesecon:rules_link_bothdir(pos, zmpos) then zm = 1 end
if xpymg == 3 and mesecon:rules_link_bothdir(pos, xpympos) then xp = 1 end
if xmymg == 3 and mesecon:rules_link_bothdir(pos, xmympos) then xm = 1 end
if zpymg == 3 and mesecon:rules_link_bothdir(pos, zpympos) then zp = 1 end
if zmymg == 3 and mesecon:rules_link_bothdir(pos, zmympos) then zm = 1 end
if xpyg == 3 then if mesecon:rules_link(pos, xpypos) then xpy = 1 end end
if zpyg == 3 then if mesecon:rules_link(pos, zpypos) then zpy = 1 end end
if xmyg == 3 then if mesecon:rules_link(pos, xmypos) then xmy = 1 end end
if zmyg == 3 then if mesecon:rules_link(pos, zmypos) then zmy = 1 end end
-- Backward compatibility
if replace_old then
xp = (xp == 1 or (string.find(minetest.env:get_node(xppos ).name, "mesecons:mesecon_") ~= nil or
string.find(minetest.env:get_node(xpympos).name, "mesecons:mesecon_") ~= nil)) and 1 or 0
zp = (zp == 1 or (string.find(minetest.env:get_node(zppos ).name, "mesecons:mesecon_") ~= nil or
string.find(minetest.env:get_node(zpympos).name, "mesecons:mesecon_") ~= nil)) and 1 or 0
xm = (xm == 1 or (string.find(minetest.env:get_node(xmpos ).name, "mesecons:mesecon_") ~= nil or
string.find(minetest.env:get_node(xmympos).name, "mesecons:mesecon_") ~= nil)) and 1 or 0
zm = (zm == 1 or (string.find(minetest.env:get_node(zmpos ).name, "mesecons:mesecon_") ~= nil or
string.find(minetest.env:get_node(zmympos).name, "mesecons:mesecon_") ~= nil)) and 1 or 0
xpy = (xpy == 1 or string.find(minetest.env:get_node(xpypos).name, "mesecons:mesecon_") ~=nil) and 1 or 0
zpy = (zpy == 1 or string.find(minetest.env:get_node(zpypos).name, "mesecons:mesecon_") ~=nil) and 1 or 0
xmy = (xmy == 1 or string.find(minetest.env:get_node(xmypos).name, "mesecons:mesecon_") ~=nil) and 1 or 0
zmy = (zmy == 1 or string.find(minetest.env:get_node(zmypos).name, "mesecons:mesecon_") ~=nil) and 1 or 0
end
if xpy == 1 then xp = 1 end if xpy == 1 then xp = 1 end
if zpy == 1 then zp = 1 end if zpy == 1 then zp = 1 end
@ -304,25 +235,46 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old)
if string.find(nodename, "_off") ~= nil then if string.find(nodename, "_off") ~= nil then
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"}) minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
else else
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" }) minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
end end
end end
minetest.register_craft({ if not minetest.registered_nodes["default:stone_with_mese"] then --before MESE update, use old recipes
output = '"mesecons:wire_00000000_off" 16', minetest.register_craft({
recipe = { output = "mesecons:wire_00000000_off 18",
{'"default:mese"'}, recipe = {
} {"default:mese"},
}) }
})
else
minetest.register_craft({
type = "cooking",
output = "mesecons:wire_00000000_off 2",
recipe = "default:mese_crystal_fragment",
cooktime = 3,
})
minetest.register_craft({
type = "cooking",
output = "mesecons:wire_00000000_off 18",
recipe = "default:mese_crystal",
cooktime = 15,
})
minetest.register_craft({
type = "cooking",
output = "mesecons:wire_00000000_off 162",
recipe = "default:mese",
cooktime = 30,
})
minetest.register_abm(
{nodenames = {"mesecons:mesecon_off", "mesecons:mesecon_on"},
interval = 2,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
mesecon:update_autoconnect(pos, false, true)
end,
})
end end
minetest.register_craft({
type = "cooking",
output = "mesecons:wire_00000000_off 16",
recipe = "default:mese_crystal",
})

View File

@ -11,7 +11,7 @@ minetest.register_alias("mesecons:wireless_receiver", "mesecons_wireless:wireles
minetest.register_alias("mesecons:wireless_transmitter", "mesecons_wireless:wireless_transmitter_off") minetest.register_alias("mesecons:wireless_transmitter", "mesecons_wireless:wireless_transmitter_off")
minetest.register_alias("mesecons:switch", "mesecons_switch:mesecon_switch_off") minetest.register_alias("mesecons:switch", "mesecons_switch:mesecon_switch_off")
minetest.register_alias("mesecons:button", "mesecons_button:button_off") minetest.register_alias("mesecons:button", "mesecons_button:button_off")
minetest.register_alias("mesecons:piston", "mesecons_pistons:piston_normal") minetest.register_alias("mesecons:piston", "mesecons_pistons:piston_normal_off")
minetest.register_alias("mesecons:blinky_plant", "mesecons_blinkyplant:blinky_plant_off") minetest.register_alias("mesecons:blinky_plant", "mesecons_blinkyplant:blinky_plant_off")
minetest.register_alias("mesecons:mesecon_torch", "mesecons_torch:mesecon_torch_on") minetest.register_alias("mesecons:mesecon_torch", "mesecons_torch:mesecon_torch_on")
minetest.register_alias("mesecons:torch", "mesecons_torch:mesecon_torch_on") minetest.register_alias("mesecons:torch", "mesecons_torch:mesecon_torch_on")
@ -23,10 +23,16 @@ minetest.register_alias("mesecons:mesecon_inverter", "mesecons_temperest:mesecon
minetest.register_alias("mesecons:movestone", "mesecons_movestones:movestone") minetest.register_alias("mesecons:movestone", "mesecons_movestones:movestone")
minetest.register_alias("mesecons:sticky_movestone", "mesecons_movestones:sticky_movestone") minetest.register_alias("mesecons:sticky_movestone", "mesecons_movestones:sticky_movestone")
minetest.register_alias("mesecons:noteblock", "mesecons_noteblock:noteblock") minetest.register_alias("mesecons:noteblock", "mesecons_noteblock:noteblock")
minetest.register_alias("mesecons:microcontroller", "mesecons_microcontroller:microcontroller") minetest.register_alias("mesecons:microcontroller", "mesecons_microcontroller:microcontroller0000")
minetest.register_alias("mesecons:delayer", "mesecons_delayer:delayer_off_1") minetest.register_alias("mesecons:delayer", "mesecons_delayer:delayer_off_1")
minetest.register_alias("mesecons:solarpanel", "mesecons_solarpanel:solar_panel_off") minetest.register_alias("mesecons:solarpanel", "mesecons_solarpanel:solar_panel_off")
--Backwards compatibility --Backwards compatibility
minetest.register_alias("mesecons:mesecon_off", "mesecons:wire_00000000_off") minetest.register_alias("mesecons:mesecon_off", "mesecons:wire_00000000_off")
minetest.register_alias("mesecons_pistons:piston_sticky", "mesecons_pistons:piston_sticky_on")
minetest.register_alias("mesecons_pistons:piston_normal", "mesecons_pistons:piston_normal_on")
minetest.register_alias("mesecons_pistons:piston_up_normal", "mesecons_pistons:piston_up_normal_on")
minetest.register_alias("mesecons_pistons:piston_down_normal", "mesecons_pistons:piston_down_normal_on")
minetest.register_alias("mesecons_pistons:piston_up_sticky", "mesecons_pistons:piston_up_sticky_on")
minetest.register_alias("mesecons_pistons:piston_down_sticky", "mesecons_pistons:piston_down_sticky_on")

View File

@ -1,4 +1,25 @@
-- The BLINKY_PLANT -- The BLINKY_PLANT
minetest.register_node("mesecons_blinkyplant:blinky_plant", {
drawtype = "plantlike",
visual_scale = 1,
tiles = {"jeija_blinky_plant_off.png"},
inventory_image = "jeija_blinky_plant_off.png",
walkable = false,
groups = {dig_immediate=3, not_in_creative_inventory=1},
drop="mesecons_blinkyplant:blinky_plant_off 1",
description="Deactivated Blinky Plant",
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
},
mesecons = {receptor = {
state = mesecon.state.off
}},
on_rightclick = function(pos, node, clicker)
minetest.set_node(pos, {name="mesecons_blinkyplant:blinky_plant_off"})
end
})
minetest.register_node("mesecons_blinkyplant:blinky_plant_off", { minetest.register_node("mesecons_blinkyplant:blinky_plant_off", {
drawtype = "plantlike", drawtype = "plantlike",
@ -7,12 +28,19 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_off", {
inventory_image = "jeija_blinky_plant_off.png", inventory_image = "jeija_blinky_plant_off.png",
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
groups = {dig_immediate=3, mesecon = 2}, groups = {dig_immediate=3, mesecon=2},
description="Blinky Plant", description="Blinky Plant",
sounds = default.node_sound_leaves_defaults(),
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
}, },
mesecons = {receptor = {
state = mesecon.state.off
}},
on_rightclick = function(pos, node, clicker)
minetest.set_node(pos, {name="mesecons_blinkyplant:blinky_plant"})
end
}) })
minetest.register_node("mesecons_blinkyplant:blinky_plant_on", { minetest.register_node("mesecons_blinkyplant:blinky_plant_on", {
@ -22,22 +50,30 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_on", {
inventory_image = "jeija_blinky_plant_off.png", inventory_image = "jeija_blinky_plant_off.png",
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
groups = {dig_immediate=3, not_in_creative_inventory=1, mesecon = 2}, groups = {dig_immediate=3, not_in_creative_inventory=1, mesecon=2},
drop='"mesecons_blinkyplant:blinky_plant_off" 1', drop="mesecons_blinkyplant:blinky_plant_off 1",
light_source = LIGHT_MAX-7, light_source = LIGHT_MAX-7,
description = "Blinky Plant", description = "Blinky Plant",
sounds = default.node_sound_leaves_defaults(),
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
}, },
mesecons = {receptor = {
state = mesecon.state.on
}},
on_rightclick = function(pos, node, clicker)
minetest.set_node(pos, {name = "mesecons_blinkyplant:blinky_plant"})
mesecon:receptor_off(pos)
end
}) })
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_blinkyplant:blinky_plant_off" 1', output = "mesecons_blinkyplant:blinky_plant_off 1",
recipe = { recipe = {
{'','"group:mesecon_conductor_craftable"',''}, {"","group:mesecon_conductor_craftable",""},
{'','"group:mesecon_conductor_craftable"',''}, {"","group:mesecon_conductor_craftable",""},
{'"default:sapling"','"default:sapling"','"default:sapling"'}, {"default:sapling","default:sapling","default:sapling"},
} }
}) })
@ -46,8 +82,8 @@ minetest.register_abm(
interval = BLINKY_PLANT_INTERVAL, interval = BLINKY_PLANT_INTERVAL,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
--minetest.env:remove_node(pos) --minetest.remove_node(pos)
minetest.env:add_node(pos, {name="mesecons_blinkyplant:blinky_plant_on"}) minetest.add_node(pos, {name="mesecons_blinkyplant:blinky_plant_on"})
nodeupdate(pos) nodeupdate(pos)
mesecon:receptor_on(pos) mesecon:receptor_on(pos)
end, end,
@ -58,12 +94,9 @@ minetest.register_abm({
interval = BLINKY_PLANT_INTERVAL, interval = BLINKY_PLANT_INTERVAL,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
--minetest.env:remove_node(pos) --minetest.remove_node(pos)
minetest.env:add_node(pos, {name="mesecons_blinkyplant:blinky_plant_off"}) minetest.add_node(pos, {name="mesecons_blinkyplant:blinky_plant_off"})
nodeupdate(pos) nodeupdate(pos)
mesecon:receptor_off(pos) mesecon:receptor_off(pos)
end, end,
}) })
mesecon:add_receptor_node("mesecons_blinkyplant:blinky_plant_on")
mesecon:add_receptor_node_off("mesecons_blinkyplant:blinky_plant_off")

View File

@ -1,7 +1,20 @@
-- WALL BUTTON -- WALL BUTTON
-- A button that when pressed emits power for 1 second
-- and then turns off again
mesecon.button_turnoff = function (pos)
local node = minetest.get_node(pos)
if node.name=="mesecons_button:button_on" then --has not been dug
minetest.swap_node(pos, {name = "mesecons_button:button_off", param2=node.param2})
minetest.sound_play("mesecons_button_pop", {pos=pos})
local rules = mesecon.rules.buttonlike_get(node)
mesecon:receptor_off(pos, rules)
end
end
minetest.register_node("mesecons_button:button_off", { minetest.register_node("mesecons_button:button_off", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
"jeija_wall_button_sides.png", "jeija_wall_button_sides.png",
"jeija_wall_button_sides.png", "jeija_wall_button_sides.png",
"jeija_wall_button_sides.png", "jeija_wall_button_sides.png",
@ -9,25 +22,37 @@ minetest.register_node("mesecons_button:button_off", {
"jeija_wall_button_sides.png", "jeija_wall_button_sides.png",
"jeija_wall_button_off.png" "jeija_wall_button_off.png"
}, },
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
legacy_wallmounted = true, legacy_wallmounted = true,
walkable = false, walkable = false,
sunlight_propagates = true, sunlight_propagates = true,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 } fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{ -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, -- the thin plate behind the button { -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, -- the thin plate behind the button
{ -4/16, -2/16, 4/16, 4/16, 2/16, 6/16 } -- the button itself { -4/16, -2/16, 4/16, 4/16, 2/16, 6/16 } -- the button itself
} }
}, },
groups = {dig_immediate=2, mesecon = 3, mesecon_needs_receiver = 1}, groups = {dig_immediate=2, mesecon_needs_receiver = 1},
description = "Button", description = "Button",
on_punch = function (pos, node)
minetest.swap_node(pos, {name = "mesecons_button:button_on", param2=node.param2})
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
minetest.sound_play("mesecons_button_push", {pos=pos})
minetest.after(1, mesecon.button_turnoff, pos)
end,
sounds = default.node_sound_stone_defaults(),
mesecons = {receptor = {
state = mesecon.state.off,
rules = mesecon.rules.buttonlike_get
}}
}) })
minetest.register_node("mesecons_button:button_on", { minetest.register_node("mesecons_button:button_on", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
@ -44,68 +69,30 @@ minetest.register_node("mesecons_button:button_on", {
walkable = false, walkable = false,
light_source = LIGHT_MAX-7, light_source = LIGHT_MAX-7,
sunlight_propagates = true, sunlight_propagates = true,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 } fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{ -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, { -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 },
{ -4/16, -2/16, 11/32, 4/16, 2/16, 6/16 } { -4/16, -2/16, 11/32, 4/16, 2/16, 6/16 }
} }
}, },
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3, mesecon_needs_receiver = 1}, groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon_needs_receiver = 1},
drop = 'mesecons_button:button_off', drop = 'mesecons_button:button_off',
description = "Button", description = "Button",
sounds = default.node_sound_stone_defaults(),
mesecons = {receptor = {
state = mesecon.state.on,
rules = mesecon.rules.buttonlike_get
}}
}) })
minetest.register_on_punchnode(function(pos, node, puncher)
if node.name == "mesecons_button:button_off" then
minetest.env:add_node(pos, {name="mesecons_button:button_on",param2=node.param2})
local rules=mesecon.button_get_rules(node.param2)
mesecon:receptor_on(pos, rules)
minetest.after(1, mesecon.button_turnoff, {pos=pos, param2=node.param2})
end
end)
mesecon.button_turnoff = function (params)
if minetest.env:get_node(params.pos).name=="mesecons_button:button_on" then
minetest.env:add_node(params.pos, {name="mesecons_button:button_off", param2=params.param2})
local rules=mesecon.button_get_rules(params.param2)
mesecon:receptor_off(params.pos, rules)
end
end
mesecon.button_get_rules = function(param2)
local rules=mesecon:get_rules("button")
if param2 == 2 then
rules=mesecon:rotate_rules_left(rules)
end
if param2 == 3 then
rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
end
if param2 == 0 then
rules=mesecon:rotate_rules_right(rules)
end
return rules
end
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_button:button_off" 2', output = "mesecons_button:button_off 2",
recipe = { recipe = {
{'"group:mesecon_conductor_craftable"','"default:stone"'}, {"group:mesecon_conductor_craftable","default:stone"},
} }
}) })
mesecon:add_rules("button", {
{x = 1, y = 0, z = 0},
{x = 1, y = 1, z = 0},
{x = 1, y =-1, z = 0},
{x = 1, y =-1, z = 1},
{x = 1, y =-1, z =-1},
{x = 2, y = 0, z = 0},})
mesecon:add_receptor_node_off("mesecons_button:button_off", nil, mesecon.button_get_rules)
mesecon:add_receptor_node("mesecons_button:button_on", nil, mesecon.button_get_rules)

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,55 @@
minetest.register_chatcommand("say", {
params = "<text>",
description = "Say <text> as the server",
privs = {server=true},
func = function(name, param)
minetest.chat_send_all(name .. ": " .. param)
end
})
minetest.register_chatcommand("tell", {
params = "<name> <text>",
description = "Say <text> to <name> privately",
func = function(name, param)
local found, _, target, message = param:find("^([^%s]+)%s+(.*)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param)
return
end
if not minetest.get_player_by_name(target) then
minetest.chat_send_player(name, "Invalid target: " .. target)
end
minetest.chat_send_player(target, name .. " whispers: " .. message, false)
end
})
minetest.register_chatcommand("tellme", {
params = "<text>",
description = "Say <text> to yourself",
func = function(name, param)
minetest.chat_send_player(name, param, false)
end
})
minetest.register_chatcommand("hp", {
params = "<name> <value>",
description = "Set health of <name> to <value> hitpoints",
privs = {ban=true},
func = function(name, param)
local found, _, target, value = param:find("^([^%s]+)%s+(%d+)$")
if found == nil then
minetest.chat_send_player(name, "Invalid usage: " .. param)
return
end
local player = minetest.get_player_by_name(target)
if player then
player:set_hp(value)
else
minetest.chat_send_player(name, "Invalid target: " .. target)
end
end
})
local initialize_data = function(meta, player, command, param) local initialize_data = function(meta, player, command, param)
meta:set_string("formspec", meta:set_string("formspec",
"invsize[9,6;]" .. "invsize[9,6;]" ..
@ -20,7 +72,7 @@ local initialize_data = function(meta, player, command, param)
end end
local construct = function(pos) local construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("player", "@nearest") meta:set_string("player", "@nearest")
meta:set_string("command", "time") meta:set_string("command", "time")
@ -33,14 +85,17 @@ end
local after_place = function(pos, placer) local after_place = function(pos, placer)
if placer then if placer then
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name()) meta:set_string("owner", placer:get_player_name())
initialize_data(meta, "@nearest", "time", "7000") initialize_data(meta, "@nearest", "time", "7000")
end end
end end
local receive_fields = function(pos, formname, fields, sender) local receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos) if fields.quit then
return
end
local meta = minetest.get_meta(pos)
if fields.nearest then if fields.nearest then
initialize_data(meta, "@nearest", fields.command, fields.param) initialize_data(meta, "@nearest", fields.command, fields.param)
elseif fields.farthest then elseif fields.farthest then
@ -87,52 +142,14 @@ local resolve_player = function(name, pos)
return name return name
end end
minetest.register_node("mesecons_commandblock:commandblock_off", { local commandblock_action_on = function(pos, node)
description = "Command Block",
tiles = {"jeija_commandblock_off.png"},
inventory_image = minetest.inventorycube("jeija_commandblock_off.png"),
groups = {cracky=2, mesecon_effector_off=1, mesecon=2},
on_construct = construct,
after_place_node = after_place,
on_receive_fields = receive_fields,
can_dig = function(pos,player)
local owner = minetest.env:get_meta(pos):get_string("owner")
return owner == "" or owner == player:get_player_name()
end,
})
minetest.register_node("mesecons_commandblock:commandblock_on", {
tiles = {"jeija_commandblock_on.png"},
groups = {cracky=2, mesecon_effector_on=1, mesecon=2, not_in_creative_inventory=1},
light_source = 10,
drop = "mesecons_commandblock:commandblock_off",
on_construct = construct,
after_place_node = after_place,
on_receive_fields = receive_fields,
can_dig = function(pos,player)
local owner = minetest.env:get_meta(pos):get_string("owner")
return owner == "" or owner == player:get_player_name()
end,
})
mesecon:register_effector("mesecons_commandblock:commandblock_on", "mesecons_commandblock:commandblock_off")
local swap_node = function(pos, name)
local node = minetest.env:get_node(pos)
local data = minetest.env:get_meta(pos):to_table()
node.name = name
minetest.env:add_node(pos, node)
minetest.env:get_meta(pos):from_table(data)
end
mesecon:register_on_signal_on(function(pos, node)
if node.name ~= "mesecons_commandblock:commandblock_off" then if node.name ~= "mesecons_commandblock:commandblock_off" then
return return
end end
swap_node(pos, "mesecons_commandblock:commandblock_on") minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_on"})
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local command = minetest.chatcommands[meta:get_string("command")] local command = minetest.chatcommands[meta:get_string("command")]
if command == nil then if command == nil then
return return
@ -148,10 +165,46 @@ mesecon:register_on_signal_on(function(pos, node)
end end
local player = resolve_player(meta:get_string("player"), pos) local player = resolve_player(meta:get_string("player"), pos)
command.func(player, meta:get_string("param")) command.func(player, meta:get_string("param"))
end) end
mesecon:register_on_signal_off(function(pos, node) local commandblock_action_off = function(pos, node)
if node.name == "mesecons_commandblock:commandblock_on" then if node.name == "mesecons_commandblock:commandblock_on" then
swap_node(pos, "mesecons_commandblock:commandblock_off") minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_off"})
end end
end) end
minetest.register_node("mesecons_commandblock:commandblock_off", {
description = "Command Block",
tiles = {"jeija_commandblock_off.png"},
inventory_image = minetest.inventorycube("jeija_commandblock_off.png"),
groups = {cracky=2, mesecon_effector_off=1},
on_construct = construct,
after_place_node = after_place,
on_receive_fields = receive_fields,
can_dig = function(pos,player)
local owner = minetest.get_meta(pos):get_string("owner")
return owner == "" or owner == player:get_player_name()
end,
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
action_on = commandblock_action_on
}}
})
minetest.register_node("mesecons_commandblock:commandblock_on", {
tiles = {"jeija_commandblock_on.png"},
groups = {cracky=2, mesecon_effector_on=1, not_in_creative_inventory=1},
light_source = 10,
drop = "mesecons_commandblock:commandblock_off",
on_construct = construct,
after_place_node = after_place,
on_receive_fields = receive_fields,
can_dig = function(pos,player)
local owner = minetest.get_meta(pos):get_string("owner")
return owner == "" or owner == player:get_player_name()
end,
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
action_off = commandblock_action_off
}}
})

View File

@ -0,0 +1,2 @@
mesecons
doors

View File

@ -0,0 +1,167 @@
doors = {}
-- Registers a door - REDEFINITION ONLY | DOORS MOD MUST HAVE BEEN LOADED BEFORE
-- name: The name of the door
-- def: a table with the folowing fields:
-- description
-- inventory_image
-- groups
-- tiles_bottom: the tiles of the bottom part of the door {front, side}
-- tiles_top: the tiles of the bottom part of the door {front, side}
-- If the following fields are not defined the default values are used
-- node_box_bottom
-- node_box_top
-- selection_box_bottom
-- selection_box_top
-- only_placer_can_open: if true only the player who placed the door can
-- open it
function doors:register_door(name, def)
def.groups.not_in_creative_inventory = 1
local box = {{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5+1.5/16}}
if not def.node_box_bottom then
def.node_box_bottom = box
end
if not def.node_box_top then
def.node_box_top = box
end
if not def.selection_box_bottom then
def.selection_box_bottom= box
end
if not def.selection_box_top then
def.selection_box_top = box
end
local tt = def.tiles_top
local tb = def.tiles_bottom
local function after_dig_node(pos, name)
if minetest.get_node(pos).name == name then
minetest.remove_node(pos)
end
end
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
pos.y = pos.y+dir
if not minetest.get_node(pos).name == check_name then
return
end
local p2 = minetest.get_node(pos).param2
p2 = params[p2+1]
local meta = minetest.get_meta(pos):to_table()
minetest.set_node(pos, {name=replace_dir, param2=p2})
minetest.get_meta(pos):from_table(meta)
pos.y = pos.y-dir
meta = minetest.get_meta(pos):to_table()
minetest.set_node(pos, {name=replace, param2=p2})
minetest.get_meta(pos):from_table(meta)
end
local function on_mesecons_signal_open (pos, node)
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
end
local function on_mesecons_signal_close (pos, node)
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
end
local function check_player_priv(pos, player)
if not def.only_placer_can_open then
return true
end
local meta = minetest.get_meta(pos)
local pn = player:get_player_name()
return meta:get_string("doors_owner") == pn
end
minetest.register_node(":"..name.."_b_1", {
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1], tb[1].."^[transformfx"},
paramtype = "light",
paramtype2 = "facedir",
drop = name,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = def.node_box_bottom
},
selection_box = {
type = "fixed",
fixed = def.selection_box_bottom
},
groups = def.groups,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
pos.y = pos.y+1
after_dig_node(pos, name.."_t_1")
end,
on_rightclick = function(pos, node, puncher)
if check_player_priv(pos, puncher) then
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
end
end,
mesecons = {effector = {
action_on = on_mesecons_signal_open
}},
can_dig = check_player_priv,
})
minetest.register_node(":"..name.."_b_2", {
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1].."^[transformfx", tb[1]},
paramtype = "light",
paramtype2 = "facedir",
drop = name,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = def.node_box_bottom
},
selection_box = {
type = "fixed",
fixed = def.selection_box_bottom
},
groups = def.groups,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
pos.y = pos.y+1
after_dig_node(pos, name.."_t_2")
end,
on_rightclick = function(pos, node, puncher)
if check_player_priv(pos, puncher) then
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
end
end,
mesecons = {effector = {
action_off = on_mesecons_signal_close
}},
can_dig = check_player_priv,
})
end
doors:register_door("doors:door_wood", {
description = "Wooden Door",
inventory_image = "door_wood.png",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1},
tiles_bottom = {"door_wood_b.png", "door_brown.png"},
tiles_top = {"door_wood_a.png", "door_brown.png"},
sounds = default.node_sound_wood_defaults(),
})
doors:register_door("doors:door_steel", {
description = "Steel Door",
inventory_image = "door_steel.png",
groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1},
tiles_bottom = {"door_steel_b.png", "door_grey.png"},
tiles_top = {"door_steel_a.png", "door_grey.png"},
only_placer_can_open = true,
sounds = default.node_sound_stone_defaults(),
})

View File

@ -1,11 +1,62 @@
-- Function that get the input/output rules of the delayer
local delayer_get_output_rules = function(node)
local rules = {{x = 0, y = 0, z = 1}}
for i = 0, node.param2 do
rules = mesecon:rotate_rules_left(rules)
end
return rules
end
local delayer_get_input_rules = function(node)
local rules = {{x = 0, y = 0, z = -1}}
for i = 0, node.param2 do
rules = mesecon:rotate_rules_left(rules)
end
return rules
end
-- Functions that are called after the delay time
local delayer_turnon = function(params)
local rules = delayer_get_output_rules(params.node)
mesecon:receptor_on(params.pos, rules)
end
local delayer_turnoff = function(params)
local rules = delayer_get_output_rules(params.node)
mesecon:receptor_off(params.pos, rules)
end
local delayer_activate = function(pos, node)
local def = minetest.registered_nodes[node.name]
local time = def.delayer_time
minetest.swap_node(pos, {name = def.delayer_onstate, param2=node.param2})
minetest.after(time, delayer_turnon , {pos = pos, node = node})
end
local delayer_deactivate = function(pos, node)
local def = minetest.registered_nodes[node.name]
local time = def.delayer_time
minetest.swap_node(pos, {name = def.delayer_offstate, param2=node.param2})
minetest.after(time, delayer_turnoff, {pos = pos, node = node})
end
-- Register the 2 (states) x 4 (delay times) delayers
for i = 1, 4 do for i = 1, 4 do
local groups = {} local groups = {}
if i == 1 then if i == 1 then
groups = {bendy=2,snappy=1,dig_immediate=2, mesecon = 3} groups = {bendy=2,snappy=1,dig_immediate=2}
else else
groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1, mesecon = 3} groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1}
end end
local delaytime
if i == 1 then delaytime = 0.1
elseif i == 2 then delaytime = 0.3
elseif i == 3 then delaytime = 0.5
elseif i == 4 then delaytime = 1.0 end
boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab
{ -2/16, -7/16, -4/16, 2/16, -26/64, -3/16 }, -- the jeweled "on" indicator { -2/16, -7/16, -4/16, 2/16, -26/64, -3/16 }, -- the jeweled "on" indicator
@ -46,6 +97,32 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), {
sunlight_propagates = true, sunlight_propagates = true,
is_ground_content = true, is_ground_content = true,
drop = 'mesecons_delayer:delayer_off_1', drop = 'mesecons_delayer:delayer_off_1',
on_punch = function (pos, node)
if node.name=="mesecons_delayer:delayer_off_1" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_2", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_off_2" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_3", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_off_3" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_4", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_off_4" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_1", param2=node.param2})
end
end,
delayer_time = delaytime,
delayer_onstate = "mesecons_delayer:delayer_on_"..tostring(i),
sounds = default.node_sound_stone_defaults(),
mesecons = {
receptor =
{
state = mesecon.state.off,
rules = delayer_get_output_rules
},
effector =
{
rules = delayer_get_input_rules,
action_on = delayer_activate
}
}
}) })
@ -69,147 +146,44 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), {
type = "fixed", type = "fixed",
fixed = boxes fixed = boxes
}, },
groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1, mesecon = 3}, groups = {bendy = 2, snappy = 1, dig_immediate = 2, not_in_creative_inventory = 1},
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = true, sunlight_propagates = true,
is_ground_content = true, is_ground_content = true,
drop = 'mesecons_delayer:delayer_off_1', drop = 'mesecons_delayer:delayer_off_1',
on_punch = function (pos, node)
if node.name=="mesecons_delayer:delayer_on_1" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_2", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_on_2" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_3", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_on_3" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_4", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_on_4" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_1", param2=node.param2})
end
end,
delayer_time = delaytime,
delayer_offstate = "mesecons_delayer:delayer_off_"..tostring(i),
mesecons = {
receptor =
{
state = mesecon.state.on,
rules = delayer_get_output_rules
},
effector =
{
rules = delayer_get_input_rules,
action_off = delayer_deactivate
}
}
}) })
end end
minetest.register_craft({
output = "mesecons_delayer:delayer_off_1",
recipe = {
minetest.register_on_punchnode(function (pos, node) {"mesecons_torch:mesecon_torch_on", "group:mesecon_conductor_craftable", "mesecons_torch:mesecon_torch_on"},
mesecon.delayer_get_output_rules(node.param2) {"default:cobble","default:cobble", "default:cobble"},
if node.name=="mesecons_delayer:delayer_off_1" then }
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2}) })
end
if node.name=="mesecons_delayer:delayer_off_2" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_3", param2=node.param2})
end
if node.name=="mesecons_delayer:delayer_off_3" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_4", param2=node.param2})
end
if node.name=="mesecons_delayer:delayer_off_4" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_1", param2=node.param2})
end
end)
minetest.register_on_punchnode(function (pos, node)
mesecon.delayer_get_output_rules(node.param2)
if node.name=="mesecons_delayer:delayer_on_1" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_2", param2=node.param2})
end
if node.name=="mesecons_delayer:delayer_on_2" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_3", param2=node.param2})
end
if node.name=="mesecons_delayer:delayer_on_3" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_4", param2=node.param2})
end
if node.name=="mesecons_delayer:delayer_on_4" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_1", param2=node.param2})
end
end)
mesecon.delayer_update = function(pos, node)
if string.find(node.name, "mesecons_delayer:delayer_off")~=nil then
local time = 0
if node.name=="mesecons_delayer:delayer_off_1" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_1", param2=node.param2})
time=0.1
end
if node.name=="mesecons_delayer:delayer_off_2" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_2", param2=node.param2})
time=0.3
end
if node.name=="mesecons_delayer:delayer_off_3" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_3", param2=node.param2})
time=0.5
end
if node.name=="mesecons_delayer:delayer_off_4" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_4", param2=node.param2})
time=1
end
minetest.after(time, mesecon.delayer_turnon, {pos=pos, param2=node.param2})
end
if string.find(node.name, "mesecons_delayer:delayer_on")~=nil then
local time = 0
if node.name=="mesecons_delayer:delayer_on_1" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_1", param2=node.param2})
time=0.1
end
if node.name=="mesecons_delayer:delayer_on_2" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2})
time=0.3
end
if node.name=="mesecons_delayer:delayer_on_3" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_3", param2=node.param2})
time=0.5
end
if node.name=="mesecons_delayer:delayer_on_4" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_4", param2=node.param2})
time=1
end
minetest.after(time, mesecon.delayer_turnoff, {pos=pos, param2=node.param2})
end
end
mesecon:register_on_signal_change(mesecon.delayer_update)
mesecon.delayer_turnon=function(params)
local rules = mesecon.delayer_get_output_rules(params.param2)
mesecon:receptor_on(params.pos, rules)
end
mesecon.delayer_turnoff=function(params)
local rules = mesecon.delayer_get_output_rules(params.param2)
mesecon:receptor_off(params.pos, rules)
end
mesecon.delayer_get_output_rules = function(param2)
local rules = {}
if param2 == 0 then
table.insert(rules, {x = 1, y = 0, z = 0})
elseif param2 == 2 then
table.insert(rules, {x =-1, y = 0, z = 0})
elseif param2 == 1 then
table.insert(rules, {x = 0, y = 0, z =-1})
elseif param2 == 3 then
table.insert(rules, {x = 0, y = 0, z = 1})
end
return rules
end
mesecon.delayer_get_input_rules = function(param2)
local rules = {}
if param2 == 0 then
table.insert(rules, {x =-1, y = 0, z = 0})
elseif param2 == 2 then
table.insert(rules, {x = 1, y = 0, z = 0})
elseif param2 == 1 then
table.insert(rules, {x = 0, y = 0, z = 1})
elseif param2 == 3 then
table.insert(rules, {x = 0, y = 0, z =-1})
end
return rules
end
all_rules = {{x = 1, y = 0, z = 0}, {x =-1, y = 0, z = 0}, {x = 0, y = 0, z =-1}, {x = 0, y = 0, z = 1}} --required to check if a newly placed should be turned on
mesecon:add_receptor_node("mesecons_delayer:delayer_on_1", all_rules, mesecon.delayer_get_output_rules)
mesecon:add_receptor_node("mesecons_delayer:delayer_on_2", all_rules, mesecon.delayer_get_output_rules)
mesecon:add_receptor_node("mesecons_delayer:delayer_on_3", all_rules, mesecon.delayer_get_output_rules)
mesecon:add_receptor_node("mesecons_delayer:delayer_on_4", all_rules, mesecon.delayer_get_output_rules)
mesecon:add_receptor_node_off("mesecons_delayer:delayer_off_1", all_rules, mesecon.delayer_get_output_rules)
mesecon:add_receptor_node_off("mesecons_delayer:delayer_off_2", all_rules, mesecon.delayer_get_output_rules)
mesecon:add_receptor_node_off("mesecons_delayer:delayer_off_3", all_rules, mesecon.delayer_get_output_rules)
mesecon:add_receptor_node_off("mesecons_delayer:delayer_off_4", all_rules, mesecon.delayer_get_output_rules)
mesecon:register_effector("mesecons_delayer:delayer_on_1", "mesecons_delayer:delayer_off_1", all_rules, mesecon.delayer_get_input_rules)
mesecon:register_effector("mesecons_delayer:delayer_on_2", "mesecons_delayer:delayer_off_2", all_rules, mesecon.delayer_get_input_rules)
mesecon:register_effector("mesecons_delayer:delayer_on_3", "mesecons_delayer:delayer_off_3", all_rules, mesecon.delayer_get_input_rules)
mesecon:register_effector("mesecons_delayer:delayer_on_4", "mesecons_delayer:delayer_off_4", all_rules, mesecon.delayer_get_input_rules)

View File

@ -1,27 +1,87 @@
--SHORT RANGE DETECTORS -- Object detector
-- Detects players in a certain radius
-- The radius can be specified in mesecons/settings.lua
local object_detector_make_formspec = function (pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[9,2.5]" ..
"field[0.3, 0;9,2;scanname;Name of player to scan for (empty for any):;${scanname}]"..
"field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]")
end
local object_detector_on_receive_fields = function(pos, formname, fields)
if fields.quit then
return
end
local meta = minetest.get_meta(pos)
meta:set_string("scanname", fields.scanname)
meta:set_string("digiline_channel", fields.digiline_channel)
object_detector_make_formspec(pos)
end
-- returns true if player was found, false if not
local object_detector_scan = function (pos)
local objs = minetest.get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS)
for k, obj in pairs(objs) do
local isname = obj:get_player_name() -- "" is returned if it is not a player; "" ~= nil!
local scanname = minetest.get_meta(pos):get_string("scanname")
if (isname == scanname and isname ~= "") or (isname ~= "" and scanname == "") then -- player with scanname found or not scanname specified
return true
end
end
return false
end
-- set player name when receiving a digiline signal on a specific channel
object_detector_digiline = {
effector = {
action = function (pos, node, channel, msg)
local meta = minetest.get_meta(pos)
local active_channel = meta:get_string("digiline_channel")
if channel == active_channel then
meta:set_string("scanname", msg)
object_detector_make_formspec(pos)
end
end,
}
}
minetest.register_node("mesecons_detector:object_detector_off", { minetest.register_node("mesecons_detector:object_detector_off", {
tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png"}, tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png"},
paramtype = "light", paramtype = "light",
walkable = true, walkable = true,
groups = {cracky=3, mesecon = 2}, groups = {cracky=3},
description="Player Detector", description="Player Detector",
mesecons = {receptor = {
state = mesecon.state.off
}},
on_construct = object_detector_make_formspec,
on_receive_fields = object_detector_on_receive_fields,
sounds = default.node_sound_stone_defaults(),
digiline = object_detector_digiline
}) })
minetest.register_node("mesecons_detector:object_detector_on", { minetest.register_node("mesecons_detector:object_detector_on", {
tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png"}, tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png"},
paramtype = "light", paramtype = "light",
walkable = true, walkable = true,
groups = {cracky=3,not_in_creative_inventory=1, mesecon = 2}, groups = {cracky=3,not_in_creative_inventory=1},
drop = 'mesecons_detector:object_detector_off', drop = 'mesecons_detector:object_detector_off',
description="Player Detector", mesecons = {receptor = {
state = mesecon.state.on
}},
on_construct = object_detector_make_formspec,
on_receive_fields = object_detector_on_receive_fields,
sounds = default.node_sound_stone_defaults(),
digiline = object_detector_digiline
}) })
minetest.register_craft({ minetest.register_craft({
output = 'mesecons_detector:object_detector_off', output = 'mesecons_detector:object_detector_off',
recipe = { recipe = {
{"default:steelblock", '', "default:steelblock"}, {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:steelblock", "mesecons_microcontroller:microcontroller0000", "default:steelblock"}, {"default:steel_ingot", "mesecons_luacontroller:luacontroller0000", "default:steel_ingot"},
{"default:steelblock", "group:mesecon_conductor_craftable", "default:steelblock"}, {"default:steel_ingot", "group:mesecon_conductor_craftable", "default:steel_ingot"},
} }
}) })
@ -29,19 +89,10 @@ minetest.register_abm(
{nodenames = {"mesecons_detector:object_detector_off"}, {nodenames = {"mesecons_detector:object_detector_off"},
interval = 1.0, interval = 1.0,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos)
local objs = minetest.env:get_objects_inside_radius(pos, 6) if object_detector_scan(pos) then
for k, obj in pairs(objs) do minetest.swap_node(pos, {name = "mesecons_detector:object_detector_on"})
if obj:get_entity_name()~="mesecons_pistons:piston_pusher_sticky" and obj:get_entity_name()~="mesecons_pistons:piston_pusher_normal" and obj:get_player_name()~=nil then -- Detected object is not piston pusher - will be changed if every entity has a type (like entity_type=mob) mesecon:receptor_on(pos)
if minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name=="default:sign_wall" then
if obj:get_player_name()~=minetest.env:get_meta({x=pos.x, y=pos.y-1, z=pos.z}):get_string("text") then
return
end
end
local objpos=obj:getpos()
minetest.env:add_node(pos, {name="mesecons_detector:object_detector_on"})
mesecon:receptor_on(pos, mesecon:get_rules("pressureplate"))
end
end end
end, end,
}) })
@ -50,28 +101,10 @@ minetest.register_abm(
{nodenames = {"mesecons_detector:object_detector_on"}, {nodenames = {"mesecons_detector:object_detector_on"},
interval = 1.0, interval = 1.0,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos)
local objs = minetest.env:get_objects_inside_radius(pos, 6) if not object_detector_scan(pos) then
local objectfound=0 minetest.swap_node(pos, {name = "mesecons_detector:object_detector_off"})
for k, obj in pairs(objs) do mesecon:receptor_off(pos)
if obj:get_entity_name()~="mesecons_pistons:piston_pusher_sticky" and obj:get_entity_name()~="mesecons_pistons:piston_pusher_normal" and obj~=nil
and obj:get_player_name()~=nil then
if minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name=="default:sign_wall" then
if minetest.env:get_meta({x=pos.x, y=pos.y-1, z=pos.z}):get_string("text")== obj:get_player_name() then
objectfound=objectfound+1
end
else
-- Detected object is not piston pusher - will be changed if every entity has a type (like entity_type=mob)
objectfound=objectfound + 1
end
end
end
if objectfound==0 then
minetest.env:add_node(pos, {name="mesecons_detector:object_detector_off"})
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
end end
end, end,
}) })
mesecon:add_receptor_node("mesecons_detector:object_detector_on", mesecon:get_rules("pressureplate"))
mesecon:add_receptor_node_off("mesecons_detector:object_detector_off", mesecon:get_rules("pressureplate"))

View File

@ -1,4 +0,0 @@
Please note:
The mesecons modules in here have been disabled for various reasons:
They are old and deprecated, are not needed anymore or are buggy atm.
You can create a module out of them, but it is not recommended to use any of them.

View File

@ -1 +0,0 @@
--read README

View File

@ -1,2 +0,0 @@
mesecons
mesecons_materials

View File

@ -1,313 +0,0 @@
--COMMON WIRELESS FUNCTIONS
mesecon.wireless_receivers={}
function mesecon:read_wlre_from_file()
print "[MESEcons] Reading Mesecon Data..."
mesecon_file=io.open(minetest.get_modpath("jeija").."/mesecon_data", "r")
if mesecon_file==nil then return end
local row=mesecon_file:read()
local i=1
while row~=nil do
mesecon.wireless_receivers[i]={}
mesecon.wireless_receivers[i].pos={}
mesecon.wireless_receivers[i].pos.x=tonumber(mesecon_file:read())
mesecon.wireless_receivers[i].pos.y=tonumber(mesecon_file:read())
mesecon.wireless_receivers[i].pos.z=tonumber(mesecon_file:read())
mesecon.wireless_receivers[i].channel=mesecon_file:read()
mesecon.wireless_receivers[i].requested_state=tonumber(mesecon_file:read())
mesecon.wireless_receivers[i].inverting=tonumber(mesecon_file:read())
i=i+1
row=mesecon_file:read()
end
mesecon_file:close()
print "[MESEcons] Finished Reading Mesecon Data..."
end
function mesecon:register_wireless_receiver(pos, inverting)
local i = 1
repeat
if mesecon.wireless_receivers[i]==nil then break end
i=i+1
until false
local node_under_pos={}
node_under_pos.x=pos.x
node_under_pos.y=pos.y
node_under_pos.z=pos.z
node_under_pos.y=node_under_pos.y-1
local node_under=minetest.env:get_node(node_under_pos)
mesecon.wireless_receivers[i]={}
mesecon.wireless_receivers[i].pos={}
mesecon.wireless_receivers[i].pos.x=pos.x
mesecon.wireless_receivers[i].pos.y=pos.y
mesecon.wireless_receivers[i].pos.z=pos.z
mesecon.wireless_receivers[i].channel=node_under.name
mesecon.wireless_receivers[i].requested_state=0
mesecon.wireless_receivers[i].inverting=inverting
end
function mesecon:remove_wireless_receiver(pos)
local i = 1
while mesecon.wireless_receivers[i]~=nil do
if mesecon.wireless_receivers[i].pos.x==pos.x and
mesecon.wireless_receivers[i].pos.y==pos.y and
mesecon.wireless_receivers[i].pos.z==pos.z then
mesecon.wireless_receivers[i]=nil
break
end
i=i+1
end
end
function mesecon:set_wlre_channel(pos, channel)
--local i = 1
--while mesecon.wireless_receivers[i]~=nil do
-- if tonumber(mesecon.wireless_receivers[i].pos.x)==tonumber(pos.x) and
-- tonumber(mesecon.wireless_receivers[i].pos.y)==tonumber(pos.y) and
-- tonumber(mesecon.wireless_receivers[i].pos.z)==tonumber(pos.z) then
-- mesecon.wireless_receivers[i].channel=channel
-- break
-- end
-- i=i+1
--end
local wlre=mesecon:get_wlre(pos)
if wlre~=nil then
wlre.channel=channel
end
end
function mesecon:get_wlre(pos)
local i=1
while mesecon.wireless_receivers[i]~=nil do
if mesecon.wireless_receivers[i].pos.x==pos.x and
mesecon.wireless_receivers[i].pos.y==pos.y and
mesecon.wireless_receivers[i].pos.z==pos.z then
return mesecon.wireless_receivers[i]
end
i=i+1
end
end
minetest.register_on_placenode(function(pos, newnode, placer)
pos.y=pos.y+1
if minetest.env:get_node(pos).name == "mesecons_wireless:wireless_receiver_off" or
minetest.env:get_node(pos).name == "mesecons_wireless:wireless_receiver_on" or
minetest.env:get_node(pos).name == "mesecons_wireless:wireless_inverter_off" or
minetest.env:get_node(pos).name == "mesecons_wireless:wireless_inverter_on" then
mesecon:set_wlre_channel(pos, newnode.name)
end
end)
minetest.register_on_dignode(
function(pos, oldnode, digger)
local channel
pos.y=pos.y+1
if minetest.env:get_node(pos).name == "mesecons_wireless:wireless_receiver_on" or
minetest.env:get_node(pos).name == "mesecons_wireless:wireless_receiver_off" or
minetest.env:get_node(pos).name == "mesecons_wireless:wireless_inverter_on" or
minetest.env:get_node(pos).name == "mesecons_wireless:wireless_inverter_off" then
mesecon:set_wlre_channel(pos, "air")
end
end
)
minetest.register_abm(
{nodenames = {"mesecons_wireless:wireless_receiver_on", "mesecons_wireless:wireless_receiver_off",
"mesecons_wireless:wireless_inverter_on", "mesecons_wireless:wireless_inverter_off"},
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local wlre=mesecon:get_wlre(pos)
if (wlre==nil) then return end
if node.name=="mesecons_wireless:wireless_receiver_on" and wlre.requested_state==0 then
minetest.env:add_node(pos, {name="mesecons_wireless:wireless_receiver_off"})
mesecon:receptor_off(pos)
end
if node.name=="mesecons_wireless:wireless_receiver_off" and wlre.requested_state==1 then
minetest.env:add_node(pos, {name="mesecons_wireless:wireless_receiver_on"})
mesecon:receptor_on(pos)
end
if node.name=="mesecons_wireless:wireless_inverter_off" and wlre.requested_state==0 and wlre.inverting==1 then
minetest.env:add_node(pos, {name="mesecons_wireless:wireless_inverter_on"})
mesecon:receptor_on(pos)
end
if node.name=="mesecons_wireless:wireless_inverter_on" and wlre.requested_state==1 and wlre.inverting==1 then
minetest.env:add_node(pos, {name="mesecons_wireless:wireless_inverter_off"})
mesecon:receptor_off(pos)
end
end,
})
--WIRELESS RECEIVER
minetest.register_node("mesecons_wireless:wireless_receiver_off", {
tile_images = {"jeija_wireless_receiver_tb_off.png", "jeija_wireless_receiver_tb_off.png", "jeija_wireless_receiver_off.png", "jeija_wireless_receiver_off.png", "jeija_wireless_receiver_off.png", "jeija_wireless_receiver_off.png"},
inventory_image = minetest.inventorycube("jeija_wireless_receiver_off.png"),
groups = {choppy=2},
description="Wireless Receiver",
after_place_node = function(pos)
mesecon:register_wireless_receiver(pos, 0)
end,
after_dig_node = function(pos)
mesecon:remove_wireless_receiver(pos)
mesecon:receptor_off(pos)
end
})
minetest.register_node("mesecons_wireless:wireless_receiver_on", {
tile_images = {"jeija_wireless_receiver_tb_on.png", "jeija_wireless_receiver_tb_on.png", "jeija_wireless_receiver_on.png", "jeija_wireless_receiver_on.png", "jeija_wireless_receiver_on.png", "jeija_wireless_receiver_on.png"},
inventory_image = minetest.inventorycube("jeija_wireless_receiver_on.png"),
groups = {choppy=2},
drop = 'mesecons_wireless:wireless_receiver_off',
description="Wireless Receiver",
after_place_node = function(pos)
mesecon:register_wireless_receiver(pos, 0)
end,
after_dig_node = function(pos)
mesecon:remove_wireless_receiver(pos)
end
})
minetest.register_craft({
output = '"mesecons_wireless:wireless_receiver_off" 2',
recipe = {
{'', "group:mesecon_conductor_craftable", ''},
{'', "group:mesecon_conductor_craftable", ''},
{'', "mesecons_materials:ic", ''},
}
})
minetest.register_abm( -- SAVE WIRELESS RECEIVERS TO FILE
{nodenames = {"mesecons_wireless:wireless_receiver_off", "mesecons_wireless:wireless_receiver_on", "mesecons_wireless:wireless_inverter_on", "mesecons_wireless:wireless_inverter_off"},
interval = 10,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local mesecon_file = io.open(minetest.get_modpath("jeija").."/mesecon_data", "w")
local i=1
while mesecon.wireless_receivers[i]~=nil do
mesecon_file:write("NEXT\n")
mesecon_file:write(mesecon.wireless_receivers[i].pos.x.."\n")
mesecon_file:write(mesecon.wireless_receivers[i].pos.y.."\n")
mesecon_file:write(mesecon.wireless_receivers[i].pos.z.."\n")
mesecon_file:write(mesecon.wireless_receivers[i].channel.."\n")
mesecon_file:write(mesecon.wireless_receivers[i].requested_state.."\n")
mesecon_file:write(mesecon.wireless_receivers[i].inverting.."\n")
i=i+1
end
mesecon_file:close()
end,
})
mesecon:add_receptor_node("mesecons_wireless:wireless_receiver_on")
mesecon:add_receptor_node_off("mesecons_wireless:wireless_receiver_off")
-- WIRELESS INVERTER OFF/ON BELONGS TO THE OUTPUT STATE (ON=INPUT OFF)
minetest.register_node("mesecons_wireless:wireless_inverter_off", {
tile_images = {"jeija_wireless_inverter_tb.png", "jeija_wireless_inverter_tb.png", "jeija_wireless_inverter_off.png", "jeija_wireless_inverter_off.png", "jeija_wireless_inverter_off.png", "jeija_wireless_inverter_off.png"},
inventory_image = minetest.inventorycube("jeija_wireless_inverter_off.png"),
groups = {choppy=2},
drop = 'mesecons_wireless:wireless_inverter_on',
description = "Wireless Inverter",
after_place_node = function(pos)
mesecon:register_wireless_receiver(pos, 1)
mesecon:receptor_on(pos)
end,
after_dig_node = function(pos)
mesecon:remove_wireless_receiver(pos)
end
})
minetest.register_node("mesecons_wireless:wireless_inverter_on", {
tile_images = {"jeija_wireless_inverter_tb.png", "jeija_wireless_inverter_tb.png", "jeija_wireless_inverter_on.png", "jeija_wireless_inverter_on.png", "jeija_wireless_inverter_on.png", "jeija_wireless_inverter_on.png"},
inventory_image = minetest.inventorycube("jeija_wireless_inverter_on.png"),
groups = {choppy=2},
description = "Wireless Inverter",
after_place_node = function(pos)
mesecon:register_wireless_receiver(pos, 1)
mesecon:receptor_on(pos)
end,
after_dig_node = function(pos)
mesecon:remove_wireless_receiver(pos)
mesecon:receptor_off(pos)
end
})
minetest.register_craft({
output = '"mesecons_wireless:wireless_inverter_off" 2',
recipe = {
{'', 'default:steel_ingot', ''},
{'mesecons_materials:ic', 'group:mesecon_conductor_craftable', 'mesecons_materials:ic'},
{'', 'group:mesecon_conductor_craftable', ''},
}
})
mesecon:add_receptor_node("mesecons_wireless:wireless_inverter_on")
mesecon:add_receptor_node_off("mesecons_wireless:wireless_inverter_off")
-- WIRELESS TRANSMITTER
function mesecon:wireless_transmit(channel, senderstate)
local i = 1
while mesecon.wireless_receivers[i]~=nil do
if mesecon.wireless_receivers[i].channel==channel then
if senderstate==1 then
mesecon.wireless_receivers[i].requested_state=1
elseif senderstate==0 then
mesecon.wireless_receivers[i].requested_state=0
end
end
i=i+1
end
end
minetest.register_node("mesecons_wireless:wireless_transmitter_on", {
tile_images = {"jeija_wireless_transmitter_tb.png", "jeija_wireless_transmitter_tb.png", "jeija_wireless_transmitter_on.png", "jeija_wireless_transmitter_on.png", "jeija_wireless_transmitter_on.png", "jeija_wireless_transmitter_on.png"},
inventory_image = minetest.inventorycube("jeija_wireless_transmitter_on.png"),
groups = {choppy=2},
drop = {'"mesecons_wireless:wireless_transmitter_off" 1'},
description="Wireless Transmitter",
})
minetest.register_node("mesecons_wireless:wireless_transmitter_off", {
tile_images = {"jeija_wireless_transmitter_tb.png", "jeija_wireless_transmitter_tb.png", "jeija_wireless_transmitter_off.png", "jeija_wireless_transmitter_off.png", "jeija_wireless_transmitter_off.png", "jeija_wireless_transmitter_off.png"},
inventory_image = minetest.inventorycube("jeija_wireless_transmitter_off.png"),
groups = {choppy=2},
description="Wireless Transmitter",
})
minetest.register_craft({
output = '"mesecons_wireless:wireless_transmitter_off" 2',
recipe = {
{'default:steel_ingot', 'group:mesecon_conductor_craftable', 'default:steel_ingot'},
{'', 'group:mesecon_conductor_craftable', ''},
{'', 'mesecons_materials:ic', ''},
}
})
mesecon:register_on_signal_on(function(pos, node)
if node.name=="mesecons_wireless:wireless_transmitter_off" then
minetest.env:add_node(pos, {name="mesecons_wireless:wireless_transmitter_on"})
local node_under_pos=pos
node_under_pos.y=node_under_pos.y-1
local node_under=minetest.env:get_node(node_under_pos)
mesecon:wireless_transmit(node_under.name, 1)
end
end)
mesecon:register_on_signal_off(function(pos, node)
if node.name=="mesecons_wireless:wireless_transmitter_on" then
minetest.env:add_node(pos, {name="mesecons_wireless:wireless_transmitter_off"})
local node_under_pos=pos
node_under_pos.y=node_under_pos.y-1
local node_under=minetest.env:get_node(node_under_pos)
mesecon:wireless_transmit(node_under.name, 0)
end
end)
mesecon:read_wlre_from_file()

View File

@ -0,0 +1,83 @@
local corner_nodebox = {
type = "fixed",
fixed = {{ -16/32-0.001, -17/32, -3/32, 0, -13/32, 3/32 },
{ -3/32, -17/32, -16/32+0.001, 3/32, -13/32, 3/32}}
}
local corner_selectionbox = {
type = "fixed",
fixed = { -16/32-0.001, -18/32, -16/32, 5/32, -12/32, 5/32 },
}
local corner_get_rules = function (node)
local rules =
{{x = 1, y = 0, z = 0},
{x = 0, y = 0, z = -1}}
for i = 0, node.param2 do
rules = mesecon:rotate_rules_left(rules)
end
return rules
end
minetest.register_node("mesecons_extrawires:corner_on", {
drawtype = "nodebox",
tiles = {
"jeija_insulated_wire_curved_tb_on.png",
"jeija_insulated_wire_curved_tb_on.png^[transformR270",
"jeija_insulated_wire_sides_on.png",
"jeija_insulated_wire_ends_on.png",
"jeija_insulated_wire_sides_on.png",
"jeija_insulated_wire_ends_on.png"
},
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
sunlight_propagates = true,
selection_box = corner_selectionbox,
node_box = corner_nodebox,
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "mesecons_extrawires:corner_off",
mesecons = {conductor =
{
state = mesecon.state.on,
rules = corner_get_rules,
offstate = "mesecons_extrawires:corner_off"
}}
})
minetest.register_node("mesecons_extrawires:corner_off", {
drawtype = "nodebox",
description = "Mesecon Corner",
tiles = {
"jeija_insulated_wire_curved_tb_off.png",
"jeija_insulated_wire_curved_tb_off.png^[transformR270",
"jeija_insulated_wire_sides_off.png",
"jeija_insulated_wire_ends_off.png",
"jeija_insulated_wire_sides_off.png",
"jeija_insulated_wire_ends_off.png"
},
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
sunlight_propagates = true,
selection_box = corner_selectionbox,
node_box = corner_nodebox,
groups = {dig_immediate = 3},
mesecons = {conductor =
{
state = mesecon.state.off,
rules = corner_get_rules,
onstate = "mesecons_extrawires:corner_on"
}}
})
minetest.register_craft({
output = "mesecons_extrawires:corner_off 3",
recipe = {
{"", "", ""},
{"mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off", ""},
{"", "mesecons_insulated:insulated_off", ""},
}
})

View File

@ -1,138 +0,0 @@
for x=-1, 1 do for z=-1, 1 do
rules = {}
nodename = "mesecons_extrawires:crossing"
if x == -1 then
nodename = nodename .. "A"
table.insert(rules, {x=-1, y=0, z=0})
end
if z == 1 then
nodename = nodename .. "B"
table.insert(rules, {x=0, y=0, z=1})
end
if x == 1 then
nodename = nodename .. "C"
table.insert(rules, {x=1, y=0, z=0})
end
if z == -1 then
nodename = nodename .. "D"
table.insert(rules, {x=0, y=0, z=-1})
end
mesecon:add_rules(nodename, rules)
mesecon:register_effector(nodename, nodename, all_rules)
if nodename == "mesecons_extrawires:crossing" then
description = "Insulated Crossing"
groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1}
else
description = "You hacker you!"
drop = "mesecons_extrawires:crossing"
groups = {dig_immediate = 3, not_in_creative_inventory=1, mesecon = 3}
mesecon:add_receptor_node(nodename, rules)
end
minetest.register_node(nodename, {
drawtype = "nodebox",
description = description,
tiles = {
"jeija_insulated_wire_sides.png",
},
paramtype = "light",
walkable = false,
stack_max = 99,
selection_box = {
type = "fixed",
fixed = { -16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001 },
},
node_box = {
type = "fixed",
fixed = {
{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
{ -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
{ -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
{ -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
{ -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
},
},
groups = groups,
drop = drop,
})
end end
function receptor_set(pos, rules, on)
if on then
mesecon:receptor_on(pos, rules)
else
mesecon:receptor_off(pos, rules)
end
end
function update_plus(pos, name)
vL = {
a = string.find(name, "A")~=nil,
b = string.find(name, "B")~=nil,
c = string.find(name, "C")~=nil,
d = string.find(name, "D")~=nil,
}
rL = yc_get_real_portstates(pos)
L = {
a = rL.c and not vL.c,
b = rL.d and not vL.d,
c = rL.a and not vL.a,
d = rL.b and not vL.b,
}
newname = "mesecons_extrawires:crossing"
if L.a then newname = newname .. "A" end
if L.b then newname = newname .. "B" end
if L.c then newname = newname .. "C" end
if L.d then newname = newname .. "D" end
if newname ~= name then
minetest.env:add_node(pos, {name = newname})
end
if L.a ~= vL.a then
receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingA"), L.a)
if not L.a and yc_get_real_portstates(pos).a then
--catch signal changing direction while on
update_plus(pos, newname)
end
end
if L.b ~= vL.b then
receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingB"), L.b)
if not L.b and yc_get_real_portstates(pos).b then
update_plus(pos, newname)
end
end
if L.c ~= vL.c then
receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingC"), L.c)
if not L.c and yc_get_real_portstates(pos).c then
update_plus(pos, newname)
end
end
if L.d ~= vL.d then
receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingD"), L.d)
if not L.c and yc_get_real_portstates(pos).d then
update_plus(pos, newname)
end
end
end
mesecon:register_on_signal_change(function(pos, node)
if string.find(node.name, "mesecons_extrawires:crossing")~=nil then
update_plus(pos, node.name)
end
end)
minetest.register_craft({
type = "shapeless",
output = "mesecons_extrawires:crossing",
recipe = {
"mesecons_insulated:insulated_off",
"mesecons_insulated:insulated_off",
},
})
minetest.register_craft({
type = "shapeless",
output = "mesecons_insulated:insulated_off 2",
recipe = {
"mesecons_extrawires:crossing",
},
})

View File

@ -0,0 +1,176 @@
function crossover_get_rules(node)
return {
{--first wire
{x=-1,y=0,z=0},
{x=1,y=0,z=0},
},
{--second wire
{x=0,y=0,z=-1},
{x=0,y=0,z=1},
},
}
end
local crossover_states = {
"mesecons_extrawires:crossover_off",
"mesecons_extrawires:crossover_01",
"mesecons_extrawires:crossover_10",
"mesecons_extrawires:crossover_on",
}
minetest.register_node("mesecons_extrawires:crossover_off", {
description = "Insulated Crossover",
drawtype = "nodebox",
tiles = {
"jeija_insulated_wire_crossing_tb_off.png",
"jeija_insulated_wire_crossing_tb_off.png",
"jeija_insulated_wire_ends_off.png"
},
paramtype = "light",
walkable = false,
stack_max = 99,
selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
node_box = {
type = "fixed",
fixed = {
{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
{ -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
{ -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
{ -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
{ -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
},
},
groups = {dig_immediate=3, mesecon=3, mesecon_conductor_craftable=1},
mesecons = {
conductor = {
states = crossover_states,
rules = crossover_get_rules(),
}
},
})
minetest.register_node("mesecons_extrawires:crossover_01", {
description = "You hacker you!",
drop = "mesecons_extrawires:crossover_off",
drawtype = "nodebox",
tiles = {
"jeija_insulated_wire_crossing_tb_01.png",
"jeija_insulated_wire_crossing_tb_01.png",
"jeija_insulated_wire_ends_01x.png",
"jeija_insulated_wire_ends_01x.png",
"jeija_insulated_wire_ends_01z.png",
"jeija_insulated_wire_ends_01z.png"
},
paramtype = "light",
walkable = false,
stack_max = 99,
selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
node_box = {
type = "fixed",
fixed = {
{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
{ -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
{ -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
{ -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
{ -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
},
},
groups = {dig_immediate=3, mesecon=3, mesecon_conductor_craftable=1, not_in_creative_inventory=1},
mesecons = {
conductor = {
states = crossover_states,
rules = crossover_get_rules(),
}
},
})
minetest.register_node("mesecons_extrawires:crossover_10", {
description = "You hacker you!",
drop = "mesecons_extrawires:crossover_off",
drawtype = "nodebox",
tiles = {
"jeija_insulated_wire_crossing_tb_10.png",
"jeija_insulated_wire_crossing_tb_10.png",
"jeija_insulated_wire_ends_10x.png",
"jeija_insulated_wire_ends_10x.png",
"jeija_insulated_wire_ends_10z.png",
"jeija_insulated_wire_ends_10z.png"
},
paramtype = "light",
walkable = false,
stack_max = 99,
selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
node_box = {
type = "fixed",
fixed = {
{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
{ -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
{ -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
{ -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
{ -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
},
},
groups = {dig_immediate=3, mesecon=3, mesecon_conductor_craftable=1, not_in_creative_inventory=1},
mesecons = {
conductor = {
states = crossover_states,
rules = crossover_get_rules(),
}
},
})
minetest.register_node("mesecons_extrawires:crossover_on", {
description = "You hacker you!",
drop = "mesecons_extrawires:crossover_off",
drawtype = "nodebox",
tiles = {
"jeija_insulated_wire_crossing_tb_on.png",
"jeija_insulated_wire_crossing_tb_on.png",
"jeija_insulated_wire_ends_on.png",
"jeija_insulated_wire_ends_on.png",
"jeija_insulated_wire_ends_on.png",
"jeija_insulated_wire_ends_on.png"
},
paramtype = "light",
walkable = false,
stack_max = 99,
selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
node_box = {
type = "fixed",
fixed = {
{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
{ -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
{ -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
{ -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
{ -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
},
},
groups = {dig_immediate=3, mesecon=3, mesecon_conductor_craftable=1, not_in_creative_inventory=1},
mesecons = {
conductor = {
states = crossover_states,
rules = crossover_get_rules(),
}
},
})
minetest.register_craft({
type = "shapeless",
output = "mesecons_extrawires:crossover_off",
recipe = {
"mesecons_insulated:insulated_off",
"mesecons_insulated:insulated_off",
},
})
minetest.register_craft({
type = "shapeless",
output = "mesecons_insulated:insulated_off 2",
recipe = {
"mesecons_extrawires:crossover_off",
},
})

View File

@ -1 +1,2 @@
default
mesecons mesecons

View File

@ -1,2 +1,5 @@
dofile(minetest.get_modpath("mesecons_extrawires").."/crossing.lua"); dofile(minetest.get_modpath("mesecons_extrawires").."/crossover.lua");
dofile(minetest.get_modpath("mesecons_extrawires").."/tjunction.lua"); dofile(minetest.get_modpath("mesecons_extrawires").."/tjunction.lua");
dofile(minetest.get_modpath("mesecons_extrawires").."/corner.lua");
dofile(minetest.get_modpath("mesecons_extrawires").."/vertical.lua");
dofile(minetest.get_modpath("mesecons_extrawires").."/mesewire.lua");

View File

@ -0,0 +1,35 @@
local mesewire_rules =
{
{x = 1, y = 0, z = 0},
{x =-1, y = 0, z = 0},
{x = 0, y = 1, z = 0},
{x = 0, y =-1, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z =-1},
}
minetest.register_node(":default:mese", {
description = "Mese Block",
tiles = {minetest.registered_nodes["default:mese"].tiles[1]},
is_ground_content = true,
groups = {cracky=1},
sounds = default.node_sound_stone_defaults(),
mesecons = {conductor = {
state = mesecon.state.off,
onstate = "mesecons_extrawires:mese_powered",
rules = mesewire_rules
}}
})
minetest.register_node("mesecons_extrawires:mese_powered", {
tiles = {minetest.registered_nodes["default:mese"].tiles[1].."^[brighten"},
is_ground_content = true,
groups = {cracky=1, not_in_creative_inventory = 1},
sounds = default.node_sound_stone_defaults(),
mesecons = {conductor = {
state = mesecon.state.on,
offstate = "default:mese",
rules = mesewire_rules
}},
drop = "default:mese"
})

View File

@ -9,14 +9,27 @@ local tjunction_selectionbox = {
fixed = { -16/32-0.001, -18/32, -16/32, 16/32+0.001, -12/32, 7/32 }, fixed = { -16/32-0.001, -18/32, -16/32, 16/32+0.001, -12/32, 7/32 },
} }
local tjunction_get_rules = function (node)
local rules =
{{x = 0, y = 0, z = 1},
{x = 1, y = 0, z = 0},
{x = 0, y = 0, z = -1}}
for i = 0, node.param2 do
rules = mesecon:rotate_rules_left(rules)
end
return rules
end
minetest.register_node("mesecons_extrawires:tjunction_on", { minetest.register_node("mesecons_extrawires:tjunction_on", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
"jeija_insulated_wire_sides.png", "jeija_insulated_wire_tjunction_tb_on.png",
"jeija_insulated_wire_sides.png", "jeija_insulated_wire_tjunction_tb_on.png^[transformR180",
"jeija_insulated_wire_ends_on.png", "jeija_insulated_wire_ends_on.png",
"jeija_insulated_wire_ends_on.png", "jeija_insulated_wire_ends_on.png",
"jeija_insulated_wire_sides.png", "jeija_insulated_wire_sides_on.png",
"jeija_insulated_wire_ends_on.png" "jeija_insulated_wire_ends_on.png"
}, },
paramtype = "light", paramtype = "light",
@ -25,20 +38,25 @@ minetest.register_node("mesecons_extrawires:tjunction_on", {
sunlight_propagates = true, sunlight_propagates = true,
selection_box = tjunction_selectionbox, selection_box = tjunction_selectionbox,
node_box = tjunction_nodebox, node_box = tjunction_nodebox,
groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1, not_in_creative_inventory = 1}, groups = {dig_immediate = 3, mesecon_conductor_craftable=1, not_in_creative_inventory = 1},
drop = "mesecons_insulated:insulated_off", drop = "mesecons_extrawires:tjunction_off",
mesecons = {conductor =
{
state = mesecon.state.on,
rules = tjunction_get_rules,
offstate = "mesecons_extrawires:tjunction_off"
}}
}) })
minetest.register_node("mesecons_extrawires:tjunction_off", { minetest.register_node("mesecons_extrawires:tjunction_off", {
drawtype = "nodebox", drawtype = "nodebox",
description = "T-junction", description = "T-junction",
tiles = { tiles = {
"jeija_insulated_wire_sides.png", "jeija_insulated_wire_tjunction_tb_off.png",
"jeija_insulated_wire_sides.png", "jeija_insulated_wire_tjunction_tb_off.png^[transformR180",
"jeija_insulated_wire_ends_off.png", "jeija_insulated_wire_ends_off.png",
"jeija_insulated_wire_ends_off.png", "jeija_insulated_wire_ends_off.png",
"jeija_insulated_wire_sides.png", "jeija_insulated_wire_sides_off.png",
"jeija_insulated_wire_ends_off.png" "jeija_insulated_wire_ends_off.png"
}, },
paramtype = "light", paramtype = "light",
@ -47,39 +65,20 @@ minetest.register_node("mesecons_extrawires:tjunction_off", {
sunlight_propagates = true, sunlight_propagates = true,
selection_box = tjunction_selectionbox, selection_box = tjunction_selectionbox,
node_box = tjunction_nodebox, node_box = tjunction_nodebox,
groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1}, groups = {dig_immediate = 3, mesecon_conductor_craftable=1},
mesecons = {conductor =
{
state = mesecon.state.off,
rules = tjunction_get_rules,
onstate = "mesecons_extrawires:tjunction_on"
}}
}) })
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_extrawires:tjunction_off" 3', output = "mesecons_extrawires:tjunction_off 3",
recipe = { recipe = {
{"", "", ""}, {"", "", ""},
{"mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off"}, {"mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off"},
{"", "mesecons_insulated:insulated_off", ""}, {"", "mesecons_insulated:insulated_off", ""},
} }
}) })
mesecon:add_rules("tjunction_all", { --all possible rules
{x = 1, y = 0, z = 0},
{x =-1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z =-1},})
mesecon:add_rules("tjunction", {
{x = 1, y = 0, z = 0},
{x =-1, y = 0, z = 0},
{x = 0, y = 0, z = -1},})
function tjunction_get_rules(param2)
local rules = mesecon:get_rules("tjunction")
if param2 == 1 then
rules = mesecon:rotate_rules_left(mesecon:get_rules("tjunction"))
elseif param2 == 2 then
rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(mesecon:get_rules("tjunction")))
elseif param2 == 3 then
rules = mesecon:rotate_rules_right(mesecon:get_rules("tjunction"))
end
return rules
end
mesecon:register_conductor("mesecons_extrawires:tjunction_on", "mesecons_extrawires:tjunction_off", mesecon:get_rules("tjunction_all"), tjunction_get_rules)

View File

@ -0,0 +1,213 @@
local vertical_box = {
type = "fixed",
fixed = {-1/16, -8/16, -1/16, 1/16, 8/16, 1/16}
}
local top_box = {
type = "fixed",
fixed = {{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16}}
}
local bottom_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16},
{-1/16, -7/16, -1/16, 1/16, 8/16, 1/16},
}
}
local vertical_rules = {
{x=0, y=1, z=0},
{x=0, y=-1, z=0},
}
local top_rules = {
{x=1,y=0, z=0},
{x=-1,y=0, z=0},
{x=0,y=0, z=1},
{x=0,y=0, z=-1},
{x=0,y=-1, z=0},
}
local bottom_rules = {
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
{x=0, y=0, z=1},
{x=0, y=0, z=-1},
{x=0, y=1, z=0},
}
local vertical_updatepos = function (pos)
local node = minetest.get_node(pos)
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].is_vertical_conductor then
local node_above = minetest.get_node(mesecon:addPosRule(pos, vertical_rules[1]))
local node_below = minetest.get_node(mesecon:addPosRule(pos, vertical_rules[2]))
local namestate = minetest.registered_nodes[node.name].vertical_conductor_state
local above = minetest.registered_nodes[node_above.name] and minetest.registered_nodes[node_above.name].is_vertical_conductor
local below = minetest.registered_nodes[node_below.name] and minetest.registered_nodes[node_below.name].is_vertical_conductor
if above and below then -- above and below: vertical mesecon
minetest.add_node(pos, {name = "mesecons_extrawires:vertical_" .. namestate})
elseif above and not below then -- above only: bottom
minetest.add_node(pos, {name = "mesecons_extrawires:vertical_bottom_" .. namestate})
elseif not above and below then -- below only: top
minetest.add_node(pos, {name = "mesecons_extrawires:vertical_top_" .. namestate})
else -- no vertical wire above, no vertical wire below: use default wire
minetest.add_node(pos, {name = "mesecons_extrawires:vertical_" .. namestate})
end
end
end
local vertical_update = function (pos, node)
vertical_updatepos(pos) -- this one
vertical_updatepos(mesecon:addPosRule(pos, vertical_rules[1])) -- above
vertical_updatepos(mesecon:addPosRule(pos, vertical_rules[2])) -- below
end
-- Vertical wire
minetest.register_node("mesecons_extrawires:vertical_on", {
description = "Vertical mesecon",
drawtype = "nodebox",
tiles = {"wires_vertical_on.png"},
walkable = false,
paramtype = "light",
sunlight_propagates = true,
groups = {dig_immediate=3, not_in_creative_inventory=1},
selection_box = vertical_box,
node_box = vertical_box,
is_vertical_conductor = true,
vertical_conductor_state = "on",
mesecons = {conductor = {
state = mesecon.state.on,
offstate = "mesecons_extrawires:vertical_off",
rules = vertical_rules,
}},
drop = "mesecons_extrawires:vertical_off",
after_place_node = vertical_update,
after_dig_node = vertical_update,
})
minetest.register_node("mesecons_extrawires:vertical_off", {
description = "Vertical mesecon",
drawtype = "nodebox",
tiles = {"wires_vertical_off.png"},
walkable = false,
paramtype = "light",
sunlight_propagates = true,
groups = {dig_immediate=3},
selection_box = vertical_box,
node_box = vertical_box,
is_vertical_conductor = true,
vertical_conductor_state = "off",
mesecons = {conductor = {
state = mesecon.state.off,
onstate = "mesecons_extrawires:vertical_on",
rules = vertical_rules,
}},
after_place_node = vertical_update,
after_dig_node = vertical_update,
})
-- Vertical wire top
minetest.register_node("mesecons_extrawires:vertical_top_on", {
description = "Vertical mesecon",
drawtype = "nodebox",
tiles = {"wires_full_on.png","wires_full_on.png","wires_vertical_on.png"},
walkable = false,
paramtype = "light",
sunlight_propagates = true,
groups = {dig_immediate=3, not_in_creative_inventory=1},
selection_box = top_box,
node_box = top_box,
is_vertical_conductor = true,
vertical_conductor_state = "on",
mesecons = {conductor = {
state = mesecon.state.on,
offstate = "mesecons_extrawires:vertical_top_off",
rules = top_rules,
}},
drop = "mesecons_extrawires:vertical_off",
after_place_node = vertical_update,
after_dig_node = vertical_update,
})
minetest.register_node("mesecons_extrawires:vertical_top_off", {
description = "Vertical mesecon",
drawtype = "nodebox",
tiles = {"wires_full_off.png","wires_full_off.png","wires_vertical_off.png"},
walkable = false,
paramtype = "light",
sunlight_propagates = true,
groups = {dig_immediate=3, not_in_creative_inventory=1},
selection_box = top_box,
node_box = top_box,
is_vertical_conductor = true,
vertical_conductor_state = "off",
mesecons = {conductor = {
state = mesecon.state.off,
onstate = "mesecons_extrawires:vertical_top_on",
rules = top_rules,
}},
drop = "mesecons_extrawires:vertical_off",
after_place_node = vertical_update,
after_dig_node = vertical_update,
})
-- Vertical wire bottom
minetest.register_node("mesecons_extrawires:vertical_bottom_on", {
description = "Vertical mesecon",
drawtype = "nodebox",
tiles = {"wires_full_on.png","wires_full_on.png","wires_vertical_on.png"},
walkable = false,
paramtype = "light",
sunlight_propagates = true,
vertical_conductor_state = "on",
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
selection_box = bottom_box,
node_box = bottom_box,
mesecons = {conductor = {
state = mesecon.state.on,
offstate = "mesecons_extrawires:vertical_bottom_off",
rules = bottom_rules,
}},
drop = "mesecons_extrawires:vertical_off",
after_place_node = vertical_update,
after_dig_node = vertical_update,
})
minetest.register_node("mesecons_extrawires:vertical_bottom_off", {
description = "Vertical mesecon",
drawtype = "nodebox",
tiles = {"wires_full_off.png","wires_full_off.png","wires_vertical_off.png"},
walkable = false,
paramtype = "light",
sunlight_propagates = true,
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
selection_box = bottom_box,
node_box = bottom_box,
is_vertical_conductor = true,
vertical_conductor_state = "off",
mesecons = {conductor = {
state = mesecon.state.off,
onstate = "mesecons_extrawires:vertical_bottom_on",
rules = bottom_rules,
}},
drop = "mesecons_extrawires:vertical_off",
after_place_node = vertical_update,
after_dig_node = vertical_update,
})
minetest.register_craft({
output = "mesecons_extrawires:vertical_off 3",
recipe = {
{"mesecons:wire_00000000_off"},
{"mesecons:wire_00000000_off"},
{"mesecons:wire_00000000_off"}
}
})
minetest.register_craft({
output = "mesecons:wire_00000000_off",
recipe = {{"mesecons_extrawires:vertical_off"}}
})

View File

@ -1,146 +1,84 @@
outrules = { function gate_rotate_rules(node)
{x=1, y=0, z=0}, for rotations = 0, node.param2 - 1 do
}
oneinput = {
{x=-1, y=0, z=0},
{x=1, y=0, z=0},
}
twoinputs = {
{x=0, y=0, z=1},
{x=0, y=0, z=-1},
{x=1, y=0, z=0},
}
function get_gate_rules(param2, onlyout, singleinput)
if onlyout then
rules = outrules
else
if singleinput then
rules = oneinput
else
rules = twoinputs
end
end
for rotations=0, param2-1 do
rules = mesecon:rotate_rules_left(rules) rules = mesecon:rotate_rules_left(rules)
end end
return rules return rules
end end
function get_gate_rules_one(param2) return get_gate_rules(param2, false, true) end function gate_get_output_rules(node)
function get_gate_rules_two(param2) return get_gate_rules(param2, false, false) end rules = {{x=1, y=0, z=0}}
function get_gate_rules_out(param2) return get_gate_rules(param2, true) end return gate_rotate_rules(node)
gates = {"diode", "not", "nand", "and", "xor"} end
for g in ipairs(gates) do gate = gates[g]
if g < 3 then function gate_get_input_rules_oneinput(node)
get_rules = get_gate_rules_one rules = {{x=-1, y=0, z=0}, {x=1, y=0, z=0}}
else return gate_rotate_rules(node)
get_rules = get_gate_rules_two end
function gate_get_input_rules_twoinputs(node)
rules = {
{x=0, y=0, z=1},
{x=0, y=0, z=-1},
{x=1, y=0, z=0}}
return gate_rotate_rules(node)
end
function update_gate(pos)
gate = get_gate(pos)
L = rotate_ports(
yc_get_real_portstates(pos),
minetest.get_node(pos).param2
)
if gate == "diode" then
set_gate(pos, L.a)
elseif gate == "not" then
set_gate(pos, not L.a)
elseif gate == "nand" then
set_gate(pos, not(L.b and L.d))
elseif gate == "and" then
set_gate(pos, L.b and L.d)
elseif gate == "xor" then
set_gate(pos, (L.b and not L.d) or (not L.b and L.d))
end end
for on=0,1 do end
nodename = "mesecons_gates:"..gate
if on == 1 then function set_gate(pos, on)
onoff = "on" gate = get_gate(pos)
drop = nodename.."_off" local meta = minetest.get_meta(pos)
nodename = nodename.."_"..onoff if on ~= gate_state(pos) then
description = "You hacker you!" yc_heat(meta)
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3} --minetest.after(0.5, yc_cool, meta)
mesecon:add_receptor_node(nodename, get_rules, get_gate_rules_out) if yc_overheat(meta) then
--mesecon:add_receptor_node(nodename, mesecon:get_rules("insulated_all")) pop_gate(pos)
else else
onoff = "off" local node = minetest.get_node(pos)
nodename = nodename.."_"..onoff if on then
description = gate.." Gate" minetest.swap_node(pos, {name = "mesecons_gates:"..gate.."_on", param2=node.param2})
groups = {dig_immediate=2, mesecon = 3} mesecon:receptor_on(pos,
--mesecon:add_receptor_node_off(nodename, get_gate_rules_out) gate_get_output_rules(node))
else
minetest.swap_node(pos, {name = "mesecons_gates:"..gate.."_off", param2=node.param2})
mesecon:receptor_off(pos,
gate_get_output_rules(node))
end
end end
tiles = "jeija_microcontroller_bottom.png^"..
"jeija_gate_"..onoff..".png^"..
"jeija_gate_"..gate..".png"
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
}
minetest.register_node(nodename, {
description = description,
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
tiles = {tiles},
inventory_image = tiles,
selection_box = node_box,
node_box = node_box,
walkable = true,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_int("heat", 0)
update_gate(pos)
end,
groups = groups,
drop = drop,
})
mesecon:register_effector(nodename, nodename, all_rules, get_rules)
end end
end end
function get_gate(pos) function get_gate(pos)
return return minetest.registered_nodes[minetest.get_node(pos).name].mesecons_gate
string.gsub(
string.gsub(
string.gsub(
minetest.env:get_node(pos).name
, "mesecons_gates:", "") --gate
,"_on", "")
,"_off", "")
end end
function gate_state(pos) function gate_state(pos)
name = minetest.env:get_node(pos).name name = minetest.get_node(pos).name
return string.find(name, "_on") ~= nil return string.find(name, "_on") ~= nil
end end
function pop_gate(pos) function pop_gate(pos)
gate = get_gate(pos) gate = get_gate(pos)
minetest.env:remove_node(pos) minetest.remove_node(pos)
minetest.after(0.2, yc_overheat_off, pos) minetest.after(0.2, yc_overheat_off, pos)
minetest.env:add_item(pos, "mesecons_gates:"..gate.."_off") minetest.add_item(pos, "mesecons_gates:"..gate.."_off")
end
function set_gate(pos, on)
gate = get_gate(pos)
local meta = minetest.env:get_meta(pos)
if on ~= gate_state(pos) then
yc_heat(meta)
minetest.after(0.5, yc_cool, meta)
if yc_overheat(meta) then
pop_gate(pos)
else
heat = meta:get_int("heat")
if on then
onoff = "_on"
else
onoff = "_off"
end
param2 = minetest.env:get_node(pos).param2
minetest.env:add_node(pos, {
name = "mesecons_gates:"..gate..onoff,
param2 = param2,
})
local meta2 = minetest.env:get_meta(pos)
meta2:set_int("heat", heat)
if on then
mesecon:receptor_on(pos, get_gate_rules(param2, true))
else
mesecon:receptor_off(pos, all_rules)
end
end
end
end end
function rotate_ports(L, param2) function rotate_ports(L, param2)
@ -154,31 +92,90 @@ function rotate_ports(L, param2)
return L return L
end end
function update_gate(pos) gates = {
gate = get_gate(pos) {name = "diode", inputnumber = 1},
L = rotate_ports( {name = "not" , inputnumber = 1},
yc_get_real_portstates(pos), {name = "nand" , inputnumber = 2},
minetest.env:get_node(pos).param2 {name = "and" , inputnumber = 2},
) {name = "xor" , inputnumber = 2}}
if gate == "diode" then
set_gate(pos, L.a) local onoff, drop, nodename, description, groups
elseif gate == "not" then for _, gate in ipairs(gates) do
set_gate(pos, not L.a) if gate.inputnumber == 1 then
elseif gate == "nand" then get_rules = gate_get_input_rules_oneinput
set_gate(pos, not(L.b and L.d)) elseif gate.inputnumber == 2 then
elseif gate == "and" then get_rules = gate_get_input_rules_twoinputs
set_gate(pos, L.b and L.d) end
else--if gate == "xor" then for on = 0, 1 do
set_gate(pos, (L.b and not L.d) or (not L.b and L.d)) nodename = "mesecons_gates:"..gate.name
if on == 1 then
onoff = "on"
drop = nodename.."_off"
nodename = nodename.."_"..onoff
description = "You hacker you!"
groups = {dig_immediate=2, not_in_creative_inventory=1, overheat = 1}
else
onoff = "off"
drop = nil
nodename = nodename.."_"..onoff
description = gate.name.." Gate"
groups = {dig_immediate=2, overheat = 1}
end
tiles = "jeija_microcontroller_bottom.png^"..
"jeija_gate_"..onoff..".png^"..
"jeija_gate_"..gate.name..".png"
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
}
local mesecon_state
if on == 1 then
mesecon_state = mesecon.state.on
else
mesecon_state = mesecon.state.off
end
minetest.register_node(nodename, {
description = description,
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
tiles = {tiles},
inventory_image = tiles,
selection_box = node_box,
node_box = node_box,
walkable = true,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("heat", 0)
update_gate(pos)
end,
groups = groups,
drop = drop,
sounds = default.node_sound_stone_defaults(),
mesecons_gate = gate.name,
mesecons =
{
receptor =
{
state = mesecon_state,
rules = gate_get_output_rules
},
effector =
{
rules = get_rules,
action_change = update_gate
}
}
})
end end
end end
mesecon:register_on_signal_change(function(pos,node)
if string.find(node.name, "mesecons_gates:")~=nil then
update_gate(pos)
end
end)
minetest.register_craft({ minetest.register_craft({
output = 'mesecons_gates:diode_off', output = 'mesecons_gates:diode_off',
recipe = { recipe = {

View File

@ -1,9 +1,12 @@
-- HYDRO_TURBINE -- HYDRO_TURBINE
-- Water turbine:
-- Active if flowing >water< above it
-- (does not work with other liquids)
minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", { minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"jeija_hydro_turbine_off.png"}, tiles = {"jeija_hydro_turbine_off.png"},
groups = {dig_immediate=2, mesecon = 2}, groups = {dig_immediate=2},
description="Water Turbine", description="Water Turbine",
paramtype = "light", paramtype = "light",
selection_box = { selection_box = {
@ -20,13 +23,17 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
{-0.45, 1.15, -0.1, 0.45, 1.45, 0.1}, {-0.45, 1.15, -0.1, 0.45, 1.45, 0.1},
{-0.1, 1.15, -0.45, 0.1, 1.45, 0.45}}, {-0.1, 1.15, -0.45, 0.1, 1.45, 0.45}},
}, },
sounds = default.node_sound_stone_defaults(),
mesecons = {receptor = {
state = mesecon.state.off
}}
}) })
minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", { minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"jeija_hydro_turbine_on.png"}, tiles = {"jeija_hydro_turbine_on.png"},
drop = '"mesecons_hydroturbine:hydro_turbine_off" 1', drop = "mesecons_hydroturbine:hydro_turbine_off 1",
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 2}, groups = {dig_immediate=2,not_in_creative_inventory=1},
description="Water Turbine", description="Water Turbine",
paramtype = "light", paramtype = "light",
selection_box = { selection_box = {
@ -43,6 +50,10 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", {
{-0.5, 1.15, -0.1, 0.5, 1.45, 0.1}, {-0.5, 1.15, -0.1, 0.5, 1.45, 0.1},
{-0.1, 1.15, -0.5, 0.1, 1.45, 0.5}}, {-0.1, 1.15, -0.5, 0.1, 1.45, 0.5}},
}, },
sounds = default.node_sound_stone_defaults(),
mesecons = {receptor = {
state = mesecon.state.on
}}
}) })
@ -52,8 +63,8 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_off"},
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local waterpos={x=pos.x, y=pos.y+1, z=pos.z} local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
if minetest.env:get_node(waterpos).name=="default:water_flowing" then if minetest.get_node(waterpos).name=="default:water_flowing" then
minetest.env:add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"}) minetest.add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"})
nodeupdate(pos) nodeupdate(pos)
mesecon:receptor_on(pos) mesecon:receptor_on(pos)
end end
@ -66,23 +77,20 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local waterpos={x=pos.x, y=pos.y+1, z=pos.z} local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
if minetest.env:get_node(waterpos).name~="default:water_flowing" then if minetest.get_node(waterpos).name~="default:water_flowing" then
minetest.env:add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"}) minetest.add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"})
nodeupdate(pos) nodeupdate(pos)
mesecon:receptor_off(pos) mesecon:receptor_off(pos)
end end
end, end,
}) })
mesecon:add_receptor_node("mesecons_hydroturbine:hydro_turbine_on")
mesecon:add_receptor_node_off("mesecons_hydroturbine:hydro_turbine_off")
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_hydroturbine:hydro_turbine_off" 2', output = "mesecons_hydroturbine:hydro_turbine_off 2",
recipe = { recipe = {
{'','"default:stick"', ''}, {"","default:stick", ""},
{'"default:stick"', '"default:steel_ingot"', '"default:stick"'}, {"default:stick", "default:steel_ingot", "default:stick"},
{'','"default:stick"', ''}, {"","default:stick", ""},
} }
}) })

View File

@ -1,13 +1,22 @@
function insulated_wire_get_rules(node)
local rules = {{x = 1, y = 0, z = 0},
{x =-1, y = 0, z = 0}}
if node.param2 == 1 or node.param2 == 3 then
return mesecon:rotate_rules_right(rules)
end
return rules
end
minetest.register_node("mesecons_insulated:insulated_on", { minetest.register_node("mesecons_insulated:insulated_on", {
drawtype = "nodebox", drawtype = "nodebox",
description = "insulated mesecons", description = "Insulated Mesecon",
tiles = { tiles = {
"jeija_insulated_wire_sides.png", "jeija_insulated_wire_sides_on.png",
"jeija_insulated_wire_sides.png", "jeija_insulated_wire_sides_on.png",
"jeija_insulated_wire_ends_on.png", "jeija_insulated_wire_ends_on.png",
"jeija_insulated_wire_ends_on.png", "jeija_insulated_wire_ends_on.png",
"jeija_insulated_wire_sides.png", "jeija_insulated_wire_sides_on.png",
"jeija_insulated_wire_sides.png" "jeija_insulated_wire_sides_on.png"
}, },
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
@ -21,21 +30,25 @@ minetest.register_node("mesecons_insulated:insulated_on", {
type = "fixed", type = "fixed",
fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 } fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
}, },
groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1, not_in_creative_inventory = 1}, groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "mesecons_insulated:insulated_off", drop = "mesecons_insulated:insulated_off",
mesecons = {conductor = {
state = mesecon.state.on,
offstate = "mesecons_insulated:insulated_off",
rules = insulated_wire_get_rules
}}
}) })
minetest.register_node("mesecons_insulated:insulated_off", { minetest.register_node("mesecons_insulated:insulated_off", {
drawtype = "nodebox", drawtype = "nodebox",
description = "insulated mesecons", description = "insulated mesecons",
tiles = { tiles = {
"jeija_insulated_wire_sides.png", "jeija_insulated_wire_sides_off.png",
"jeija_insulated_wire_sides.png", "jeija_insulated_wire_sides_off.png",
"jeija_insulated_wire_ends_off.png", "jeija_insulated_wire_ends_off.png",
"jeija_insulated_wire_ends_off.png", "jeija_insulated_wire_ends_off.png",
"jeija_insulated_wire_sides.png", "jeija_insulated_wire_sides_off.png",
"jeija_insulated_wire_sides.png" "jeija_insulated_wire_sides_off.png"
}, },
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
@ -49,11 +62,16 @@ minetest.register_node("mesecons_insulated:insulated_off", {
type = "fixed", type = "fixed",
fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 } fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
}, },
groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1}, groups = {dig_immediate = 3},
mesecons = {conductor = {
state = mesecon.state.off,
onstate = "mesecons_insulated:insulated_on",
rules = insulated_wire_get_rules
}}
}) })
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_insulated:insulated_off" 3', output = "mesecons_insulated:insulated_off 3",
recipe = { recipe = {
{"mesecons_materials:fiber", "mesecons_materials:fiber", "mesecons_materials:fiber"}, {"mesecons_materials:fiber", "mesecons_materials:fiber", "mesecons_materials:fiber"},
{"mesecons:wire_00000000_off", "mesecons:wire_00000000_off", "mesecons:wire_00000000_off"}, {"mesecons:wire_00000000_off", "mesecons:wire_00000000_off", "mesecons:wire_00000000_off"},
@ -61,21 +79,6 @@ minetest.register_craft({
} }
}) })
mesecon:add_rules("insulated_all", { --all possible rules
{x = 1, y = 0, z = 0},
{x =-1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z =-1},})
mesecon:add_rules("insulated", { mesecon:add_rules("insulated", {
{x = 1, y = 0, z = 0}, {x = 1, y = 0, z = 0},
{x =-1, y = 0, z = 0},}) {x =-1, y = 0, z = 0}})
function insulated_wire_get_rules(param2)
if param2 == 1 or param2 == 3 then
return mesecon:rotate_rules_right(mesecon:get_rules("insulated"))
end
return mesecon:get_rules("insulated")
end
mesecon:register_conductor("mesecons_insulated:insulated_on", "mesecons_insulated:insulated_off", mesecon:get_rules("insulated_all"), insulated_wire_get_rules)

View File

@ -1,4 +1,14 @@
-- MESELAMPS -- MESELAMPS
-- A lamp is "is an electrical device used to create artificial light" (wikipedia)
-- guess what?
mesecon_lamp_box = {
type = "wallmounted",
wall_top = {-0.3125,0.375,-0.3125,0.3125,0.5,0.3125},
wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125},
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125},
}
minetest.register_node("mesecons_lamp:lamp_on", { minetest.register_node("mesecons_lamp:lamp_on", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"jeija_meselamp_on.png"}, tiles = {"jeija_meselamp_on.png"},
@ -8,20 +18,16 @@ minetest.register_node("mesecons_lamp:lamp_on", {
sunlight_propagates = true, sunlight_propagates = true,
walkable = true, walkable = true,
light_source = LIGHT_MAX, light_source = LIGHT_MAX,
node_box = { node_box = mesecon_lamp_box,
type = "wallmounted", selection_box = mesecon_lamp_box,
wall_top = {-0.3125,0.375,-0.3125,0.3125,0.5,0.3125}, groups = {dig_immediate=3,not_in_creative_inventory=1, mesecon_effector_on = 1},
wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125}, drop="mesecons_lamp:lamp_off 1",
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125}, sounds = default.node_sound_glass_defaults(),
}, mesecons = {effector = {
selection_box = { action_off = function (pos, node)
type = "wallmounted", minetest.swap_node(pos, {name = "mesecons_lamp:lamp_off", param2 = node.param2})
wall_top = {-0.3125,0.375,-0.3125,0.3125,0.5,0.3125}, end
wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125}, }}
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125},
},
groups = {dig_immediate=3,not_in_creative_inventory=1, mesecon_effector_on = 1, mesecon = 2},
drop='"mesecons_lamp:lamp_off" 1',
}) })
minetest.register_node("mesecons_lamp:lamp_off", { minetest.register_node("mesecons_lamp:lamp_off", {
@ -33,43 +39,23 @@ minetest.register_node("mesecons_lamp:lamp_off", {
paramtype2 = "wallmounted", paramtype2 = "wallmounted",
sunlight_propagates = true, sunlight_propagates = true,
walkable = true, walkable = true,
node_box = { node_box = mesecon_lamp_box,
type = "wallmounted", selection_box = mesecon_lamp_box,
wall_top = {-0.3125,0.375,-0.3125,0.3125,0.5,0.3125}, groups = {dig_immediate=3, mesecon_receptor_off = 1, mesecon_effector_off = 1},
wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125},
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125},
},
selection_box = {
type = "wallmounted",
wall_top = {-0.3125,0.375,-0.3125,0.3125,0.5,0.3125},
wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125},
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125},
},
groups = {dig_immediate=3, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2},
description="Meselamp", description="Meselamp",
sounds = default.node_sound_glass_defaults(),
mesecons = {effector = {
action_on = function (pos, node)
minetest.swap_node(pos, {name = "mesecons_lamp:lamp_on", param2 = node.param2})
end
}}
}) })
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_lamp:lamp_off" 1', output = "mesecons_lamp:lamp_off 1",
recipe = { recipe = {
{'', '"default:glass"', ''}, {"", "default:glass", ""},
{'"group:mesecon_conductor_craftable"', '"default:steel_ingot"', '"group:mesecon_conductor_craftable"'}, {"group:mesecon_conductor_craftable", "default:steel_ingot", "group:mesecon_conductor_craftable"},
{'', '"default:glass"', ''}, {"", "default:glass", ""},
} }
}) })
mesecon:register_on_signal_on(function(pos, node)
if node.name == "mesecons_lamp:lamp_off" then
minetest.env:add_node(pos, {name="mesecons_lamp:lamp_on", param2 = node.param2})
nodeupdate(pos)
end
end)
mesecon:register_on_signal_off(function(pos, node)
if node.name == "mesecons_lamp:lamp_on" then
minetest.env:add_node(pos, {name="mesecons_lamp:lamp_off", param2 = node.param2})
nodeupdate(pos)
end
end)
mesecon:register_effector("mesecons_lamp:lamp_on", "mesecons_lamp:lamp_off")

View File

@ -1,44 +1,60 @@
local lightstone_rules = {
{x=0, y=0, z=-1},
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
{x=0, y=0, z=1},
{x=1, y=1, z=0},
{x=1, y=-1, z=0},
{x=-1, y=1, z=0},
{x=-1, y=-1, z=0},
{x=0, y=1, z=1},
{x=0, y=-1, z=1},
{x=0, y=1, z=-1},
{x=0, y=-1, z=-1},
{x=0, y=-1, z=0},
}
function mesecon:lightstone_add(name, base_item, texture_off, texture_on) function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
minetest.register_node("mesecons_lightstone:lightstone_" .. name .. "_off", { minetest.register_node("mesecons_lightstone:lightstone_" .. name .. "_off", {
tiles = {texture_off}, tiles = {texture_off},
inventory_image = minetest.inventorycube(texture_off), groups = {cracky=2, mesecon_effector_off = 1, mesecon = 2},
groups = {cracky=2, mesecon_effector_off = 1, mesecon = 2}, description=name.." Lightstone",
description=name.." Lightstone", sounds = default.node_sound_stone_defaults(),
}) mesecons = {effector = {
minetest.register_node("mesecons_lightstone:lightstone_" .. name .. "_on", { rules = lightstone_rules,
tiles = {texture_on}, action_on = function (pos, node)
inventory_image = minetest.inventorycube(texture_on), minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_" .. name .. "_on", param2 = node.param2})
groups = {cracky=2,not_in_creative_inventory=1, mesecon = 2}, end,
drop = "node mesecons_lightstone:lightstone_" .. name .. "_off 1", }}
light_source = LIGHT_MAX-2, })
description=name.." Lightstone", minetest.register_node("mesecons_lightstone:lightstone_" .. name .. "_on", {
}) tiles = {texture_on},
assert(loadstring('mesecon:register_on_signal_on(function(pos, node) \n \ groups = {cracky=2,not_in_creative_inventory=1, mesecon = 2},
if node.name == "mesecons_lightstone:lightstone_' .. name .. '_off" then \n \ drop = "mesecons_lightstone:lightstone_" .. name .. "_off",
minetest.env:add_node(pos, {name="mesecons_lightstone:lightstone_' .. name .. '_on"}) \n \ light_source = LIGHT_MAX-2,
nodeupdate(pos) \n \ sounds = default.node_sound_stone_defaults(),
end \n \ mesecons = {effector = {
end)'))() rules = lightstone_rules,
assert(loadstring('mesecon:register_on_signal_off(function(pos, node) \n \ action_off = function (pos, node)
if node.name == "mesecons_lightstone:lightstone_' .. name .. '_on" then \n \ minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_" .. name .. "_off", param2 = node.param2})
minetest.env:add_node(pos, {name="mesecons_lightstone:lightstone_' .. name .. '_off"}) \n \ end,
nodeupdate(pos) \n \ }}
end \n \ })
end)'))()
minetest.register_craft({ minetest.register_craft({
output = "node mesecons_lightstone:lightstone_" .. name .. "_off 1", output = "mesecons_lightstone:lightstone_" .. name .. "_off",
recipe = { recipe = {
{'',base_item,''}, {"",base_item,""},
{base_item,'default:torch',base_item}, {base_item,"default:torch",base_item},
{'','group:mesecon_conductor_craftable',''}, {"","group:mesecon_conductor_craftable",""}
} }
}) })
mesecon:register_effector("mesecons_lightstone:lightstone_" .. name .. "_on", "mesecons_lightstone:lightstone_" .. name .. "_off")
end end
mesecon:lightstone_add("red", "craft default:clay_brick 1", "jeija_lightstone_red_off.png", "jeija_lightstone_red_on.png") mesecon:lightstone_add("red", "default:clay_brick", "jeija_lightstone_red_off.png", "jeija_lightstone_red_on.png")
mesecon:lightstone_add("green", "node default:cactus 1", "jeija_lightstone_green_off.png", "jeija_lightstone_green_on.png") mesecon:lightstone_add("green", "default:cactus", "jeija_lightstone_green_off.png", "jeija_lightstone_green_on.png")
mesecon:lightstone_add("blue", "node mesecons_materials:fiber 1", "jeija_lightstone_blue_off.png", "jeija_lightstone_blue_on.png") mesecon:lightstone_add("blue", "mesecons_materials:fiber", "jeija_lightstone_blue_off.png", "jeija_lightstone_blue_on.png")
mesecon:lightstone_add("gray", "node default:cobble 1", "jeija_lightstone_gray_off.png", "jeija_lightstone_gray_on.png") mesecon:lightstone_add("gray", "default:cobble", "jeija_lightstone_gray_off.png", "jeija_lightstone_gray_on.png")
mesecon:lightstone_add("darkgray", "node default:gravel 1", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_darkgray_on.png") mesecon:lightstone_add("darkgray", "default:gravel", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_darkgray_on.png")
mesecon:lightstone_add("yellow", "default:mese_crystal_fragment", "jeija_lightstone_yellow_off.png", "jeija_lightstone_yellow_on.png")

View File

@ -0,0 +1 @@
mesecons

View File

@ -0,0 +1,563 @@
-- Reference
-- ports = get_real_portstates(pos): gets if inputs are powered from outside
-- newport = merge_portstates(state1, state2): just does result = state1 or state2 for every port
-- action_setports(pos, rule, state): activates/deactivates the mesecons according to the portstates (helper for action)
-- action(pos, ports): Applies new portstates to a luacontroller at pos
-- lc_update(pos): updates the controller at pos by executing the code
-- reset_meta (pos, code, errmsg): performs a software-reset, installs new code and prints error messages
-- reset (pos): performs a hardware reset, turns off all ports
--
-- The Sandbox
-- The whole code of the controller runs in a sandbox,
-- a very restricted environment.
-- However, as this does not prevent you from using e.g. loops,
-- we need to check for these prohibited commands first.
-- Actually the only way to damage the server is to
-- use too much memory from the sandbox.
-- You can add more functions to the environment
-- (see where local env is defined)
-- Something nice to play is is appending minetest.env to it.
local BASENAME = "mesecons_luacontroller:luacontroller"
local rules = {}
rules.a = {x = -1, y = 0, z = 0, name="A"}
rules.b = {x = 0, y = 0, z = 1, name="B"}
rules.c = {x = 1, y = 0, z = 0, name="C"}
rules.d = {x = 0, y = 0, z = -1, name="D"}
------------------
-- Action stuff --
------------------
-- These helpers are required to set the portstates of the luacontroller
local get_real_portstates = function(pos) -- determine if ports are powered (by itself or from outside)
ports = {
a = mesecon:is_power_on(mesecon:addPosRule(pos, rules.a), mesecon:invertRule(rules.a))
and mesecon:rules_link(mesecon:addPosRule(pos, rules.a), pos),
b = mesecon:is_power_on(mesecon:addPosRule(pos, rules.b), mesecon:invertRule(rules.b))
and mesecon:rules_link(mesecon:addPosRule(pos, rules.b), pos),
c = mesecon:is_power_on(mesecon:addPosRule(pos, rules.c), mesecon:invertRule(rules.c))
and mesecon:rules_link(mesecon:addPosRule(pos, rules.c), pos),
d = mesecon:is_power_on(mesecon:addPosRule(pos, rules.d), mesecon:invertRule(rules.d))
and mesecon:rules_link(mesecon:addPosRule(pos, rules.d), pos),
}
return ports
end
local merge_portstates = function (ports, vports)
local npo = {a=false, b=false, c=false, d=false}
npo.a = vports.a or ports.a
npo.b = vports.b or ports.b
npo.c = vports.c or ports.c
npo.d = vports.d or ports.d
return npo
end
local generate_name = function (ports)
local overwrite = overwrite or {}
local d = ports.d and 1 or 0
local c = ports.c and 1 or 0
local b = ports.b and 1 or 0
local a = ports.a and 1 or 0
return BASENAME..d..c..b..a
end
local setport = function (pos, rule, state)
if state then
mesecon:receptor_on(pos, {rule})
else
mesecon:receptor_off(pos, {rule})
end
end
local action = function (pos, ports)
local node = minetest.get_node(pos)
local name = node.name
local vports = minetest.registered_nodes[name].virtual_portstates
local newname = generate_name(ports)
if name ~= newname and vports then
local rules_on = {}
local rules_off = {}
minetest.swap_node(pos, {name = newname, param2 = node.param2})
if ports.a ~= vports.a then setport(pos, rules.a, ports.a) end
if ports.b ~= vports.b then setport(pos, rules.b, ports.b) end
if ports.c ~= vports.c then setport(pos, rules.c, ports.c) end
if ports.d ~= vports.d then setport(pos, rules.d, ports.d) end
end
end
--------------------
-- Overheat stuff --
--------------------
local heat = function (meta) -- warm up
h = meta:get_int("heat")
if h ~= nil then
meta:set_int("heat", h + 1)
end
end
--local cool = function (meta) -- cool down after a while
-- h = meta:get_int("heat")
-- if h ~= nil then
-- meta:set_int("heat", h - 1)
-- end
--end
local overheat = function (meta) -- determine if too hot
h = meta:get_int("heat")
if h == nil then return true end -- if nil then overheat
if h > 40 then
return true
else
return false
end
end
local overheat_off = function(pos)
mesecon:receptor_off(pos, mesecon.rules.flat)
end
-------------------
-- Parsing stuff --
-------------------
local code_prohibited = function(code)
-- Clean code
local prohibited = {"while", "for", "repeat", "until", "function", "goto"}
for _, p in ipairs(prohibited) do
if string.find(code, p) then
return "Prohibited command: "..p
end
end
end
local safe_print = function(param)
print(dump(param))
end
deep_copy = function(original, visited) --deep copy that removes functions
visited = visited or {}
if visited[original] ~= nil then --already visited this node
return visited[original]
end
if type(original) == 'table' then --nested table
local copy = {}
visited[original] = copy
for key, value in next, original, nil do
copy[deep_copy(key, visited)] = deep_copy(value, visited)
end
setmetatable(copy, deep_copy(getmetatable(original), visited))
return copy
elseif type(original) == 'function' then --ignore functions
return nil
else --by-value type
return original
end
end
local safe_serialize = function(value)
return minetest.serialize(deep_copy(value))
end
local interrupt = function(params)
lc_update(params.pos, {type="interrupt", iid = params.iid})
end
local getinterrupt = function(pos)
local interrupt = function (time, iid) -- iid = interrupt id
if type(time) ~= "number" then return end
local iid = iid or math.random()
local meta = minetest.get_meta(pos)
local interrupts = minetest.deserialize(meta:get_string("lc_interrupts")) or {}
local found = false
local search = safe_serialize(iid)
for _, i in ipairs(interrupts) do
if safe_serialize(i) == search then
found = true
break
end
end
if not found then
table.insert(interrupts, iid)
meta:set_string("lc_interrupts", safe_serialize(interrupts))
end
minetest.after(time, interrupt, {pos=pos, iid = iid})
end
return interrupt
end
local getdigiline_send = function (pos)
local digiline_send = function (channel, msg)
if digiline then
digiline:receptor_send(pos, digiline.rules.default, channel, msg)
end
end
return digiline_send
end
local create_environment = function(pos, mem, event)
-- Gather variables for the environment
local vports = minetest.registered_nodes[minetest.get_node(pos).name].virtual_portstates
vports = {a = vports.a, b = vports.b, c = vports.c, d = vports.d}
local rports = get_real_portstates(pos)
return {
print = safe_print,
pin = merge_portstates(vports, rports),
port = vports,
interrupt = getinterrupt(pos),
digiline_send = getdigiline_send(pos),
mem = mem,
tostring = tostring,
tonumber = tonumber,
string = {
byte = string.byte,
char = string.char,
find = string.find,
format = string.format,
gmatch = string.gmatch,
gsub = string.gsub,
len = string.len,
lower = string.lower,
match = string.match,
rep = string.rep,
reverse = string.reverse,
sub = string.sub,
},
math = {
abs = math.abs,
acos = math.acos,
asin = math.asin,
atan = math.atan,
atan2 = math.atan2,
ceil = math.ceil,
cos = math.cos,
cosh = math.cosh,
deg = math.deg,
exp = math.exp,
floor = math.floor,
fmod = math.fmod,
frexp = math.frexp,
huge = math.huge,
ldexp = math.ldexp,
log = math.log,
log10 = math.log10,
max = math.max,
min = math.min,
modf = math.modf,
pi = math.pi,
pow = math.pow,
rad = math.rad,
random = math.random,
sin = math.sin,
sinh = math.sinh,
sqrt = math.sqrt,
tan = math.tan,
tanh = math.tanh,
},
table = {
insert = table.insert,
maxn = table.maxn,
remove = table.remove,
sort = table.sort
},
event = event,
}
end
local create_sandbox = function (code, env)
-- Create Sandbox
if code:byte(1) == 27 then
return _, "You Hacker You! Don't use binary code!"
end
f, msg = loadstring(code)
if not f then return _, msg end
setfenv(f, env)
return f
end
local do_overheat = function (pos, meta)
-- Overheat protection
heat(meta)
--minetest.after(0.5, cool, meta)
if overheat(meta) then
local node = minetest.get_node(pos)
minetest.swap_node(pos, {name = BASENAME.."_burnt", param2 = node.param2})
minetest.get_meta(pos):set_string("lc_interrupts", "")
minetest.after(0.2, overheat_off, pos) -- wait for pending operations
return true
end
end
local load_memory = function(meta)
return minetest.deserialize(meta:get_string("lc_memory")) or {}
end
local save_memory = function(meta, mem)
meta:set_string("lc_memory", safe_serialize(mem))
end
local interrupt_allow = function (meta, event)
if event.type ~= "interrupt" then return true end
local interrupts = minetest.deserialize(meta:get_string("lc_interrupts")) or {}
local search = safe_serialize(event.iid)
for _, i in ipairs(interrupts) do
if safe_serialize(i) == search then
return true
end
end
return false
end
local ports_invalid = function (var)
if type(var) == "table" then
return false
end
return "The ports you set are invalid"
end
----------------------
-- Parsing function --
----------------------
lc_update = function (pos, event)
local meta = minetest.get_meta(pos)
if not interrupt_allow(meta, event) then return end
if do_overheat(pos, meta) then return end
-- load code & mem from memory
local mem = load_memory(meta)
local code = meta:get_string("code")
-- make sure code is ok and create environment
local prohibited = code_prohibited(code)
if prohibited then return prohibited end
local env = create_environment(pos, mem, event)
-- create the sandbox and execute code
local chunk, msg = create_sandbox (code, env)
if not chunk then return msg end
local success, msg = pcall(f)
if not success then return msg end
if ports_invalid(env.port) then return ports_invalid(env.port) end
save_memory(meta, mem)
-- Actually set the ports
minetest.after(0, action, pos, env.port)
end
local reset_meta = function(pos, code, errmsg)
local meta = minetest.get_meta(pos)
meta:set_string("code", code)
code = minetest.formspec_escape(code or "")
errmsg = minetest.formspec_escape(errmsg or "")
meta:set_string("formspec", "size[10,8]"..
"background[-0.2,-0.25;10.4,8.75;jeija_luac_background.png]"..
"textarea[0.2,0.6;10.2,5;code;;"..code.."]"..
"image_button[3.75,6;2.5,1;jeija_luac_runbutton.png;program;]"..
"image_button_exit[9.72,-0.25;0.425,0.4;jeija_close_window.png;exit;]"..
"label[0.1,5;"..errmsg.."]")
meta:set_int("heat", 0)
end
local reset = function (pos)
minetest.get_meta(pos):set_string("lc_interrupts", "")
action(pos, {a=false, b=false, c=false, d=false}, true)
end
-- ______
-- |
-- |
-- | __ ___ _ __ _ _
-- | | | | | |\ | | |_| | | | | |_ |_|
-- |___| |______ |__| | \| | | \ |__| |_ |_ |_ |\
-- |
-- |
--
-----------------------
-- Node Registration --
-----------------------
local output_rules={}
local input_rules={}
local nodebox = {
type = "fixed",
fixed = {
{ -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 }, -- bottom slab
{ -5/16, -7/16, -5/16, 5/16, -6/16, 5/16 }, -- circuit board
{ -3/16, -6/16, -3/16, 3/16, -5/16, 3/16 }, -- IC
}
}
local selectionbox = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -5/16, 8/16 },
}
local digiline = {
receptor = {},
effector = {
action = function (pos, node, channel, msg)
lc_update (pos, {type = "digiline", channel = channel, msg = msg})
end
}
}
for a = 0, 1 do -- 0 = off; 1 = on
for b = 0, 1 do
for c = 0, 1 do
for d = 0, 1 do
local cid = tostring(d)..tostring(c)..tostring(b)..tostring(a)
local nodename = BASENAME..cid
local top = "jeija_luacontroller_top.png"
if a == 1 then
top = top.."^jeija_luacontroller_LED_A.png"
end
if b == 1 then
top = top.."^jeija_luacontroller_LED_B.png"
end
if c == 1 then
top = top.."^jeija_luacontroller_LED_C.png"
end
if d == 1 then
top = top.."^jeija_luacontroller_LED_D.png"
end
if a + b + c + d ~= 0 then
groups = {dig_immediate=2, not_in_creative_inventory=1, overheat = 1}
else
groups = {dig_immediate=2, overheat = 1}
end
output_rules[cid] = {}
input_rules[cid] = {}
if (a == 1) then table.insert(output_rules[cid], rules.a) end
if (b == 1) then table.insert(output_rules[cid], rules.b) end
if (c == 1) then table.insert(output_rules[cid], rules.c) end
if (d == 1) then table.insert(output_rules[cid], rules.d) end
if (a == 0) then table.insert(input_rules[cid], rules.a) end
if (b == 0) then table.insert(input_rules[cid], rules.b) end
if (c == 0) then table.insert(input_rules[cid], rules.c) end
if (d == 0) then table.insert(input_rules[cid], rules.d) end
local mesecons = {
effector =
{
rules = input_rules[cid],
action_change = function (pos, _, rulename, newstate)
lc_update(pos, {type=newstate, pin=rulename})
end,
},
receptor =
{
state = mesecon.state.on,
rules = output_rules[cid]
}
}
minetest.register_node(nodename, {
description = "Luacontroller",
drawtype = "nodebox",
tiles = {
top,
"jeija_microcontroller_bottom.png",
"jeija_microcontroller_sides.png",
"jeija_microcontroller_sides.png",
"jeija_microcontroller_sides.png",
"jeija_microcontroller_sides.png"
},
inventory_image = top,
paramtype = "light",
groups = groups,
drop = BASENAME.."0000",
sunlight_propagates = true,
selection_box = selectionbox,
node_box = nodebox,
on_construct = reset_meta,
on_receive_fields = function(pos, formname, fields)
if fields.quit then
return
end
reset(pos)
reset_meta(pos, fields.code)
local err = lc_update(pos, {type="program"})
if err then print(err) end
reset_meta(pos, fields.code, err)
end,
sounds = default.node_sound_stone_defaults(),
mesecons = mesecons,
digiline = digiline,
is_luacontroller = true,
virtual_portstates = { a = a == 1, -- virtual portstates are
b = b == 1, -- the ports the the
c = c == 1, -- controller powers itself
d = d == 1},-- so those that light up
after_dig_node = function (pos, node)
mesecon:receptor_off(pos, output_rules)
end,
})
end
end
end
end
--overheated luacontroller
minetest.register_node(BASENAME .. "_burnt", {
drawtype = "nodebox",
tiles = {
"jeija_luacontroller_burnt_top.png",
"jeija_microcontroller_bottom.png",
"jeija_microcontroller_sides.png",
"jeija_microcontroller_sides.png",
"jeija_microcontroller_sides.png",
"jeija_microcontroller_sides.png"
},
inventory_image = "jeija_luacontroller_burnt_top.png",
paramtype = "light",
groups = {dig_immediate=2, not_in_creative_inventory=1},
drop = BASENAME.."0000",
sunlight_propagates = true,
selection_box = selectionbox,
node_box = nodebox,
on_construct = reset_meta,
on_receive_fields = function(pos, formname, fields)
if fields.quit then
return
end
reset(pos)
reset_meta(pos, fields.code)
local err = lc_update(pos, {type="program"})
if err then print(err) end
reset_meta(pos, fields.code, err)
end,
sounds = default.node_sound_stone_defaults(),
is_luacontroller = true,
virtual_portstates = {a = false, b = false, c = false, d = false},
})
------------------------
-- Craft Registration --
------------------------
minetest.register_craft({
output = BASENAME.."0000 2",
recipe = {
{'mesecons_materials:silicon', 'mesecons_materials:silicon', 'group:mesecon_conductor_craftable'},
{'mesecons_materials:silicon', 'mesecons_materials:silicon', 'group:mesecon_conductor_craftable'},
{'group:mesecon_conductor_craftable', 'group:mesecon_conductor_craftable', ''},
}
})

View File

@ -12,14 +12,14 @@ minetest.register_craftitem("mesecons_materials:fiber", {
}) })
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_materials:glue" 2', output = "mesecons_materials:glue 2",
type = "cooking", type = "cooking",
recipe = "default:sapling", recipe = "default:sapling",
cooktime = 2 cooktime = 2
}) })
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_materials:fiber" 6', output = "mesecons_materials:fiber 6",
type = "cooking", type = "cooking",
recipe = "mesecons_materials:glue", recipe = "mesecons_materials:glue",
cooktime = 4 cooktime = 4
@ -33,9 +33,9 @@ minetest.register_craftitem("mesecons_materials:silicon", {
}) })
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_materials:silicon" 4', output = "mesecons_materials:silicon 4",
recipe = { recipe = {
{'"default:sand"', '"default:sand"'}, {"default:sand", "default:sand"},
{'"default:sand"', '"default:steel_ingot"'}, {"default:sand", "default:steel_ingot"},
} }
}) })

Binary file not shown.

View File

@ -19,10 +19,37 @@ if tostring(d) == "1" then
top = top.."^jeija_microcontroller_LED_D.png" top = top.."^jeija_microcontroller_LED_D.png"
end end
if tostring(d)..tostring(c)..tostring(b)..tostring(a) ~= "0000" then if tostring(d)..tostring(c)..tostring(b)..tostring(a) ~= "0000" then
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3} groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3, overheat = 1}
else else
groups = {dig_immediate=2, mesecon = 3} groups = {dig_immediate=2, mesecon = 3, overheat = 1}
end end
local rules={}
if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end
if (b == 1) then table.insert(rules, {x = 0, y = 0, z = 1}) end
if (c == 1) then table.insert(rules, {x = 1, y = 0, z = 0}) end
if (d == 1) then table.insert(rules, {x = 0, y = 0, z = -1}) end
local input_rules={}
if (a == 0) then table.insert(input_rules, {x = -1, y = 0, z = 0, name = "A"}) end
if (b == 0) then table.insert(input_rules, {x = 0, y = 0, z = 1, name = "B"}) end
if (c == 0) then table.insert(input_rules, {x = 1, y = 0, z = 0, name = "C"}) end
if (d == 0) then table.insert(input_rules, {x = 0, y = 0, z = -1, name = "D"}) end
mesecon:add_rules(nodename, rules)
local mesecons = {effector =
{
rules = input_rules,
action_change = function (pos, node, rulename)
update_yc(pos)
end
}}
if nodename ~= "mesecons_microcontroller:microcontroller0000" then
mesecons.receptor = {
state = mesecon.state.on,
rules = rules
}
end
minetest.register_node(nodename, { minetest.register_node(nodename, {
description = "Microcontroller", description = "Microcontroller",
drawtype = "nodebox", drawtype = "nodebox",
@ -39,7 +66,7 @@ minetest.register_node(nodename, {
paramtype = "light", paramtype = "light",
walkable = true, walkable = true,
groups = groups, groups = groups,
drop = '"mesecons_microcontroller:microcontroller0000" 1', drop = "mesecons_microcontroller:microcontroller0000 1",
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -5/16, 8/16 }, fixed = { -8/16, -8/16, -8/16, 8/16, -5/16, 8/16 },
@ -53,7 +80,7 @@ minetest.register_node(nodename, {
} }
}, },
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("code", "") meta:set_string("code", "")
meta:set_string("formspec", "size[9,2.5]".. meta:set_string("formspec", "size[9,2.5]"..
"field[0.256,-0.2;9,2;code;Code:;]".. "field[0.256,-0.2;9,2;code;Code:;]"..
@ -71,7 +98,10 @@ minetest.register_node(nodename, {
meta:set_string("eeprom", r) meta:set_string("eeprom", r)
end, end,
on_receive_fields = function(pos, formanme, fields, sender) on_receive_fields = function(pos, formanme, fields, sender)
local meta = minetest.env:get_meta(pos) if fields.quit then
return
end
local meta = minetest.get_meta(pos)
if fields.band then if fields.band then
fields.code = "sbi(C, A&B) :A and B are inputs, C is output" fields.code = "sbi(C, A&B) :A and B are inputs, C is output"
elseif fields.bxor then elseif fields.bxor then
@ -89,7 +119,7 @@ minetest.register_node(nodename, {
meta:set_string("code", fields.code) meta:set_string("code", fields.code)
meta:set_string("formspec", "size[9,2.5]".. meta:set_string("formspec", "size[9,2.5]"..
"field[0.256,-0.2;9,2;code;Code:;"..fields.code.."]".. "field[0.256,-0.2;9,2;code;Code:;"..minetest.formspec_escape(fields.code).."]"..
"button[0 ,0.2;1.5,3;band;AND]".. "button[0 ,0.2;1.5,3;band;AND]"..
"button[1.5,0.2;1.5,3;bxor;XOR]".. "button[1.5,0.2;1.5,3;bxor;XOR]"..
"button[3 ,0.2;1.5,3;bnot;NOT]".. "button[3 ,0.2;1.5,3;bnot;NOT]"..
@ -101,25 +131,13 @@ minetest.register_node(nodename, {
yc_reset (pos) yc_reset (pos)
update_yc(pos) update_yc(pos)
end, end,
sounds = default.node_sound_stone_defaults(),
mesecons = mesecons,
after_dig_node = function (pos, node)
rules = mesecon:get_rules(node.name)
mesecon:receptor_off(pos, rules)
end,
}) })
local rules={}
if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end
if (b == 1) then table.insert(rules, {x = 0, y = 0, z = 1}) end
if (c == 1) then table.insert(rules, {x = 1, y = 0, z = 0}) end
if (d == 1) then table.insert(rules, {x = 0, y = 0, z = -1}) end
local input_rules={}
if (a == 0) then table.insert(input_rules, {x = -1, y = 0, z = 0}) end
if (b == 0) then table.insert(input_rules, {x = 0, y = 0, z = 1}) end
if (c == 0) then table.insert(input_rules, {x = 1, y = 0, z = 0}) end
if (d == 0) then table.insert(input_rules, {x = 0, y = 0, z = -1}) end
mesecon:add_rules(nodename, rules)
mesecon:register_effector(nodename, nodename, input_rules)
if nodename ~= "mesecons_microcontroller:microcontroller0000" then
mesecon:add_receptor_node(nodename, rules)
end
end end
end end
end end
@ -136,7 +154,7 @@ minetest.register_craft({
function yc_reset(pos) function yc_reset(pos)
yc_action(pos, {a=false, b=false, c=false, d=false}) yc_action(pos, {a=false, b=false, c=false, d=false})
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("heat", 0) meta:set_int("heat", 0)
meta:set_int("afterid", 0) meta:set_int("afterid", 0)
local r = "" local r = ""
@ -145,13 +163,13 @@ function yc_reset(pos)
end end
function update_yc(pos) function update_yc(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
yc_heat(meta) yc_heat(meta)
minetest.after(0.5, yc_cool, meta) --minetest.after(0.5, yc_cool, meta)
if (yc_overheat(meta)) then if (yc_overheat(meta)) then
minetest.env:remove_node(pos) minetest.remove_node(pos)
minetest.after(0.2, yc_overheat_off, pos) --wait for pending parsings minetest.after(0.2, yc_overheat_off, pos) --wait for pending parsings
minetest.env:add_item(pos, "mesecons_microcontroller:microcontroller0000") minetest.add_item(pos, "mesecons_microcontroller:microcontroller0000")
end end
local code = meta:get_string("code") local code = meta:get_string("code")
@ -180,7 +198,7 @@ function yc_code_remove_commentary(code)
end end
function yc_parsecode(code, pos) function yc_parsecode(code, pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local endi = 1 local endi = 1
local Lreal = yc_get_real_portstates(pos) local Lreal = yc_get_real_portstates(pos)
local Lvirtual = yc_get_virtual_portstates(pos) local Lvirtual = yc_get_virtual_portstates(pos)
@ -228,7 +246,7 @@ function yc_parsecode(code, pos)
end end
if Lvirtual == nil then return nil end if Lvirtual == nil then return nil end
if eeprom == nil then return nil else if eeprom == nil then return nil else
minetest.env:get_meta(pos):set_string("eeprom", eeprom) end minetest.get_meta(pos):set_string("eeprom", eeprom) end
end end
yc_action(pos, Lvirtual) yc_action(pos, Lvirtual)
return true return true
@ -414,14 +432,14 @@ function yc_command_after(params, pos)
local code = string.sub(params[2], 2, #params[2] - 1) local code = string.sub(params[2], 2, #params[2] - 1)
local afterid = math.random(10000) local afterid = math.random(10000)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("afterid", afterid) meta:set_int("afterid", afterid)
minetest.after(time, yc_command_after_execute, {pos = pos, code = code, afterid = afterid}) minetest.after(time, yc_command_after_execute, {pos = pos, code = code, afterid = afterid})
return true return true
end end
function yc_command_after_execute(params) function yc_command_after_execute(params)
local meta = minetest.env:get_meta(params.pos) local meta = minetest.get_meta(params.pos)
if meta:get_int("afterid") == params.afterid then --make sure the node has not been changed if meta:get_int("afterid") == params.afterid then --make sure the node has not been changed
if yc_parsecode(params.code, params.pos) == nil then if yc_parsecode(params.code, params.pos) == nil then
meta:set_string("infotext", "Code in after() not valid!") meta:set_string("infotext", "Code in after() not valid!")
@ -570,14 +588,13 @@ end
--Real I/O functions --Real I/O functions
function yc_action(pos, L) --L-->Lvirtual function yc_action(pos, L) --L-->Lvirtual
local Lv = yc_get_virtual_portstates(pos) local Lv = yc_get_virtual_portstates(pos)
local metatable = minetest.env:get_meta(pos):to_table()
local name = "mesecons_microcontroller:microcontroller" local name = "mesecons_microcontroller:microcontroller"
..tonumber(L.d and 1 or 0) ..tonumber(L.d and 1 or 0)
..tonumber(L.c and 1 or 0) ..tonumber(L.c and 1 or 0)
..tonumber(L.b and 1 or 0) ..tonumber(L.b and 1 or 0)
..tonumber(L.a and 1 or 0) ..tonumber(L.a and 1 or 0)
minetest.env:add_node(pos, {name=name}) local node = minetest.get_node(pos)
minetest.env:get_meta(pos):from_table(metatable) minetest.swap_node(pos, {name = name, param2 = node.param2})
yc_action_setports(pos, L, Lv) yc_action_setports(pos, L, Lv)
end end
@ -616,22 +633,30 @@ function yc_set_portstate(port, state, L)
return L return L
end end
function yc_get_real_portstates(pos) function yc_get_real_portstates(pos) -- port powered or not (by itself or from outside)?
rulesA = mesecon:get_rules("mesecons_microcontroller:microcontroller0001") rulesA = mesecon:get_rules("mesecons_microcontroller:microcontroller0001")
rulesB = mesecon:get_rules("mesecons_microcontroller:microcontroller0010") rulesB = mesecon:get_rules("mesecons_microcontroller:microcontroller0010")
rulesC = mesecon:get_rules("mesecons_microcontroller:microcontroller0100") rulesC = mesecon:get_rules("mesecons_microcontroller:microcontroller0100")
rulesD = mesecon:get_rules("mesecons_microcontroller:microcontroller1000") rulesD = mesecon:get_rules("mesecons_microcontroller:microcontroller1000")
L = { L = {
a = mesecon:is_power_on({x=pos.x+rulesA[1].x, y=pos.y+rulesA[1].y, z=pos.z+rulesA[1].z}) and mesecon:rules_link({x=pos.x+rulesA[1].x, y=pos.y+rulesA[1].y, z=pos.z+rulesA[1].z}, pos), a = mesecon:is_power_on(mesecon:addPosRule(pos, rulesA[1]),
b = mesecon:is_power_on({x=pos.x+rulesB[1].x, y=pos.y+rulesB[1].y, z=pos.z+rulesB[1].z}) and mesecon:rules_link({x=pos.x+rulesB[1].x, y=pos.y+rulesB[1].y, z=pos.z+rulesB[1].z}, pos), mesecon:invertRule(rulesA[1])) and
c = mesecon:is_power_on({x=pos.x+rulesC[1].x, y=pos.y+rulesC[1].y, z=pos.z+rulesC[1].z}) and mesecon:rules_link({x=pos.x+rulesC[1].x, y=pos.y+rulesC[1].y, z=pos.z+rulesC[1].z}, pos), mesecon:rules_link(mesecon:addPosRule(pos, rulesA[1]), pos),
d = mesecon:is_power_on({x=pos.x+rulesD[1].x, y=pos.y+rulesD[1].y, z=pos.z+rulesD[1].z}) and mesecon:rules_link({x=pos.x+rulesD[1].x, y=pos.y+rulesD[1].y, z=pos.z+rulesD[1].z}, pos) b = mesecon:is_power_on(mesecon:addPosRule(pos, rulesB[1]),
mesecon:invertRule(rulesB[1])) and
mesecon:rules_link(mesecon:addPosRule(pos, rulesB[1]), pos),
c = mesecon:is_power_on(mesecon:addPosRule(pos, rulesC[1]),
mesecon:invertRule(rulesC[1])) and
mesecon:rules_link(mesecon:addPosRule(pos, rulesC[1]), pos),
d = mesecon:is_power_on(mesecon:addPosRule(pos, rulesD[1]),
mesecon:invertRule(rulesD[1])) and
mesecon:rules_link(mesecon:addPosRule(pos, rulesD[1]), pos),
} }
return L return L
end end
function yc_get_virtual_portstates(pos) function yc_get_virtual_portstates(pos) -- portstates according to the name
name = minetest.env:get_node(pos).name name = minetest.get_node(pos).name
b, a = string.find(name, ":microcontroller") b, a = string.find(name, ":microcontroller")
if a == nil then return nil end if a == nil then return nil end
a = a + 1 a = a + 1
@ -661,17 +686,18 @@ function yc_heat(meta)
end end
end end
function yc_cool(meta) --function yc_cool(meta)
h = meta:get_int("heat") -- h = meta:get_int("heat")
if h ~= nil then -- if h ~= nil then
meta:set_int("heat", h - 1) -- meta:set_int("heat", h - 1)
end -- end
end --end
function yc_overheat(meta) function yc_overheat(meta)
if MESECONS_GLOBALSTEP then return false end
h = meta:get_int("heat") h = meta:get_int("heat")
if h == nil then return true end -- if nil the overheat if h == nil then return true end -- if nil the overheat
if h>30 then if h>60 then
return true return true
else else
return false return false
@ -682,16 +708,3 @@ function yc_overheat_off(pos)
rules = mesecon:get_rules("mesecons_microcontroller:microcontroller1111") rules = mesecon:get_rules("mesecons_microcontroller:microcontroller1111")
mesecon:receptor_off(pos, rules) mesecon:receptor_off(pos, rules)
end end
mesecon:register_on_signal_change(function(pos, node)
if string.find(node.name, "mesecons_microcontroller:microcontroller")~=nil then
update_yc(pos)
end
end)
minetest.register_on_dignode(function(pos, node)
if string.find(node.name, "mesecons_microcontroller:microcontroller") then
rules = mesecon:get_rules(node.name)
mesecon:receptor_off(pos, rules)
end
end)

View File

@ -1,33 +1,53 @@
-- MOVESTONE -- MOVESTONE
-- Non-sticky:
-- Moves along mesecon lines
-- Pushes all blocks in front of it
--
-- Sticky one
-- Moves along mesecon lines
-- Pushes all block in front of it
-- Pull all blocks in its back
function mesecon:get_movestone_direction(pos) function mesecon:get_movestone_direction(pos)
getactivated=0 getactivated = 0
local lpos local lpos
local getactivated=0 local getactivated = 0
local rules=mesecon:get_rules("movestone") local rules = {
{x=0, y=1, z=-1},
{x=0, y=0, z=-1},
{x=0, y=-1, z=-1},
{x=0, y=1, z=1},
{x=0, y=-1, z=1},
{x=0, y=0, z=1},
{x=1, y=0, z=0},
{x=1, y=1, z=0},
{x=1, y=-1, z=0},
{x=-1, y=1, z=0},
{x=-1, y=-1, z=0},
{x=-1, y=0, z=0}}
lpos={x=pos.x+1, y=pos.y, z=pos.z} lpos = {x=pos.x+1, y=pos.y, z=pos.z}
for n=1, 3 do for n = 1, 3 do
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
return {x=0, y=0, z=-1} return {x=0, y=0, z=-1}
end end
end end
lpos={x=pos.x-1, y=pos.y, z=pos.z} lpos = {x = pos.x-1, y = pos.y, z = pos.z}
for n=4, 6 do for n=4, 6 do
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
return {x=0, y=0, z=1} return {x=0, y=0, z=1}
end end
end end
lpos={x=pos.x, y=pos.y, z=pos.z+1} lpos = {x = pos.x, y = pos.y, z = pos.z+1}
for n=7, 9 do for n=7, 9 do
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
return {x=-1, y=0, z=0} return {x=-1, y=0, z=0}
end end
end end
lpos={x=pos.x, y=pos.y, z=pos.z-1} lpos = {x = pos.x, y = pos.y, z = pos.z-1}
for n=10, 12 do for n=10, 12 do
if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then if mesecon:is_power_on(lpos, rules[n].x, rules[n].y, rules[n].z) then
return {x=1, y=0, z=0} return {x=1, y=0, z=0}
@ -41,19 +61,25 @@ minetest.register_node("mesecons_movestones:movestone", {
legacy_facedir_simple = true, legacy_facedir_simple = true,
groups = {cracky=3}, groups = {cracky=3},
description="Movestone", description="Movestone",
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
action_on = function (pos, node)
local direction=mesecon:get_movestone_direction(pos)
if not direction then return end
minetest.remove_node(pos)
mesecon:update_autoconnect(pos)
minetest.add_entity(pos, "mesecons_movestones:movestone_entity")
end
}}
}) })
mesecon:register_effector("mesecons_movestones:movestone", "mesecons_movestones:movestone")
minetest.register_entity("mesecons_movestones:movestone_entity", { minetest.register_entity("mesecons_movestones:movestone_entity", {
physical = false, physical = false,
visual = "sprite", visual = "sprite",
textures = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_arrows.png", "jeija_movestone_arrows.png"}, textures = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_arrows.png", "jeija_movestone_arrows.png"},
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, collisionbox = {-0.5,-0.5,-0.5, 0.5, 0.5, 0.5},
visual = "cube", visual = "cube",
--on_activate = function(self, staticdata) lastdir = {x=0, y=0, z=0},
--self.object:setsprite({x=0,y=0}, 1, 0, true)
--self.object:setvelocity({x=-3, y=0, z=0})
--end,
on_punch = function(self, hitter) on_punch = function(self, hitter)
self.object:remove() self.object:remove()
@ -62,51 +88,47 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
on_step = function(self, dtime) on_step = function(self, dtime)
local pos = self.object:getpos() local pos = self.object:getpos()
local direction=mesecon:get_movestone_direction(pos) pos.x, pos.y, pos.z = math.floor(pos.x+0.5), math.floor(pos.y+0.5), math.floor(pos.z+0.5)
local direction = mesecon:get_movestone_direction(pos)
if not direction then if not direction then -- no mesecon power
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"}) --push only solid nodes
local name = minetest.get_node(pos).name
if name ~= "air" and name ~= "ignore"
and ((not minetest.registered_nodes[name])
or minetest.registered_nodes[name].liquidtype == "none") then
mesecon:mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH)
end
minetest.add_node(pos, {name="mesecons_movestones:movestone"})
self.object:remove() self.object:remove()
return return
end end
self.object:setvelocity({x=direction.x*3, y=direction.y*3, z=direction.z*3}) local success, stack, oldstack =
mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
if not success then -- Too large stack/stopper in the way
minetest.add_node(pos, {name="mesecons_movestones:movestone"})
self.object:remove()
return
else
mesecon:mvps_process_stack (stack)
mesecon:mvps_move_objects (pos, direction, oldstack)
self.lastdir = direction
end
mesecon:mvps_push(pos, direction) self.object:setvelocity({x=direction.x*2, y=direction.y*2, z=direction.z*2})
end end,
}) })
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_movestones:movestone" 2', output = "mesecons_movestones:movestone 2",
recipe = { recipe = {
{'"default:stone"', '"default:stone"', '"default:stone"'}, {"default:stone", "default:stone", "default:stone"},
{'"group:mesecon_conductor_craftable"', '"group:mesecon_conductor_craftable"', '"group:mesecon_conductor_craftable"'}, {"group:mesecon_conductor_craftable", "group:mesecon_conductor_craftable", "group:mesecon_conductor_craftable"},
{'"default:stone"', '"default:stone"', '"default:stone"'}, {"default:stone", "default:stone", "default:stone"},
} }
}) })
mesecon:register_on_signal_on(function (pos, node)
if node.name=="mesecons_movestones:movestone" then
local direction=mesecon:get_movestone_direction(pos)
if not direction then return end
local checknode={}
local collpos={x=pos.x, y=pos.y, z=pos.z}
repeat -- Check if it collides with a stopper
collpos={x=collpos.x+direction.x, y=collpos.y+direction.y, z=collpos.z+direction.z}
checknode=minetest.env:get_node(collpos)
if mesecon:is_mvps_stopper(checknode.name) then
return
end
until checknode.name=="air"
or checknode.name=="ignore"
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
minetest.env:remove_node(pos)
nodeupdate(pos)
minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity")
end
end)
-- STICKY_MOVESTONE -- STICKY_MOVESTONE
@ -118,13 +140,22 @@ minetest.register_node("mesecons_movestones:sticky_movestone", {
legacy_facedir_simple = true, legacy_facedir_simple = true,
groups = {cracky=3}, groups = {cracky=3},
description="Sticky Movestone", description="Sticky Movestone",
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
action_on = function (pos, node)
local direction=mesecon:get_movestone_direction(pos)
if not direction then return end
minetest.remove_node(pos)
mesecon:update_autoconnect(pos)
minetest.add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
end
}}
}) })
mesecon:register_effector("mesecons_movestones:sticky_movestone", "mesecons_movestones:sticky_movestone")
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_movestones:sticky_movestone" 2', output = "mesecons_movestones:sticky_movestone 2",
recipe = { recipe = {
{'"mesecons_materials:glue"', '"mesecons_movestones:movestone"', '"mesecons_materials:glue"'}, {"mesecons_materials:glue", "mesecons_movestones:movestone", "mesecons_materials:glue"},
} }
}) })
@ -132,8 +163,9 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
physical = false, physical = false,
visual = "sprite", visual = "sprite",
textures = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_sticky_movestone.png", "jeija_sticky_movestone.png"}, textures = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_sticky_movestone.png", "jeija_sticky_movestone.png"},
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
visual = "cube", visual = "cube",
lastdir = {x=0, y=0, z=0},
on_punch = function(self, hitter) on_punch = function(self, hitter)
self.object:remove() self.object:remove()
@ -142,66 +174,43 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
on_step = function(self, dtime) on_step = function(self, dtime)
local pos = self.object:getpos() local pos = self.object:getpos()
local colp = pos pos.x, pos.y, pos.z = math.floor(pos.x+0.5), math.floor(pos.y+0.5), math.floor(pos.z+0.5)
local direction=mesecon:get_movestone_direction(colp) local direction = mesecon:get_movestone_direction(pos)
if not direction then if not direction then -- no mesecon power
--or (minetest.env:get_node_or_nil(pos).name ~="air" --push only solid nodes
--and minetest.env:get_node_or_nil(pos).name ~= nil) then local name = minetest.get_node(pos).name
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"}) if name ~= "air" and name ~= "ignore"
and ((not minetest.registered_nodes[name])
or minetest.registered_nodes[name].liquidtype == "none") then
mesecon:mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH)
--STICKY
mesecon:mvps_pull_all(pos, self.lastdir)
end
minetest.add_node(pos, {name="mesecons_movestones:sticky_movestone"})
self.object:remove() self.object:remove()
return return
end end
self.object:setvelocity({x=direction.x*3, y=direction.y*3, z=direction.z*3}) local success, stack, oldstack =
mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
if not success then -- Too large stack/stopper in the way
minetest.add_node(pos, {name="mesecons_movestones:sticky_movestone"})
self.object:remove()
return
else
mesecon:mvps_process_stack (stack)
mesecon:mvps_move_objects (pos, direction, oldstack)
self.lastdir = direction
end
mesecon:mvps_push(pos, direction) self.object:setvelocity({x=direction.x*2, y=direction.y*2, z=direction.z*2})
--STICKY --STICKY
mesecon:mvps_pull_all(pos, direction) mesecon:mvps_pull_all(pos, direction)
end end,
}) })
mesecon:register_on_signal_on(function (pos, node)
if node.name=="mesecons_movestones:sticky_movestone" then
local direction=mesecon:get_movestone_direction(pos)
if not direction then return end
local checknode={}
local collpos={x=pos.x, y=pos.y, z=pos.z}
repeat -- Check if it collides with a stopper
collpos={x=collpos.x+direction.x, y=collpos.y+direction.y, z=collpos.z+direction.z}
checknode=minetest.env:get_node(collpos)
if mesecon:is_mvps_stopper(checknode.name) then
return
end
until checknode.name=="air"
or checknode.name=="ignore"
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
repeat -- Check if it collides with a stopper (pull direction)
collpos={x=collpos.x-direction.x, y=collpos.y-direction.y, z=collpos.z-direction.z}
checknode=minetest.env:get_node(collpos)
if mesecon:is_mvps_stopper(checknode.name) then
return
end
until checknode.name=="air"
or checknode.name=="ignore"
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
minetest.env:remove_node(pos)
nodeupdate(pos)
minetest.env:add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
end
end)
mesecon:add_rules("movestone", { mesecon:register_mvps_unmov("mesecons_movestones:movestone_entity")
{x=0, y=1, z=-1}, mesecon:register_mvps_unmov("mesecons_movestones:sticky_movestone_entity")
{x=0, y=0, z=-1},
{x=0, y=-1, z=-1},
{x=0, y=1, z=1},
{x=0, y=-1, z=1},
{x=0, y=0, z=1},
{x=1, y=0, z=0},
{x=1, y=1, z=0},
{x=1, y=-1, z=0},
{x=-1, y=1, z=0},
{x=-1, y=-1, z=0},
{x=-1, y=0, z=0}})

View File

@ -1,67 +1,238 @@
--register stoppers for movestones/pistons --register stoppers for movestones/pistons
mesecon.mvps_stoppers={} mesecon.mvps_stoppers = {}
mesecon.mvps_unmov = {}
mesecon.on_mvps_move = {}
function mesecon:is_mvps_stopper(nodename) function mesecon:is_mvps_stopper(node, pushdir, stack, stackid)
local i=1 local get_stopper = mesecon.mvps_stoppers[node.name]
repeat if type (get_stopper) == "function" then
i=i+1 get_stopper = get_stopper(node, pushdir, stack, stackid)
if mesecon.mvps_stoppers[i]==nodename then return true end end
until mesecon.mvps_stoppers[i]==nil return get_stopper
return false
end end
function mesecon:register_mvps_stopper(nodename) function mesecon:register_mvps_stopper(nodename, get_stopper)
local i=1 if get_stopper == nil then
repeat get_stopper = true
i=i+1 end
if mesecon.mvps_stoppers[i]==nil then break end mesecon.mvps_stoppers[nodename] = get_stopper
until false
mesecon.mvps_stoppers[i]=nodename
end end
function mesecon:mvps_push(pos, direction) -- pos: pos of mvps; direction: direction of push -- Objects that cannot be moved (e.g. movestones)
pos.x=pos.x+direction.x function mesecon:register_mvps_unmov(objectname)
pos.y=pos.y+direction.y mesecon.mvps_unmov[objectname] = true;
pos.z=pos.z+direction.z end
local lpos = {x=pos.x, y=pos.y, z=pos.z} function mesecon:is_mvps_unmov(objectname)
local lnode = minetest.env:get_node(lpos) return mesecon.mvps_unmov[objectname]
local newnode end
minetest.env:remove_node(lpos)
while not(lnode.name == "ignore" or lnode.name == "air" or not(minetest.registered_nodes[lnode.name].liquidtype == "none")) do -- Functions to be called on mvps movement
lpos.x=lpos.x+direction.x function mesecon:register_on_mvps_move(callback)
lpos.y=lpos.y+direction.y mesecon.on_mvps_move[#mesecon.on_mvps_move+1] = callback
lpos.z=lpos.z+direction.z end
newnode = lnode
lnode = minetest.env:get_node(lpos) local function on_mvps_move(moved_nodes)
minetest.env:add_node(lpos, newnode) for _, callback in ipairs(mesecon.on_mvps_move) do
nodeupdate(lpos) callback(moved_nodes)
end
end
function mesecon:mvps_process_stack(stack)
-- update mesecons for placed nodes ( has to be done after all nodes have been added )
for _, n in ipairs(stack) do
nodeupdate(n.pos)
mesecon.on_placenode(n.pos, minetest.get_node(n.pos))
mesecon:update_autoconnect(n.pos)
end
end
function mesecon:mvps_get_stack(pos, dir, maximum)
-- determine the number of nodes to be pushed
local np = {x = pos.x, y = pos.y, z = pos.z}
local nodes = {}
while true do
local nn = minetest.get_node_or_nil(np)
if not nn or #nodes > maximum then
-- don't push at all, something is in the way (unloaded map or too many nodes)
return nil
end end
if nn.name == "air"
or (minetest.registered_nodes[nn.name]
and minetest.registered_nodes[nn.name].liquidtype ~= "none") then --is liquid
break
end
table.insert (nodes, {node = nn, pos = np})
np = mesecon:addPosRule(np, dir)
end
return nodes
end
function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: direction of push; maximum: maximum nodes to be pushed
local nodes = mesecon:mvps_get_stack(pos, dir, maximum)
if not nodes then return end
-- determine if one of the nodes blocks the push
for id, n in ipairs(nodes) do
if mesecon:is_mvps_stopper(n.node, dir, nodes, id) then
return
end
end
-- remove all nodes
for _, n in ipairs(nodes) do
n.meta = minetest.get_meta(n.pos):to_table()
minetest.remove_node(n.pos)
end
-- update mesecons for removed nodes ( has to be done after all nodes have been removed )
for _, n in ipairs(nodes) do
mesecon.on_dignode(n.pos, n.node)
mesecon:update_autoconnect(n.pos)
end
-- add nodes
for _, n in ipairs(nodes) do
np = mesecon:addPosRule(n.pos, dir)
minetest.add_node(np, n.node)
minetest.get_meta(np):from_table(n.meta)
end
local moved_nodes = {}
local oldstack = mesecon:tablecopy(nodes)
for i in ipairs(nodes) do
moved_nodes[i] = {}
moved_nodes[i].oldpos = nodes[i].pos
nodes[i].pos = mesecon:addPosRule(nodes[i].pos, dir)
moved_nodes[i].pos = nodes[i].pos
moved_nodes[i].node = nodes[i].node
moved_nodes[i].meta = nodes[i].meta
end
on_mvps_move(moved_nodes)
return true, nodes, oldstack
end
mesecon:register_on_mvps_move(function(moved_nodes)
for _, n in ipairs(moved_nodes) do
mesecon.on_placenode(n.pos, n.node)
mesecon:update_autoconnect(n.pos)
end
end)
function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: direction of pull (matches push direction for sticky pistons)
np = mesecon:addPosRule(pos, dir)
nn = minetest.get_node(np)
if ((not minetest.registered_nodes[nn.name]) --unregistered node
or minetest.registered_nodes[nn.name].liquidtype == "none") --non-liquid node
and not mesecon:is_mvps_stopper(nn, {x = -dir.x, y = -dir.y, z = -dir.z}, {{pos = np, node = nn}}, 1) then --non-stopper node
local meta = minetest.get_meta(np):to_table()
minetest.remove_node(np)
minetest.add_node(pos, nn)
minetest.get_meta(pos):from_table(meta)
nodeupdate(np)
nodeupdate(pos)
mesecon.on_dignode(np, nn)
mesecon:update_autoconnect(np)
on_mvps_move({{pos = pos, oldpos = np, node = nn, meta = meta}})
end
return {{pos = np, node = {param2 = 0, name = "air"}}, {pos = pos, node = nn}}
end end
function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull
local lpos = {x=pos.x-direction.x, y=pos.y-direction.y, z=pos.z-direction.z} -- 1 away local lpos = {x=pos.x-direction.x, y=pos.y-direction.y, z=pos.z-direction.z} -- 1 away
local lnode = minetest.env:get_node(lpos) local lnode = minetest.get_node(lpos)
local lpos2 = {x=pos.x-direction.x*2, y=pos.y-direction.y*2, z=pos.z-direction.z*2} -- 2 away local lpos2 = {x=pos.x-direction.x*2, y=pos.y-direction.y*2, z=pos.z-direction.z*2} -- 2 away
local lnode2 = minetest.env:get_node(lpos2) local lnode2 = minetest.get_node(lpos2)
if lnode.name ~= "ignore" and lnode.name ~= "air" and minetest.registered_nodes[lnode.name].liquidtype == "none" then return end --avoid pulling solid nodes
if lnode2.name == "ignore" or lnode2.name == "air" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none") then return end if lnode.name ~= "ignore"
and lnode.name ~= "air"
and ((not minetest.registered_nodes[lnode.name])
or minetest.registered_nodes[lnode.name].liquidtype == "none") then
return
end
local oldpos = {x=lpos2.x+direction.x, y=lpos2.y+direction.y, z=lpos2.z+direction.z} --avoid pulling empty or liquid nodes
repeat if lnode2.name == "ignore"
minetest.env:add_node(oldpos, {name=minetest.env:get_node(lpos2).name}) or lnode2.name == "air"
nodeupdate(oldpos) or (minetest.registered_nodes[lnode2.name]
oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z} and minetest.registered_nodes[lnode2.name].liquidtype ~= "none") then
lpos2.x = lpos2.x-direction.x return
lpos2.y = lpos2.y-direction.y end
lpos2.z = lpos2.z-direction.z
lnode = minetest.env:get_node(lpos2) local moved_nodes = {}
until lnode.name=="air" or lnode.name=="ignore" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none") local oldpos = {x=lpos2.x + direction.x, y=lpos2.y + direction.y, z=lpos2.z + direction.z}
minetest.env:remove_node(oldpos) repeat
lnode2 = minetest.get_node(lpos2)
local meta = minetest.get_meta(lnode2):to_table()
minetest.add_node(oldpos, lnode2)
minetest.get_meta(oldpos):from_table(meta)
moved_nodes[#moved_nodes+1] = {pos = oldpos, oldpos = lnode2, node = lnode2, meta = meta}
nodeupdate(oldpos)
oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z}
lpos2.x = lpos2.x-direction.x
lpos2.y = lpos2.y-direction.y
lpos2.z = lpos2.z-direction.z
lnode = minetest.get_node(lpos2)
until lnode.name == "air"
or lnode.name == "ignore"
or (minetest.registered_nodes[lnode.name]
and minetest.registered_nodes[lnode.name].liquidtype ~= "none")
minetest.remove_node(oldpos)
mesecon.on_dignode(oldpos, lnode2)
mesecon:update_autoconnect(oldpos)
on_mvps_move(moved_nodes)
end
function mesecon:mvps_move_objects(pos, dir, nodestack)
local objects_to_move = {}
-- Move object at tip of stack
local pushpos = mesecon:addPosRule(pos, -- get pos at tip of stack
{x = dir.x * #nodestack,
y = dir.y * #nodestack,
z = dir.z * #nodestack})
local objects = minetest.get_objects_inside_radius(pushpos, 1)
for _, obj in ipairs(objects) do
table.insert(objects_to_move, obj)
end
-- Move objects lying/standing on the stack (before it was pushed - oldstack)
if tonumber(minetest.setting_get("movement_gravity")) > 0 and dir.y == 0 then
-- If gravity positive and dir horizontal, push players standing on the stack
for _, n in ipairs(nodestack) do
local p_above = mesecon:addPosRule(n.pos, {x=0, y=1, z=0})
local objects = minetest.get_objects_inside_radius(p_above, 1)
for _, obj in ipairs(objects) do
table.insert(objects_to_move, obj)
end
end
end
for _, obj in ipairs(objects_to_move) do
local entity = obj:get_luaentity()
if not entity or not mesecon:is_mvps_unmov(entity.name) then
local np = mesecon:addPosRule(obj:getpos(), dir)
--move only if destination is not solid
local nn = minetest.get_node(np)
if not ((not minetest.registered_nodes[nn.name])
or minetest.registered_nodes[nn.name].walkable) then
obj:setpos(np)
end
end
end
end end
mesecon:register_mvps_stopper("default:chest")
mesecon:register_mvps_stopper("default:chest_locked") mesecon:register_mvps_stopper("default:chest_locked")
mesecon:register_mvps_stopper("default:furnace") mesecon:register_mvps_stopper("default:furnace")

View File

@ -1,33 +1,35 @@
minetest.register_node("mesecons_noteblock:noteblock", { minetest.register_node("mesecons_noteblock:noteblock", {
description = "Noteblock", description = "Noteblock",
tiles = {"mesecons_noteblock.png"}, tiles = {"mesecons_noteblock.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
drawtype = "allfaces_optional", drawtype = "allfaces_optional",
visual_scale = 1.3, visual_scale = 1.3,
paramtype="light", paramtype="light",
after_place_node = function(pos) after_place_node = function(pos)
minetest.env:add_node(pos, {name="mesecons_noteblock:noteblock", param2=0}) minetest.add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
end end,
}) on_punch = function (pos, node) -- change sound when punched
mesecon:register_effector("mesecons_noteblock:noteblock", "mesecons_noteblock:noteblock")
minetest.register_craft({
output = '"mesecons_noteblock:noteblock" 1',
recipe = {
{"default:wood", "default:wood", "default:wood"},
{"group:mesecon_conductor_craftable", "default:steel_ingot", "group:mesecon_conductor_craftable"},
{"default:wood", "default:wood", "default:wood"},
}
})
minetest.register_on_punchnode(function (pos, node)
if node.name=="mesecons_noteblock:noteblock" then
local param2 = node.param2+1 local param2 = node.param2+1
if param2==12 then param2=0 end if param2==12 then param2=0 end
minetest.env:add_node(pos, {name=node.name, param2=param2}) minetest.add_node(pos, {name = node.name, param2 = param2})
mesecon.noteblock_play(pos, param2) mesecon.noteblock_play(pos, param2)
end end,
end) sounds = default.node_sound_wood_defaults(),
mesecons = {effector = { -- play sound when activated
action_on = function (pos, node)
mesecon.noteblock_play(pos, node.param2)
end
}}
})
minetest.register_craft({
output = "mesecons_noteblock:noteblock 1",
recipe = {
{"group:wood", "group:wood", "group:wood"},
{"group:mesecon_conductor_craftable", "default:steel_ingot", "group:mesecon_conductor_craftable"},
{"group:wood", "group:wood", "group:wood"},
}
})
mesecon.noteblock_play = function (pos, param2) mesecon.noteblock_play = function (pos, param2)
local soundname local soundname
@ -56,7 +58,7 @@ mesecon.noteblock_play = function (pos, param2)
elseif param2==7 then elseif param2==7 then
soundname="mesecons_noteblock_gsharp" soundname="mesecons_noteblock_gsharp"
end end
local block_below_name = minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name local block_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
if block_below_name == "default:glass" then if block_below_name == "default:glass" then
soundname="mesecons_noteblock_hihat" soundname="mesecons_noteblock_hihat"
end end
@ -75,9 +77,3 @@ mesecon.noteblock_play = function (pos, param2)
minetest.sound_play(soundname, minetest.sound_play(soundname,
{pos = pos, gain = 1.0, max_hear_distance = 32,}) {pos = pos, gain = 1.0, max_hear_distance = 32,})
end end
mesecon:register_on_signal_on(function(pos, node)
if node.name=="mesecons_noteblock:noteblock" then
mesecon.noteblock_play(pos, node.param2)
end
end)

View File

@ -1,3 +1,2 @@
mesecons mesecons
mesecons_materials
mesecons_mvps mesecons_mvps

View File

@ -1,253 +1,758 @@
--PISTONS -- Get mesecon rules of pistons
piston_rules =
{{x=0, y=0, z=1}, --everything apart from z- (pusher side)
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
{x=1, y=1, z=0},
{x=1, y=-1, z=0},
{x=-1, y=1, z=0},
{x=-1, y=-1, z=0},
{x=0, y=1, z=1},
{x=0, y=-1, z=1}}
minetest.register_node("mesecons_pistons:piston_normal", { local piston_up_rules =
{{x=0, y=0, z=-1}, --everything apart from y+ (pusher side)
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
{x=0, y=0, z=1},
{x=1, y=-1, z=0},
{x=-1, y=-1, z=0},
{x=0, y=-1, z=1},
{x=0, y=-1, z=-1}}
local piston_down_rules =
{{x=0, y=0, z=-1}, --everything apart from y- (pusher side)
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
{x=0, y=0, z=1},
{x=1, y=1, z=0},
{x=-1, y=1, z=0},
{x=0, y=1, z=1},
{x=0, y=1, z=-1}}
local piston_get_rules = function (node)
local rules = piston_rules
for i = 1, node.param2 do
rules = mesecon:rotate_rules_left(rules)
end
return rules
end
piston_facedir_direction = function (node)
local rules = {{x = 0, y = 0, z = -1}}
for i = 1, node.param2 do
rules = mesecon:rotate_rules_left(rules)
end
return rules[1]
end
piston_get_direction = function(dir, node)
if type(dir) == "function" then
return dir(node)
else
return dir
end
end
local piston_remove_pusher = function(pos, node)
pistonspec = minetest.registered_nodes[node.name].mesecons_piston
if pushername == pistonspec.pusher then --make sure there actually is a pusher (for compatibility reasons mainly)
return
end
dir = piston_get_direction(pistonspec.dir, node)
local pusherpos = mesecon:addPosRule(pos, dir)
local pushername = minetest.get_node(pusherpos).name
minetest.remove_node(pusherpos)
minetest.sound_play("piston_retract", {
pos = pos,
max_hear_distance = 20,
gain = 0.3,
})
nodeupdate(pusherpos)
end
local piston_on = function(pos, node)
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
local dir = piston_get_direction(pistonspec.dir, node)
local np = mesecon:addPosRule(pos, dir)
local success, stack, oldstack = mesecon:mvps_push(np, dir, PISTON_MAXIMUM_PUSH)
if success then
minetest.add_node(pos, {param2 = node.param2, name = pistonspec.onname})
minetest.add_node(np, {param2 = node.param2, name = pistonspec.pusher})
minetest.sound_play("piston_extend", {
pos = pos,
max_hear_distance = 20,
gain = 0.3,
})
mesecon:mvps_process_stack (stack)
mesecon:mvps_move_objects (np, dir, oldstack)
end
end
local piston_off = function(pos, node)
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
minetest.add_node(pos, {param2 = node.param2, name = pistonspec.offname})
piston_remove_pusher(pos, node)
if pistonspec.sticky then
dir = piston_get_direction(pistonspec.dir, node)
pullpos = mesecon:addPosRule(pos, dir)
stack = mesecon:mvps_pull_single(pullpos, dir)
mesecon:mvps_process_stack(pos, dir, stack)
end
end
local piston_orientate = function(pos, placer)
-- not placed by player
if not placer then return end
-- placer pitch in degrees
local pitch = placer:get_look_pitch() * (180 / math.pi)
local node = minetest.get_node(pos)
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
if pitch > 55 then --looking upwards
minetest.add_node(pos, {name=pistonspec.piston_down})
elseif pitch < -55 then --looking downwards
minetest.add_node(pos, {name=pistonspec.piston_up})
end
end
-- Horizontal pistons
local pt = 3/16 -- pusher thickness
local piston_pusher_box = {
type = "fixed",
fixed = {
{-2/16, -2/16, -.5 + pt, 2/16, 2/16, .5 + pt},
{-.5 , -.5 , -.5 , .5 , .5 , -.5 + pt},
}
}
local piston_on_box = {
type = "fixed",
fixed = {
{-.5, -.5, -.5 + pt, .5, .5, .5}
}
}
-- Normal (non-sticky) ones:
local pistonspec_normal = {
offname = "mesecons_pistons:piston_normal_off",
onname = "mesecons_pistons:piston_normal_on",
dir = piston_facedir_direction,
pusher = "mesecons_pistons:piston_pusher_normal",
piston_down = "mesecons_pistons:piston_down_normal_off",
piston_up = "mesecons_pistons:piston_up_normal_off",
}
-- offstate
minetest.register_node("mesecons_pistons:piston_normal_off", {
description = "Piston", description = "Piston",
tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_side.png"}, tiles = {
groups = {cracky=3, mesecon=2}, "mesecons_piston_top.png",
"mesecons_piston_bottom.png",
"mesecons_piston_left.png",
"mesecons_piston_right.png",
"mesecons_piston_back.png",
"mesecons_piston_pusher_front.png"
},
groups = {cracky = 3},
paramtype2 = "facedir", paramtype2 = "facedir",
after_destruct = function(pos, oldnode) after_place_node = piston_orientate,
local dir = mesecon:piston_get_direction(oldnode) mesecons_piston = pistonspec_normal,
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check sounds = default.node_sound_wood_defaults(),
mesecons = {effector={
--ensure piston is extended action_on = piston_on,
local checknode = minetest.env:get_node(pos) rules = piston_get_rules
if checknode.name == "mesecons_pistons:piston_pusher_normal" then }}
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
minetest.env:remove_node(pos) --remove the pusher
end
end
end,
on_timer = function(pos, elapsed)
if mesecon:is_powered(pos) then
mesecon:piston_push(pos)
else
mesecon:piston_pull(pos)
end
return false
end,
}) })
mesecon:register_effector("mesecons_pistons:piston_normal", "mesecons_pistons:piston_normal")
minetest.register_node("mesecons_pistons:piston_sticky", { -- onstate
minetest.register_node("mesecons_pistons:piston_normal_on", {
drawtype = "nodebox",
tiles = {
"mesecons_piston_top.png",
"mesecons_piston_bottom.png",
"mesecons_piston_left.png",
"mesecons_piston_right.png",
"mesecons_piston_back.png",
"mesecons_piston_on_front.png"
},
inventory_image = "mesecons_piston_top.png",
wield_image = "mesecons_piston_top.png",
groups = {cracky = 3, not_in_creative_inventory = 1},
paramtype = "light",
paramtype2 = "facedir",
drop = "mesecons_pistons:piston_normal_off",
after_dig_node = piston_remove_pusher,
node_box = piston_on_box,
selection_box = piston_on_box,
mesecons_piston = pistonspec_normal,
sounds = default.node_sound_wood_defaults(),
mesecons = {effector={
action_off = piston_off,
rules = piston_get_rules
}}
})
-- pusher
minetest.register_node("mesecons_pistons:piston_pusher_normal", {
drawtype = "nodebox",
tiles = {
"mesecons_piston_pusher_top.png",
"mesecons_piston_pusher_bottom.png",
"mesecons_piston_pusher_left.png",
"mesecons_piston_pusher_right.png",
"mesecons_piston_pusher_back.png",
"mesecons_piston_pusher_front.png"
},
paramtype = "light",
paramtype2 = "facedir",
diggable = false,
corresponding_piston = "mesecons_pistons:piston_normal_on",
selection_box = piston_pusher_box,
node_box = piston_pusher_box,
})
-- Sticky ones
local pistonspec_sticky = {
offname = "mesecons_pistons:piston_sticky_off",
onname = "mesecons_pistons:piston_sticky_on",
dir = piston_facedir_direction,
pusher = "mesecons_pistons:piston_pusher_sticky",
sticky = true,
piston_down = "mesecons_pistons:piston_down_sticky_off",
piston_up = "mesecons_pistons:piston_up_sticky_off",
}
-- offstate
minetest.register_node("mesecons_pistons:piston_sticky_off", {
description = "Sticky Piston", description = "Sticky Piston",
tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_sticky_side.png"}, tiles = {
groups = {cracky=3, mesecon=2}, "mesecons_piston_top.png",
"mesecons_piston_bottom.png",
"mesecons_piston_left.png",
"mesecons_piston_right.png",
"mesecons_piston_back.png",
"mesecons_piston_pusher_front_sticky.png"
},
groups = {cracky = 3},
paramtype2 = "facedir", paramtype2 = "facedir",
after_destruct = function(pos, oldnode) after_place_node = piston_orientate,
local dir = mesecon:piston_get_direction(oldnode) mesecons_piston = pistonspec_sticky,
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check sounds = default.node_sound_wood_defaults(),
mesecons = {effector={
action_on = piston_on,
rules = piston_get_rules
}}
})
--ensure piston is extended -- onstate
local checknode = minetest.env:get_node(pos) minetest.register_node("mesecons_pistons:piston_sticky_on", {
if checknode.name == "mesecons_pistons:piston_pusher_sticky" then drawtype = "nodebox",
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston tiles = {
minetest.env:remove_node(pos) --remove the pusher "mesecons_piston_top.png",
"mesecons_piston_bottom.png",
"mesecons_piston_left.png",
"mesecons_piston_right.png",
"mesecons_piston_back.png",
"mesecons_piston_on_front.png"
},
inventory_image = "mesecons_piston_top.png",
wield_image = "mesecons_piston_top.png",
groups = {cracky = 3, not_in_creative_inventory = 1},
paramtype = "light",
paramtype2 = "facedir",
drop = "mesecons_pistons:piston_normal_off",
after_dig_node = piston_remove_pusher,
node_box = piston_on_box,
selection_box = piston_on_box,
mesecons_piston = pistonspec_sticky,
sounds = default.node_sound_wood_defaults(),
mesecons = {effector={
action_off = piston_off,
rules = piston_get_rules
}}
})
-- pusher
minetest.register_node("mesecons_pistons:piston_pusher_sticky", {
drawtype = "nodebox",
tiles = {
"mesecons_piston_pusher_top.png",
"mesecons_piston_pusher_bottom.png",
"mesecons_piston_pusher_left.png",
"mesecons_piston_pusher_right.png",
"mesecons_piston_pusher_back.png",
"mesecons_piston_pusher_front_sticky.png"
},
paramtype = "light",
paramtype2 = "facedir",
diggable = false,
corresponding_piston = "mesecons_pistons:piston_sticky_on",
selection_box = piston_pusher_box,
node_box = piston_pusher_box,
})
--
--
-- UP
--
--
local piston_up_pusher_box = {
type = "fixed",
fixed = {
{-2/16, -.5 - pt, -2/16, 2/16, .5 - pt, 2/16},
{-.5 , .5 - pt, -.5 , .5 , .5 , .5},
}
}
local piston_up_on_box = {
type = "fixed",
fixed = {
{-.5, -.5, -.5 , .5, .5-pt, .5}
}
}
-- Normal
local pistonspec_normal_up = {
offname = "mesecons_pistons:piston_up_normal_off",
onname = "mesecons_pistons:piston_up_normal_on",
dir = {x = 0, y = 1, z = 0},
pusher = "mesecons_pistons:piston_up_pusher_normal"
}
-- offstate
minetest.register_node("mesecons_pistons:piston_up_normal_off", {
tiles = {
"mesecons_piston_pusher_front.png",
"mesecons_piston_back.png",
"mesecons_piston_left.png^[transformR270",
"mesecons_piston_right.png^[transformR90",
"mesecons_piston_bottom.png",
"mesecons_piston_top.png^[transformR180",
},
inventory_image = "mesecons_piston_top.png",
wield_image = "mesecons_piston_top.png",
groups = {cracky = 3, not_in_creative_inventory = 1},
paramtype2 = "facedir",
drop = "mesecons_pistons:piston_normal_off",
mesecons_piston = pistonspec_normal_up,
mesecons = {effector={
action_on = piston_on,
rules = piston_up_rules,
}}
})
-- onstate
minetest.register_node("mesecons_pistons:piston_up_normal_on", {
drawtype = "nodebox",
tiles = {
"mesecons_piston_on_front.png",
"mesecons_piston_back.png",
"mesecons_piston_left.png^[transformR270",
"mesecons_piston_right.png^[transformR90",
"mesecons_piston_bottom.png",
"mesecons_piston_top.png^[transformR180",
},
inventory_image = "mesecons_piston_top.png",
wield_image = "mesecons_piston_top.png",
groups = {cracky = 3, not_in_creative_inventory = 1},
paramtype = "light",
paramtype2 = "facedir",
drop = "mesecons_pistons:piston_normal_off",
after_dig_node = piston_remove_pusher,
node_box = piston_up_on_box,
selection_box = piston_up_on_box,
mesecons_piston = pistonspec_normal_up,
sounds = default.node_sound_wood_defaults(),
mesecons = {effector={
action_off = piston_off,
rules = piston_up_rules,
}}
})
-- pusher
minetest.register_node("mesecons_pistons:piston_up_pusher_normal", {
drawtype = "nodebox",
tiles = {
"mesecons_piston_pusher_front.png",
"mesecons_piston_pusher_back.png",
"mesecons_piston_pusher_left.png^[transformR270",
"mesecons_piston_pusher_right.png^[transformR90",
"mesecons_piston_pusher_bottom.png",
"mesecons_piston_pusher_top.png^[transformR180",
},
paramtype = "light",
paramtype2 = "facedir",
diggable = false,
corresponding_piston = "mesecons_pistons:piston_up_normal_on",
selection_box = piston_up_pusher_box,
node_box = piston_up_pusher_box,
})
-- Sticky
local pistonspec_sticky_up = {
offname = "mesecons_pistons:piston_up_sticky_off",
onname = "mesecons_pistons:piston_up_sticky_on",
dir = {x = 0, y = 1, z = 0},
pusher = "mesecons_pistons:piston_up_pusher_sticky",
sticky = true
}
-- offstate
minetest.register_node("mesecons_pistons:piston_up_sticky_off", {
tiles = {
"mesecons_piston_pusher_front_sticky.png",
"mesecons_piston_back.png",
"mesecons_piston_left.png^[transformR270",
"mesecons_piston_right.png^[transformR90",
"mesecons_piston_bottom.png",
"mesecons_piston_top.png^[transformR180",
"mesecons_piston_tb.png"
},
inventory_image = "mesecons_piston_top.png",
wield_image = "mesecons_piston_top.png",
groups = {cracky = 3, not_in_creative_inventory = 1},
paramtype2 = "facedir",
drop = "mesecons_pistons:piston_sticky_off",
mesecons_piston = pistonspec_sticky_up,
sounds = default.node_sound_wood_defaults(),
mesecons = {effector={
action_on = piston_on,
rules = piston_up_rules,
}}
})
-- onstate
minetest.register_node("mesecons_pistons:piston_up_sticky_on", {
drawtype = "nodebox",
tiles = {
"mesecons_piston_on_front.png",
"mesecons_piston_back.png",
"mesecons_piston_left.png^[transformR270",
"mesecons_piston_right.png^[transformR90",
"mesecons_piston_bottom.png",
"mesecons_piston_top.png^[transformR180",
},
inventory_image = "mesecons_piston_top.png",
wield_image = "mesecons_piston_top.png",
groups = {cracky = 3, not_in_creative_inventory = 1},
paramtype = "light",
paramtype2 = "facedir",
drop = "mesecons_pistons:piston_normal_off",
after_dig_node = piston_remove_pusher,
node_box = piston_up_on_box,
selection_box = piston_up_on_box,
mesecons_piston = pistonspec_sticky_up,
sounds = default.node_sound_wood_defaults(),
mesecons = {effector={
action_off = piston_off,
rules = piston_up_rules,
}}
})
-- pusher
minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", {
drawtype = "nodebox",
tiles = {
"mesecons_piston_pusher_front_sticky.png",
"mesecons_piston_pusher_back.png",
"mesecons_piston_pusher_left.png^[transformR270",
"mesecons_piston_pusher_right.png^[transformR90",
"mesecons_piston_pusher_bottom.png",
"mesecons_piston_pusher_top.png^[transformR180",
},
paramtype = "light",
paramtype2 = "facedir",
diggable = false,
corresponding_piston = "mesecons_pistons:piston_up_sticky_on",
selection_box = piston_up_pusher_box,
node_box = piston_up_pusher_box,
})
--
--
-- DOWN
--
--
local piston_down_pusher_box = {
type = "fixed",
fixed = {
{-2/16, -.5 + pt, -2/16, 2/16, .5 + pt, 2/16},
{-.5 , -.5 , -.5 , .5 , -.5 + pt, .5},
}
}
local piston_down_on_box = {
type = "fixed",
fixed = {
{-.5, -.5+pt, -.5 , .5, .5, .5}
}
}
-- Normal
local pistonspec_normal_down = {
offname = "mesecons_pistons:piston_down_normal_off",
onname = "mesecons_pistons:piston_down_normal_on",
dir = {x = 0, y = -1, z = 0},
pusher = "mesecons_pistons:piston_down_pusher_normal",
}
-- offstate
minetest.register_node("mesecons_pistons:piston_down_normal_off", {
tiles = {
"mesecons_piston_back.png",
"mesecons_piston_pusher_front.png",
"mesecons_piston_left.png^[transformR90",
"mesecons_piston_right.png^[transformR270",
"mesecons_piston_bottom.png^[transformR180",
"mesecons_piston_top.png",
},
inventory_image = "mesecons_piston_top.png",
wield_image = "mesecons_piston_top.png",
groups = {cracky = 3, not_in_creative_inventory = 1},
paramtype2 = "facedir",
drop = "mesecons_pistons:piston_normal_off",
mesecons_piston = pistonspec_normal_down,
sounds = default.node_sound_wood_defaults(),
mesecons = {effector={
action_on = piston_on,
rules = piston_down_rules,
}}
})
-- onstate
minetest.register_node("mesecons_pistons:piston_down_normal_on", {
drawtype = "nodebox",
tiles = {
"mesecons_piston_back.png",
"mesecons_piston_on_front.png",
"mesecons_piston_left.png^[transformR90",
"mesecons_piston_right.png^[transformR270",
"mesecons_piston_bottom.png^[transformR180",
"mesecons_piston_top.png",
},
inventory_image = "mesecons_piston_top.png",
wield_image = "mesecons_piston_top.png",
groups = {cracky = 3, not_in_creative_inventory = 1},
paramtype = "light",
paramtype2 = "facedir",
drop = "mesecons_pistons:piston_normal_off",
after_dig_node = piston_remove_pusher,
node_box = piston_down_on_box,
selection_box = piston_down_on_box,
mesecons_piston = pistonspec_normal_down,
sounds = default.node_sound_wood_defaults(),
mesecons = {effector={
action_off = piston_off,
rules = piston_down_rules,
}}
})
-- pusher
minetest.register_node("mesecons_pistons:piston_down_pusher_normal", {
drawtype = "nodebox",
tiles = {
"mesecons_piston_pusher_back.png",
"mesecons_piston_pusher_front.png",
"mesecons_piston_pusher_left.png^[transformR90",
"mesecons_piston_pusher_right.png^[transformR270",
"mesecons_piston_pusher_bottom.png^[transformR180",
"mesecons_piston_pusher_top.png",
},
paramtype = "light",
paramtype2 = "facedir",
diggable = false,
corresponding_piston = "mesecons_pistons:piston_down_normal_on",
selection_box = piston_down_pusher_box,
node_box = piston_down_pusher_box,
})
-- Sticky
local pistonspec_sticky_down = {
onname = "mesecons_pistons:piston_down_sticky_on",
offname = "mesecons_pistons:piston_down_sticky_off",
dir = {x = 0, y = -1, z = 0},
pusher = "mesecons_pistons:piston_down_pusher_sticky",
sticky = true
}
-- offstate
minetest.register_node("mesecons_pistons:piston_down_sticky_off", {
tiles = {
"mesecons_piston_back.png",
"mesecons_piston_pusher_front_sticky.png",
"mesecons_piston_left.png^[transformR90",
"mesecons_piston_right.png^[transformR270",
"mesecons_piston_bottom.png^[transformR180",
"mesecons_piston_top.png",
},
inventory_image = "mesecons_piston_top.png",
wield_image = "mesecons_piston_top.png",
groups = {cracky = 3, not_in_creative_inventory = 1},
paramtype2 = "facedir",
drop = "mesecons_pistons:piston_sticky_off",
mesecons_piston = pistonspec_sticky_down,
sounds = default.node_sound_wood_defaults(),
mesecons = {effector={
action_on = piston_on,
rules = piston_down_rules,
}}
})
-- onstate
minetest.register_node("mesecons_pistons:piston_down_sticky_on", {
drawtype = "nodebox",
tiles = {
"mesecons_piston_back.png",
"mesecons_piston_on_front.png",
"mesecons_piston_left.png^[transformR90",
"mesecons_piston_right.png^[transformR270",
"mesecons_piston_bottom.png^[transformR180",
"mesecons_piston_top.png",
},
inventory_image = "mesecons_piston_top.png",
wield_image = "mesecons_piston_top.png",
groups = {cracky = 3, not_in_creative_inventory = 1},
paramtype = "light",
paramtype2 = "facedir",
drop = "mesecons_pistons:piston_sticky_off",
after_dig_node = piston_remove_pusher,
node_box = piston_down_on_box,
selection_box = piston_down_on_box,
mesecons_piston = pistonspec_sticky_down,
sounds = default.node_sound_wood_defaults(),
mesecons = {effector={
action_off = piston_off,
rules = piston_down_rules,
}}
})
-- pusher
minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", {
drawtype = "nodebox",
tiles = {
"mesecons_piston_pusher_back.png",
"mesecons_piston_pusher_front_sticky.png",
"mesecons_piston_pusher_left.png^[transformR90",
"mesecons_piston_pusher_right.png^[transformR270",
"mesecons_piston_pusher_bottom.png^[transformR180",
"mesecons_piston_pusher_top.png",
},
paramtype = "light",
paramtype2 = "facedir",
diggable = false,
corresponding_piston = "mesecons_pistons:piston_down_sticky_on",
selection_box = piston_down_pusher_box,
node_box = piston_down_pusher_box,
})
-- Register pushers as stoppers if they would be seperated from the piston
local piston_pusher_get_stopper = function (node, dir, stack, stackid)
if (stack[stackid + 1]
and stack[stackid + 1].node.name == minetest.registered_nodes[node.name].corresponding_piston
and stack[stackid + 1].node.param2 == node.param2)
or (stack[stackid - 1]
and stack[stackid - 1].node.name == minetest.registered_nodes[node.name].corresponding_piston
and stack[stackid - 1].node.param2 == node.param2) then
return false
end
return true
end
local piston_pusher_up_down_get_stopper = function (node, dir, stack, stackid)
if (stack[stackid + 1]
and stack[stackid + 1].node.name == minetest.registered_nodes[node.name].corresponding_piston)
or (stack[stackid - 1]
and stack[stackid - 1].node.name == minetest.registered_nodes[node.name].corresponding_piston) then
return false
end
return true
end
mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_normal", piston_pusher_get_stopper)
mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_sticky", piston_pusher_get_stopper)
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_normal", piston_pusher_up_down_get_stopper)
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_sticky", piston_pusher_up_down_get_stopper)
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_normal", piston_pusher_up_down_get_stopper)
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_sticky", piston_pusher_up_down_get_stopper)
-- Register pistons as stoppers if they would be seperated from the stopper
local piston_up_down_get_stopper = function (node, dir, stack, stackid)
if (stack[stackid + 1]
and stack[stackid + 1].node.name == minetest.registered_nodes[node.name].mesecons_piston.pusher)
or (stack[stackid - 1]
and stack[stackid - 1].node.name == minetest.registered_nodes[node.name].mesecons_piston.pusher) then
return false
end
return true
end
local piston_get_stopper = function (node, dir, stack, stackid)
pistonspec = minetest.registered_nodes[node.name].mesecons_piston
dir = piston_get_direction(pistonspec.dir, node)
local pusherpos = mesecon:addPosRule(stack[stackid].pos, dir)
local pushernode = minetest.get_node(pusherpos)
if minetest.registered_nodes[node.name].mesecons_piston.pusher == pushernode.name then
for _, s in ipairs(stack) do
if mesecon:cmpPos(s.pos, pusherpos) -- pusher is also to be pushed
and s.node.param2 == node.param2 then
return false
end end
end end
end, end
on_timer = function(pos, elapsed) return true
if mesecon:is_powered(pos) then end
mesecon:piston_push(pos)
else
mesecon:piston_pull(pos)
end
return false
end,
})
mesecon:register_effector("mesecons_pistons:piston_sticky", "mesecons_pistons:piston_sticky")
mesecon:register_mvps_stopper("mesecons_pistons:piston_normal_on", piston_get_stopper)
mesecon:register_mvps_stopper("mesecons_pistons:piston_sticky_on", piston_get_stopper)
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_normal_on", piston_up_down_get_stopper)
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_sticky_on", piston_up_down_get_stopper)
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_normal_on", piston_up_down_get_stopper)
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_sticky_on", piston_up_down_get_stopper)
--craft recipes
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_pistons:piston_normal" 2', output = "mesecons_pistons:piston_normal_off 2",
recipe = { recipe = {
{"default:wood", "default:wood", "default:wood"}, {"group:wood", "group:wood", "group:wood"},
{"default:cobble", "default:steel_ingot", "default:cobble"}, {"default:cobble", "default:steel_ingot", "default:cobble"},
{"default:cobble", "group:mesecon_conductor_craftable", "default:cobble"}, {"default:cobble", "group:mesecon_conductor_craftable", "default:cobble"},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "mesecons_pistons:piston_sticky", output = "mesecons_pistons:piston_sticky_off",
recipe = { recipe = {
{"mesecons_materials:glue"}, {"mesecons_materials:glue"},
{"mesecons_pistons:piston_normal"}, {"mesecons_pistons:piston_normal_off"},
} }
}) })
minetest.register_node("mesecons_pistons:piston_pusher_normal", {
drawtype = "nodebox",
tiles = {"jeija_piston_pusher_normal.png"},
paramtype = "light",
paramtype2 = "facedir",
diggable = false,
selection_box = {
type = "fixed",
fixed = {
{-0.2, -0.2, -0.3, 0.2, 0.2, 0.5},
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3},
},
},
node_box = {
type = "fixed",
fixed = {
{-0.2, -0.2, -0.3, 0.2, 0.2, 0.5},
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3},
},
},
})
minetest.register_node("mesecons_pistons:piston_pusher_sticky", {
drawtype = "nodebox",
tiles = {
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_sticky.png"
},
paramtype = "light",
paramtype2 = "facedir",
diggable = false,
selection_box = {
type = "fixed",
fixed = {
{-0.2, -0.2, -0.3, 0.2, 0.2, 0.5},
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3},
},
},
node_box = {
type = "fixed",
fixed = {
{-0.2, -0.2, -0.3, 0.2, 0.2, 0.5},
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3},
},
},
})
mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_normal")
mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_sticky")
local update = function(pos, node)
if node.name ~= "mesecons_pistons:piston_normal" and node.name ~= "mesecons_pistons:piston_sticky" then
return
end
local timer = minetest.env:get_node_timer(pos)
timer:stop()
timer:start(0)
end
mesecon:register_on_signal_on(update) --push action
mesecon:register_on_signal_off(update) --pull action
function mesecon:piston_push(pos)
local node = minetest.env:get_node(pos)
local dir = mesecon:piston_get_direction(node)
pos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to first node being pushed
--determine the number of nodes that need to be pushed
local count = 0
local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed
while true do
local checknode = minetest.env:get_node(checkpos)
--check for collision with stopper or bounds
if mesecon:is_mvps_stopper(checknode.name) or checknode.name == "ignore" then
return
end
--check for column end
if checknode.name == "air"
or not(minetest.registered_nodes[checknode.name].liquidtype == "none") then
break
end
--limit piston pushing capacity
count = count + 1
if count > 15 then
return
end
checkpos.x, checkpos.y, checkpos.z = checkpos.x + dir.x, checkpos.y + dir.y, checkpos.z + dir.z
end
local checknode = minetest.env:get_node(pos)
--add pusher
if node.name == "mesecons_pistons:piston_normal" then
minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_normal", param2=node.param2})
else
minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_sticky", param2=node.param2})
end
--move nodes forward
for i = 1, count do
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the next node
--check for conductor
if mesecon:is_conductor_on(checknode.name) then
checknode.name = mesecon:get_conductor_off(checknode.name)
end
--move the node forward
local nextnode = minetest.env:get_node(pos)
minetest.env:add_node(pos, checknode)
checknode = nextnode
end
--update nodes
for i = 1, count do
mesecon:updatenode(pos)
nodeupdate(pos)
pos.x, pos.y, pos.z = pos.x - dir.x, pos.y - dir.y, pos.z - dir.z --move to the previous node
end
end
function mesecon:piston_pull(pos)
local node = minetest.env:get_node(pos)
local dir = mesecon:piston_get_direction(node)
pos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to first node being replaced
--ensure piston is extended
local checknode = minetest.env:get_node(pos)
if checknode.name ~= "mesecons_pistons:piston_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_pusher_sticky" then
return
end
if checknode.param2 ~= node.param2 then --pusher is not facing the same direction as the piston
return --piston is not extended
end
--retract piston
minetest.env:remove_node(pos) --remove pusher
if node.name == "mesecons_pistons:piston_sticky" then --retract block
local checkpos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to the node to be retracted
checknode = minetest.env:get_node(checkpos)
if checknode.name ~= "air"
and checknode.name ~= "ignore"
and minetest.registered_nodes[checknode.name].liquidtype == "none"
and not mesecon:is_mvps_stopper(checknode.name) then
minetest.env:add_node(pos, checknode)
minetest.env:remove_node(checkpos)
mesecon:updatenode(checkpos)
nodeupdate(checkpos)
end
end
mesecon:updatenode(pos)
nodeupdate(pos)
end
-- get piston direction
function mesecon:piston_get_direction(node)
if node.param2 == 3 then
return {x=1, y=0, z=0}
elseif node.param2 == 2 then
return {x=0, y=0, z=1}
elseif node.param2 == 1 then
return {x=-1, y=0, z=0}
else --node.param2 == 0
return {x=0, y=0, z=-1}
end
end
dofile(minetest.get_modpath("mesecons_pistons").."/pistons_down.lua")
dofile(minetest.get_modpath("mesecons_pistons").."/pistons_up.lua")

View File

@ -1,214 +0,0 @@
--PISTONS
--registration normal one:
minetest.register_node("mesecons_pistons:piston_down_normal", {
description = "Piston DOWN",
tiles = {"jeija_piston_tb.png", "jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"},
groups = {cracky=3, mesecon = 2},
after_dig_node = function(pos, oldnode)
local dir = {x=0, y=-1, z=0}
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
--ensure piston is extended
local checknode = minetest.env:get_node(pos)
if checknode.name == "mesecons_pistons:piston_down_pusher_normal" then
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
minetest.env:remove_node(pos) --remove the pusher
end
end
end,
})
mesecon:register_effector("mesecons_pistons:piston_down_normal", "mesecons_pistons:piston_down_normal")
--registration sticky one:
minetest.register_node("mesecons_pistons:piston_down_sticky", {
description = "Sticky Piston DOWN",
tiles = {"jeija_piston_tb.png", "jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"},
groups = {cracky=3, mesecon = 2},
after_dig_node = function(pos, oldnode)
local dir = {x=0, y=-1, z=0}
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
--ensure piston is extended
local checknode = minetest.env:get_node(pos)
if checknode.name == "mesecons_pistons:piston_down_pusher_sticky" then
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
minetest.env:remove_node(pos) --remove the pusher
end
end
end,
})
mesecon:register_effector("mesecons_pistons:piston_down_sticky", "mesecons_pistons:piston_down_sticky")
minetest.register_craft({
output = "mesecons_pistons:piston_down_normal",
recipe = {
{"mesecons_pistons:piston_up_normal"},
}
})
minetest.register_craft({
output = "mesecons_pistons:piston_normal",
recipe = {
{"mesecons_pistons:piston_down_normal"},
}
})
minetest.register_craft({
output = "mesecons_pistons:piston_down_sticky",
recipe = {
{"mesecons_pistons:piston_up_sticky"},
}
})
minetest.register_craft({
output = "mesecons_pistons:piston_sticky",
recipe = {
{"mesecons_pistons:piston_down_sticky"},
}
})
minetest.register_node("mesecons_pistons:piston_down_pusher_normal", {
drawtype = "nodebox",
tiles = {"jeija_piston_pusher_normal.png"},
paramtype = "light",
diggable = false,
selection_box = {
type = "fixed",
fixed = {
{-0.2, -0.3, -0.2, 0.2, 0.5, 0.2},
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
},
},
node_box = {
type = "fixed",
fixed = {
{-0.2, -0.3, -0.2, 0.2, 0.5, 0.2},
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
},
},
})
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_normal")
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_sticky")
minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", {
drawtype = "nodebox",
tiles = {
"jeija_piston_pusher_sticky.png",
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_normal.png"
},
paramtype = "light",
diggable = false,
selection_box = {
type = "fixed",
fixed = {
{-0.2, -0.3, -0.2, 0.2, 0.5, 0.2},
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
},
},
node_box = {
type = "fixed",
fixed = {
{-0.2, -0.3, -0.2, 0.2, 0.5, 0.2},
{-0.5, -0.5, -0.5, 0.5, -0.3, 0.5},
},
},
})
-- Push action
mesecon:register_on_signal_on(function(pos, node)
if node.name ~= "mesecons_pistons:piston_down_normal" and node.name ~= "mesecons_pistons:piston_down_sticky" then
return
end
local dir = {x=0, y=-1, z=0}
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node being pushed
--determine the number of nodes that need to be pushed
local count = 0
local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed
while true do
local checknode = minetest.env:get_node(checkpos)
--check for collision with stopper or bounds
if mesecon:is_mvps_stopper(checknode.name) or checknode.name == "ignore" then
return
end
--check for column end
if checknode.name == "air"
or not(minetest.registered_nodes[checknode.name].liquidtype == "none") then
break
end
--limit piston pushing capacity
count = count + 1
if count > 15 then
return
end
checkpos.x, checkpos.y, checkpos.z = checkpos.x + dir.x, checkpos.y + dir.y, checkpos.z + dir.z
end
local checknode = minetest.env:get_node(pos)
minetest.env:remove_node(pos) --remove the first node
mesecon:updatenode(pos)
--add pusher
if node.name == "mesecons_pistons:piston_down_normal" then
minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_pusher_normal", param2=node.param2})
else
minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_pusher_sticky", param2=node.param2})
end
--move nodes forward
for i = 1, count do
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the next node
--move the node forward
local nextnode = minetest.env:get_node(pos)
--minetest.env:dig_node(pos)
minetest.env:set_node(pos, checknode)
mesecon:updatenode(pos)
checknode = nextnode
end
end)
--Pull action
mesecon:register_on_signal_off(function(pos, node)
if node.name ~= "mesecons_pistons:piston_down_normal" and node.name ~= "mesecons_pistons:piston_down_sticky" then
return
end
local dir = {x=0, y=-1, z=0}
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the node to be replaced
--ensure piston is extended
local checknode = minetest.env:get_node(pos)
if checknode.name ~= "mesecons_pistons:piston_down_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_down_pusher_sticky" then
return
end
if checknode.param2 ~= node.param2 then --pusher is not facing the same direction as the piston
return --piston is not extended
end
--retract piston
minetest.env:remove_node(pos) --remove pusher
if node.name == "mesecons_pistons:piston_down_sticky" then --retract block
local checkpos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to the node to be retracted
checknode = minetest.env:get_node(checkpos)
if checknode.name ~= "air"
and checknode.name ~= "ignore"
and minetest.registered_nodes[checknode.name].liquidtype == "none"
and not mesecon:is_mvps_stopper(checknode.name) then
minetest.env:remove_node(checkpos)
mesecon:updatenode(checkpos)
minetest.env:set_node(pos, checknode)
mesecon:updatenode(pos)
end
end
nodeupdate(pos)
end)

View File

@ -1,202 +0,0 @@
--PISTONS
--registration normal one:
minetest.register_node("mesecons_pistons:piston_up_normal", {
description = "Piston UP",
tiles = {"jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"},
groups = {cracky=3, mesecon = 2},
after_dig_node = function(pos, oldnode)
local dir = {x=0, y=1, z=0}
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
--ensure piston is extended
local checknode = minetest.env:get_node(pos)
if checknode.name == "mesecons_pistons:piston_up_pusher_normal" then
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
minetest.env:remove_node(pos) --remove the pusher
end
end
end,
})
mesecon:register_effector("mesecons_pistons:piston_up_normal", "mesecons_pistons:piston_up_normal")
--registration sticky one:
minetest.register_node("mesecons_pistons:piston_up_sticky", {
description = "Sticky Piston UP",
tiles = {"jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"},
groups = {cracky=3, mesecon = 2},
after_dig_node = function(pos, oldnode)
local dir = {x=0, y=1, z=0}
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
--ensure piston is extended
local checknode = minetest.env:get_node(pos)
if checknode.name == "mesecons_pistons:piston_up_pusher_sticky" then
if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston
minetest.env:remove_node(pos) --remove the pusher
end
end
end,
})
mesecon:register_effector("mesecons_pistons:piston_up_sticky", "mesecons_pistons:piston_up_sticky")
minetest.register_craft({
output = "mesecons_pistons:piston_up_normal",
recipe = {
{"mesecons_pistons:piston_normal"},
}
})
minetest.register_craft({
output = "mesecons_pistons:piston_up_sticky",
recipe = {
{"mesecons_pistons:piston_sticky"},
}
})
minetest.register_node("mesecons_pistons:piston_up_pusher_normal", {
drawtype = "nodebox",
tiles = {"jeija_piston_pusher_normal.png"},
paramtype = "light",
diggable = false,
selection_box = {
type = "fixed",
fixed = {
{-0.2, -0.5, -0.2, 0.2, 0.3, 0.2},
{-0.5, 0.3, -0.5, 0.5, 0.5, 0.5},
},
},
node_box = {
type = "fixed",
fixed = {
{-0.2, -0.5, -0.2, 0.2, 0.3, 0.2},
{-0.5, 0.3, -0.5, 0.5, 0.5, 0.5},
},
},
})
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_normal")
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_sticky")
minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", {
drawtype = "nodebox",
tiles = {
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_sticky.png",
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_normal.png",
"jeija_piston_pusher_normal.png"
},
paramtype = "light",
diggable = false,
selection_box = {
type = "fixed",
fixed = {
{-0.2, -0.5, -0.2, 0.2, 0.3, 0.2},
{-0.5, 0.3, -0.5, 0.5, 0.5, 0.5},
},
},
node_box = {
type = "fixed",
fixed = {
{-0.2, -0.5, -0.2, 0.2, 0.3, 0.2},
{-0.5, 0.3, -0.5, 0.5, 0.5, 0.5},
},
},
})
-- Push action
mesecon:register_on_signal_on(function(pos, node)
if node.name ~= "mesecons_pistons:piston_up_normal" and node.name ~= "mesecons_pistons:piston_up_sticky" then
return
end
local dir = {x=0, y=1, z=0}
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node being pushed
--determine the number of nodes that need to be pushed
local count = 0
local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed
while true do
local checknode = minetest.env:get_node(checkpos)
--check for collision with stopper or bounds
if mesecon:is_mvps_stopper(checknode.name) or checknode.name == "ignore" then
return
end
--check for column end
if checknode.name == "air"
or not(minetest.registered_nodes[checknode.name].liquidtype == "none") then
break
end
--limit piston pushing capacity
count = count + 1
if count > 15 then
return
end
checkpos.x, checkpos.y, checkpos.z = checkpos.x + dir.x, checkpos.y + dir.y, checkpos.z + dir.z
end
local checknode = minetest.env:get_node(pos)
minetest.env:remove_node(pos) --remove the first node
mesecon:updatenode(pos)
--add pusher
if node.name == "mesecons_pistons:piston_up_normal" then
minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_pusher_normal", param2=node.param2})
else
minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_pusher_sticky", param2=node.param2})
end
--move nodes forward
for i = 1, count do
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the next node
--move the node forward
local nextnode = minetest.env:get_node(pos)
--minetest.env:dig_node(pos)
minetest.env:set_node(pos, checknode)
mesecon:updatenode(pos)
checknode = nextnode
end
end)
--Pull action
mesecon:register_on_signal_off(function(pos, node)
if node.name ~= "mesecons_pistons:piston_up_normal" and node.name ~= "mesecons_pistons:piston_up_sticky" then
return
end
local dir = {x=0, y=1, z=0}
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the node to be replaced
--ensure piston is extended
local checknode = minetest.env:get_node(pos)
if checknode.name ~= "mesecons_pistons:piston_up_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_up_pusher_sticky" then
return
end
if checknode.param2 ~= node.param2 then --pusher is not facing the same direction as the piston
return --piston is not extended
end
--retract piston
minetest.env:remove_node(pos) --remove pusher
if node.name == "mesecons_pistons:piston_up_sticky" then --retract block
local checkpos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to the node to be retracted
checknode = minetest.env:get_node(checkpos)
if checknode.name ~= "air"
and checknode.name ~= "ignore"
and minetest.registered_nodes[checknode.name].liquidtype == "none"
and not mesecon:is_mvps_stopper(checknode.name) then
minetest.env:remove_node(checkpos)
mesecon:updatenode(checkpos)
minetest.env:set_node(pos, checknode)
mesecon:updatenode(pos)
end
end
nodeupdate(pos)
end)

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,5 @@
-- The POWER_PLANT -- The POWER_PLANT
-- Just emits power. always.
minetest.register_node("mesecons_powerplant:power_plant", { minetest.register_node("mesecons_powerplant:power_plant", {
drawtype = "plantlike", drawtype = "plantlike",
@ -12,17 +13,19 @@ minetest.register_node("mesecons_powerplant:power_plant", {
description="Power Plant", description="Power Plant",
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
}, },
sounds = default.node_sound_leaves_defaults(),
mesecons = {receptor = {
state = mesecon.state.on
}}
}) })
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_powerplant:power_plant" 1', output = "mesecons_powerplant:power_plant 1",
recipe = { recipe = {
{'"group:mesecon_conductor_craftable"'}, {"group:mesecon_conductor_craftable"},
{'"group:mesecon_conductor_craftable"'}, {"group:mesecon_conductor_craftable"},
{'"default:sapling"'}, {"default:sapling"},
} }
}) })
mesecon:add_receptor_node("mesecons_powerplant:power_plant")

View File

@ -1,174 +1,127 @@
-- PRESSURE PLATE WOOD local pp_box_off = {
type = "fixed",
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
}
minetest.register_node("mesecons_pressureplates:pressure_plate_wood_off", { local pp_box_on = {
drawtype = "nodebox", type = "fixed",
tiles = {"jeija_pressure_plate_wood_off.png"}, fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 },
inventory_image = "jeija_pressure_plate_wood_off.png", }
wield_image = "jeija_pressure_plate_wood_off.png",
paramtype = "light",
is_ground_content = true,
walkable = true,
selection_box = {
type = "fixed",
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
},
node_box = {
type = "fixed",
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3, mesecon = 2},
description="Wood Pressure Plate",
on_timer = function(pos, elapsed) pp_on_timer = function (pos, elapsed)
local objs = minetest.env:get_objects_inside_radius(pos, 1) local node = minetest.get_node(pos)
local ppspec = minetest.registered_nodes[node.name].pressureplate
-- This is a workaround for a strange bug that occurs when the server is started
-- For some reason the first time on_timer is called, the pos is wrong
if not ppspec then return end
local objs = minetest.get_objects_inside_radius(pos, 1)
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})
if objs[1] == nil and node.name == ppspec.onstate then
minetest.add_node(pos, {name = ppspec.offstate})
mesecon:receptor_off(pos)
-- force deactivation of mesecon two blocks below (hacky)
if not mesecon:connected_to_receptor(two_below) then
mesecon:turnoff(two_below)
end
else
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
local objpos=obj:getpos() local objpos = obj:getpos()
if objpos.y>pos.y-1 and objpos.y<pos.y then if objpos.y > pos.y-1 and objpos.y < pos.y then
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_wood_on"}) minetest.add_node(pos, {name=ppspec.onstate})
mesecon:receptor_on(pos, mesecon:get_rules("pressureplate")) mesecon:receptor_on(pos)
-- force activation of mesecon two blocks below (hacky)
mesecon:turnon(two_below)
end end
end end
return true end
end, return true
end
on_construct = function(pos) -- Register a Pressure Plate
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) -- offstate: name of the pressure plate when inactive
end, -- onstate: name of the pressure plate when active
}) -- description: description displayed in the player's inventory
-- tiles_off: textures of the pressure plate when inactive
-- tiles_on: textures of the pressure plate when active
-- image: inventory and wield image of the pressure plate
-- recipe: crafting recipe of the pressure plate
minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", { function mesecon:register_pressure_plate(offstate, onstate, description, textures_off, textures_on, image_w, image_i, recipe)
drawtype = "nodebox", local ppspec = {
tiles = {"jeija_pressure_plate_wood_on.png"}, offstate = offstate,
paramtype = "light", onstate = onstate
is_ground_content = true,
walkable = true,
selection_box = {
type = "fixed",
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
},
node_box = {
type = "fixed",
fixed = { -7/16, -8/16, -7/16, 7/16, -31/64, 7/16 },
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2},
drop='"mesecons_pressureplates:pressure_plate_wood_off" 1',
on_timer = function(pos, elapsed)
local objs = minetest.env:get_objects_inside_radius(pos, 1)
if objs[1]==nil then
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_wood_off"})
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
end
return true
end,
on_construct = function(pos)
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
end,
})
minetest.register_craft({
output = '"mesecons_pressureplates:pressure_plate_wood_off" 1',
recipe = {
{'"default:wood"', '"default:wood"'},
} }
})
-- PRESSURE PLATE STONE minetest.register_node(offstate, {
drawtype = "nodebox",
tiles = textures_off,
inventory_image = image_i,
wield_image = image_w,
paramtype = "light",
selection_box = pp_box_off,
node_box = pp_box_off,
groups = {snappy = 2, oddly_breakable_by_hand = 3},
description = description,
pressureplate = ppspec,
on_timer = pp_on_timer,
mesecons = {receptor = {
state = mesecon.state.off
}},
on_construct = function(pos)
minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
end,
})
minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", { minetest.register_node(onstate, {
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"jeija_pressure_plate_stone_off.png"}, tiles = textures_on,
inventory_image = "jeija_pressure_plate_stone_off.png", paramtype = "light",
wield_image = "jeija_pressure_plate_stone_off.png", selection_box = pp_box_on,
paramtype = "light", node_box = pp_box_on,
is_ground_content = true, groups = {snappy = 2, oddly_breakable_by_hand = 3, not_in_creative_inventory = 1},
walkable = true, drop = offstate,
selection_box = { pressureplate = ppspec,
type = "fixed", on_timer = pp_on_timer,
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 }, sounds = default.node_sound_wood_defaults(),
}, mesecons = {receptor = {
node_box = { state = mesecon.state.on
type = "fixed", }},
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 }, on_construct = function(pos)
}, minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3, mesecon = 2}, end,
description="Stone Pressure Plate", after_dig_node = function(pos)
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})
on_timer = function(pos, elapsed) if not mesecon:connected_to_receptor(two_below) then
local objs = minetest.env:get_objects_inside_radius(pos, 1) mesecon:turnoff(two_below)
for k, obj in pairs(objs) do
local objpos=obj:getpos()
if objpos.y>pos.y-1 and objpos.y<pos.y then
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_stone_on"})
mesecon:receptor_on(pos, mesecon:get_rules("pressureplate"))
end end
end end
return true })
end,
on_construct = function(pos) minetest.register_craft({
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) output = offstate,
end, recipe = recipe,
}) })
end
minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", { mesecon:register_pressure_plate(
drawtype = "nodebox", "mesecons_pressureplates:pressure_plate_wood_off",
tiles = {"jeija_pressure_plate_stone_on.png"}, "mesecons_pressureplates:pressure_plate_wood_on",
paramtype = "light", "Wooden Pressure Plate",
is_ground_content = true, {"jeija_pressure_plate_wood_off.png","jeija_pressure_plate_wood_off.png","jeija_pressure_plate_wood_off_edges.png"},
walkable = true, {"jeija_pressure_plate_wood_on.png","jeija_pressure_plate_wood_on.png","jeija_pressure_plate_wood_on_edges.png"},
selection_box = { "jeija_pressure_plate_wood_wield.png",
type = "fixed", "jeija_pressure_plate_wood_inv.png",
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 }, {{"group:wood", "group:wood"}})
},
node_box = {
type = "fixed",
fixed = { -7/16, -8/16, -7/16, 7/16, -31/64, 7/16 },
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2},
drop='"mesecons_pressureplates:pressure_plate_stone_off" 1',
on_timer = function(pos, elapsed) mesecon:register_pressure_plate(
local objs = minetest.env:get_objects_inside_radius(pos, 1) "mesecons_pressureplates:pressure_plate_stone_off",
if objs[1]==nil then "mesecons_pressureplates:pressure_plate_stone_on",
minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_stone_off"}) "Stone Pressure Plate",
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate")) {"jeija_pressure_plate_stone_off.png","jeija_pressure_plate_stone_off.png","jeija_pressure_plate_stone_off_edges.png"},
end {"jeija_pressure_plate_stone_on.png","jeija_pressure_plate_stone_on.png","jeija_pressure_plate_stone_on_edges.png"},
return true "jeija_pressure_plate_stone_wield.png",
end, "jeija_pressure_plate_stone_inv.png",
{{"default:cobble", "default:cobble"}})
on_construct = function(pos)
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
end,
})
minetest.register_craft({
output = '"mesecons_pressureplates:pressure_plate_stone_off" 1',
recipe = {
{'"default:cobble"', '"default:cobble"'},
}
})
mesecon:add_rules("pressureplate",
{{x=0, y=1, z=-1},
{x=0, y=0, z=-1},
{x=0, y=-1, z=-1},
{x=0, y=1, z=1},
{x=0, y=-1, z=1},
{x=0, y=0, z=1},
{x=1, y=0, z=0},
{x=1, y=1, z=0},
{x=1, y=-1, z=0},
{x=-1, y=1, z=0},
{x=-1, y=-1, z=0},
{x=-1, y=0, z=0},
{x=0, y=-1, z=0},
{x=0, y=-2, z=0},
{x=0, y=1, z=0}})
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_wood_on", mesecon:get_rules("pressureplate"))
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_wood_off", mesecon:get_rules("pressureplate"))
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_stone_on", mesecon:get_rules("pressureplate"))
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_stone_off", mesecon:get_rules("pressureplate"))

View File

@ -3,12 +3,17 @@
minetest.register_node("mesecons_random:removestone", { minetest.register_node("mesecons_random:removestone", {
tiles = {"jeija_removestone.png"}, tiles = {"jeija_removestone.png"},
inventory_image = minetest.inventorycube("jeija_removestone_inv.png"), inventory_image = minetest.inventorycube("jeija_removestone_inv.png"),
groups = {cracky=3, mesecon=2}, groups = {cracky=3},
description="Removestone", description="Removestone",
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
action_on = function (pos, node)
minetest.remove_node(pos)
mesecon:update_autoconnect(pos)
end
}}
}) })
mesecon:register_effector(nil, "mesecons_random:removestone")
minetest.register_craft({ minetest.register_craft({
output = 'mesecons_random:removestone 4', output = 'mesecons_random:removestone 4',
recipe = { recipe = {
@ -18,12 +23,6 @@ minetest.register_craft({
} }
}) })
mesecon:register_on_signal_on(function(pos, node)
if node.name == "mesecons_random:removestone" then
minetest.env:remove_node(pos)
end
end)
-- GHOSTSTONE -- GHOSTSTONE
minetest.register_node("mesecons_random:ghoststone", { minetest.register_node("mesecons_random:ghoststone", {
@ -31,8 +30,20 @@ minetest.register_node("mesecons_random:ghoststone", {
tiles = {"jeija_ghoststone.png"}, tiles = {"jeija_ghoststone.png"},
is_ground_content = true, is_ground_content = true,
inventory_image = minetest.inventorycube("jeija_ghoststone_inv.png"), inventory_image = minetest.inventorycube("jeija_ghoststone_inv.png"),
groups = {cracky=3, mesecon=2}, groups = {cracky=3},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
mesecons = {conductor = {
state = mesecon.state.off,
rules = { --axes
{x = -1, y = 0, z = 0},
{x = 1, y = 0, z = 0},
{x = 0, y = -1, z = 0},
{x = 0, y = 1, z = 0},
{x = 0, y = 0, z = -1},
{x = 0, y = 0, z = 1},
},
onstate = "mesecons_random:ghoststone_active"
}}
}) })
minetest.register_node("mesecons_random:ghoststone_active", { minetest.register_node("mesecons_random:ghoststone_active", {
@ -41,10 +52,28 @@ minetest.register_node("mesecons_random:ghoststone_active", {
walkable = false, walkable = false,
diggable = false, diggable = false,
sunlight_propagates = true, sunlight_propagates = true,
groups = {mesecon=2}, paramtype = "light",
mesecons = {conductor = {
state = mesecon.state.on,
rules = {
{x = -1, y = 0, z = 0},
{x = 1, y = 0, z = 0},
{x = 0, y = -1, z = 0},
{x = 0, y = 1, z = 0},
{x = 0, y = 0, z = -1},
{x = 0, y = 0, z = 1},
},
offstate = "mesecons_random:ghoststone"
}},
on_construct = function(pos)
--remove shadow
pos2 = {x = pos.x, y = pos.y + 1, z = pos.z}
if ( minetest.get_node(pos2).name == "air" ) then
minetest.dig_node(pos2)
end
end
}) })
mesecon:register_effector("mesecons_random:ghoststone_active", "mesecons_random:ghoststone")
minetest.register_craft({ minetest.register_craft({
output = 'mesecons_random:ghoststone 4', output = 'mesecons_random:ghoststone 4',
@ -54,17 +83,3 @@ minetest.register_craft({
{"default:steel_ingot", "default:cobble", "default:steel_ingot"}, {"default:steel_ingot", "default:cobble", "default:steel_ingot"},
} }
}) })
mesecon:register_on_signal_on(function(pos, node)
if node.name == "mesecons_random:ghoststone" then
minetest.env:add_node(pos, {name="mesecons_random:ghoststone_active"})
nodeupdate(pos)
end
end)
mesecon:register_on_signal_off(function(pos, node)
if node.name == "mesecons_random:ghoststone_active" then
minetest.env:add_node(pos, {name="mesecons_random:ghoststone"})
nodeupdate(pos)
end
end)

View File

@ -1,10 +1,23 @@
rcvboxes = { rcvboxes = {
{ -3/16, -3/16 , -8/16 , 3/16, 3/16, -13/32 }, -- the smaller bump { -3/16, -3/16 , -8/16 , 3/16, 3/16, -13/32 }, -- the smaller bump
{ -5/32, -5/32 , -13/32 , 5/32, 5/32, -12/32 }, -- the receiver itself { -1/32, -1/32 , -3/2 , 1/32, 1/32, -1/2 }, -- the wire through the block
{ -3/32, -.5-1/32, -.5 , 3/32, 0 , -.5002+3/32 }, -- the vertical wire bit { -2/32, -.5-1/32, -.5 , 2/32, 0 , -.5002+3/32 }, -- the vertical wire bit
{ -3/32, -17/32 , -7/16+0.002 , 3/32, -13/32, 16/32+0.001 } -- the horizontal wire { -2/32, -17/32 , -7/16+0.002 , 2/32, -14/32, 16/32+0.001 } -- the horizontal wire
} }
local receiver_get_rules = function (node)
local rules = { {x = 1, y = 0, z = 0},
{x = -2, y = 0, z = 0}}
if node.param2 == 2 then
rules = mesecon:rotate_rules_left(rules)
elseif node.param2 == 3 then
rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
elseif node.param2 == 0 then
rules = mesecon:rotate_rules_right(rules)
end
return rules
end
minetest.register_node("mesecons_receiver:receiver_on", { minetest.register_node("mesecons_receiver:receiver_on", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
@ -18,6 +31,7 @@ minetest.register_node("mesecons_receiver:receiver_on", {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = true, sunlight_propagates = true,
walkable = false,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 } fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
@ -26,9 +40,13 @@ minetest.register_node("mesecons_receiver:receiver_on", {
type = "fixed", type = "fixed",
fixed = rcvboxes fixed = rcvboxes
}, },
groups = {dig_immediate = 3, mesecon = 3, not_in_creative_inventory = 1}, groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "mesecons:wire_00000000_off", drop = "mesecons:wire_00000000_off",
mesecons = {conductor = {
state = mesecon.state.on,
rules = receiver_get_rules,
offstate = "mesecons_receiver:receiver_off"
}}
}) })
minetest.register_node("mesecons_receiver:receiver_off", { minetest.register_node("mesecons_receiver:receiver_off", {
@ -45,6 +63,7 @@ minetest.register_node("mesecons_receiver:receiver_off", {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = true, sunlight_propagates = true,
walkable = false,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 } fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
@ -53,8 +72,13 @@ minetest.register_node("mesecons_receiver:receiver_off", {
type = "fixed", type = "fixed",
fixed = rcvboxes fixed = rcvboxes
}, },
groups = {dig_immediate = 3, mesecon = 3, not_in_creative_inventory = 1}, groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "mesecons:wire_00000000_off", drop = "mesecons:wire_00000000_off",
mesecons = {conductor = {
state = mesecon.state.off,
rules = receiver_get_rules,
onstate = "mesecons_receiver:receiver_on"
}}
}) })
mesecon:add_rules("receiver_pos", {{x = 2, y = 0, z = 0}}) mesecon:add_rules("receiver_pos", {{x = 2, y = 0, z = 0}})
@ -65,37 +89,9 @@ mesecon:add_rules("receiver_pos_all", {
{x = 0, y = 0, z = 2}, {x = 0, y = 0, z = 2},
{x = 0, y = 0, z =-2}}) {x = 0, y = 0, z =-2}})
mesecon:add_rules("mesecon_receiver", {
{x = 1, y = 0, z = 0},
{x = -2, y = 0, z = 0},})
mesecon:add_rules("mesecon_receiver_all", {
{x = 1, y = 0, z = 0},
{x =-2, y = 0, z = 0},
{x =-1, y = 0, z = 0},
{x = 2, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z =-2},
{x = 1, y = 0, z =-1},
{x =-2, y = 0, z = 2},})
function receiver_get_rules(param2)
local rules = mesecon:get_rules("mesecon_receiver")
if param2 == 2 then
rules = mesecon:rotate_rules_left(rules)
elseif param2 == 3 then
rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
elseif param2 == 0 then
rules = mesecon:rotate_rules_right(rules)
end
return rules
end
mesecon:register_conductor("mesecons_receiver:receiver_on", "mesecons_receiver:receiver_off", mesecon:get_rules("mesecon_receiver_all"), receiver_get_rules)
function mesecon:receiver_get_pos_from_rcpt(pos, param2) function mesecon:receiver_get_pos_from_rcpt(pos, param2)
local rules = mesecon:get_rules("receiver_pos") local rules = mesecon:get_rules("receiver_pos")
if param2 == nil then param2 = minetest.env:get_node(pos).param2 end if param2 == nil then param2 = minetest.get_node(pos).param2 end
if param2 == 2 then if param2 == 2 then
rules = mesecon:rotate_rules_left(rules) rules = mesecon:rotate_rules_left(rules)
elseif param2 == 3 then elseif param2 == 3 then
@ -111,17 +107,17 @@ function mesecon:receiver_get_pos_from_rcpt(pos, param2)
end end
function mesecon:receiver_place(rcpt_pos) function mesecon:receiver_place(rcpt_pos)
local node = minetest.env:get_node(rcpt_pos) local node = minetest.get_node(rcpt_pos)
local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, node.param2) local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, node.param2)
local nn = minetest.env:get_node(pos) local nn = minetest.get_node(pos)
if string.find(nn.name, "mesecons:wire_") ~= nil then if string.find(nn.name, "mesecons:wire_") ~= nil then
minetest.env:dig_node(pos) minetest.dig_node(pos)
if mesecon:is_power_on(rcpt_pos) then if mesecon:is_power_on(rcpt_pos) then
minetest.env:add_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2}) minetest.add_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2})
mesecon:receptor_on(pos, receiver_get_rules(node.param2)) mesecon:receptor_on(pos, receiver_get_rules(node))
else else
minetest.env:add_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2}) minetest.add_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2})
end end
mesecon:update_autoconnect(pos) mesecon:update_autoconnect(pos)
end end
@ -129,11 +125,13 @@ end
function mesecon:receiver_remove(rcpt_pos, dugnode) function mesecon:receiver_remove(rcpt_pos, dugnode)
local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, dugnode.param2) local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, dugnode.param2)
local nn = minetest.env:get_node(pos) local nn = minetest.get_node(pos)
if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then
minetest.env:dig_node(pos) minetest.dig_node(pos)
minetest.env:place_node(pos, {name = "mesecons:wire_00000000_off"}) local node = {name = "mesecons:wire_00000000_off"}
minetest.add_node(pos, node)
mesecon:update_autoconnect(pos) mesecon:update_autoconnect(pos)
mesecon.on_placenode(pos, node)
end end
end end
@ -158,7 +156,7 @@ minetest.register_on_placenode(function (pos, node)
x = pos.x + rules[i].x, x = pos.x + rules[i].x,
y = pos.y + rules[i].y, y = pos.y + rules[i].y,
z = pos.z + rules[i].z} z = pos.z + rules[i].z}
if minetest.get_item_group(minetest.env:get_node(np).name, "mesecon_needs_receiver") == 1 then if minetest.get_item_group(minetest.get_node(np).name, "mesecon_needs_receiver") == 1 then
mesecon:receiver_place(np) mesecon:receiver_place(np)
end end
i = i + 1 i = i + 1

View File

@ -21,8 +21,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_on", {
wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 }, wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
}, },
drop = "mesecons_solarpanel:solar_panel_off", drop = "mesecons_solarpanel:solar_panel_off",
groups = {dig_immediate=3, mesecon = 2, not_in_creative_inventory = 1}, groups = {dig_immediate=3, not_in_creative_inventory = 1},
description="Solar Panel", sounds = default.node_sound_glass_defaults(),
mesecons = {receptor = {
state = mesecon.state.on
}}
}) })
-- Solar Panel -- Solar Panel
@ -47,15 +50,19 @@ minetest.register_node("mesecons_solarpanel:solar_panel_off", {
wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 }, wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 }, wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
}, },
groups = {dig_immediate=3, mesecon = 2}, groups = {dig_immediate=3},
description="Solar Panel", description="Solar Panel",
sounds = default.node_sound_glass_defaults(),
mesecons = {receptor = {
state = mesecon.state.off
}}
}) })
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_solarpanel:solar_panel_off" 1', output = "mesecons_solarpanel:solar_panel_off 1",
recipe = { recipe = {
{'"mesecons_materials:silicon"', '"mesecons_materials:silicon"'}, {"mesecons_materials:silicon", "mesecons_materials:silicon"},
{'"mesecons_materials:silicon"', '"mesecons_materials:silicon"'}, {"mesecons_materials:silicon", "mesecons_materials:silicon"},
} }
}) })
@ -64,10 +71,10 @@ minetest.register_abm(
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.env:get_node_light(pos, nil) local light = minetest.get_node_light(pos, nil)
if light >= 12 then if light >= 12 then
minetest.env:set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2}) minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2})
mesecon:receptor_on(pos) mesecon:receptor_on(pos)
end end
end, end,
@ -78,14 +85,11 @@ minetest.register_abm(
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.env:get_node_light(pos, nil) local light = minetest.get_node_light(pos, nil)
if light < 12 then if light < 12 then
minetest.env:set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2}) minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
mesecon:receptor_off(pos) mesecon:receptor_off(pos)
end end
end, end,
}) })
mesecon:add_receptor_node("mesecons_solarpanel:solar_panel_on")
mesecon:add_receptor_node_off("mesecons_solarpanel:solar_panel_off")

View File

@ -3,37 +3,39 @@
minetest.register_node("mesecons_switch:mesecon_switch_off", { minetest.register_node("mesecons_switch:mesecon_switch_off", {
tiles = {"jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_off.png"}, tiles = {"jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_off.png"},
paramtype2="facedir", paramtype2="facedir",
groups = {dig_immediate=2, mesecon = 2}, groups = {dig_immediate=2},
description="Switch", description="Switch",
sounds = default.node_sound_stone_defaults(),
mesecons = {receptor = {
state = mesecon.state.off
}},
on_punch = function(pos, node)
minetest.swap_node(pos, {name = "mesecons_switch:mesecon_switch_on", param2 = node.param2})
mesecon:receptor_on(pos)
minetest.sound_play("mesecons_switch", {pos=pos})
end
}) })
minetest.register_node("mesecons_switch:mesecon_switch_on", { minetest.register_node("mesecons_switch:mesecon_switch_on", {
tiles = {"jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_on.png"}, tiles = {"jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_on.png"},
paramtype2="facedir", paramtype2="facedir",
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 2}, groups = {dig_immediate=2,not_in_creative_inventory=1},
drop='"mesecons_switch:mesecon_switch_off" 1', drop="mesecons_switch:mesecon_switch_off 1",
description="Switch", sounds = default.node_sound_stone_defaults(),
}) mesecons = {receptor = {
state = mesecon.state.on
mesecon:register_receptor("mesecons_switch:mesecon_switch_on", "mesecons_switch:mesecon_switch_off") }},
on_punch = function(pos, node)
minetest.register_on_punchnode(function(pos, node, puncher) minetest.swap_node(pos, {name = "mesecons_switch:mesecon_switch_off", param2 = node.param2})
if node.name == "mesecons_switch:mesecon_switch_on" then
minetest.env:add_node(pos, {name="mesecons_switch:mesecon_switch_off", param2=node.param2})
nodeupdate(pos)
mesecon:receptor_off(pos) mesecon:receptor_off(pos)
minetest.sound_play("mesecons_switch", {pos=pos})
end end
if node.name == "mesecons_switch:mesecon_switch_off" then })
minetest.env:add_node(pos, {name="mesecons_switch:mesecon_switch_on", param2=node.param2})
nodeupdate(pos)
mesecon:receptor_on(pos)
end
end)
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_switch:mesecon_switch_off" 2', output = "mesecons_switch:mesecon_switch_off 2",
recipe = { recipe = {
{'"default:steel_ingot"', '"default:cobble"', '"default:steel_ingot"'}, {"default:steel_ingot", "default:cobble", "default:steel_ingot"},
{'"group:mesecon_conductor_craftable"','', '"group:mesecon_conductor_craftable"'}, {"group:mesecon_conductor_craftable","", "group:mesecon_conductor_craftable"},
} }
}) })

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 B

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 B

After

Width:  |  Height:  |  Size: 126 B

View File

Before

Width:  |  Height:  |  Size: 200 B

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 648 B

After

Width:  |  Height:  |  Size: 555 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 680 B

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Some files were not shown because too many files have changed in this diff Show More