Organize mods into modpacks for better overview

This commit is contained in:
Wuzzy 2017-02-16 01:45:21 +01:00
parent f9db58bf50
commit 3696ee3761
1683 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,24 @@
-- |\ /| ____ ____ ____ _____ ____ _____
-- | \ / | | | | | | | |\ | |
-- | \/ | |___ ____ |___ | | | | \ | |____
-- | | | | | | | | | \ | |
-- | | |___ ____| |___ |____ |____| | \| ____|
-- 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

View file

@ -0,0 +1,13 @@
mesecons
mcl_core
mcl_sounds
mcl_fire
mcl_tnt
mcl_heads
mcl_dye
mcl_farming
mcl_minecarts
mcl_boats
mobs_mc
bucket
3d_armor_stand

View file

@ -0,0 +1,417 @@
--[[ This mod registers 3 nodes:
- One node for the horizontal-facing dispensers (mcl_dispensers:dispenser)
- One node for the upwards-facing dispensers (mcl_dispenser:dispenser_up)
- One node for the downwards-facing dispensers (mcl_dispenser:dispenser_down)
3 node definitions are needed because of the way the textures are defined.
All node definitions share a lot of code, so this is the reason why there
are so many weird tables below.
]]
-- For after_place_node
local setup_dispenser = function(pos)
-- Set formspec and inventory
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]"..
mcl_core.inventory_header..
"image[3,-0.2;5,0.75;mcl_dispensers_fnt_dispenser.png]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..
"list[current_name;main;3,0.5;3,3;]"..
"listring[current_name;main]"..
"listring[current_player;main]"
local meta = minetest.get_meta(pos)
meta:set_string("formspec", form)
local inv = meta:get_inventory()
inv:set_size("main", 9)
end
-- Shared core definition table
local dispenserdef = {
is_ground_content = false,
sounds = mcl_sounds.node_sound_stone_defaults(),
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.get_meta(pos)
local meta2 = meta
meta:from_table(oldmetadata)
local inv = meta:get_inventory()
for i=1, inv:get_size("main") do
local stack = inv:get_stack("main", i)
if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
minetest.add_item(p, stack)
end
end
meta:from_table(meta2:to_table())
end,
mesecons = {effector = {
-- Dispense random item when triggered
action_on = function (pos, node)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local droppos, dropdir
if node.name == "mcl_dispensers:dispenser" then
dropdir = vector.multiply(minetest.facedir_to_dir(node.param2), -1)
droppos = vector.add(pos, dropdir)
elseif node.name == "mcl_dispensers:dispenser_up" then
dropdir = {x=0, y=1, z=0}
droppos = {x=pos.x, y=pos.y+1, z=pos.z}
elseif node.name == "mcl_dispensers:dispenser_down" then
dropdir = {x=0, y=-1, z=0}
droppos = {x=pos.x, y=pos.y-1, z=pos.z}
end
local dropnode = minetest.get_node(droppos)
-- Do not dispense into solid nodes
local dropnodedef = minetest.registered_nodes[dropnode.name]
if dropnodedef.walkable then
return
end
local stacks = {}
for i=1,inv:get_size("main") do
local stack = inv:get_stack("main", i)
if not stack:is_empty() then
table.insert(stacks, {stack = stack, stackpos = i})
end
end
if #stacks >= 1 then
local r = math.random(1, #stacks)
local stack = stacks[r].stack
local dropitem = ItemStack(stack:get_name())
local stack_id = stacks[r].stackpos
local iname = stack:get_name()
local igroups = minetest.registered_items[iname].groups
--[===[ Dispense item ]===]
if iname == "mcl_throwing:arrow" then
-- Shoot arrow
local shootpos = vector.add(pos, vector.multiply(dropdir, 0.51))
local yaw = math.atan2(dropdir.z, dropdir.x) + math.pi/2
mcl_throwing.shoot_arrow(iname, shootpos, dropdir, yaw, nil)
stack:take_item()
inv:set_stack("main", stack_id, stack)
elseif iname == "mcl_throwing:egg" or iname == "mcl_throwing:snowball" then
-- Throw egg or snowball
local shootpos = vector.add(pos, vector.multiply(dropdir, 0.51))
mcl_throwing.throw(iname, shootpos, dropdir)
stack:take_item()
inv:set_stack("main", stack_id, stack)
elseif iname == "mcl_fire:fire_charge" then
-- Throw fire charge
local shootpos = vector.add(pos, vector.multiply(dropdir, 0.51))
local fireball = minetest.add_entity(shootpos, "mobs_mc:blaze_fireball")
local ent = fireball:get_luaentity()
local v = ent.velocity or 1
fireball:setvelocity(vector.multiply(dropdir, v))
ent.switch = 1
stack:take_item()
inv:set_stack("main", stack_id, stack)
elseif iname == "mcl_fire:flint_and_steel" then
-- Ignite air or fire
if dropnode.name == "air" then
minetest.add_node(droppos, {name="mcl_fire:basic_flame"})
if not minetest.setting_getbool("creative_mode") then
stack:add_wear(65535/65) -- 65 uses
end
elseif dropnode.name == "mcl_tnt:tnt" then
tnt.ignite(droppos)
if not minetest.setting_getbool("creative_mode") then
stack:add_wear(65535/65) -- 65 uses
end
end
inv:set_stack("main", stack_id, stack)
elseif iname == "mcl_tnt:tnt" then
-- Place and ignite TNT
if dropnodedef.buildable_to then
minetest.set_node(droppos, {name = iname})
tnt.ignite(droppos)
stack:take_item()
inv:set_stack("main", stack_id, stack)
end
elseif iname == "bucket:bucket_empty" then
-- Fill empty bucket with liquid or drop bucket if no liquid
local collect_liquid = false
local bucket_id
if dropnode.name == "mcl_core:water_source" then
collect_liquid = true
bucket_id = "bucket:bucket_water"
elseif dropnode.name == "mcl_core:lava_source" then
collect_liquid = true
bucket_id = "bucket:bucket_lava"
end
if collect_liquid then
minetest.set_node(droppos, {name="air"})
-- Fill bucket with liquid and put it back into inventory
-- if there's still space. If not, drop it.
stack:take_item()
inv:set_stack("main", stack_id, stack)
local new_bucket = ItemStack(bucket_id)
if inv:room_for_item("main", new_bucket) then
inv:add_item("main", new_bucket)
else
minetest.add_item(droppos, dropitem)
end
else
-- No liquid found: Drop empty bucket
minetest.add_item(droppos, dropitem)
stack:take_item()
inv:set_stack("main", stack_id, stack)
end
elseif iname == "bucket:bucket_water" or iname == "bucket:bucket_lava" then
-- Place water/lava source
if dropnodedef.buildable_to then
if iname == "bucket:bucket_water" then
minetest.set_node(droppos, {name = "mcl_core:water_source"})
elseif iname == "bucket:bucket_lava" then
minetest.set_node(droppos, {name = "mcl_core:lava_source"})
end
stack:take_item()
inv:set_stack("main", stack_id, stack)
if inv:room_for_item("main", "bucket:bucket_empty") then
inv:add_item("main", "bucket:bucket_empty")
else
minetest.add_item(droppos, dropitem)
end
end
elseif igroups.head or igroups.shulker_box or iname == "mcl_farming:pumpkin_face" then
-- Place head, shulker box, or pumpkin
if dropnodedef.buildable_to then
minetest.set_node(droppos, {name = iname, param2 = node.param2})
stack:take_item()
inv:set_stack("main", stack_id, stack)
end
elseif iname == "mcl_dye:white" then
-- Apply bone meal, if possible
if dropnode.name == "air" then
pointed_thing = { above = droppos, under = { x=droppos.x, y=droppos.y-1, z=droppos.z } }
else
pointed_thing = { above = pos, under = droppos }
end
local success = mcl_dye.apply_bone_meal(pointed_thing)
if success then
stack:take_item()
inv:set_stack("main", stack_id, stack)
end
elseif iname == "mcl_minecarts:minecart" then
-- Place minecart as entity on rail
if dropnodedef.groups.rail then
minetest.add_entity(droppos, "mcl_minecarts:minecart")
else
-- Drop item
minetest.add_item(droppos, dropitem)
end
stack:take_item()
inv:set_stack("main", stack_id, stack)
elseif igroups.boat then
local below = {x=droppos.x, y=droppos.y-1, z=droppos.z}
local belownode = minetest.get_node(below)
-- Place boat as entity on or in water
if dropnodedef.groups.water or (dropnode.name == "air" and minetest.registered_nodes[belownode.name].groups.water) then
minetest.add_entity(droppos, "mcl_boats:boat")
else
minetest.add_item(droppos, dropitem)
end
stack:take_item()
inv:set_stack("main", stack_id, stack)
elseif igroups.armor_head or igroups.armor_torso or igroups.armor_legs or igroups.armor_feet then
local armor_type, armor_slot
if igroups.armor_head then
armor_type = "armor_head"
armor_slot = 2
elseif igroups.armor_torso then
armor_type = "armor_torso"
armor_slot = 3
elseif igroups.armor_legs then
armor_type = "armor_legs"
armor_slot = 4
elseif igroups.armor_feet then
armor_type = "armor_feet"
armor_slot = 5
end
local droppos_below = {x=droppos.x, y=droppos.y-1, z=droppos.z}
local dropnode_below = minetest.get_node(droppos_below)
-- Put armor on player or armor stand
local standpos
if dropnode.name == "3d_armor_stand:armor_stand" then
standpos = droppos
elseif dropnode_below.name == "3d_armor_stand:armor_stand" then
standpos = droppos_below
end
if standpos then
local dropmeta = minetest.get_meta(standpos)
local dropinv = dropmeta:get_inventory()
if dropinv:room_for_item(armor_type, dropitem) then
dropinv:add_item(armor_type, dropitem)
--[[ FIXME: For some reason, this function is not called after calling add_item,
so we call it manually to update the armor stand entity.
This may need investigation and the following line may be a small hack. ]]
minetest.registered_nodes["3d_armor_stand:armor_stand"].on_metadata_inventory_put(standpos)
stack:take_item()
inv:set_stack("main", stack_id, stack)
end
else
-- Put armor on nearby player
-- First search for player in front of dispenser (check 2 nodes)
local objs1 = minetest.get_objects_inside_radius(droppos, 1)
local objs2 = minetest.get_objects_inside_radius(droppos_below, 1)
local objs_table = {objs1, objs2}
local player
for oi=1, #objs_table do
local objs_inner = objs_table[oi]
for o=1, #objs_inner do
--[[ First player in list is the lucky one. The other player get nothing :-(
If multiple players are close to the dispenser, it can be a bit
-- unpredictable on who gets the armor. ]]
if objs_inner[o]:is_player() then
player = objs_inner[o]
break
end
end
if player then
break
end
end
-- If player found, add armor
if player then
local ainv = minetest.get_inventory({type="detached", name=player:get_player_name().."_armor"})
local pinv = player:get_inventory()
if ainv:get_stack("armor", armor_slot):is_empty() and pinv:get_stack("armor", armor_slot):is_empty() then
ainv:set_stack("armor", armor_slot, dropitem)
pinv:set_stack("armor", armor_slot, dropitem)
armor:set_player_armor(player)
armor:update_inventory(player)
stack:take_item()
inv:set_stack("main", stack_id, stack)
end
end
end
elseif igroups.spawn_egg then
-- Place spawn egg
if not dropnodedef.walkable then
pointed_thing = { above = droppos, under = { x=droppos.x, y=droppos.y-1, z=droppos.z } }
minetest.registered_items[iname].on_place(ItemStack(iname), nil, pointed_thing)
stack:take_item()
inv:set_stack("main", stack_id, stack)
end
-- TODO: Many other dispenser actions
else
-- Drop item
minetest.add_item(droppos, dropitem)
stack:take_item()
inv:set_stack("main", stack_id, stack)
end
end
end
}}
}
-- Horizontal dispenser
local horizontal_def = table.copy(dispenserdef)
horizontal_def.description = "Dispenser"
horizontal_def.after_place_node = function(pos, placer, itemstack, pointed_thing)
setup_dispenser(pos)
-- When placed up and down, convert node to up/down dispenser
if pointed_thing.above.y < pointed_thing.under.y then
minetest.swap_node(pos, {name = "mcl_dispensers:dispenser_down"})
elseif pointed_thing.above.y > pointed_thing.under.y then
minetest.swap_node(pos, {name = "mcl_dispensers:dispenser_up"})
end
-- Else, the normal facedir logic applies
end
horizontal_def.tiles = {
"default_furnace_top.png", "default_furnace_bottom.png",
"default_furnace_side.png", "default_furnace_side.png",
"default_furnace_side.png", "mcl_dispensers_dispenser_front_horizontal.png"
}
horizontal_def.paramtype2 = "facedir"
horizontal_def.groups = {cracky=2,container=2}
minetest.register_node("mcl_dispensers:dispenser", horizontal_def)
-- Down dispenser
local down_def = table.copy(dispenserdef)
down_def.description = "Downwards-Facing Dispenser"
down_def.after_place_node = setup_dispenser
down_def.tiles = {
"default_furnace_top.png", "mcl_dispensers_dispenser_front_vertical.png",
"default_furnace_side.png", "default_furnace_side.png",
"default_furnace_side.png", "default_furnace_side.png"
}
down_def.groups = {cracky=2,container=2,not_in_creative_inventory=1}
down_def.drop = "mcl_dispensers:dispenser"
minetest.register_node("mcl_dispensers:dispenser_down", down_def)
-- Up dispenser
-- The up dispenser is almost identical to the down dispenser , it only differs in textures
up_def = table.copy(down_def)
up_def.description = "Upwards-Facing Dispenser"
up_def.tiles = {
"mcl_dispensers_dispenser_front_vertical.png", "default_furnace_bottom.png",
"default_furnace_side.png", "default_furnace_side.png",
"default_furnace_side.png", "default_furnace_side.png"
}
minetest.register_node("mcl_dispensers:dispenser_up", up_def)
minetest.register_craft({
output = 'mcl_dispensers:dispenser',
recipe = {
{"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",},
{"mcl_core:cobble", "mcl_throwing:bow", "mcl_core:cobble",},
{"mcl_core:cobble", "mesecons:redstone", "mcl_core:cobble",},
}
})
-- Only allow crafting if the bow is intact
local check_craft = function(itemstack, player, old_craft_grid, craft_inv)
if itemstack:get_name() == "mcl_dispensers:dispenser" then
local bow, id
for i=1, craft_inv:get_size("craft") do
local item = craft_inv:get_stack("craft", i)
if item:get_name() == "mcl_throwing:bow" then
bow = item
id = i
break
end
end
if bow and bow:get_wear() ~= 0 then
return ""
end
end
return nil
end
minetest.register_on_craft(check_craft)
minetest.register_craft_predict(check_craft)

Binary file not shown.

After

Width:  |  Height:  |  Size: 888 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 980 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 973 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

View file

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

View file

@ -0,0 +1,153 @@
--[[ This mod registers 3 nodes:
- One node for the horizontal-facing dropper (mcl_droppers:dropper)
- One node for the upwards-facing droppers (mcl_droppers:dropper_up)
- One node for the downwards-facing droppers (mcl_droppers:dropper_down)
3 node definitions are needed because of the way the textures are defined.
All node definitions share a lot of code, so this is the reason why there
are so many weird tables below.
]]
-- For after_place_node
local setup_dropper = function(pos)
-- Set formspec and inventory
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]"..
mcl_core.inventory_header..
"image[3,-0.2;5,0.75;mcl_droppers_fnt_dropper.png]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..
"list[current_name;main;3,0.5;3,3;]"..
"listring[current_name;main]"..
"listring[current_player;main]"
local meta = minetest.get_meta(pos)
meta:set_string("formspec", form)
local inv = meta:get_inventory()
inv:set_size("main", 9)
end
-- Shared core definition table
local dropperdef = {
is_ground_content = false,
sounds = mcl_sounds.node_sound_stone_defaults(),
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.get_meta(pos)
local meta2 = meta
meta:from_table(oldmetadata)
local inv = meta:get_inventory()
for i=1, inv:get_size("main") do
local stack = inv:get_stack("main", i)
if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
minetest.add_item(p, stack)
end
end
meta:from_table(meta2:to_table())
end,
mesecons = {effector = {
-- Drop random item when triggered
action_on = function (pos, node)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local droppos
if node.name == "mcl_droppers:dropper" then
droppos = vector.subtract(pos, minetest.facedir_to_dir(node.param2))
elseif node.name == "mcl_droppers:dropper_up" then
droppos = {x=pos.x, y=pos.y+1, z=pos.z}
elseif node.name == "mcl_droppers:dropper_down" then
droppos = {x=pos.x, y=pos.y-1, z=pos.z}
end
local dropnode = minetest.get_node(droppos)
-- Do not drop into solid nodes, unless they are containers
local dropnodedef = minetest.registered_nodes[dropnode.name]
if dropnodedef.walkable and not dropnodedef.groups.container then
return
end
local stacks = {}
for i=1,inv:get_size("main") do
local stack = inv:get_stack("main", i)
if not stack:is_empty() then
table.insert(stacks, {stack = stack, stackpos = i})
end
end
if #stacks >= 1 then
local r = math.random(1, #stacks)
local stack = stacks[r].stack
local dropitem = ItemStack(stack:get_name())
local stack_id = stacks[r].stackpos
-- If it's a container, attempt to put it into the container
local dropped = mcl_util.move_item_container(pos, "main", stack_id, droppos)
-- No container?
if not dropped and not dropnodedef.groups.container then
-- Drop item normally
minetest.add_item(droppos, dropitem)
stack:take_item()
inv:set_stack("main", stack_id, stack)
end
end
end
}}
}
-- Horizontal dropper
local horizontal_def = table.copy(dropperdef)
horizontal_def.description = "Dropper"
horizontal_def.after_place_node = function(pos, placer, itemstack, pointed_thing)
setup_dropper(pos)
-- When placed up and down, convert node to up/down dropper
if pointed_thing.above.y < pointed_thing.under.y then
minetest.swap_node(pos, {name = "mcl_droppers:dropper_down"})
elseif pointed_thing.above.y > pointed_thing.under.y then
minetest.swap_node(pos, {name = "mcl_droppers:dropper_up"})
end
-- Else, the normal facedir logic applies
end
horizontal_def.tiles = {
"default_furnace_top.png", "default_furnace_bottom.png",
"default_furnace_side.png", "default_furnace_side.png",
"default_furnace_side.png", "mcl_droppers_dropper_front_horizontal.png"
}
horizontal_def.paramtype2 = "facedir"
horizontal_def.groups = {cracky=2,container=2}
minetest.register_node("mcl_droppers:dropper", horizontal_def)
-- Down dropper
local down_def = table.copy(dropperdef)
down_def.description = "Downwards-Facing Dropper"
down_def.after_place_node = setup_dropper
down_def.tiles = {
"default_furnace_top.png", "mcl_droppers_dropper_front_vertical.png",
"default_furnace_side.png", "default_furnace_side.png",
"default_furnace_side.png", "default_furnace_side.png"
}
down_def.groups = {cracky=2,container=2,not_in_creative_inventory=1}
down_def.drop = "mcl_droppers:dropper"
minetest.register_node("mcl_droppers:dropper_down", down_def)
-- Up dropper
-- The up dropper is almost identical to the down dropper, it only differs in textures
up_def = table.copy(down_def)
up_def.description = "Upwards-Facing Dropper"
up_def.tiles = {
"mcl_droppers_dropper_front_vertical.png", "default_furnace_bottom.png",
"default_furnace_side.png", "default_furnace_side.png",
"default_furnace_side.png", "default_furnace_side.png"
}
minetest.register_node("mcl_droppers:dropper_up", up_def)
-- Ladies and gentlemen, I present to you: the crafting recipe!
minetest.register_craft({
output = 'mcl_droppers:dropper',
recipe = {
{"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",},
{"mcl_core:cobble", "", "mcl_core:cobble",},
{"mcl_core:cobble", "mesecons:redstone", "mcl_core:cobble",},
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

View file

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

View file

@ -0,0 +1,48 @@
minetest.register_node("mcl_observers:observer", {
description = "Observer (WIP)",
is_ground_content = false,
sounds = mcl_sounds.node_sound_stone_defaults(),
paramtype2 = "facedir",
-- TODO: Add to craft guide and creative inventory when it's useful
groups = { cracky=2, not_in_craft_guide=1, not_in_creative_inventory=1 },
tiles = {
"mcl_observers_observer_top.png", "default_furnace_bottom.png",
"mcl_observers_observer_side.png", "mcl_observers_observer_side.png",
"mcl_observers_observer_front.png", "mcl_observers_observer_back.png",
},
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.get_meta(pos)
local meta2 = meta
meta:from_table(oldmetadata)
local inv = meta:get_inventory()
for i=1, inv:get_size("main") do
local stack = inv:get_stack("main", i)
if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
minetest.add_item(p, stack)
end
end
meta:from_table(meta2:to_table())
end,
-- TODO: Mesecons handling
mesecons = {effector = {
}}
})
minetest.register_craft({
output = "mcl_observers:observer",
recipe = {
{ "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" },
{ "mcl_nether:quartz", "mesecons:redstone", "mesecons:redstone" },
{ "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" },
}
})
minetest.register_craft({
output = "mcl_observers:observer",
recipe = {
{ "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" },
{ "mesecons:redstone", "mesecons:redstone", "mcl_nether:quartz" },
{ "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" },
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,023 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 996 B

View file

@ -0,0 +1 @@
0.41 DEV

View file

@ -0,0 +1,2 @@
mcl_sounds
mcl_core

View file

@ -0,0 +1,114 @@
-- |\ /| ____ ____ ____ _____ ____ _____
-- | \ / | | | | | | | |\ | |
-- | \/ | |___ ____ |___ | | | | \ | |____
-- | | | | | | | | | \ | |
-- | | |___ ____| |___ |____ |____| | \| ____|
-- by Jeija, Uberi (Temperest), sfan5, VanessaE
--
--
--
-- This mod adds mesecons[=minecraft redstone] and different receptors/effectors to minetest.
-- See the documentation on the forum for additional information, especially about crafting
--
--
-- 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
-- }
--}
local init = os.clock()
-- PUBLIC VARIABLES
mesecon={} -- contains all functions and all global variables
mesecon.actions_on={} -- Saves registered function callbacks for mesecon on | DEPRECATED
mesecon.actions_off={} -- Saves registered function callbacks for mesecon off | DEPRECATED
mesecon.actions_change={} -- Saves registered function callbacks for mesecon change | DEPRECATED
mesecon.receptors={} -- saves all information about receptors | DEPRECATED
mesecon.effectors={} -- saves all information about effectors | DEPRECATED
mesecon.conductors={} -- saves all information about conductors | DEPRECATED
-- 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(pos, rules)
rules = rules or mesecon.rules.default
for _, rule in ipairs(rules) do
local np = mesecon:addPosRule(pos, rule)
local link, rulename = mesecon:rules_link(pos, np, rules)
if link then
mesecon:turnon(np, rulename)
end
end
end
function mesecon:receptor_off(pos, rules)
rules = rules or mesecon.rules.default
for _, rule in ipairs(rules) do
local np = mesecon:addPosRule(pos, rule)
local link, rulename = mesecon:rules_link(pos, np, rules)
if link then
if not mesecon:connected_to_receptor(np) then
mesecon:turnoff(np, rulename)
else
mesecon:changesignal(np, minetest.get_node(np), rulename, mesecon.state.off)
end
end
end
end
--The actual wires
dofile(minetest.get_modpath("mesecons").."/wires.lua");
--Services like turnoff receptor on dignode and so on
dofile(minetest.get_modpath("mesecons").."/services.lua");
local time_to_load= os.clock() - init
print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load))

View file

@ -0,0 +1,472 @@
-- Internal.lua - The core of mesecons
--
-- For more practical developer resources see mesecons.tk
--
-- Function overview
-- mesecon:get_effector(nodename) --> Returns the mesecons.effector -specifictation in the nodedef by the nodename
-- mesecon:get_receptor(nodename) --> Returns the mesecons.receptor -specifictation in the nodedef by the nodename
-- mesecon:get_conductor(nodename) --> Returns the mesecons.conductor-specifictation in the nodedef by the nodename
-- mesecon:get_any_inputrules (node) --> Returns the rules of a node if it is a conductor or an effector
-- mesecon:get_any_outputrules (node) --> Returns the rules of a node if it is a conductor or a receptor
-- RECEPTORS
-- mesecon:is_receptor(nodename) --> Returns true if nodename is a receptor
-- mesecon:is_receptor_on(nodename) --> Returns true if nodename is an receptor with state = mesecon.state.on
-- mesecon:is_receptor_off(nodename) --> Returns true if nodename is an receptor with state = mesecon.state.off
-- mesecon:receptor_get_rules(node) --> Returns the rules of the receptor (mesecon.rules.default if none specified)
-- EFFECTORS
-- mesecon:is_effector(nodename) --> Returns true if nodename is an effector
-- mesecon:is_effector_on(nodename) --> Returns true if nodename is an effector with nodedef.mesecons.effector.action_off
-- mesecon:is_effector_off(nodename) --> Returns true if nodename is an effector with nodedef.mesecons.effector.action_on
-- mesecon:effector_get_rules(node) --> Returns the input rules of the effector (mesecon.rules.default if none specified)
-- SIGNALS
-- mesecon:activate(pos, node) --> Activates the effector node at the specific pos (calls nodedef.mesecons.effector.action_on)
-- mesecon:deactivate(pos, node) --> Deactivates the effector node at the specific pos (calls nodedef.mesecons.effector.action_off)
-- mesecon:changesignal(pos, node, rulename, newstate) --> Changes the effector node at the specific pos (calls nodedef.mesecons.effector.action_change)
-- RULES
-- mesecon:add_rules(name, rules) | deprecated? --> Saves rules table by name
-- mesecon:get_rules(name, rules) | deprecated? --> Loads rules table with name
-- CONDUCTORS
-- mesecon:is_conductor(nodename) --> Returns true if nodename is a conductor
-- mesecon:is_conductor_on(nodename) --> Returns true if nodename is a conductor with state = mesecon.state.on
-- mesecon:is_conductor_off(nodename) --> Returns true if nodename is a conductor with state = mesecon.state.off
-- mesecon:get_conductor_on(offstate) --> Returns the onstate nodename of the conductor with the name offstate
-- mesecon:get_conductor_off(onstate) --> Returns the offstate nodename of the conductor with the name onstate
-- mesecon:conductor_get_rules(node) --> Returns the input+output rules of a conductor (mesecon.rules.default if none specified)
-- HIGH-LEVEL Internals
-- mesecon:is_power_on(pos) --> Returns true if pos emits power in any way
-- mesecon:is_power_off(pos) --> Returns true if pos does not emit power in any way
-- mesecon:turnon(pos, rulename) --> Returns true whatever there is at pos. Calls itself for connected nodes (if pos is a conductor) --> recursive, the rulename is the name of the input rule that caused calling turnon
-- mesecon:turnoff(pos, rulename) --> Turns off whatever there is at pos. Calls itself for connected nodes (if pos is a conductor) --> recursive, the rulename is the name of the input rule that caused calling turnoff
-- mesecon:connected_to_receptor(pos) --> Returns true if pos is connected to a receptor directly or via conductors; calls itself if pos is a conductor --> recursive
-- mesecon:rules_link(output, input, dug_outputrules) --> Returns true if outputposition + outputrules = inputposition and inputposition + inputrules = outputposition (if the two positions connect)
-- mesecon:rules_link_anydir(outp., inp., d_outpr.) --> Same as rules mesecon:rules_link but also returns true if output and input are swapped
-- mesecon:is_powered(pos) --> Returns true if pos is powered by a receptor or a conductor
-- RULES ROTATION helpsers
-- mesecon:rotate_rules_right(rules)
-- mesecon:rotate_rules_left(rules)
-- mesecon:rotate_rules_up(rules)
-- mesecon:rotate_rules_down(rules)
-- These functions return rules that have been rotated in the specific direction
-- General
function mesecon:get_effector(nodename)
if minetest.registered_nodes[nodename]
and minetest.registered_nodes[nodename].mesecons
and minetest.registered_nodes[nodename].mesecons.effector then
return minetest.registered_nodes[nodename].mesecons.effector
end
end
function mesecon:get_receptor(nodename)
if minetest.registered_nodes[nodename]
and minetest.registered_nodes[nodename].mesecons
and minetest.registered_nodes[nodename].mesecons.receptor then
return minetest.registered_nodes[nodename].mesecons.receptor
end
end
function mesecon:get_conductor(nodename)
if minetest.registered_nodes[nodename]
and minetest.registered_nodes[nodename].mesecons
and minetest.registered_nodes[nodename].mesecons.conductor then
return minetest.registered_nodes[nodename].mesecons.conductor
end
end
function mesecon:get_any_outputrules (node)
if mesecon:is_conductor(node.name) then
return mesecon:conductor_get_rules(node)
elseif mesecon:is_receptor(node.name) then
return mesecon:receptor_get_rules(node)
end
return false
end
function mesecon:get_any_inputrules (node)
if mesecon:is_conductor(node.name) then
return mesecon:conductor_get_rules(node)
elseif mesecon:is_effector(node.name) then
return mesecon:effector_get_rules(node)
end
return false
end
-- Receptors
-- Nodes that can power mesecons
function mesecon:is_receptor_on(nodename)
local receptor = mesecon:get_receptor(nodename)
if receptor and receptor.state == mesecon.state.on then
return true
end
return false
end
function mesecon:is_receptor_off(nodename)
local receptor = mesecon:get_receptor(nodename)
if receptor and receptor.state == mesecon.state.off then
return true
end
return false
end
function mesecon:is_receptor(nodename)
local receptor = mesecon:get_receptor(nodename)
if receptor then
return true
end
return false
end
function mesecon:receptor_get_rules(node)
local receptor = mesecon:get_receptor(node.name)
if receptor then
local rules = receptor.rules
if type(rules) == 'function' then
return rules(node)
elseif rules then
return rules
end
end
return mesecon.rules.default
end
-- Effectors
-- Nodes that can be powered by mesecons
function mesecon:is_effector_on(nodename)
local effector = mesecon:get_effector(nodename)
if effector and effector.action_off then
return true
end
return false
end
function mesecon:is_effector_off(nodename)
local effector = mesecon:get_effector(nodename)
if effector and effector.action_on then
return true
end
return false
end
function mesecon:is_effector(nodename)
local effector = mesecon:get_effector(nodename)
if effector then
return true
end
return false
end
function mesecon:effector_get_rules(node)
local effector = mesecon:get_effector(node.name)
if effector then
local rules = effector.rules
if type(rules) == 'function' then
return rules(node)
elseif rules then
return rules
end
end
return mesecon.rules.default
end
--Signals
function mesecon:activate(pos, node, rulename)
local effector = mesecon:get_effector(node.name)
if effector and effector.action_on then
effector.action_on (pos, node, rulename)
end
end
function mesecon:deactivate(pos, node, rulename)
local effector = mesecon:get_effector(node.name)
if effector and effector.action_off then
effector.action_off (pos, node, rulename)
end
end
function mesecon:changesignal(pos, node, rulename, newstate)
local effector = mesecon:get_effector(node.name)
if effector and effector.action_change then
effector.action_change (pos, node, rulename, newstate)
end
end
--Rules
function mesecon:add_rules(name, rules)
mesecon.rules[name] = rules
end
function mesecon:get_rules(name)
return mesecon.rules[name]
end
-- Conductors
function mesecon:is_conductor_on(nodename)
local conductor = mesecon:get_conductor(nodename)
if conductor and conductor.state == mesecon.state.on then
return true
end
return false
end
function mesecon:is_conductor_off(nodename)
local conductor = mesecon:get_conductor(nodename)
if conductor and conductor.state == mesecon.state.off then
return true
end
return false
end
function mesecon:is_conductor(nodename)
local conductor = mesecon:get_conductor(nodename)
if conductor then
return true
end
return false
end
function mesecon:get_conductor_on(offstate)
local conductor = mesecon:get_conductor(offstate)
if conductor then
return conductor.onstate
end
return false
end
function mesecon:get_conductor_off(onstate)
local conductor = mesecon:get_conductor(onstate)
if conductor then
return conductor.offstate
end
return false
end
function mesecon:conductor_get_rules(node)
local conductor = mesecon:get_conductor(node.name)
if conductor then
local rules = conductor.rules
if type(rules) == 'function' then
return rules(node)
elseif rules then
return rules
end
end
return mesecon.rules.default
end
-- some more general high-level stuff
function mesecon:is_power_on(pos)
local node = minetest.get_node(pos)
if mesecon:is_conductor_on(node.name) or mesecon:is_receptor_on(node.name) then
return true
end
return false
end
function mesecon:is_power_off(pos)
local node = minetest.get_node(pos)
if mesecon:is_conductor_off(node.name) or mesecon:is_receptor_off(node.name) then
return true
end
return false
end
function mesecon:turnon(pos, rulename)
local node = minetest.get_node(pos)
if mesecon:is_conductor_off(node.name) then
local rules = mesecon:conductor_get_rules(node)
minetest.add_node(pos, {name = mesecon:get_conductor_on(node.name), param2 = node.param2})
for _, rule in ipairs(rules) do
local np = mesecon:addPosRule(pos, rule)
local link, rulename = mesecon:rules_link(pos, np)
if link then
mesecon:turnon(np, rulename)
end
end
elseif mesecon:is_effector(node.name) then
mesecon:changesignal(pos, node, rulename, mesecon.state.on)
if mesecon:is_effector_off(node.name) then
mesecon:activate(pos, node, rulename)
end
end
end
function mesecon:turnoff(pos, rulename)
local node = minetest.get_node(pos)
if mesecon:is_conductor_on(node.name) then
local rules = mesecon:conductor_get_rules(node)
minetest.add_node(pos, {name = mesecon:get_conductor_off(node.name), param2 = node.param2})
for _, rule in ipairs(rules) do
local np = mesecon:addPosRule(pos, rule)
local link, rulename = mesecon:rules_link(pos, np)
if link then
mesecon:turnoff(np, rulename)
end
end
elseif mesecon:is_effector(node.name) then
mesecon:changesignal(pos, node, rulename, mesecon.state.off)
if mesecon:is_effector_on(node.name)
and not mesecon:is_powered(pos) then
mesecon:deactivate(pos, node, rulename)
end
end
end
function mesecon:connected_to_receptor(pos)
local node = minetest.get_node(pos)
-- Check if conductors around are connected
local rules = mesecon:get_any_inputrules(node)
if not rules then return false end
for _, rule in ipairs(rules) do
local np = mesecon:addPosRule(pos, rule)
if mesecon:rules_link(np, pos) then
if mesecon:find_receptor_on(np, {}) then
return true
end
end
end
return false
end
function mesecon:find_receptor_on(pos, checked)
-- find out if node has already been checked (to prevent from endless loop)
for _, cp in ipairs(checked) do
if mesecon:cmpPos(cp, pos) then
return false, checked
end
end
-- add current position to checked
table.insert(checked, {x=pos.x, y=pos.y, z=pos.z})
local node = minetest.get_node(pos)
if mesecon:is_receptor_on(node.name) then
return true
end
if mesecon:is_conductor(node.name) then
local rules = mesecon:conductor_get_rules(node)
for _, rule in ipairs(rules) do
local np = mesecon:addPosRule(pos, rule)
if mesecon:rules_link(np, pos) then
if mesecon:find_receptor_on(np, checked) then
return true
end
end
end
end
return false
end
function mesecon:rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug), second return value: the name of the affected input rule
local outputnode = minetest.get_node(output)
local inputnode = minetest.get_node(input)
local outputrules = dug_outputrules or mesecon:get_any_outputrules (outputnode)
local inputrules = mesecon:get_any_inputrules (inputnode)
if not outputrules or not inputrules then
return
end
for _, outputrule in ipairs(outputrules) do
-- Check if output sends to input
if mesecon:cmpPos(mesecon:addPosRule(output, outputrule), input) then
for _, inputrule in ipairs(inputrules) do
-- Check if input accepts from output
if mesecon:cmpPos(mesecon:addPosRule(input, inputrule), output) then
return true, inputrule.name
end
end
end
end
return false
end
function mesecon:rules_link_anydir(pos1, pos2)
return mesecon:rules_link(pos1, pos2) or mesecon:rules_link(pos2, pos1)
end
function mesecon:is_powered(pos)
local node = minetest.get_node(pos)
local rules = mesecon:get_any_inputrules(node)
if not rules then return false end
for _, rule in ipairs(rules) do
local np = mesecon:addPosRule(pos, rule)
local nn = minetest.get_node(np)
if (mesecon:is_conductor_on (nn.name) or mesecon:is_receptor_on (nn.name))
and mesecon:rules_link(np, pos) then
return true
end
end
return false
end
--Rules rotation Functions:
function mesecon:rotate_rules_right(rules)
local nr = {}
for i, rule in ipairs(rules) do
table.insert(nr, {
x = -rule.z,
y = rule.y,
z = rule.x})
end
return nr
end
function mesecon:rotate_rules_left(rules)
local nr = {}
for i, rule in ipairs(rules) do
table.insert(nr, {
x = rule.z,
y = rule.y,
z = -rule.x})
end
return nr
end
function mesecon:rotate_rules_down(rules)
local nr = {}
for i, rule in ipairs(rules) do
table.insert(nr, {
x = -rule.y,
y = rule.x,
z = rule.z})
end
return nr
end
function mesecon:rotate_rules_up(rules)
local nr = {}
for i, rule in ipairs(rules) do
table.insert(nr, {
x = rule.y,
y = -rule.x,
z = rule.z})
end
return nr
end

View 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 = false,
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, dig_by_water=1, mesecon_conductor_craftable=1},
description="Redstone",
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 = false,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
},
groups = {dig_immediate=3, dig_by_water = 1, 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"
}}
})

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

