Compare commits

...

15 Commits

Author SHA1 Message Date
loosewheel
51ab3bdc3c Add files via upload 2022-02-05 02:14:40 +10:00
loosewheel
f873bb551f Add files via upload 2022-02-05 02:08:42 +10:00
loosewheel
326275cea6 Add files via upload 2022-02-05 02:07:16 +10:00
loosewheel
f869a4c40b Add files via upload 2022-02-05 02:05:18 +10:00
loosewheel
37488db8b9 Add files via upload 2022-02-05 02:04:35 +10:00
loosewheel
cf54a3d548 Add files via upload 2022-02-05 02:03:48 +10:00
loosewheel
9519eae026 Add files via upload 2022-01-20 17:58:09 +10:00
loosewheel
5caa7b6408 Add files via upload 2022-01-08 20:03:32 +10:00
loosewheel
6d4369ee91 Add files via upload 2022-01-07 18:55:19 +10:00
loosewheel
c7ec545ef7 Add files via upload 2022-01-07 18:53:39 +10:00
loosewheel
923faa59a3 Add files via upload 2022-01-07 18:50:47 +10:00
loosewheel
201c01131f Add files via upload 2022-01-07 18:49:57 +10:00
loosewheel
a0c9dd1d0c Add files via upload 2022-01-07 18:49:14 +10:00
loosewheel
c43dab66d7 Add files via upload 2021-12-06 21:15:05 +10:00
loosewheel
ca31c40d8b Add files via upload 2021-12-05 01:24:47 +10:00
30 changed files with 1764 additions and 56 deletions

View File

@@ -74,3 +74,27 @@ v0.1.12
* Added cannon shells. * Added cannon shells.
* Fixed bug in utils.is_creative. * Fixed bug in utils.is_creative.
* Increased cannon pitch to -20 to 70. * Increased cannon pitch to -20 to 70.
v0.1.13
* Removed optional dependency lwdrops.
v0.1.14
* Calls on_drop when item is dropped.
v0.1.15
* Fixed bug call to clear_map in fan on_blast.
* Added pistons.
v0.1.16
* Fixed piston interaction with non-walkable nodes.
v0.1.17
* Fixed unintended global variable in pistons.lua.
v0.1.18
* Added mesecons through wire.

View File

@@ -49,7 +49,21 @@ minetest.register_craft( {
{ "default:iron_lump", "default:coalblock" }, { "default:iron_lump", "default:coalblock" },
}, },
}) })
end end -- minetest.global_exists ("fire")
if utils.mesecon_supported then
minetest.register_craft( {
output = "lwcomponents:through_wire_off 2",
recipe = {
{ "", "mesecons:wire_00000000_off" },
{ "mesecons:wire_00000000_off", "" },
},
})
end -- utils.mesecon_supported
@@ -218,6 +232,26 @@ minetest.register_craft( {
}, },
}) })
minetest.register_craft({
output = "lwcomponents:piston 2",
recipe = {
{ "group:wood", "group:wood", "group:wood" },
{ "default:cobble", "default:steel_ingot", "default:cobble" },
{ "default:stone", "default:copper_ingot", "default:stone" },
}
})
minetest.register_craft({
output = "lwcomponents:piston_sticky",
recipe = {
{"group:sapling"},
{"lwcomponents:piston"},
}
})
end -- utils.digilines_supported or utils.mesecon_supported end -- utils.digilines_supported or utils.mesecon_supported

View File

@@ -1,5 +1,4 @@
default default
lwdrops?
mesecons? mesecons?
digilines? digilines?
unifieddyes? unifieddyes?

View File

@@ -73,7 +73,7 @@ end
local function place_node (itemname, pos) local function place_node (item, pos)
local node = minetest.get_node_or_nil ({ x = pos.x, y = pos.y - 1, z = pos.z }) local node = minetest.get_node_or_nil ({ x = pos.x, y = pos.y - 1, z = pos.z })
if not node then if not node then
@@ -100,8 +100,8 @@ local function place_node (itemname, pos)
end end
end end
local stack = ItemStack (itemname) local stack = ItemStack (item)
local itemdef = utils.find_item_def (itemname) local itemdef = utils.find_item_def (stack:get_name ())
if stack and itemdef then if stack and itemdef then
local placed = false local placed = false
@@ -122,23 +122,23 @@ local function place_node (itemname, pos)
end end
if itemdef and itemdef.on_place then if itemdef and itemdef.on_place then
local result, msg = pcall (itemdef.on_place, stack, nil, pointed_thing) local result, leftover = pcall (itemdef.on_place, stack, nil, pointed_thing)
placed = result placed = result
if not placed then if not placed then
if utils.settings.alert_handler_errors then if utils.settings.alert_handler_errors then
minetest.log ("error", "on_place handler for "..itemname.." crashed - "..msg) minetest.log ("error", "on_place handler for "..stack:get_name ().." crashed - "..leftover)
end end
end end
end end
if not placed then if not placed then
if not minetest.registered_nodes[itemname] then if not minetest.registered_nodes[stack:get_name ()] then
return false return false
end end
minetest.set_node (pos, { name = itemname, param1 = 0, param2 = 0 }) minetest.set_node (pos, { name = stack:get_name (), param1 = 0, param2 = 0 })
if itemdef and itemdef.after_place_node then if itemdef and itemdef.after_place_node then
local result, msg = pcall (itemdef.after_place_node, pos, nil, stack, pointed_thing) local result, msg = pcall (itemdef.after_place_node, pos, nil, stack, pointed_thing)
@@ -154,11 +154,13 @@ local function place_node (itemname, pos)
pcall (minetest.sound_play, itemdef.sounds.place, { pos = pos }) pcall (minetest.sound_play, itemdef.sounds.place, { pos = pos })
end end
end end
end
return true return true
end end
return false
end
-- slot: -- slot:
@@ -219,7 +221,7 @@ local function deploy_item (pos, node, slot, range)
local deploypos = get_deploy_pos (pos, node.param2, range) local deploypos = get_deploy_pos (pos, node.param2, range)
if item and deploypos then if item and deploypos then
if place_node (name, deploypos) then if place_node (stack, deploypos) then
stack:set_count (stack:get_count () - 1) stack:set_count (stack:get_count () - 1)
inv:set_stack ("main", slot, stack) inv:set_stack ("main", slot, stack)

31
docs/pistons.txt Normal file
View File

@@ -0,0 +1,31 @@
Pistons and sticky pistons
--------------------------
* These blocks are only available if digilines and/or mesecons are loaded.
Pistons push up to the setting Maximum piston nodes (default 15) in front
of the pusher when extended. Sticky piston draw back a single node in
front of the pusher when retracted. Piston also act as a digilines
conductor.
UI
Channel - digilines channel of piston.
Single move - pusher extends 1 node if checked, otherwise 2 nodes.
Mesecons
Piston extends while power is turned on.
Digilines messages
"extend n"
Extends the piston pusher to extent n (0, 1 or 2). If n is not given
pusher extends to maximum extent. 0 is retracted.
"retract"
Same as 'extend 0'.
"single"
Sets piston to single move mode.
"double"
Sets piston to double move mode.

