diff options
author | rubenwardy <rubenwardy@gmail.com> | 2017-09-20 17:05:04 +0100 |
---|---|---|
committer | orwell96 <mono96.mml@gmail.com> | 2017-09-20 18:05:04 +0200 |
commit | d65c4916ceaeed6eec5fe3f344d4e71b3c96a80b (patch) | |
tree | ae2a4a1ca5bdbcb0a2a867287d4556f92478405a /advtrains_luaautomation/p_mesecon_iface.lua | |
parent | b75c83ea43bb9f6e3bee2b4db955e2a9e7be885e (diff) | |
download | advtrains-d65c4916ceaeed6eec5fe3f344d4e71b3c96a80b.tar.gz advtrains-d65c4916ceaeed6eec5fe3f344d4e71b3c96a80b.tar.bz2 advtrains-d65c4916ceaeed6eec5fe3f344d4e71b3c96a80b.zip |
Remove zip release files, move mod to root, exclude assets from Makefile (#92)
Diffstat (limited to 'advtrains_luaautomation/p_mesecon_iface.lua')
-rw-r--r-- | advtrains_luaautomation/p_mesecon_iface.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/advtrains_luaautomation/p_mesecon_iface.lua b/advtrains_luaautomation/p_mesecon_iface.lua new file mode 100644 index 0000000..95e5d8a --- /dev/null +++ b/advtrains_luaautomation/p_mesecon_iface.lua @@ -0,0 +1,53 @@ +-- p_mesecon_iface.lua +-- Mesecons interface by overriding the switch + +if not mesecon then return end + +minetest.override_item("mesecons_switch:mesecon_switch_off", { + groups = { + dig_immediate=2, + save_in_nodedb=1, + }, + on_rightclick = function (pos, node) + advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_on", param2=node.param2}) + mesecon.receptor_on(pos) + minetest.sound_play("mesecons_switch", {pos=pos}) + end, + on_updated_from_nodedb = function(pos, node) + mesecon.receptor_off(pos) + end, + luaautomation = { + getstate = "off", + setstate = function(pos, node, newstate) + if newstate=="on" then + advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_on", param2=node.param2}) + mesecon.receptor_on(pos) + end + end, + }, +}) + +minetest.override_item("mesecons_switch:mesecon_switch_on", { + groups = { + dig_immediate=2, + save_in_nodedb=1, + not_in_creative_inventory=1, + }, + on_rightclick = function (pos, node) + advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_off", param2=node.param2}) + mesecon.receptor_off(pos) + minetest.sound_play("mesecons_switch", {pos=pos}) + end, + on_updated_from_nodedb = function(pos, node) + mesecon.receptor_on(pos) + end, + luaautomation = { + getstate = "on", + setstate = function(pos, node, newstate) + if newstate=="off" then + advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_off", param2=node.param2}) + mesecon.receptor_off(pos) + end + end, + }, +}) |