@ -0,0 +1,28 @@
mesecon.on_placenode = function (pos, node)
if mesecon:is_receptor_on(node.name) then
mesecon:receptor_on(pos, mesecon:receptor_get_rules(node))
elseif mesecon:is_powered(pos) then
if mesecon:is_conductor(node.name) then
mesecon:turnon (pos)
mesecon:receptor_on (pos, mesecon:conductor_get_rules(node))
else
mesecon:changesignal(pos, node)
mesecon:activate(pos, node)
end
elseif mesecon:is_conductor_on(node.name) then
mesecon:swap_node(pos, mesecon:get_conductor_off(node.name))
elseif mesecon:is_effector_on (node.name) then
mesecon:deactivate(pos, node)
end
end
mesecon.on_dignode = function (pos, node)
if mesecon:is_conductor_on(node.name) then
mesecon:receptor_off(pos, mesecon:conductor_get_rules(node))
elseif mesecon:is_receptor_on(node.name) then
mesecon:receptor_off(pos, mesecon:receptor_get_rules(node))
end
end
minetest.register_on_placenode(mesecon.on_placenode)
minetest.register_on_dignode(mesecon.on_dignode)

View file

@ -0,0 +1,7 @@
-- SETTINGS
BLINKY_PLANT_INTERVAL = 3
NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires
PRESSURE_PLATE_INTERVAL = 0.04
OBJECT_DETECTOR_RADIUS = 6
PISTON_MAXIMUM_PUSH = 11 -- +1
MOVESTONE_MAXIMUM_PUSH = 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