7
docs/through_wire.txt Normal file
View File

@@ -0,0 +1,7 @@
Mesecons Through Wire
---------------------
* This block is only available if mesecons is loaded.
Will transmit mesecons power when placed one to two blocks apart opposing
each other, through solid blocks or open space. Can also be used as a mesecons
crossover.

View File

@@ -199,14 +199,10 @@ local function on_blast (pos, intensity)
if meta then if meta then
if intensity >= 1.0 then if intensity >= 1.0 then
clear_map (pos)
minetest.remove_node (pos) minetest.remove_node (pos)
else -- intensity < 1.0 else -- intensity < 1.0
clear_map (pos)
local node = minetest.get_node_or_nil (pos) local node = minetest.get_node_or_nil (pos)
if node then if node then
local items = minetest.get_node_drops (node, nil) local items = minetest.get_node_drops (node, nil)

View File

@@ -1,4 +1,4 @@
local version = "0.1.12" local version = "0.1.18"
local mod_storage = minetest.get_mod_storage () local mod_storage = minetest.get_mod_storage ()
@@ -34,6 +34,8 @@ loadfile (modpath.."/fan.lua") (utils)
loadfile (modpath.."/conduit.lua") (utils, mod_storage) loadfile (modpath.."/conduit.lua") (utils, mod_storage)
loadfile (modpath.."/cannon.lua") (utils) loadfile (modpath.."/cannon.lua") (utils)
loadfile (modpath.."/cannon_shell.lua") (utils) loadfile (modpath.."/cannon_shell.lua") (utils)
loadfile (modpath.."/pistons.lua") (utils)
loadfile (modpath.."/through_wire.lua") (utils)
loadfile (modpath.."/extras.lua") (utils) loadfile (modpath.."/extras.lua") (utils)
loadfile (modpath.."/digiswitch.lua") (utils) loadfile (modpath.."/digiswitch.lua") (utils)
loadfile (modpath.."/movefloor.lua") (utils) loadfile (modpath.."/movefloor.lua") (utils)

View File

@@ -13,6 +13,8 @@ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
See the GNU Lesser General Public License for more details: See the GNU Lesser General Public License for more details:
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
Mesecons through wire code was adapted from mesecons_receiver.
lwsiren-buzz.ogg lwsiren-buzz.ogg
@@ -74,6 +76,8 @@ released under CC0 1.0 (originally from https://freesound.org/s/80401/)
boom image from tnt, released under CC BY-SA 3.0. boom image from tnt, released under CC BY-SA 3.0.
Piston images and sounds from mesecons_pistons, released under CC-BY-SA 3.0.
All other media, or media not covered by a licence, is licensed All other media, or media not covered by a licence, is licensed
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)

View File

@@ -3,4 +3,4 @@ description = Various components for mesecons and digilines.
title = LWComponents title = LWComponents
name = lwcomponents name = lwcomponents
depends = default depends = default
optional_depends = lwdrops, mesecons, digilines, unifieddyes, intllib, hopper, digistuff optional_depends = mesecons, digilines, unifieddyes, intllib, hopper, digistuff

143
models/piston_normal_1.obj Normal file
View File

@@ -0,0 +1,143 @@
# Blender v2.82 (sub 7) OBJ File: ''
# www.blender.org
mtllib piston_normal_1.mtl
o cube
v 0.500000 -0.500000 0.500000
v -0.500000 -0.500000 0.500000
v -0.500000 -0.500000 -0.312500
v 0.500000 -0.500000 -0.312500
v 0.500000 0.500000 0.500000
v 0.500000 0.500000 -0.312500
v -0.500000 0.500000 0.500000
v -0.500000 0.500000 -0.312500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.333333 0.333333
vt 0.666667 0.333333
vt 0.666667 0.666667
vt 0.333333 0.666667
vt 0.333333 0.666667
vt 0.666667 1.000000
vt 0.333333 1.000000
vn 0.0000 -1.0000 0.0000
vn 1.0000 -0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 -0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -0.0000 1.0000
usemtl m_7
s 1
f 1/1/1 2/2/1 3/3/1 4/4/1
f 5/5/2 1/6/2 4/7/2 6/8/2
f 7/9/3 5/10/3 6/11/3 8/12/3
f 2/13/4 7/14/4 8/15/4 3/16/4
f 8/17/5 6/18/5 4/19/5 3/20/5
f 2/21/6 1/1/6 5/22/6 7/23/6
o cube.000
v 0.500000 -0.500000 -1.312500
v -0.500000 -0.500000 -1.312500
v -0.500000 -0.500000 -1.500000
v 0.500000 -0.500000 -1.500000
v 0.500000 0.500000 -1.312500
v 0.500000 0.500000 -1.500000
v -0.500000 0.500000 -1.312500
v -0.500000 0.500000 -1.500000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.333333 0.000000
vt 0.666667 0.000000
vt 0.666667 0.333333
vt 0.333333 0.333333
vt 0.666667 0.333333
vt 1.000000 0.333333
vt 1.000000 0.666667
vt 0.666667 0.666667
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
usemtl m_7
s 1
f 9/24/7 10/25/7 11/26/7 12/27/7
f 13/28/8 9/29/8 12/30/8 14/31/8
f 15/32/9 13/33/9 14/34/9 16/35/9
f 10/36/10 15/37/10 16/38/10 11/39/10
f 16/40/11 14/41/11 12/42/11 11/43/11
f 10/44/12 9/45/12 13/46/12 15/47/12
o cube.001
v 0.125000 -0.125000 0.375000
v -0.125000 -0.125000 0.375000
v -0.125000 -0.125000 -1.375000
v 0.125000 -0.125000 -1.375000
v 0.125000 0.125000 0.375000
v 0.125000 0.125000 -1.375000
v -0.125000 0.125000 0.375000
v -0.125000 0.125000 -1.375000
vt 0.125000 0.354167
vt 0.208333 0.354167
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.125000 0.354167
vt 0.208333 0.354167
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.125000 0.354167
vt 0.208333 0.354167
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.125000 0.354167
vt 0.208333 0.354167
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.458333 0.130208
vt 0.541667 0.130208
vt 0.541667 0.213542
vt 0.458333 0.213542
vt 0.791667 0.463542
vt 0.875000 0.463542
vt 0.875000 0.546875
vt 0.791667 0.546875
vn 0.0000 -1.0000 -0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
usemtl m_7
s 1
f 17/48/13 18/49/13 19/50/13 20/51/13
f 21/52/14 17/53/14 20/54/14 22/55/14
f 23/56/15 21/57/15 22/58/15 24/59/15
f 18/60/16 23/61/16 24/62/16 19/63/16
f 24/64/17 22/65/17 20/66/17 19/67/17
f 18/68/18 17/69/18 21/70/18 23/71/18