View file

@ -0,0 +1,24 @@
function mesecon:swap_node(pos, name)
local node = minetest.get_node(pos)
local data = minetest.get_meta(pos):to_table()
node.name = name
minetest.add_node(pos, node)
minetest.get_meta(pos):from_table(data)
end
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
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

View file

@ -0,0 +1,257 @@
-- naming scheme: wire:(xp)(zp)(xm)(zm)_on/off
-- The conditions in brackets define whether there is a mesecon at that place or not
-- 1 = there is one; 0 = there is none
-- y always means y+
box_center = {-1/16, -.5, -1/16, 1/16, -.5+1/64, 1/16}
box_bump1 = { -2/16, -.5, -2/16, 2/16, -.5+1/64, 2/16 }
box_xp = {1/16, -.5, -1/16, 8/16, -.5+1/64, 1/16}
box_zp = {-1/16, -.5, 1/16, 1/16, -.5+1/64, 8/16}
box_xm = {-8/16, -.5, -1/16, -1/16, -.5+1/64, 1/16}
box_zm = {-1/16, -.5, -8/16, 1/16, -.5+1/64, -1/16}
box_xpy = {.5-1/16, -.5+1/64, -1/16, .5, .4999+1/64, 1/16}
box_zpy = {-1/16, -.5+1/64, .5-1/16, 1/16, .4999+1/64, .5}
box_xmy = {-.5, -.5+1/64, -1/16, -.5+1/16, .4999+1/64, 1/16}
box_zmy = {-1/16, -.5+1/64, -.5, 1/16, .4999+1/64, -.5+1/16}
-- Registering the wires
for xp=0, 1 do
for zp=0, 1 do
for xm=0, 1 do
for zm=0, 1 do
for xpy=0, 1 do
for zpy=0, 1 do
for xmy=0, 1 do
for zmy=0, 1 do
if (xpy == 1 and xp == 0) or (zpy == 1 and zp == 0)
or (xmy == 1 and xm == 0) or (zmy == 1 and zm == 0) then break end
local groups
local nodeid = tostring(xp )..tostring(zp )..tostring(xm )..tostring(zm )..
tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy)
if nodeid == "00000000" then
groups = {dig_immediate = 3, mesecon_conductor_craftable = 1, attach_node = 1, dig_by_water = 1}
wiredesc = "Redstone"
else
groups = {dig_immediate = 3, not_in_creative_inventory = 1, attach_node = 1, dig_by_water = 1}
wiredesc = "Redstone Trail (ID: "..nodeid..")"
end
local nodebox = {}
local adjx = false
local adjz = false
if xp == 1 then table.insert(nodebox, box_xp) adjx = true end
if zp == 1 then table.insert(nodebox, box_zp) adjz = true end
if xm == 1 then table.insert(nodebox, box_xm) adjx = true end
if zm == 1 then table.insert(nodebox, box_zm) adjz = true end
if xpy == 1 then table.insert(nodebox, box_xpy) end
if zpy == 1 then table.insert(nodebox, box_zpy) end
if xmy == 1 then table.insert(nodebox, box_xmy) end
if zmy == 1 then table.insert(nodebox, box_zmy) end
if adjx and adjz and (xp + zp + xm + zm > 2) then
table.insert(nodebox, box_bump1)
tiles_off = {
"jeija_mesecon_crossing_off.png",
"jeija_mesecon_crossing_off.png",
"jeija_mesecon_off.png",
"jeija_mesecon_off.png",
"jeija_mesecon_off.png",
"jeija_mesecon_off.png"
}
tiles_on = {
"jeija_mesecon_crossing_on.png",
"jeija_mesecon_crossing_on.png",
"jeija_mesecon_on.png",
"jeija_mesecon_on.png",
"jeija_mesecon_on.png",
"jeija_mesecon_on.png"
}
else
table.insert(nodebox, box_center)
tiles_off = {
"jeija_mesecon_crossing_off.png",
"jeija_mesecon_crossing_off.png",
"jeija_mesecon_off.png",
"jeija_mesecon_off.png",
"jeija_mesecon_off.png",
"jeija_mesecon_off.png"
}
tiles_on = {
"jeija_mesecon_crossing_on.png",
"jeija_mesecon_crossing_on.png",
"jeija_mesecon_on.png",
"jeija_mesecon_on.png",
"jeija_mesecon_on.png",
"jeija_mesecon_on.png"
}
end
if nodeid == "00000000" then
nodebox = {-8/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
end
minetest.register_node("mesecons:wire_"..nodeid.."_off", {
description = "Redstone",
drawtype = "nodebox",
tiles = tiles_off,
is_ground_content = false,
-- inventory_image = "wires_inv.png",
-- wield_image = "wires_inv.png",
inventory_image = "redstone_redstone_dust.png",
wield_image = "redstone_redstone_dust.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5}
},
node_box = {
type = "fixed",
fixed = nodebox
},
groups = groups,
walkable = false,
stack_max = 64,
drop = "mesecons:wire_00000000_off",
mesecons = {conductor={
state = mesecon.state.off,
onstate = "mesecons:wire_"..nodeid.."_on"
}},
sounds = mcl_sounds.node_sound_defaults(),
})
minetest.register_node("mesecons:wire_"..nodeid.."_on", {
description = "Redstone",
drawtype = "nodebox",
tiles = tiles_on,
is_ground_content = false,
-- inventory_image = "wires_inv.png",
-- wield_image = "wires_inv.png",
inventory_image = "redstone_redstone_dust.png",
wield_image = "redstone_redstone_dust.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5}
},
node_box = {
type = "fixed",
fixed = nodebox
},
groups = {dig_immediate = 3, mesecon = 2, dig_by_water = 1, not_in_creative_inventory = 1},
walkable = false,
stack_max = 64,
drop = "mesecons:wire_00000000_off",
mesecons = {conductor={
state = mesecon.state.on,
offstate = "mesecons:wire_"..nodeid.."_off"
}},
sounds = mcl_sounds.node_sound_defaults(),
})
end
end
end
end
end
end
end
end
-- Updating the wires:
-- Place the right connection wire
local update_on_place_dig = function (pos, node)
if minetest.registered_nodes[node.name]
and minetest.registered_nodes[node.name].mesecons then
mesecon:update_autoconnect(pos)
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)
local xppos = {x=pos.x+1, y=pos.y, z=pos.z}
local zppos = {x=pos.x, y=pos.y, z=pos.z+1}
local xmpos = {x=pos.x-1, y=pos.y, z=pos.z}
local zmpos = {x=pos.x, y=pos.y, z=pos.z-1}
local xpympos = {x=pos.x+1, y=pos.y-1, z=pos.z}
local zpympos = {x=pos.x, y=pos.y-1, z=pos.z+1}
local xmympos = {x=pos.x-1, y=pos.y-1, z=pos.z}
local zmympos = {x=pos.x, y=pos.y-1, z=pos.z-1}
local xpypos = {x=pos.x+1, y=pos.y+1, z=pos.z}
local zpypos = {x=pos.x, y=pos.y+1, z=pos.z+1}
local xmypos = {x=pos.x-1, y=pos.y+1, z=pos.z}
local zmypos = {x=pos.x, y=pos.y+1, z=pos.z-1}
if secondcall == nil then
mesecon:update_autoconnect(xppos, true)
mesecon:update_autoconnect(zppos, true)
mesecon:update_autoconnect(xmpos, true)
mesecon:update_autoconnect(zmpos, true)
mesecon:update_autoconnect(xpypos, true)
mesecon:update_autoconnect(zpypos, true)
mesecon:update_autoconnect(xmypos, true)
mesecon:update_autoconnect(zmypos, true)
mesecon:update_autoconnect(xpympos, true)
mesecon:update_autoconnect(zpympos, true)
mesecon:update_autoconnect(xmympos, true)
mesecon:update_autoconnect(zmympos, true)
end
local nodename = minetest.get_node(pos).name
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 mesecon:rules_link_anydir(pos, xpympos) then xp = 1 end
if mesecon:rules_link_anydir(pos, xmympos) then xm = 1 end
if mesecon:rules_link_anydir(pos, zpympos) then zp = 1 end
if mesecon:rules_link_anydir(pos, zmympos) then zm = 1 end
if mesecon:rules_link_anydir(pos, xpypos) then xpy = 1 else xpy = 0 end
if mesecon:rules_link_anydir(pos, zpypos) then zpy = 1 else zpy = 0 end
if mesecon:rules_link_anydir(pos, xmypos) then xmy = 1 else xmy = 0 end
if mesecon:rules_link_anydir(pos, zmypos) then zmy = 1 else zmy = 0 end
if xpy == 1 then xp = 1 end
if zpy == 1 then zp = 1 end
if xmy == 1 then xm = 1 end
if zmy == 1 then zm = 1 end
local nodeid = tostring(xp )..tostring(zp )..tostring(xm )..tostring(zm )..
tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy)
if string.find(nodename, "_off") ~= nil then
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
else
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
end
end
minetest.register_alias("mesecons:redstone", "mesecons:wire_00000000_off")
minetest.register_craft({
type = "cooking",
output = "mesecons:redstone",
recipe = "mcl_core:stone_with_redstone",
cooktime = 10,
})

View file

@ -0,0 +1 @@
mesecons

View file

@ -0,0 +1,41 @@
-- This file registers aliases for the /give /giveme commands.
minetest.register_alias("mesecons:removestone", "mesecons_random:removestone")
minetest.register_alias("mesecons:power_plant", "mesecons_powerplant:power_plant")
minetest.register_alias("mesecons:powerplant", "mesecons_powerplant:power_plant")
minetest.register_alias("mesecons:meselamp", "mesecons_lamp:lamp_off")
minetest.register_alias("mesecons:mesecon", "mesecons:wire_00000000_off")
minetest.register_alias("mesecons:object_detector", "mesecons_detector:object_detector_off")
minetest.register_alias("mesecons:wireless_inverter", "mesecons_wireless:wireless_inverter_on")
minetest.register_alias("mesecons:wireless_receiver", "mesecons_wireless:wireless_receiver_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:button", "mesecons_button:button_off")
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:mesecon_torch", "mesecons_torch:mesecon_torch_on")
minetest.register_alias("mesecons:torch", "mesecons_torch:mesecon_torch_on")
minetest.register_alias("mesecons:hydro_turbine", "mesecons_hydroturbine:hydro_turbine_off")
minetest.register_alias("mesecons:pressure_plate_stone", "mesecons_pressureplates:pressure_plate_stone_off")
minetest.register_alias("mesecons:pressure_plate_wood", "mesecons_pressureplates:pressure_plate_wood_off")
minetest.register_alias("mesecons:mesecon_socket", "mesecons_temperest:mesecon_socket_off")
minetest.register_alias("mesecons:mesecon_inverter", "mesecons_temperest:mesecon_inverter_on")
minetest.register_alias("mesecons:movestone", "mesecons_movestones:movestone")
minetest.register_alias("mesecons:sticky_movestone", "mesecons_movestones:sticky_movestone")
minetest.register_alias("mesecons:noteblock", "mesecons_noteblock:noteblock")
minetest.register_alias("mesecons:microcontroller", "mesecons_microcontroller:microcontroller0000")
minetest.register_alias("mesecons:delayer", "mesecons_delayer:delayer_off_1")
minetest.register_alias("mesecons:solarpanel", "mesecons_solarpanel:solar_panel_off")
--Backwards compatibility
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")
--MineClone 2 specials
minetest.register_alias("mesecons_materials:glue", "mcl_mobitems:slimeball")