143
models/piston_normal_2.obj Normal file
View File

@@ -0,0 +1,143 @@
# Blender v2.82 (sub 7) OBJ File: ''
# www.blender.org
mtllib piston_normal_2.mtl
o cube.011
v 0.500000 -0.500000 0.500000
v -0.500000 -0.500000 0.500000
v -0.500000 -0.500000 -0.312500
v 0.500000 -0.500000 -0.312500
v 0.500000 0.500000 0.500000
v 0.500000 0.500000 -0.312500
v -0.500000 0.500000 0.500000
v -0.500000 0.500000 -0.312500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.333333 0.333333
vt 0.666667 0.333333
vt 0.666667 0.666667
vt 0.333333 0.666667
vt 0.333333 0.666667
vt 0.666667 1.000000
vt 0.333333 1.000000
vn 0.0000 -1.0000 0.0000
vn 1.0000 -0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 -0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -0.0000 1.0000
usemtl m_0.001
s 1
f 1/1/1 2/2/1 3/3/1 4/4/1
f 5/5/2 1/6/2 4/7/2 6/8/2
f 7/9/3 5/10/3 6/11/3 8/12/3
f 2/13/4 7/14/4 8/15/4 3/16/4
f 8/17/5 6/18/5 4/19/5 3/20/5
f 2/21/6 1/1/6 5/22/6 7/23/6
o cube.012
v 0.500000 -0.500000 -2.312500
v -0.500000 -0.500000 -2.312500
v -0.500000 -0.500000 -2.500000
v 0.500000 -0.500000 -2.500000
v 0.500000 0.500000 -2.312500
v 0.500000 0.500000 -2.500000
v -0.500000 0.500000 -2.312500
v -0.500000 0.500000 -2.500000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.333333 0.000000
vt 0.666667 0.000000
vt 0.666667 0.333333
vt 0.333333 0.333333
vt 0.666667 0.333333
vt 1.000000 0.333333
vt 1.000000 0.666667
vt 0.666667 0.666667
vn 0.0000 -1.0000 -0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
usemtl m_0.001
s 1
f 9/24/7 10/25/7 11/26/7 12/27/7
f 13/28/8 9/29/8 12/30/8 14/31/8
f 15/32/9 13/33/9 14/34/9 16/35/9
f 10/36/10 15/37/10 16/38/10 11/39/10
f 16/40/11 14/41/11 12/42/11 11/43/11
f 10/44/12 9/45/12 13/46/12 15/47/12
o cube.013
v 0.125000 -0.125000 0.375000
v -0.125000 -0.125000 0.375000
v -0.125000 -0.125000 -2.375000
v 0.125000 -0.125000 -2.375000
v 0.125000 0.125000 0.375000
v 0.125000 0.125000 -2.375000
v -0.125000 0.125000 0.375000
v -0.125000 0.125000 -2.375000
vt 0.125000 0.020833
vt 0.208333 0.020833
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.125000 0.020833
vt 0.208333 0.020833
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.125000 0.020833
vt 0.208333 0.020833
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.125000 0.020833
vt 0.208333 0.020833
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.562500 0.229167
vt 0.458333 0.229167
vt 0.458333 0.125000
vt 0.562500 0.125000
vt 0.875000 0.458333
vt 0.791667 0.458333
vt 0.791667 0.541667
vt 0.875000 0.541667
vn 0.0000 -1.0000 -0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
usemtl m_0.001
s 1
f 17/48/13 18/49/13 19/50/13 20/51/13
f 21/52/14 17/53/14 20/54/14 22/55/14
f 23/56/15 21/57/15 22/58/15 24/59/15
f 18/60/16 23/61/16 24/62/16 19/63/16
f 24/64/17 22/65/17 20/66/17 19/67/17
f 18/68/18 17/69/18 21/70/18 23/71/18

143
models/piston_sticky_1.obj Normal file
View File

@@ -0,0 +1,143 @@
# Blender v2.82 (sub 7) OBJ File: ''
# www.blender.org
mtllib piston_sticky_1.mtl
o cube.002
v 0.500000 -0.500000 0.500000
v -0.500000 -0.500000 0.500000
v -0.500000 -0.500000 -0.312500
v 0.500000 -0.500000 -0.312500
v 0.500000 0.500000 0.500000
v 0.500000 0.500000 -0.312500
v -0.500000 0.500000 0.500000
v -0.500000 0.500000 -0.312500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.333333 0.333333
vt 0.666667 0.333333
vt 0.666667 0.666667
vt 0.333333 0.666667
vt 0.333333 0.666667
vt 0.666667 1.000000
vt 0.333333 1.000000
vn 0.0000 -1.0000 0.0000
vn 1.0000 -0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 -0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -0.0000 1.0000
usemtl m_7.001
s 1
f 1/1/1 2/2/1 3/3/1 4/4/1
f 5/5/2 1/6/2 4/7/2 6/8/2
f 7/9/3 5/10/3 6/11/3 8/12/3
f 2/13/4 7/14/4 8/15/4 3/16/4
f 8/17/5 6/18/5 4/19/5 3/20/5
f 2/21/6 1/1/6 5/22/6 7/23/6
o cube.003
v 0.500000 -0.500000 -1.312500
v -0.500000 -0.500000 -1.312500
v -0.500000 -0.500000 -1.500000
v 0.500000 -0.500000 -1.500000
v 0.500000 0.500000 -1.312500
v 0.500000 0.500000 -1.500000
v -0.500000 0.500000 -1.312500
v -0.500000 0.500000 -1.500000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.000000
vt 1.000000 0.000000
vt 1.000000 0.333333
vt 0.666667 0.333333
vt 0.666667 0.333333
vt 1.000000 0.333333
vt 1.000000 0.666667
vt 0.666667 0.666667
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
usemtl m_7.001
s 1
f 9/24/7 10/25/7 11/26/7 12/27/7
f 13/28/8 9/29/8 12/30/8 14/31/8
f 15/32/9 13/33/9 14/34/9 16/35/9
f 10/36/10 15/37/10 16/38/10 11/39/10
f 16/40/11 14/41/11 12/42/11 11/43/11
f 10/44/12 9/45/12 13/46/12 15/47/12
o cube.004
v 0.125000 -0.125000 0.375000
v -0.125000 -0.125000 0.375000
v -0.125000 -0.125000 -1.375000
v 0.125000 -0.125000 -1.375000
v 0.125000 0.125000 0.375000
v 0.125000 0.125000 -1.375000
v -0.125000 0.125000 0.375000
v -0.125000 0.125000 -1.375000
vt 0.125000 0.354167
vt 0.208333 0.354167
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.125000 0.354167
vt 0.208333 0.354167
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.125000 0.354167
vt 0.208333 0.354167
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.125000 0.354167
vt 0.208333 0.354167
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.458333 0.130208
vt 0.541667 0.130208
vt 0.541667 0.213542
vt 0.458333 0.213542
vt 0.791667 0.463542
vt 0.875000 0.463542
vt 0.875000 0.546875
vt 0.791667 0.546875
vn 0.0000 -1.0000 -0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
usemtl m_7.001
s 1
f 17/48/13 18/49/13 19/50/13 20/51/13
f 21/52/14 17/53/14 20/54/14 22/55/14
f 23/56/15 21/57/15 22/58/15 24/59/15
f 18/60/16 23/61/16 24/62/16 19/63/16
f 24/64/17 22/65/17 20/66/17 19/67/17
f 18/68/18 17/69/18 21/70/18 23/71/18