View file

@ -0,0 +1 @@
mesecons

View file

@ -0,0 +1,156 @@
-- 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_stone_on" then --has not been dug
mesecon:swap_node(pos, "mesecons_button:button_stone_off")
minetest.sound_play("mesecons_button_pop", {pos=pos})
local rules = mesecon.rules.buttonlike_get(node)
mesecon:receptor_off(pos, rules)
elseif node.name=="mesecons_button:button_wood_on" then --has not been dug
mesecon:swap_node(pos, "mesecons_button:button_wood_off")
minetest.sound_play("mesecons_button_pop", {pos=pos})
local rules = mesecon.rules.buttonlike_get(node)
mesecon:receptor_off(pos, rules)
end
end
local boxes_off = { -4/16, -2/16, 8/16, 4/16, 2/16, 6/16 } -- The button
local boxes_on = { -4/16, -2/16, 8/16, 4/16, 2/16, 7/16 } -- The button
minetest.register_node("mesecons_button:button_stone_off", {
drawtype = "nodebox",
tiles = {"default_stone.png"},
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
walkable = false,
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = boxes_off
},
node_box = {
type = "fixed",
fixed = boxes_off -- the button itself
},
groups = {cracky=3, attached_node=1, dig_by_water=1},
description = "Stone Button",
on_rightclick = function (pos, node)
mesecon:swap_node(pos, "mesecons_button:button_stone_on")
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 = mcl_sounds.node_sound_stone_defaults(),
mesecons = {receptor = {
state = mesecon.state.off,
rules = mesecon.rules.buttonlike_get
}}
})
minetest.register_node("mesecons_button:button_stone_on", {
drawtype = "nodebox",
tiles = {"default_stone.png"},
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
walkable = false,
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = boxes_on
},
node_box = {
type = "fixed",
fixed = boxes_on -- the button itself
},
groups = {cracky=3, not_in_creative_inventory=1, attached_node=1, dig_by_water=1},
drop = 'mesecons_button:button_stone_off',
description = "Stone Button",
sounds = mcl_sounds.node_sound_stone_defaults(),
mesecons = {receptor = {
state = mesecon.state.on,
rules = mesecon.rules.buttonlike_get
}}
})
minetest.register_node("mesecons_button:button_wood_off", {
drawtype = "nodebox",
tiles = {"default_wood.png"},
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
walkable = false,
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = boxes_off
},
node_box = {
type = "fixed",
fixed = boxes_off -- the button itself
},
groups = {choppy=3, attached_node=1, dig_by_water=1},
description = "Wooden Button",
on_rightclick = function (pos, node)
mesecon:swap_node(pos, "mesecons_button:button_wood_on")
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 = mcl_sounds.node_sound_wood_defaults(),
mesecons = {receptor = {
state = mesecon.state.off,
rules = mesecon.rules.buttonlike_get
}}
})
minetest.register_node("mesecons_button:button_wood_on", {
drawtype = "nodebox",
tiles = {"default_wood.png"},
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
walkable = false,
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = boxes_on
},
node_box = {
type = "fixed",
fixed = boxes_on -- the button itself
},
groups = {choppy=3, not_in_creative_inventory=1, attached_node=1, dig_by_water=1},
drop = 'mesecons_button:button_wood_off',
description = "Wooden Button",
sounds = mcl_sounds.node_sound_wood_defaults(),
mesecons = {receptor = {
state = mesecon.state.on,
rules = mesecon.rules.buttonlike_get
}}
})
minetest.register_craft({
output = 'mesecons_button:button_stone_off',
recipe = {
{'mcl_core:stone'},
}
})
minetest.register_craft({
output = 'mesecons_button:button_wood_off',
recipe = {
{'group:wood'},
}
})
minetest.register_craft({
type = "fuel",
recipe = 'mesecons_button:button_wood_off',
burntime = 5,
})