143
models/piston_sticky_2.obj Normal file
View File

@@ -0,0 +1,143 @@
# Blender v2.82 (sub 7) OBJ File: ''
# www.blender.org
mtllib piston_sticky_2.mtl
o cube.008
v 0.500000 -0.500000 0.500000
v -0.500000 -0.500000 0.500000
v -0.500000 -0.500000 -0.312500
v 0.500000 -0.500000 -0.312500
v 0.500000 0.500000 0.500000
v 0.500000 0.500000 -0.312500
v -0.500000 0.500000 0.500000
v -0.500000 0.500000 -0.312500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.666667 0.666667
vt 1.000000 0.666667
vt 1.000000 0.937500
vt 0.666667 0.937500
vt 0.333333 0.333333
vt 0.666667 0.333333
vt 0.666667 0.666667
vt 0.333333 0.666667
vt 0.333333 0.666667
vt 0.666667 1.000000
vt 0.333333 1.000000
vn 0.0000 -1.0000 0.0000
vn 1.0000 -0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 -0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -0.0000 1.0000
usemtl m_0
s 1
f 1/1/1 2/2/1 3/3/1 4/4/1
f 5/5/2 1/6/2 4/7/2 6/8/2
f 7/9/3 5/10/3 6/11/3 8/12/3
f 2/13/4 7/14/4 8/15/4 3/16/4
f 8/17/5 6/18/5 4/19/5 3/20/5
f 2/21/6 1/1/6 5/22/6 7/23/6
o cube.009
v 0.500000 -0.500000 -2.312500
v -0.500000 -0.500000 -2.312500
v -0.500000 -0.500000 -2.500000
v 0.500000 -0.500000 -2.500000
v 0.500000 0.500000 -2.312500
v 0.500000 0.500000 -2.500000
v -0.500000 0.500000 -2.312500
v -0.500000 0.500000 -2.500000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.937500
vt 1.000000 0.937500
vt 1.000000 1.000000
vt 0.666667 1.000000
vt 0.666667 0.000000
vt 1.000000 0.000000
vt 1.000000 0.333333
vt 0.666667 0.333333
vt 0.666667 0.333333
vt 1.000000 0.333333
vt 1.000000 0.666667
vt 0.666667 0.666667
vn 0.0000 -1.0000 -0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
usemtl m_0
s 1
f 9/24/7 10/25/7 11/26/7 12/27/7
f 13/28/8 9/29/8 12/30/8 14/31/8
f 15/32/9 13/33/9 14/34/9 16/35/9
f 10/36/10 15/37/10 16/38/10 11/39/10
f 16/40/11 14/41/11 12/42/11 11/43/11
f 10/44/12 9/45/12 13/46/12 15/47/12
o cube.010
v 0.125000 -0.125000 0.375000
v -0.125000 -0.125000 0.375000
v -0.125000 -0.125000 -2.375000
v 0.125000 -0.125000 -2.375000
v 0.125000 0.125000 0.375000
v 0.125000 0.125000 -2.375000
v -0.125000 0.125000 0.375000
v -0.125000 0.125000 -2.375000
vt 0.125000 0.020833
vt 0.208333 0.020833
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.125000 0.020833
vt 0.208333 0.020833
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.125000 0.020833
vt 0.208333 0.020833
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.125000 0.020833
vt 0.208333 0.020833
vt 0.208333 0.979167
vt 0.125000 0.979167
vt 0.562500 0.229167
vt 0.458333 0.229167
vt 0.458333 0.125000
vt 0.562500 0.125000
vt 0.875000 0.458333
vt 0.791667 0.458333
vt 0.791667 0.541667
vt 0.875000 0.541667
vn 0.0000 -1.0000 -0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
usemtl m_0
s 1
f 17/48/13 18/49/13 19/50/13 20/51/13
f 21/52/14 17/53/14 20/54/14 22/55/14
f 23/56/15 21/57/15 22/58/15 24/59/15
f 18/60/16 23/61/16 24/62/16 19/63/16
f 24/64/17 22/65/17 20/66/17 19/67/17
f 18/68/18 17/69/18 21/70/18 23/71/18

937
pistons.lua Normal file
View File

@@ -0,0 +1,937 @@
local utils = ...
local S = utils.S
if utils.digilines_supported or utils.mesecon_supported then
local piston_interval = 0.2
local function direction_vector (node)
local axis = math.floor (node.param2 / 4)
local rotate = node.param2 % 4
local vec = { x = 0, y = 0, z = 0 }
if rotate == 0 then
vec = { x = 0, y = 0, z = -1 }
elseif rotate == 1 then
vec = { x = -1, y = 0, z = 0 }
elseif rotate == 2 then
vec = { x = 0, y = 0, z = 1 }
elseif rotate == 3 then
vec = { x = 1, y = 0, z = 0 }
end
if axis == 1 then
vec = vector.rotate (vec, { x = math.pi / -2, y = 0, z = 0 })
elseif axis == 2 then
vec = vector.rotate (vec, { x = math.pi / 2, y = 0, z = 0 })
elseif axis == 3 then
vec = vector.rotate (vec, { x = 0, y = 0, z = math.pi / 2 })
elseif axis == 4 then
vec = vector.rotate (vec, { x = 0, y = 0, z = math.pi / -2 })
elseif axis == 5 then
vec = vector.rotate (vec, { x = math.pi, y = 0, z = 0 })
end
return vec
end
local function push_entities (pos, vec)
local tpos = vector.add (pos, vec)
local tnode = utils.get_far_node (tpos)
local can_move = false
if tnode then
if tnode.name == "air" then
can_move = true
else
local tdef = utils.find_item_def (tnode.name)
can_move = tdef and not tdef.walkable
end
end
if can_move then
local object = minetest.get_objects_inside_radius (pos, 1.5)
for j = 1, #object do
if object[j].get_pos then
local opos = object[j]:get_pos ()
if opos.x > (pos.x - 0.5) and opos.x < (pos.x + 0.5) and
opos.z > (pos.z - 0.5) and opos.z < (pos.z + 0.5) and
opos.y > (pos.y - 0.5) and opos.y < (pos.y + 0.5) then
object[j]:set_pos (vector.add (opos, vec))
end
end
end
end
end
local function push_nodes (pos, extent)
local node = utils.get_far_node (pos)
if node then
local vec = direction_vector (node)
local last = vector.add (pos, vector.multiply (vec, extent))
local maxnodes = utils.settings.max_piston_nodes + 1
local count = 0
for i = 1, maxnodes do
local tnode = utils.get_far_node (last)
if not tnode then
return false
end
local tdef = utils.find_item_def (tnode.name)
if tnode.name == "air" or (tdef and not tdef.walkable) then
count = i - 1
break
end
if i == maxnodes then
return false
end
last = vector.add (last, vec)
end
push_entities (last, vec)
for i = 1, count, 1 do
local cpos = vector.subtract (last, vec)
local cnode = utils.get_far_node (cpos)
local cmeta = minetest.get_meta (cpos)
if not cnode or not cmeta then
return false
end
local tmeta = cmeta:to_table ()
push_entities (cpos, vec)
minetest.remove_node (cpos)
minetest.set_node (last, cnode)
if tmeta then
cmeta = minetest.get_meta (last)
if not cmeta then
return false
end
cmeta:from_table (tmeta)
end
last = cpos
end
end
return true
end
local function pull_node (pos, extent)
local node = utils.get_far_node (pos)
if node then
local vec = direction_vector (node)
local cpos = vector.add (pos, vector.multiply (vec, extent))
local cnode = utils.get_far_node (cpos)
local cdef = cnode and utils.find_item_def (cnode.name)
if cnode and cnode.name ~= "air" and cdef and cdef.walkable then
local cmeta = minetest.get_meta (cpos)
if cmeta then
local tpos = vector.subtract (cpos, vec)
local tmeta = cmeta:to_table ()
minetest.remove_node (cpos)
minetest.set_node (tpos, cnode)
if tmeta then
cmeta = minetest.get_meta (tpos)
if cmeta then
cmeta:from_table (tmeta)
end
end
end
end
end
end
local function place_blank (pos, extent)
local node = utils.get_far_node (pos)
if node then
local vec = direction_vector (node)
local blank_pos = vector.add (pos, vector.multiply (vec, extent))
local blank_node = utils.get_far_node (blank_pos)
local blank_def = blank_node and utils.find_item_def (blank_node.name)
if blank_node and blank_node.name == "air" or
(blank_def and not blank_def.walkable) then
minetest.set_node (blank_pos,
{
name = "lwcomponents:piston_blank_"..tostring (extent),
param2 = node.param2
})
end
end
end
local function remove_blank (pos, extent)
local node = utils.get_far_node (pos)
if node then
local vec = direction_vector (node)
local blank_pos = vector.add (pos, vector.multiply (vec, extent))
local blank_node = utils.get_far_node (blank_pos)
if blank_node and
blank_node.name == "lwcomponents:piston_blank_"..tostring (extent) then
minetest.remove_node (blank_pos)
end
end
end
local function extend_piston (pos, extent)
local node = utils.get_far_node (pos)
local meta = minetest.get_meta (pos)
if node and meta then
extent = math.max (math.min (tonumber (extent or 2), meta:get_int ("max_extent")), 0)
if node.name == "lwcomponents:piston" then
if extent ~= 0 then
if push_nodes (pos, 1) then
node.name = "lwcomponents:piston_1"
minetest.swap_node (pos, node)
place_blank (pos, 1)
minetest.sound_play ("lwpiston_extend",
{
pos = pos,
max_hear_distance = 20,
gain = 0.3
},
true)
if extent == 2 then
meta:set_int ("extent", 2)
minetest.get_node_timer (pos):start (piston_interval)
return true
end
end
end
elseif node.name == "lwcomponents:piston_1" then
if extent == 0 then
remove_blank (pos, 1)
node.name = "lwcomponents:piston"
minetest.swap_node (pos, node)
minetest.sound_play ("lwpiston_retract",
{
pos = pos,
max_hear_distance = 20,
gain = 0.3
},
true)
elseif extent == 2 then
if push_nodes (pos, 2) then
node.name = "lwcomponents:piston_2"
minetest.swap_node (pos, node)
place_blank (pos, 2)
minetest.sound_play ("lwpiston_extend",
{
pos = pos,
max_hear_distance = 20,
gain = 0.3
},
true)
end
end
elseif node.name == "lwcomponents:piston_2" then
if extent ~= 2 then
remove_blank (pos, 2)
node.name = "lwcomponents:piston_1"
minetest.swap_node (pos, node)
minetest.sound_play ("lwpiston_retract",
{
pos = pos,
max_hear_distance = 20,
gain = 0.3
},
true)
if extent == 0 then
meta:set_int ("extent", 0)
minetest.get_node_timer (pos):start (piston_interval)
return true
end
end
elseif node.name == "lwcomponents:piston_sticky" then
if extent ~= 0 then
if push_nodes (pos, 1) then
node.name = "lwcomponents:piston_sticky_1"
minetest.swap_node (pos, node)
place_blank (pos, 1)
minetest.sound_play ("lwpiston_extend",
{
pos = pos,
max_hear_distance = 20,
gain = 0.3
},
true)
if extent == 2 then
meta:set_int ("extent", 2)
minetest.get_node_timer (pos):start (piston_interval)
return true
end
end
end
elseif node.name == "lwcomponents:piston_sticky_1" then
if extent == 0 then
remove_blank (pos, 1)
node.name = "lwcomponents:piston_sticky"
minetest.swap_node (pos, node)
pull_node (pos, 2)
minetest.sound_play ("lwpiston_retract",
{
pos = pos,
max_hear_distance = 20,
gain = 0.3
},
true)
elseif extent == 2 then
if push_nodes (pos, 2) then
node.name = "lwcomponents:piston_sticky_2"
minetest.swap_node (pos, node)
place_blank (pos, 2)
minetest.sound_play ("lwpiston_extend",
{
pos = pos,
max_hear_distance = 20,
gain = 0.3
},
true)
end
end
elseif node.name == "lwcomponents:piston_sticky_2" then
if extent ~= 2 then
remove_blank (pos, 2)
node.name = "lwcomponents:piston_sticky_1"
minetest.swap_node (pos, node)
pull_node (pos, 3)
minetest.sound_play ("lwpiston_retract",
{
pos = pos,
max_hear_distance = 20,
gain = 0.3
},
true)
if extent == 0 then
meta:set_int ("extent", 0)
minetest.get_node_timer (pos):start (piston_interval)
return true
end
end
end
end
return false
end
local function on_destruct_1 (pos)
remove_blank (pos, 1)
end
local function on_destruct_2 (pos)
remove_blank (pos, 2)
remove_blank (pos, 1)
end
local function on_place (itemstack, placer, pointed_thing)
local param2 = 0
if placer and placer:is_player () then
param2 = minetest.dir_to_facedir (placer:get_look_dir (), true)
elseif pointed_thing and pointed_thing.type == "node" then
param2 = minetest.dir_to_facedir (vector.subtract (pointed_thing.under, pointed_thing.above), true)
end
return minetest.item_place (itemstack, placer, pointed_thing, param2)
end
local function after_place_node (pos, placer, itemstack, pointed_thing)
local meta = minetest.get_meta (pos)
local spec =
"size[7,3.3]"..
"field[1,1;4,2;channel;Channel;${channel}]"..
"button_exit[4.6,1.15;1.5,1;submit;Set]"..
"checkbox[1,2;single;Single move;false]"
meta:set_string ("formspec", spec)
meta:set_int ("max_extent", 2)
-- If return true no item is taken from itemstack
return false
end
local function on_receive_fields (pos, formname, fields, sender)
if not utils.can_interact_with_node (pos, sender) then
return
end
local meta = minetest.get_meta (pos)
if meta then
if fields.submit then
meta:set_string ("channel", fields.channel)
end
if fields.single then
if fields.single == "true" then
local spec =
"size[7,3.3]"..
"field[1,1;4,2;channel;Channel;${channel}]"..
"button_exit[4.6,1.15;1.5,1;submit;Set]"..
"checkbox[1,2;single;Single move;true]"
meta:set_int ("max_extent", 1)
meta:set_string ("formspec", spec)
else
local spec =
"size[7,3.3]"..
"field[1,1;4,2;channel;Channel;${channel}]"..
"button_exit[4.6,1.15;1.5,1;submit;Set]"..
"checkbox[1,2;single;Single move;false]"
meta:set_int ("max_extent", 2)
meta:set_string ("formspec", spec)
end
end
end
end
local function on_blast (pos, intensity)
local meta = minetest.get_meta (pos)
if meta then
if intensity >= 1.0 then
minetest.remove_node (pos)
else -- intensity < 1.0
local node = minetest.get_node_or_nil (pos)
if node then
local items = minetest.get_node_drops (node, nil)
if items and #items > 0 then
local stack = ItemStack (items[1])
if stack then
preserve_metadata (pos, node, meta, { stack })
utils.item_drop (stack, nil, pos)
minetest.remove_node (pos)
end
end
end
end
end
end
local function can_dig (pos, player)
if not utils.can_interact_with_node (pos, player) then
return false
end
return true
end
local function on_rightclick (pos, node, clicker, itemstack, pointed_thing)
if not utils.can_interact_with_node (pos, clicker) then
if clicker and clicker:is_player () then
local owner = "<unknown>"
local meta = minetest.get_meta (pos)
if meta then
owner = meta:get_string ("owner")
end
local spec =
"formspec_version[3]"..
"size[8.0,4.0,false]"..
"label[1.0,1.0;Owned by "..minetest.formspec_escape (owner).."]"..
"button_exit[3.0,2.0;2.0,1.0;close;Close]"
minetest.show_formspec (clicker:get_player_name (),
"lwcomponents:component_privately_owned",
spec)
end
end
return itemstack
end
local function on_timer (pos, elapsed)
local meta = minetest.get_meta (pos)
if meta then
return extend_piston (pos, meta:get_int ("extent"))
end
return false
end
local function digilines_support ()
if utils.digilines_supported then
return
{
wire =
{
rules = utils.digilines_default_rules,
},
effector =
{
action = function (pos, node, channel, msg)
local meta = minetest.get_meta(pos)
if meta then
local this_channel = meta:get_string ("channel")
if this_channel ~= "" and this_channel == channel then
if type (msg) == "string" then
local m = { }
for w in string.gmatch(msg, "[^%s]+") do
m[#m + 1] = w
end
if m[1] == "extend" then
extend_piston (pos, m[2])
elseif m[1] == "retract" then
extend_piston (pos, 0)
elseif m[1] == "single" then
local spec =
"size[7,3.3]"..
"field[1,1;4,2;channel;Channel;${channel}]"..
"button_exit[4.6,1.15;1.5,1;submit;Set]"..
"checkbox[1,2;single;Single move;true]"
meta:set_int ("max_extent", 1)
meta:set_string ("formspec", spec)
elseif m[1] == "double" then
local spec =
"size[7,3.3]"..
"field[1,1;4,2;channel;Channel;${channel}]"..
"button_exit[4.6,1.15;1.5,1;submit;Set]"..
"checkbox[1,2;single;Single move;false]"
meta:set_int ("max_extent", 2)
meta:set_string ("formspec", spec)
end
end
end
end
end,
}
}
end
return nil
end
local function mesecon_support ()
if utils.mesecon_supported then
return
{
effector =
{
rules = utils.mesecon_default_rules,
action_on = function (pos, node)
-- do something to turn the effector on
extend_piston (pos, 2)
end,
action_off = function (pos, node)
-- do something to turn the effector off
extend_piston (pos, 0)
end,
}
}
end
return nil
end
minetest.register_node("lwcomponents:piston_blank_1", {
description = S("Piston blank"),
drawtype = "airlike",
light_source = 0,
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
climbable = false,
buildable_to = false,
floodable = false,
is_ground_content = false,
drop = "",
groups = { not_in_creative_inventory = 1 },
paramtype = "light",
-- unaffected by explosions
on_blast = function() end,
})
minetest.register_node("lwcomponents:piston_blank_2", {
description = S("Piston blank"),
drawtype = "airlike",
paramtype = "none",
param1 = 0,
paramtype2 = "facedir",
param2 = 0,
collision_box = {
type = "fixed",
fixed = {
{-0.125, -0.125, -0.4, 0.125, 0.125, 0.4},
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.3125},
},
},
light_source = 0,
sunlight_propagates = true,
walkable = true,
pointable = false,
diggable = false,
climbable = false,
buildable_to = false,
floodable = false,
is_ground_content = false,
drop = "",
groups = { not_in_creative_inventory = 1 },
paramtype = "light",
-- unaffected by explosions
on_blast = function() end,
})
minetest.register_node("lwcomponents:piston", {
description = S("Double Piston"),
tiles = { "lwcomponents_piston_top.png", "lwcomponents_piston_bottom.png",
"lwcomponents_piston_right.png", "lwcomponents_piston_left.png",
"lwcomponents_piston_base.png", "lwcomponents_piston_pusher.png" },
is_ground_content = false,
groups = { cracky = 3 },
sounds = default.node_sound_stone_defaults (),
paramtype = "none",
param1 = 0,
paramtype2 = "facedir",
param2 = 0,
floodable = false,
drop = "lwcomponents:piston",
_digistuff_channelcopier_fieldname = "channel",
mesecons = mesecon_support (),
digiline = digilines_support (),
on_place = on_place,
on_receive_fields = on_receive_fields,
can_dig = can_dig,
after_place_node = after_place_node,
on_blast = on_blast,
on_rightclick = on_rightclick,
on_timer = on_timer
})
minetest.register_node("lwcomponents:piston_1", {
description = S("Double Piston"),
drawtype = "mesh",
mesh = "piston_normal_1.obj",
tiles = { "lwcomponents_piston.png" },
visual_scale = 1.0,
selection_box = {
type = "fixed",
fixed = {
{-0.125, -0.125, -1.4, 0.125, 0.125, 0.4},
{-0.5, -0.5, -1.5, 0.5, 0.5, -1.3125},
{-0.5, -0.5, -0.3125, 0.5, 0.5, 0.5},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.125, -0.125, -1.4, 0.125, 0.125, 0.4},
{-0.5, -0.5, -1.5, 0.5, 0.5, -1.3125},
{-0.5, -0.5, -0.3125, 0.5, 0.5, 0.5},
},
},
is_ground_content = false,
groups = { cracky = 3 , not_in_creative_inventory = 1 },
sounds = default.node_sound_stone_defaults (),
paramtype = "none",
param1 = 0,
paramtype2 = "facedir",
param2 = 0,
floodable = false,
drop = "lwcomponents:piston",
_digistuff_channelcopier_fieldname = "channel",
mesecons = mesecon_support (),
digiline = digilines_support (),
on_destruct = on_destruct_1,
on_receive_fields = on_receive_fields,
can_dig = can_dig,
after_place_node = after_place_node,
on_blast = on_blast,
on_rightclick = on_rightclick,
on_timer = on_timer
})
minetest.register_node("lwcomponents:piston_2", {
description = S("Double Piston"),
drawtype = "mesh",
mesh = "piston_normal_2.obj",
tiles = { "lwcomponents_piston.png" },
visual_scale = 1.0,
selection_box = {
type = "fixed",
fixed = {
{-0.125, -0.125, -2.4, 0.125, 0.125, 0.4},
{-0.5, -0.5, -2.5, 0.5, 0.5, -2.3125},
{-0.5, -0.5, -0.3125, 0.5, 0.5, 0.5},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.125, -0.125, -2.4, 0.125, 0.125, 0.4},
{-0.5, -0.5, -2.5, 0.5, 0.5, -2.3125},
{-0.5, -0.5, -0.3125, 0.5, 0.5, 0.5},
},
},
is_ground_content = false,
groups = { cracky = 3 , not_in_creative_inventory = 1 },
sounds = default.node_sound_stone_defaults (),
paramtype = "none",
param1 = 0,
paramtype2 = "facedir",
param2 = 0,
floodable = false,
drop = "lwcomponents:piston",
_digistuff_channelcopier_fieldname = "channel",
mesecons = mesecon_support (),
digiline = digilines_support (),
on_destruct = on_destruct_2,
on_receive_fields = on_receive_fields,
can_dig = can_dig,
after_place_node = after_place_node,
on_blast = on_blast,
on_rightclick = on_rightclick,
on_timer = on_timer
})
minetest.register_node("lwcomponents:piston_sticky", {
description = S("Double Sticky Piston"),
tiles = { "lwcomponents_piston_top.png", "lwcomponents_piston_bottom.png",
"lwcomponents_piston_right.png", "lwcomponents_piston_left.png",
"lwcomponents_piston_base.png", "lwcomponents_piston_pusher_sticky.png" },
is_ground_content = false,
groups = { cracky = 3 },
sounds = default.node_sound_stone_defaults (),
paramtype = "none",
param1 = 0,
paramtype2 = "facedir",
param2 = 0,
floodable = false,
drop = "lwcomponents:piston_sticky",
_digistuff_channelcopier_fieldname = "channel",
mesecons = mesecon_support (),
digiline = digilines_support (),
on_place = on_place,
on_receive_fields = on_receive_fields,
can_dig = can_dig,
after_place_node = after_place_node,
on_blast = on_blast,
on_rightclick = on_rightclick,
on_timer = on_timer
})
minetest.register_node("lwcomponents:piston_sticky_1", {
description = S("Double Sticky Piston"),
drawtype = "mesh",
mesh = "piston_sticky_1.obj",
tiles = { "lwcomponents_piston.png" },
visual_scale = 1.0,
selection_box = {
type = "fixed",
fixed = {
{-0.125, -0.125, -1.4, 0.125, 0.125, 0.4},
{-0.5, -0.5, -1.5, 0.5, 0.5, -1.3125},
{-0.5, -0.5, -0.3125, 0.5, 0.5, 0.5},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.125, -0.125, -1.4, 0.125, 0.125, 0.4},
{-0.5, -0.5, -1.5, 0.5, 0.5, -1.3125},
{-0.5, -0.5, -0.3125, 0.5, 0.5, 0.5},
},
},
is_ground_content = false,
groups = { cracky = 3 , not_in_creative_inventory = 1 },
sounds = default.node_sound_stone_defaults (),
paramtype = "none",
param1 = 0,
paramtype2 = "facedir",
param2 = 0,
floodable = false,
drop = "lwcomponents:piston_sticky",
_digistuff_channelcopier_fieldname = "channel",
mesecons = mesecon_support (),
digiline = digilines_support (),
on_destruct = on_destruct_1,
on_receive_fields = on_receive_fields,
can_dig = can_dig,
after_place_node = after_place_node,
on_blast = on_blast,
on_rightclick = on_rightclick,
on_timer = on_timer
})
minetest.register_node("lwcomponents:piston_sticky_2", {
description = S("Double Sticky Piston"),
drawtype = "mesh",
mesh = "piston_sticky_2.obj",
tiles = { "lwcomponents_piston.png" },
visual_scale = 1.0,
selection_box = {
type = "fixed",
fixed = {
{-0.125, -0.125, -2.4, 0.125, 0.125, 0.4},
{-0.5, -0.5, -2.5, 0.5, 0.5, -2.3125},
{-0.5, -0.5, -0.3125, 0.5, 0.5, 0.5},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.125, -0.125, -2.4, 0.125, 0.125, 0.4},
{-0.5, -0.5, -2.5, 0.5, 0.5, -2.3125},
{-0.5, -0.5, -0.3125, 0.5, 0.5, 0.5},
},
},
is_ground_content = false,
groups = { cracky = 3 , not_in_creative_inventory = 1 },
sounds = default.node_sound_stone_defaults (),
paramtype = "none",
param1 = 0,
paramtype2 = "facedir",
param2 = 0,
floodable = false,
drop = "lwcomponents:piston_sticky",
_digistuff_channelcopier_fieldname = "channel",
mesecons = mesecon_support (),
digiline = digilines_support (),
on_destruct = on_destruct_2,
on_receive_fields = on_receive_fields,
can_dig = can_dig,
after_place_node = after_place_node,
on_blast = on_blast,
on_rightclick = on_rightclick,
on_timer = on_timer
})
end -- utils.digilines_supported or utils.mesecon_supported