View file

@ -0,0 +1,3 @@
mesecons
doc?
doc_items?

View file

@ -0,0 +1,208 @@
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("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 function initialize_data(meta)
local commands = minetest.formspec_escape(meta:get_string("commands"))
meta:set_string("formspec",
"invsize[9,5;]" ..
"textarea[0.5,0.5;8.5,4;commands;Commands;"..commands.."]" ..
"label[1,3.8;@nearest, @farthest, and @random are replaced by the respective player names]" ..
"button_exit[3.3,4.5;2,1;submit;Submit]")
local owner = meta:get_string("owner")
if owner == "" then
owner = "not owned"
else
owner = "owned by " .. owner
end
end
local function construct(pos)
local meta = minetest.get_meta(pos)
meta:set_string("commands", "")
meta:set_string("owner", "")
initialize_data(meta)
end
local function after_place(pos, placer)
if placer then
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name())
initialize_data(meta)
end
end
local function receive_fields(pos, formname, fields, sender)
if not fields.submit then
return
end
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if owner ~= "" and sender:get_player_name() ~= owner then
return
end
meta:set_string("commands", fields.commands)
initialize_data(meta)
end
local function resolve_commands(commands, pos)
local players = minetest.get_connected_players()
-- No players online: remove all commands containing
-- @nearest, @farthest and @random
if #players == 0 then
commands = commands:gsub("[^\r\n]+", function (line)
if line:find("@nearest") then return "" end
if line:find("@farthest") then return "" end
if line:find("@random") then return "" end
return line
end)
return commands
end
local nearest, farthest = nil, nil
local min_distance, max_distance = math.huge, -1
for index, player in pairs(players) do
local distance = vector.distance(pos, player:getpos())
if distance < min_distance then
min_distance = distance
nearest = player:get_player_name()
end
if distance > max_distance then
max_distance = distance
farthest = player:get_player_name()
end
end
local random = players[math.random(#players)]:get_player_name()
commands = commands:gsub("@nearest", nearest)
commands = commands:gsub("@farthest", farthest)
commands = commands:gsub("@random", random)
return commands
end
local function commandblock_action_on(pos, node)
if node.name ~= "mesecons_commandblock:commandblock_off" then
return
end
minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_on"})
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if owner == "" then
return
end
local commands = resolve_commands(meta:get_string("commands"), pos)
for _, command in pairs(commands:split("\n")) do
local pos = command:find(" ")
local cmd, param = command, ""
if pos then
cmd = command:sub(1, pos - 1)
param = command:sub(pos + 1)
end
local cmddef = minetest.chatcommands[cmd]
if not cmddef then
minetest.chat_send_player(owner, "The command "..cmd.." does not exist")
return
end
local has_privs, missing_privs = minetest.check_player_privs(owner, cmddef.privs)
if not has_privs then
minetest.chat_send_player(owner, "You don't have permission "
.."to run "..cmd
.." (missing privileges: "
..table.concat(missing_privs, ", ")..")")
return
end
cmddef.func(owner, param)
end
end
local function commandblock_action_off(pos, node)
if node.name == "mesecons_commandblock:commandblock_on" then
minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_off"})
end
end
local function can_dig(pos, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
return owner == "" or owner == player:get_player_name()
end
minetest.register_node("mesecons_commandblock:commandblock_off", {
description = "Command Block",
tiles = {{name="jeija_commandblock_off.png", animation={type="vertical_frames", aspect_w=32, aspect_h=32, length=2}}},
groups = {mesecon_effector_off=1, not_in_creative_inventory=1, oddly_breakable_by_hand=5},
drop = "",
on_blast = function() end,
on_construct = construct,
is_ground_content = false,
after_place_node = after_place,
on_receive_fields = receive_fields,
can_dig = can_dig,
sounds = mcl_sounds.node_sound_stone_defaults(),
mesecons = {effector = {
action_on = commandblock_action_on
}},
})
minetest.register_node("mesecons_commandblock:commandblock_on", {
tiles = {{name="jeija_commandblock_off.png", animation={type="vertical_frames", aspect_w=32, aspect_h=32, length=2}}},
groups = {mesecon_effector_on=1, not_in_creative_inventory=1, oddly_breakable_by_hand=5},
drop = "",
on_blast = function() end,
on_construct = construct,
is_ground_content = false,
after_place_node = after_place,
on_receive_fields = receive_fields,
can_dig = can_dig,
sounds = mcl_sounds.node_sound_stone_defaults(),
mesecons = {effector = {
action_off = commandblock_action_off
}}
})

View file

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

View file

@ -0,0 +1,151 @@
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",
is_ground_content = false,
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",
is_ground_content = false,
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

View file

@ -0,0 +1 @@
mesecons

View file

@ -0,0 +1,204 @@
-- 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
mesecon:swap_node(pos, def.delayer_onstate)
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
mesecon:swap_node(pos, def.delayer_offstate)
minetest.after(time, delayer_turnoff, {pos = pos, node = node})
end
-- Register the 2 (states) x 4 (delay times) delayers
for i = 1, 4 do
local groups = {}
if i == 1 then
groups = {snappy=1,dig_immediate=3,dig_by_water=1}
else
groups = {snappy=1,dig_immediate=3,dig_by_water=1, not_in_creative_inventory=1}
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
local boxes
if i == 1 then
boxes = {
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab
{ 6/16, -6/16, -1/16, 4/16, -1/16, 1/16}, -- still torch
{ 0/16, -6/16, -1/16, 2/16, -1/16, 1/16}, -- moved torch
}
elseif i == 2 then
boxes = {
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab
{ 6/16, -6/16, -1/16, 4/16, -1/16, 1/16}, -- still torch
{ -2/16, -6/16, -1/16, 0/16, -1/16, 1/16}, -- moved torch
}
elseif i == 3 then
boxes = {
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab
{ 6/16, -6/16, -1/16, 4/16, -1/16, 1/16}, -- still torch
{ -4/16, -6/16, -1/16, -2/16, -1/16, 1/16}, -- moved torch
}
elseif i == 4 then
boxes = {
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab
{ 6/16, -6/16, -1/16, 4/16, -1/16, 1/16}, -- still torch
{ -6/16, -6/16, -1/16, -4/16, -1/16, 1/16}, -- moved torch
}
end
minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), {
description = "Redstone Repeater",
drawtype = "nodebox",
tiles = {
"mesecons_delayer_off.png",
"mesecons_delayer_bottom.png",
"mesecons_delayer_ends_off.png",
"mesecons_delayer_ends_off.png",
"mesecons_delayer_sides_off.png",
"mesecons_delayer_sides_off.png"
},
wield_image = "mesecons_delayer_off.png",
walkable = true,
selection_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 },
},
node_box = {
type = "fixed",
fixed = boxes
},
groups = groups,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = false,
drop = 'mesecons_delayer:delayer_off_1',
on_rightclick = function (pos, node)
if node.name=="mesecons_delayer:delayer_off_1" then
mesecon:swap_node(pos,"mesecons_delayer:delayer_off_2")
elseif node.name=="mesecons_delayer:delayer_off_2" then
mesecon:swap_node(pos,"mesecons_delayer:delayer_off_3")
elseif node.name=="mesecons_delayer:delayer_off_3" then
mesecon:swap_node(pos,"mesecons_delayer:delayer_off_4")
elseif node.name=="mesecons_delayer:delayer_off_4" then
mesecon:swap_node(pos,"mesecons_delayer:delayer_off_1")
end
end,
delayer_time = delaytime,
delayer_onstate = "mesecons_delayer:delayer_on_"..tostring(i),
sounds = mcl_sounds.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
}
}
})
minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), {
description = "You hacker you",
drawtype = "nodebox",
tiles = {
"mesecons_delayer_on.png",
"mesecons_delayer_bottom.png",
"mesecons_delayer_ends_on.png",
"mesecons_delayer_ends_on.png",
"mesecons_delayer_sides_on.png",
"mesecons_delayer_sides_on.png"
},
walkable = true,
selection_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 },
},
node_box = {
type = "fixed",
fixed = boxes
},
groups = {snappy = 1, dig_immediate = 3, dig_by_water=1, not_in_creative_inventory = 1},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = false,
drop = 'mesecons_delayer:delayer_off_1',
on_rightclick = function (pos, node)
if node.name=="mesecons_delayer:delayer_on_1" then
mesecon:swap_node(pos,"mesecons_delayer:delayer_on_2")
elseif node.name=="mesecons_delayer:delayer_on_2" then
mesecon:swap_node(pos,"mesecons_delayer:delayer_on_3")
elseif node.name=="mesecons_delayer:delayer_on_3" then
mesecon:swap_node(pos,"mesecons_delayer:delayer_on_4")
elseif node.name=="mesecons_delayer:delayer_on_4" then
mesecon:swap_node(pos,"mesecons_delayer:delayer_on_1")
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
minetest.register_craft({
output = "mesecons_delayer:delayer_off_1",
recipe = {
{"mesecons_torch:mesecon_torch_on", "mesecons:redstone", "mesecons_torch:mesecon_torch_on"},
{"mcl_core:stone","mcl_core:stone", "mcl_core:stone"},
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

View file

@ -0,0 +1 @@
mesecons

View file

@ -0,0 +1,3 @@
-- dofile(minetest.get_modpath("mesecons_extrawires").."/crossing.lua");
-- The crossing code is not active right now because it is hard to maintain
dofile(minetest.get_modpath("mesecons_extrawires").."/mesewire.lua");

View file

@ -0,0 +1,9 @@
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},
}

View file

@ -0,0 +1 @@
mesecons

View file

@ -0,0 +1,38 @@
minetest.register_node("mesecons_lightstone:lightstone_off", {
tiles = {"jeija_lightstone_gray_off.png"},
inventory_image = minetest.inventorycube("jeija_lightstone_gray_off.png"),
groups = {cracky=2, mesecon_effector_off = 1, mesecon = 2},
is_ground_content = false,
description= "Redstone Lamp",
sounds = mcl_sounds.node_sound_stone_defaults(),
mesecons = {effector = {
action_on = function (pos, node)
mesecon:swap_node(pos, "mesecons_lightstone:lightstone_on")
end
}}
})
minetest.register_node("mesecons_lightstone:lightstone_on", {
tiles = {"jeija_lightstone_gray_on.png"},
inventory_image = minetest.inventorycube("jeija_lightstone_gray_off.png"),
groups = {cracky=2,not_in_creative_inventory=1, mesecon = 2},
drop = "node mesecons_lightstone:lightstone_off",
is_ground_content = false,
-- Real light level: 15 (Minetest caps at 14)
light_source = 14,
sounds = mcl_sounds.node_sound_stone_defaults(),
mesecons = {effector = {
action_off = function (pos, node)
mesecon:swap_node(pos, "mesecons_lightstone:lightstone_off")
end
}}
})
minetest.register_craft({
output = "node mesecons_lightstone:lightstone_off",
recipe = {
{'',"mesecons:redstone",''},
{"mesecons:redstone",'mcl_nether:glowstone',"mesecons:redstone"},
{'','mesecons:redstone',''},
}
})

View file

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

View file

@ -0,0 +1 @@
mesecons

View file

@ -0,0 +1,149 @@
--register stoppers for movestones/pistons
mesecon.mvps_stoppers={}
function mesecon:is_mvps_stopper(node, pushdir, stack, stackid)
local get_stopper = mesecon.mvps_stoppers[node.name]
if type (get_stopper) == "function" then
get_stopper = get_stopper(node, pushdir, stack, stackid)
end
return get_stopper
end
function mesecon:register_mvps_stopper(nodename, get_stopper)
if get_stopper == nil then
get_stopper = true
end
mesecon.mvps_stoppers[nodename] = get_stopper
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
core.check_for_falling(n.pos)
mesecon.on_placenode(n.pos, minetest.get_node(n.pos))
mesecon:update_autoconnect(n.pos)
end
end
function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: direction of push; maximum: maximum nodes to be pushed
np = {x = pos.x, y = pos.y, z = pos.z}
-- determine the number of nodes to be pushed
local nodes = {}
while true do
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
end
if nn.name == "air"
or 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
-- 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
for i in ipairs(nodes) do
nodes[i].pos = mesecon:addPosRule(nodes[i].pos, dir)
end
return true, nodes
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 minetest.registered_nodes[nn.name].liquidtype == "none"
and not mesecon:is_mvps_stopper(nn, {x = -dir.x, y = -dir.y, z = -dir.z}, {{pos = np, node = nn}}, 1) then
local meta = minetest.get_meta(np):to_table()
minetest.remove_node(np)
minetest.add_node(pos, nn)
minetest.get_meta(pos):from_table(meta)
core.check_for_falling(np)
core.check_for_falling(pos)
mesecon.on_dignode(np, nn)
mesecon:update_autoconnect(np)
end
return {{pos = np, node = {param2 = 0, name = "air"}}, {pos = pos, node = nn}}
end
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 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 lnode2 = minetest.get_node(lpos2)
if lnode.name ~= "ignore" and lnode.name ~= "air" and minetest.registered_nodes[lnode.name].liquidtype == "none" then return end
if lnode2.name == "ignore" or lnode2.name == "air" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none") then return end
local oldpos = {x=lpos2.x+direction.x, y=lpos2.y+direction.y, z=lpos2.z+direction.z}
repeat
lnode2 = minetest.get_node(lpos2)
minetest.add_node(oldpos, {name=lnode2.name})
core.check_for_falling(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 not(minetest.registered_nodes[lnode2.name].liquidtype == "none")
minetest.remove_node(oldpos)
end
mesecon:register_mvps_stopper("mcl_core:sign")
mesecon:register_mvps_stopper("mcl_core:obsidian")
mesecon:register_mvps_stopper("mcl_core:bedrock")
mesecon:register_mvps_stopper("mcl_core:barrier")
mesecon:register_mvps_stopper("mcl_chests:chest")
mesecon:register_mvps_stopper("mcl_chests:chest_left")
mesecon:register_mvps_stopper("mcl_chests:chest_right")
mesecon:register_mvps_stopper("mcl_chests:ender_chest")
mesecon:register_mvps_stopper("mcl_furnaces:furnace")
mesecon:register_mvps_stopper("mcl_furnaces:furnace_active")
mesecon:register_mvps_stopper("mcl_hoppers:hopper")
mesecon:register_mvps_stopper("mcl_hoppers:hopper_side")
mesecon:register_mvps_stopper("mcl_droppers:dropper")
mesecon:register_mvps_stopper("mcl_droppers:dropper_up")
mesecon:register_mvps_stopper("mcl_droppers:dropper_down")
mesecon:register_mvps_stopper("mcl_jukebox:jukebox")
mesecon:register_mvps_stopper("mobs:spawner")
mesecon:register_mvps_stopper("mesecons_commandblock:commandblock_off")
mesecon:register_mvps_stopper("mesecons_commandblock:commandblock_on")
mesecon:register_mvps_stopper("mesecons_solarpanel:solar_panel_off")
mesecon:register_mvps_stopper("mesecons_solarpanel:solar_panel_on")
mesecon:register_mvps_stopper("mesecons_solarpanel:solar_panel_inverted_off")
mesecon:register_mvps_stopper("mesecons_solarpanel:solar_panel_inverted_on")
mesecon:register_mvps_stopper("mesecons_noteblock:noteblock")

View file

@ -0,0 +1 @@
mesecons

View file

@ -0,0 +1,86 @@
minetest.register_node("mesecons_noteblock:noteblock", {
description = "Note Block",
tiles = {"mesecons_noteblock.png"},
groups = {choppy=2,oddly_breakable_by_hand=2},
drawtype = "allfaces_optional",
visual_scale = 1.3,
paramtype="light",
is_ground_content = false,
after_place_node = function(pos)
minetest.add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
end,
on_rightclick = function (pos, node) -- change sound when punched
local param2 = node.param2+1
if param2==12 then param2=0 end
minetest.add_node(pos, {name = node.name, param2 = param2})
mesecon.noteblock_play(pos, param2)
end,
sounds = mcl_sounds.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:wood", "mesecons:redstone", "group:wood"},
{"group:wood", "group:wood", "group:wood"},
}
})
minetest.register_craft({
type = "fuel",
recipe = "mesecons_noteblock:noteblock",
burntime = 15
})
mesecon.noteblock_play = function (pos, param2)
local soundname
if param2==8 then
soundname="mesecons_noteblock_a"
elseif param2==9 then
soundname="mesecons_noteblock_asharp"
elseif param2==10 then
soundname="mesecons_noteblock_b"
elseif param2==11 then
soundname="mesecons_noteblock_c"
elseif param2==0 then
soundname="mesecons_noteblock_csharp"
elseif param2==1 then
soundname="mesecons_noteblock_d"
elseif param2==2 then
soundname="mesecons_noteblock_dsharp"
elseif param2==3 then
soundname="mesecons_noteblock_e"
elseif param2==4 then
soundname="mesecons_noteblock_f"
elseif param2==5 then
soundname="mesecons_noteblock_fsharp"
elseif param2==6 then
soundname="mesecons_noteblock_g"
elseif param2==7 then
soundname="mesecons_noteblock_gsharp"
end
local block_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
if block_below_name == "mcl_core:glass" then
soundname="mesecons_noteblock_hihat"
end
if block_below_name == "mcl_core:stone" then
soundname="mesecons_noteblock_kick"
end
if block_below_name == "mcl_core:chest" then
soundname="mesecons_noteblock_snare"
end
if block_below_name == "mcl_core:tree" then
soundname="mesecons_noteblock_crash"
end
if block_below_name == "mcl_core:wood" then
soundname="mesecons_noteblock_litecrash"
end
minetest.sound_play(soundname,
{pos = pos, gain = 1.0, max_hear_distance = 32,})
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

View file

@ -0,0 +1,3 @@
mesecons
mesecons_mvps
mcl_mobitems

View file

@ -0,0 +1,764 @@
-- 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}}
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
dir = piston_get_direction(pistonspec.dir, node)
local pusherpos = mesecon:addPosRule(pos, dir)
local pushername = minetest.get_node(pusherpos).name
if pushername == pistonspec.pusher then --make sure there actually is a pusher (for compatibility reasons mainly)
minetest.remove_node(pusherpos)
core.check_for_falling(pusherpos)
end
end
local piston_on = function (pos, node)
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
dir = piston_get_direction(pistonspec.dir, node)
local np = mesecon:addPosRule(pos, dir)
success, stack = 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})
mesecon:mvps_process_stack(stack)
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(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",
tiles = {
"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",
is_ground_content = false,
after_place_node = piston_orientate,
mesecons_piston = pistonspec_normal,
sounds = mcl_sounds.node_sound_wood_defaults(),
mesecons = {effector={
action_on = piston_on,
rules = piston_get_rules
}}
})
-- 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",
is_ground_content = false,
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 = mcl_sounds.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",
is_ground_content = false,
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",
tiles = {
"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",
is_ground_content = false,
after_place_node = piston_orientate,
mesecons_piston = pistonspec_sticky,
sounds = mcl_sounds.node_sound_wood_defaults(),
mesecons = {effector={
action_on = piston_on,
rules = piston_get_rules
}}
})
-- onstate
minetest.register_node("mesecons_pistons:piston_sticky_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",
is_ground_content = false,
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 = mcl_sounds.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",
is_ground_content = false,
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",
is_ground_content = false,
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",
is_ground_content = false,
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 = mcl_sounds.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",
is_ground_content = false,
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",
is_ground_content = false,
drop = "mesecons_pistons:piston_sticky_off",
mesecons_piston = pistonspec_sticky_up,
sounds = mcl_sounds.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",
is_ground_content = false,
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 = mcl_sounds.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",
is_ground_content = false,
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",
is_ground_content = false,
drop = "mesecons_pistons:piston_normal_off",
mesecons_piston = pistonspec_normal_down,
sounds = mcl_sounds.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",
is_ground_content = false,
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 = mcl_sounds.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",
is_ground_content = false,
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",
is_ground_content = false,
drop = "mesecons_pistons:piston_sticky_off",
mesecons_piston = pistonspec_sticky_down,
sounds = mcl_sounds.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",
is_ground_content = false,
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 = mcl_sounds.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",
is_ground_content = false,
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
return true
end
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({
output = 'mesecons_pistons:piston_normal_off',
recipe = {
{"group:wood", "group:wood", "group:wood"},
{"mcl_core:cobble", "mcl_core:iron_ingot", "mcl_core:cobble"},
{"mcl_core:cobble", "mesecons:redstone", "mcl_core:cobble"},
}
})
minetest.register_craft({
output = "mesecons_pistons:piston_sticky_off",
recipe = {
{"mcl_mobitems:slimeball"},
{"mesecons_pistons:piston_normal_off"},
}
})

View file

@ -0,0 +1 @@
mesecons

View file

@ -0,0 +1,133 @@
local pp_box_off = {
type = "fixed",
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
}
local pp_box_on = {
type = "fixed",
fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 },
}
pp_on_timer = function (pos, elapsed)
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
local objpos = obj:getpos()
if objpos.y > pos.y-1 and objpos.y < pos.y then
minetest.add_node(pos, {name=ppspec.onstate})
mesecon:receptor_on(pos)
-- force activation of mesecon two blocks below (hacky)
mesecon:turnon(two_below)
end
end
end
return true
end
-- Register a Pressure Plate
-- offstate: name of the pressure plate when inactive
-- 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
function mesecon:register_pressure_plate(offstate, onstate, description, texture_off, texture_on, recipe, sounds)
local ppspec = {
offstate = offstate,
onstate = onstate
}
minetest.register_node(offstate, {
drawtype = "nodebox",
tiles = {texture_off},
wield_image = texture_off,
paramtype = "light",
selection_box = pp_box_off,
node_box = pp_box_off,
groups = {snappy = 2, oddly_breakable_by_hand = 3, attached_node = 1},
is_ground_content = false,
description = description,
pressureplate = ppspec,
on_timer = pp_on_timer,
sounds = sounds,
mesecons = {receptor = {
state = mesecon.state.off
}},
on_construct = function(pos)
minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
end,
})
minetest.register_node(onstate, {
drawtype = "nodebox",
tiles = {texture_on},
paramtype = "light",
selection_box = pp_box_on,
node_box = pp_box_on,
groups = {snappy = 2, oddly_breakable_by_hand = 3, attached_node = 1, not_in_creative_inventory = 1},
is_ground_content = false,
drop = offstate,
pressureplate = ppspec,
on_timer = pp_on_timer,
sounds = sounds,
mesecons = {receptor = {
state = mesecon.state.on
}},
on_construct = function(pos)
minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
end,
after_dig_node = function(pos)
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})
if not mesecon:connected_to_receptor(two_below) then
mesecon:turnoff(two_below)
end
end
})
minetest.register_craft({
output = offstate,
recipe = recipe,
})
end
mesecon:register_pressure_plate(
"mesecons_pressureplates:pressure_plate_wood_off",
"mesecons_pressureplates:pressure_plate_wood_on",
"Wooden Pressure Plate",
"default_wood.png",
"default_wood.png",
{{"group:wood", "group:wood"}},
mcl_sounds.node_sound_wood_defaults())
mesecon:register_pressure_plate(
"mesecons_pressureplates:pressure_plate_stone_off",
"mesecons_pressureplates:pressure_plate_stone_on",
"Stone Pressure Plate",
"default_stone.png",
"default_stone.png",
{{"mcl_core:stone", "mcl_core:stone"}},
mcl_sounds.node_sound_stone_defaults())
minetest.register_craft({
type = "fuel",
recipe = "mesecons_pressureplates:pressure_plate_wood_off",
burntime = 15
})