View File

@@ -13,7 +13,7 @@ CC BY-SA 3.0
Version Version
======= =======
0.1.12 0.1.18
Minetest Version Minetest Version
@@ -28,7 +28,6 @@ default
Optional Dependencies Optional Dependencies
===================== =====================
lwdrops
mesecons mesecons
digilines digilines
unifieddyes unifieddyes
@@ -64,8 +63,10 @@ Various components for mesecons and digilines.
* Fan, blows any entity, player or drop in front of the fan. * Fan, blows any entity, player or drop in front of the fan.
* Conduit, connected in a circuit to move items. * Conduit, connected in a circuit to move items.
* Cannon, shoots an item on command with directional aiming (plus 3 shells). * Cannon, shoots an item on command with directional aiming (plus 3 shells).
* Double (optionally single) reach pistons and sticky pistons.
* Digiswitch, digilines controlled mesecons power. * Digiswitch, digilines controlled mesecons power.
* Movefloor, similar to vertical mesecons movestone. * Movefloor, similar to vertical mesecons movestone.
* Mesecons Through Wire, transmits through 1 to 2 solid blocks.
* Solid color conductor blocks, same as Solid Color Block but also mesecons * Solid color conductor blocks, same as Solid Color Block but also mesecons
and digilines conductor. and digilines conductor.
@@ -93,6 +94,9 @@ Alert handler errors
Issue errors when handler's of other mods fail. Issue errors when handler's of other mods fail.
Default: true Default: true
Maximum piston nodes
Maximum nodes a piston can push.
Default: 15
------------------------------------------------------------------------ ------------------------------------------------------------------------

View File

@@ -9,6 +9,9 @@ utils.settings.spawn_mobs =
utils.settings.alert_handler_errors = utils.settings.alert_handler_errors =
minetest.settings:get_bool ("lwcomponents_alert_handler_errors", true) minetest.settings:get_bool ("lwcomponents_alert_handler_errors", true)
utils.settings.max_piston_nodes =
tonumber(minetest.settings:get("lwcomponents_max_piston_nodes") or 15)
-- --

View File

@@ -3,3 +3,6 @@ lwcomponents_spawn_mobs (Spawn mobs) bool true
# Issue errors when handler's of other mods fail. # Issue errors when handler's of other mods fail.
lwcomponents_alert_handler_errors (Alert handler errors) bool true lwcomponents_alert_handler_errors (Alert handler errors) bool true
# Maximum nodes a piston can push.
lwcomponents_max_piston_nodes (Maximum piston nodes) int 15

BIN
sounds/lwpiston_extend.ogg Normal file

Binary file not shown.

BIN
sounds/lwpiston_retract.ogg Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 857 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

80
through_wire.lua Normal file
View File

@@ -0,0 +1,80 @@
local utils = ...
local S = utils.S
if utils.mesecon_supported then
local through_wire_get_rules = function (node)
local rules = { {x = -1, y = 0, z = 0},
{x = 2, y = 0, z = 0},
{x = 3, 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
mesecon.register_node ("lwcomponents:through_wire", {
description = S("Mesecons Through Wire"),
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
sunlight_propagates = true,
walkable = false,
on_rotate = false,
selection_box = {
type = "fixed",
fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
},
node_box = {
type = "fixed",
fixed = {
{ -3/16, -3/16, 13/32 , 3/16, 3/16 , 8/16 }, -- the smaller bump
{ -1/32, -1/32, 1/2 , 1/32, 1/32 , 3/2 }, -- the wire through the block
{ -2/32, -1/2 , 0.5002-3/32 , 2/32, 0 , 0.5 }, -- the vertical wire bit
{ -2/32, -1/2 , -16/32+0.001 , 2/32, -14/32, 7/16+0.002 } -- the horizontal wire
}
},
drop = "lwcomponents:through_wire_off",
sounds = default.node_sound_defaults(),
}, {
tiles = { "mesecons_wire_off.png" },
groups = { dig_immediate = 3 },
mesecons = {
conductor = {
state = mesecon.state.off,
rules = through_wire_get_rules,
onstate = "lwcomponents:through_wire_on"
}
}
}, {
tiles = { "mesecons_wire_on.png" },
groups = { dig_immediate = 3, not_in_creative_inventory = 1 },
mesecons = {
conductor = {
state = mesecon.state.on,
rules = through_wire_get_rules,
offstate = "lwcomponents:through_wire_off"
}
}
})
end -- utils.mesecon_supported
--

View File

@@ -67,43 +67,6 @@ end
-- check for lwdrops
if minetest.global_exists ("lwdrops") then
utils.lwdrops_supported = true
utils.on_destroy = lwdrops.on_destroy
utils.item_pickup = lwdrops.item_pickup
utils.item_drop = lwdrops.item_drop
else
utils.lwdrops_supported = false
-- dummy
utils.on_destroy = function (itemstack)
end
utils.item_pickup = function (entity, cleanup)
local stack = nil
if entity and entity.name and entity.name == "__builtin:item" and
entity.itemstring and entity.itemstring ~= "" then
stack = ItemStack (entity.itemstring)
if cleanup ~= false then
entity.itemstring = ""
entity.object:remove ()
end
end
return stack
end
utils.item_drop = function (itemstack, dropper, pos)
return minetest.item_drop (itemstack, dropper, pos)
end
end
-- check for unifieddyes -- check for unifieddyes
if minetest.global_exists ("unifieddyes") then if minetest.global_exists ("unifieddyes") then
utils.unifieddyes_supported = true utils.unifieddyes_supported = true
@@ -138,6 +101,53 @@ end
function utils.on_destroy (itemstack)
local stack = ItemStack (itemstack)
if stack and stack:get_count () > 0 then
local def = utils.find_item_def (stack:get_name ())
if def and def.on_destroy then
def.on_destroy (stack)
end
end
end
function utils.item_pickup (entity, cleanup)
local stack = nil
if entity and entity.name and entity.name == "__builtin:item" and
entity.itemstring and entity.itemstring ~= "" then
stack = ItemStack (entity.itemstring)
if cleanup ~= false then
entity.itemstring = ""
entity.object:remove ()
end
end
return stack
end
function utils.item_drop (itemstack, dropper, pos)
if itemstack then
local def = utils.find_item_def (itemstack:get_name ())
if def and def.on_drop then
return def.on_drop (itemstack, dropper, pos)
end
end
return minetest.item_drop (itemstack, dropper, pos)
end
function utils.can_interact_with_node (pos, player) function utils.can_interact_with_node (pos, player)
if not player or not player:is_player () then if not player or not player:is_player () then
return false return false