View file

@ -0,0 +1 @@
mesecons

View file

@ -0,0 +1,194 @@
local boxes = { -8/16, -8/16, -8/16, 8/16, -2/16, 8/16 } -- Solar Pannel
-- Solar Panel
minetest.register_node("mesecons_solarpanel:solar_panel_on", {
drawtype = "nodebox",
tiles = { "jeija_solar_panel.png","jeija_solar_panel.png","jeija_solar_panel_side.png",
"jeija_solar_panel_side.png","jeija_solar_panel_side.png","jeija_solar_panel_side.png", },
wield_image = "jeija_solar_panel.png",
wield_scale = { x=1, y=1, z=3 },
paramtype = "light",
is_ground_content = false,
selection_box = {
type = "fixed",
fixed = boxes
},
node_box = {
type = "fixed",
fixed = boxes
},
drop = "mesecons_solarpanel:solar_panel_off",
description="Daylight Sensor",
groups = {dig_immediate=3, not_in_creative_inventory = 1},
sounds = mcl_sounds.node_sound_glass_defaults(),
mesecons = {receptor = {
state = mesecon.state.on
}},
on_rightclick = function(pos, node, clicker, pointed_thing)
minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_inverted_off"})
mesecon:receptor_off(pos)
end,
})
-- Solar Panel
minetest.register_node("mesecons_solarpanel:solar_panel_off", {
drawtype = "nodebox",
tiles = { "jeija_solar_panel.png","jeija_solar_panel.png","jeija_solar_panel_side.png",
"jeija_solar_panel_side.png","jeija_solar_panel_side.png","jeija_solar_panel_side.png", },
wield_image = "jeija_solar_panel.png",
wield_scale = { x=1, y=1, z=3 },
paramtype = "light",
is_ground_content = false,
selection_box = {
type = "fixed",
fixed = boxes
},
node_box = {
type = "fixed",
fixed = boxes
},
groups = {dig_immediate=3},
description="Daylight Sensor",
sounds = mcl_sounds.node_sound_glass_defaults(),
mesecons = {receptor = {
state = mesecon.state.off
}},
on_rightclick = function(pos, node, clicker, pointed_thing)
minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_inverted_on"})
mesecon:receptor_on(pos)
end,
})
minetest.register_craft({
output = 'mesecons_solarpanel:solar_panel_off',
recipe = {
{'mcl_core:glass', 'mcl_core:glass', 'mcl_core:glass'},
{'mcl_nether:quartz', 'mcl_nether:quartz', 'mcl_nether:quartz'},
{'group:wood_slab', 'group:wood_slab', 'group:wood_slab'},
}
})
minetest.register_abm(
{nodenames = {"mesecons_solarpanel:solar_panel_off"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.get_node_light(pos, nil)
if light >= 12 and minetest.get_timeofday() > 0.2 and minetest.get_timeofday() < 0.8 then
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2})
mesecon:receptor_on(pos)
end
end,
})
minetest.register_abm(
{nodenames = {"mesecons_solarpanel:solar_panel_on"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.get_node_light(pos, nil)
if light < 12 then
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
mesecon:receptor_off(pos)
end
end,
})
--- Solar panel inversed
-- Solar Panel
minetest.register_node("mesecons_solarpanel:solar_panel_inverted_on", {
drawtype = "nodebox",
tiles = { "jeija_solar_panel_inverted.png","jeija_solar_panel_inverted.png","jeija_solar_panel_side.png",
"jeija_solar_panel_side.png","jeija_solar_panel_side.png","jeija_solar_panel_side.png", },
wield_image = "jeija_solar_panel_inverted.png",
wield_scale = { x=1, y=1, z=3 },
paramtype = "light",
is_ground_content = false,
selection_box = {
type = "fixed",
fixed = boxes
},
node_box = {
type = "fixed",
fixed = boxes
},
drop = "mesecons_solarpanel:solar_panel_off",
groups = {dig_immediate=3, not_in_creative_inventory = 1},
description="Inverted Daylight Sensor",
sounds = mcl_sounds.node_sound_glass_defaults(),
mesecons = {receptor = {
state = mesecon.state.on
}},
on_rightclick = function(pos, node, clicker, pointed_thing)
minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_off"})
mesecon:receptor_off(pos)
end,
})
-- Solar Panel
minetest.register_node("mesecons_solarpanel:solar_panel_inverted_off", {
drawtype = "nodebox",
tiles = { "jeija_solar_panel_inverted.png","jeija_solar_panel_inverted.png","jeija_solar_panel_side.png",
"jeija_solar_panel_side.png","jeija_solar_panel_side.png","jeija_solar_panel_side.png", },
wield_image = "jeija_solar_panel_inverted.png",
wield_scale = { x=1, y=1, z=3 },
paramtype = "light",
is_ground_content = false,
selection_box = {
type = "fixed",
fixed = boxes
},
node_box = {
type = "fixed",
fixed = boxes
},
drop = "mesecons_solarpanel:solar_panel_off",
groups = {dig_immediate=3, not_in_creative_inventory=1},
description="Inverted Daylight Sensor",
sounds = mcl_sounds.node_sound_glass_defaults(),
mesecons = {receptor = {
state = mesecon.state.off
}},
on_rightclick = function(pos, node, clicker, pointed_thing)
minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_on"})
mesecon:receptor_on(pos)
end,
})
minetest.register_abm(
{nodenames = {"mesecons_solarpanel:solar_panel_inverted_off"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.get_node_light(pos, nil)
if light < 12 then
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_on", param2=node.param2})
mesecon:receptor_on(pos)
end
end,
})
minetest.register_abm(
{nodenames = {"mesecons_solarpanel:solar_panel_inverted_on"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.get_node_light(pos, nil)
if light >= 12 and minetest.get_timeofday() > 0.8 and minetest.get_timeofday() < 0.2 then
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_off", param2=node.param2})
mesecon:receptor_off(pos)
end
end,
})
minetest.register_craft({
type = "fuel",
recipe = "mesecons_solarpanel:solar_panel_off",
burntime = 15
})

View file

@ -0,0 +1 @@
-- place texture packs for mesecons into the textures folder here

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 916 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 916 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 954 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,017 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

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