Compare commits
78 Commits
Author | SHA1 | Date | |
---|---|---|---|
1711cbcbd8 | |||
6efe579f68 | |||
fa0cf15cd9 | |||
8be0d0e1d9 | |||
f9ce95154e | |||
24160d45ff | |||
682cf34792 | |||
6f83f4cf1e | |||
255e363b04 | |||
ac9a05df0b | |||
cc20b9ba47 | |||
163384f308 | |||
d4f18d08c0 | |||
9299111900 | |||
13757ac854 | |||
0a9bcf26ca | |||
b3fb406727 | |||
b0bef909a0 | |||
fc5245139d | |||
109d817df6 | |||
1a5b1b4691 | |||
10bacdd7f4 | |||
8afc6abcd5 | |||
e88e99b54f | |||
01d8c26b5b | |||
3b1afb1783 | |||
6cfd12e63c | |||
c08e868be2 | |||
f1a327ad16 | |||
e45a2a511e | |||
63a18f1a51 | |||
57e1547515 | |||
3b38bbcaf2 | |||
e789794c75 | |||
2cc38909a1 | |||
36bcce57b0 | |||
21550b3727 | |||
6983db6d82 | |||
1ff437b7b0 | |||
5f9e655c13 | |||
3c3e45c7ea | |||
5fd1cf5c80 | |||
e1211729cc | |||
588e41c786 | |||
79bb4a3433 | |||
e1577eba46 | |||
4406654fa4 | |||
db90c1cb4b | |||
3792b692aa | |||
84d5546df1 | |||
629a52af11 | |||
4c0988ceab | |||
ac23eb070a | |||
e707afef1a | |||
2848df007e | |||
c9e89189eb | |||
36263d481a | |||
a0920104fc | |||
cc41f136cc | |||
8827cfd66f | |||
d36dd865ad | |||
ad9dde706e | |||
09ac201bac | |||
1c4ab938ad | |||
eeed4f148d | |||
10ea3c971b | |||
591e2d7cde | |||
59cd72191b | |||
2b30360da2 | |||
18da94006a | |||
ef087f2bb6 | |||
62ddebaecb | |||
fc384aedbb | |||
ec517becab | |||
0d44144421 | |||
240fb83e8b | |||
e297a02ec2 | |||
bd749ec4d4 |
24
README
@ -1,24 +0,0 @@
|
||||
-- |\ /| ____ ____ ____ _____ ____ _____
|
||||
-- | \ / | | | | | | | |\ | |
|
||||
-- | \/ | |___ ____ |___ | | | | \ | |____
|
||||
-- | | | | | | | | | \ | |
|
||||
-- | | |___ ____| |___ |____ |____| | \| ____|
|
||||
-- by Jeija and contributors
|
||||
|
||||
Credits:
|
||||
Jeija: main developer
|
||||
VanessaE: Awesome textures & design, coding
|
||||
sfan5: coding, textures
|
||||
temperest: coding, textures
|
||||
Jordach: Sounds for the noteblock
|
||||
minerd247: Some textures
|
||||
...other contributors
|
||||
|
||||
This is a mod for minetest-c55.
|
||||
Copy the minetest-mod-mesecons directory into you game's mod folder
|
||||
(e.g. games/minetest_game/mods/minetest-mod-mesecons)
|
||||
|
||||
You can remove modules of this mod by deleting the mesecons_*
|
||||
folders in the minetest-mod-mesecons directory.
|
||||
|
||||
Mod dependencies: none
|
76
README.md
Normal file
@ -0,0 +1,76 @@
|
||||
########################################################################
|
||||
## __ __ _____ _____ _____ _____ _____ _ _ _____ ##
|
||||
## | \ / | | ___| | ___| | ___| | ___| | _ | | \ | | | ___| ##
|
||||
## | \/ | | |___ | |___ | |___ | | | | | | | \| | | |___ ##
|
||||
## | |\__/| | | ___| |___ | | ___| | | | | | | | | |___ | ##
|
||||
## | | | | | |___ ___| | | |___ | |___ | |_| | | |\ | ___| | ##
|
||||
## |_| |_| |_____| |_____| |_____| |_____| |_____| |_| \_| |_____| ##
|
||||
## ##
|
||||
########################################################################
|
||||
|
||||
MESECONS by Jeija and contributors
|
||||
|
||||
Mezzee-what?
|
||||
------------
|
||||
[Mesecons](http://mesecons.net/)! They're yellow, they're conductive, and they'll add a whole new dimension to Minetest's gameplay.
|
||||
|
||||
Mesecons is a mod for [Minetest](http://minetest.net/) that implements a ton of items related to digital circuitry, such as wires, buttons, lights, and even programmable controllers. Among other things, there are also pistons, solar panels, pressure plates, and note blocks.
|
||||
|
||||
Mesecons has a similar goal to Redstone in Minecraft, but works in its own way, with different rules and mechanics.
|
||||
|
||||
OK, I want in.
|
||||
--------------
|
||||
Go get it!
|
||||
|
||||
[DOWNLOADS PAGE](http://mesecons.net/downloads.php)
|
||||
|
||||
Now go ahead and install it like any other Minetest mod. Don't know how? Check out [the wonderful page about it](http://wiki.minetest.com/wiki/Mods) over at the Minetest Wiki. For your convenience, here's a quick summary:
|
||||
|
||||
1. If Mesecons is still in a ZIP file, extract the folder inside to somewhere on the computer.
|
||||
2. Make sure that when you open the folder, you can directly find `README.md` in the listing. If you just see another folder, move that folder up one level and delete the old one.
|
||||
3. Open up the Minetest mods folder - usually `/mods/`. If you see the `minetest` or folder inside of that, that is your mod folder instead.
|
||||
4. Copy the Mesecons folder into the mods folder.
|
||||
|
||||
Don't like some parts of Mesecons? Open up the Mesecons folder and delete the subfolder containing the mod you don't want. If you didn't want movestones, for example, all you have to do is delete the `mesecons_movestones` folder and they will no longer be available.
|
||||
|
||||
There are no dependencies - it will work right after installing!
|
||||
|
||||
How do I use this thing?
|
||||
------------------------
|
||||
How about a [quick overview video](https://www.youtube.com/watch?v=6kmeQj6iW5k)?
|
||||
|
||||
Or maybe a [comprehensive reference](http://mesecons.net/items.php) is your style?
|
||||
|
||||
An overview for the very newest of new beginners? How does [this one](http://uberi.mesecons.net/projects/MeseconsBasics/index.html) look?
|
||||
|
||||
Want to get more into building? Why not check out the [Mesecons Laboratory](http://uberi.mesecons.net/), a website dedicated to advanced Mesecons builders?
|
||||
|
||||
Want to contribute to Mesecons itself? Check out the [source code](https://github.com/Jeija/minetest-mod-mesecons)!
|
||||
|
||||
Who wrote it anyways?
|
||||
---------------------
|
||||
These awesome people made Mesecons possible!
|
||||
|
||||
| Contributor | Contribution |
|
||||
| --------------- | ---------------------------------- |
|
||||
| Jat15 | Various tweaks. |
|
||||
| Jeija | **Main developer! Everything.** |
|
||||
| Jordach | Noteblock sounds. |
|
||||
| khonkhortistan | Coding, recipes, textures. |
|
||||
| Kotolegokot | Nodeboxes for items. |
|
||||
| minerd247 | Textures. |
|
||||
| RealBadAngel | Fixes, improvements. |
|
||||
| sfan5 | Coding, recipes, textures. |
|
||||
| Uberi/Temperest | Coding, textures, documentation. |
|
||||
| VanessaE | Coding, recipes, textures, design. |
|
||||
| Whiskers75 | Logic gates implementation. |
|
||||
|
||||
There are also a whole bunch of other people helping with everything from code to testing and feedback. Mesecons would also not be possible without their help!
|
||||
|
||||
Alright, how can I use it?
|
||||
--------------------------
|
||||
All textures in this project are licensed under the CC-BY-SA 2.0 (Creative Commons Attribution-ShareAlike 2.0 Generic). That means you can distribute and remix them as much as you want to, under the condition that you give credit to the authors and the project, and that if you remix and release them, they must be under the same or similar license to this one.
|
||||
|
||||
All code in this project is licensed under the LGPL version 3 or later. That means you have unlimited freedom to distribute and modify the work however you see fit, provided that if you decide to distribute it or any modified versions of it, you must also use the same license. The LGPL also grants the additional freedom to write extensions for the software and distribute them without the extensions being subject to the terms of the LGPL, although the software itself retains its license.
|
||||
|
||||
No warranty is provided, express or implied, for any part of the project.
|
@ -98,7 +98,7 @@ function mesecon:receptor_off(pos, rules)
|
||||
if not mesecon:connected_to_receptor(np) then
|
||||
mesecon:turnoff(np, rulename)
|
||||
else
|
||||
mesecon:changesignal(np, minetest.env:get_node(np), rulename)
|
||||
mesecon:changesignal(np, minetest.env:get_node(np), rulename, mesecon.state.off)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -24,7 +24,7 @@
|
||||
-- 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) --> Changes the effector node at the specific pos (calls nodedef.mesecons.effector.action_change)
|
||||
-- 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
|
||||
@ -193,10 +193,10 @@ function mesecon:deactivate(pos, node, rulename)
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:changesignal(pos, node, rulename)
|
||||
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)
|
||||
effector.action_change (pos, node, rulename, newstate)
|
||||
end
|
||||
end
|
||||
|
||||
@ -299,7 +299,7 @@ function mesecon:turnon(pos, rulename)
|
||||
end
|
||||
end
|
||||
elseif mesecon:is_effector(node.name) then
|
||||
mesecon:changesignal(pos, node, rulename)
|
||||
mesecon:changesignal(pos, node, rulename, mesecon.state.on)
|
||||
if mesecon:is_effector_off(node.name) then
|
||||
mesecon:activate(pos, node, rulename)
|
||||
end
|
||||
@ -322,7 +322,7 @@ function mesecon:turnoff(pos, rulename)
|
||||
end
|
||||
end
|
||||
elseif mesecon:is_effector(node.name) then
|
||||
mesecon:changesignal(pos, node, rulename)
|
||||
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)
|
||||
|
@ -29,7 +29,7 @@ minetest.register_node("mesecons:mesecon_on", {
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
|
||||
},
|
||||
groups = {dig_immediate=3, not_in_creaive_inventory=1, mesecon=1},
|
||||
drop = '"mesecons:mesecon_off" 1',
|
||||
drop = "mesecons:mesecon_off 1",
|
||||
light_source = LIGHT_MAX-11,
|
||||
mesecons = {conductor={
|
||||
state = mesecon.state.on,
|
||||
|
@ -1,4 +1,5 @@
|
||||
mesecon.on_placenode = function (pos, node)
|
||||
mesecon.on_placenode = function (pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
if mesecon:is_receptor_on(node.name) then
|
||||
mesecon:receptor_on(pos, mesecon:receptor_get_rules(node))
|
||||
elseif mesecon:is_powered(pos) then
|
||||
|
@ -4,3 +4,4 @@ NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires
|
||||
PRESSURE_PLATE_INTERVAL = 0.1
|
||||
OBJECT_DETECTOR_RADIUS = 6
|
||||
PISTON_MAXIMUM_PUSH = 15
|
||||
MOVESTONE_MAXIMUM_PUSH = 100
|
||||
|
@ -22,3 +22,17 @@ end
|
||||
function mesecon:cmpPos(p1, p2)
|
||||
return (p1.x == p2.x and p1.y == p2.y and p1.z == p2.z)
|
||||
end
|
||||
|
||||
function mesecon:tablecopy(table) -- deep table copy
|
||||
local newtable = {}
|
||||
|
||||
for idx, item in pairs(table) do
|
||||
if type(item) == "table" then
|
||||
newtable[idx] = mesecon:tablecopy(item)
|
||||
else
|
||||
newtable[idx] = item
|
||||
end
|
||||
end
|
||||
|
||||
return newtable
|
||||
end
|
||||
|
@ -108,7 +108,7 @@ for zmy=0, 1 do
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5}
|
||||
fixed = {-.5, -.5, -.5, .5, -.5+4/16, .5}
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -137,7 +137,7 @@ for zmy=0, 1 do
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5}
|
||||
fixed = {-.5, -.5, -.5, .5, -.5+4/16, .5}
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -276,6 +276,6 @@ end
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = '"mesecons:wire_00000000_off" 16',
|
||||
output = "mesecons:wire_00000000_off 16",
|
||||
recipe = "default:mese_crystal",
|
||||
})
|
||||
|
@ -9,9 +9,10 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_off", {
|
||||
walkable = false,
|
||||
groups = {dig_immediate=3, mesecon = 2},
|
||||
description="Blinky Plant",
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
|
||||
},
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off
|
||||
@ -26,12 +27,13 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_on", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = {dig_immediate=3, not_in_creative_inventory=1, mesecon = 2},
|
||||
drop='"mesecons_blinkyplant:blinky_plant_off" 1',
|
||||
drop="mesecons_blinkyplant:blinky_plant_off 1",
|
||||
light_source = LIGHT_MAX-7,
|
||||
description = "Blinky Plant",
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
|
||||
},
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on
|
||||
@ -39,11 +41,11 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_on", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_blinkyplant:blinky_plant_off" 1',
|
||||
output = "mesecons_blinkyplant:blinky_plant_off 1",
|
||||
recipe = {
|
||||
{'','"group:mesecon_conductor_craftable"',''},
|
||||
{'','"group:mesecon_conductor_craftable"',''},
|
||||
{'"default:sapling"','"default:sapling"','"default:sapling"'},
|
||||
{"","group:mesecon_conductor_craftable",""},
|
||||
{"","group:mesecon_conductor_craftable",""},
|
||||
{"default:sapling","default:sapling","default:sapling"},
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -6,6 +6,7 @@ mesecon.button_turnoff = function (pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
if node.name=="mesecons_button:button_on" then --has not been dug
|
||||
mesecon:swap_node(pos, "mesecons_button:button_off")
|
||||
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
||||
local rules = mesecon.rules.buttonlike_get(node)
|
||||
mesecon:receptor_off(pos, rules)
|
||||
end
|
||||
@ -42,8 +43,10 @@ minetest.register_node("mesecons_button:button_off", {
|
||||
on_punch = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_button:button_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 = default.node_sound_stone_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off,
|
||||
rules = mesecon.rules.buttonlike_get
|
||||
@ -80,6 +83,7 @@ minetest.register_node("mesecons_button:button_on", {
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon_needs_receiver = 1},
|
||||
drop = 'mesecons_button:button_off',
|
||||
description = "Button",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on,
|
||||
rules = mesecon.rules.buttonlike_get
|
||||
@ -87,8 +91,8 @@ minetest.register_node("mesecons_button:button_on", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_button:button_off" 2',
|
||||
output = "mesecons_button:button_off 2",
|
||||
recipe = {
|
||||
{'"group:mesecon_conductor_craftable"','"default:stone"'},
|
||||
{"group:mesecon_conductor_craftable","default:stone"},
|
||||
}
|
||||
})
|
||||
|
BIN
mesecons_button/sounds/mesecons_button_pop.ogg
Normal file
BIN
mesecons_button/sounds/mesecons_button_push.ogg
Normal file
@ -3,7 +3,7 @@ minetest.register_chatcommand("say", {
|
||||
description = "Say <text> as the server",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
minetest.chat_send_all(param)
|
||||
minetest.chat_send_all(name .. ": " .. param)
|
||||
end
|
||||
})
|
||||
|
||||
@ -16,7 +16,37 @@ minetest.register_chatcommand("tell", {
|
||||
minetest.chat_send_player(name, "Invalid usage: " .. param)
|
||||
return
|
||||
end
|
||||
minetest.chat_send_player(target, name .. " whispers: " .. message)
|
||||
if not minetest.env:get_player_by_name(target) then
|
||||
minetest.chat_send_player(name, "Invalid target: " .. target)
|
||||
end
|
||||
minetest.chat_send_player(target, name .. " whispers: " .. message, false)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("tellme", {
|
||||
params = "<text>",
|
||||
description = "Say <text> to yourself",
|
||||
func = function(name, param)
|
||||
minetest.chat_send_player(name, param, false)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("hp", {
|
||||
params = "<name> <value>",
|
||||
description = "Set health of <name> to <value> hitpoints",
|
||||
privs = {ban=true},
|
||||
func = function(name, param)
|
||||
local found, _, target, value = param:find("^([^%s]+)%s+(%d+)$")
|
||||
if found == nil then
|
||||
minetest.chat_send_player(name, "Invalid usage: " .. param)
|
||||
return
|
||||
end
|
||||
local player = minetest.env:get_player_by_name(target)
|
||||
if player then
|
||||
player:set_hp(value)
|
||||
else
|
||||
minetest.chat_send_player(name, "Invalid target: " .. target)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
@ -152,6 +182,7 @@ minetest.register_node("mesecons_commandblock:commandblock_off", {
|
||||
local owner = minetest.env:get_meta(pos):get_string("owner")
|
||||
return owner == "" or owner == player:get_player_name()
|
||||
end,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_on = commandblock_action_on
|
||||
}}
|
||||
@ -169,6 +200,7 @@ minetest.register_node("mesecons_commandblock:commandblock_on", {
|
||||
local owner = minetest.env:get_meta(pos):get_string("owner")
|
||||
return owner == "" or owner == player:get_player_name()
|
||||
end,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_off = commandblock_action_off
|
||||
}}
|
||||
|
@ -153,6 +153,7 @@ doors:register_door("doors:door_wood", {
|
||||
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1},
|
||||
tiles_bottom = {"door_wood_b.png", "door_brown.png"},
|
||||
tiles_top = {"door_wood_a.png", "door_brown.png"},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
doors:register_door("doors:door_steel", {
|
||||
@ -162,4 +163,5 @@ doors:register_door("doors:door_steel", {
|
||||
tiles_bottom = {"door_steel_b.png", "door_grey.png"},
|
||||
tiles_top = {"door_steel_a.png", "door_grey.png"},
|
||||
only_placer_can_open = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
@ -110,6 +110,7 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), {
|
||||
end,
|
||||
delayer_time = delaytime,
|
||||
delayer_onstate = "mesecons_delayer:delayer_on_"..tostring(i),
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {
|
||||
receptor =
|
||||
{
|
||||
|
@ -1,7 +1,48 @@
|
||||
-- Object detector
|
||||
-- Detects all entities in a certain radius
|
||||
-- Detects players in a certain radius
|
||||
-- The radius can be specified in mesecons/settings.lua
|
||||
|
||||
local object_detector_make_formspec = function (pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec", "size[9,2.5]" ..
|
||||
"field[0.3, 0;9,2;scanname;Name of player to scan for (empty for any):;${scanname}]"..
|
||||
"field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]")
|
||||
end
|
||||
|
||||
local object_detector_on_receive_fields = function (pos, formname, fields)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("scanname", fields.scanname)
|
||||
meta:set_string("digiline_channel", fields.digiline_channel)
|
||||
object_detector_make_formspec(pos)
|
||||
end
|
||||
|
||||
-- returns true if player was found, false if not
|
||||
local object_detector_scan = function (pos)
|
||||
local objs = minetest.env:get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS)
|
||||
for k, obj in pairs(objs) do
|
||||
local isname = obj:get_player_name() -- "" is returned if it is not a player; "" ~= nil!
|
||||
local scanname = minetest.env:get_meta(pos):get_string("scanname")
|
||||
if (isname == scanname and isname ~= "") or (isname ~= "" and scanname == "") then -- player with scanname found or not scanname specified
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- set player name when receiving a digiline signal on a specific channel
|
||||
object_detector_digiline = {
|
||||
effector = {
|
||||
action = function (pos, node, channel, msg)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local active_channel = meta:get_string("digiline_channel")
|
||||
if channel == active_channel then
|
||||
meta:set_string("scanname", msg)
|
||||
object_detector_make_formspec(pos)
|
||||
end
|
||||
end,
|
||||
}
|
||||
}
|
||||
|
||||
minetest.register_node("mesecons_detector:object_detector_off", {
|
||||
tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png"},
|
||||
paramtype = "light",
|
||||
@ -10,7 +51,11 @@ minetest.register_node("mesecons_detector:object_detector_off", {
|
||||
description="Player Detector",
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off
|
||||
}}
|
||||
}},
|
||||
on_construct = object_detector_make_formspec,
|
||||
on_receive_fields = object_detector_on_receive_fields,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
digiline = object_detector_digiline
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_detector:object_detector_on", {
|
||||
@ -21,15 +66,19 @@ minetest.register_node("mesecons_detector:object_detector_on", {
|
||||
drop = 'mesecons_detector:object_detector_off',
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on
|
||||
}}
|
||||
}},
|
||||
on_construct = object_detector_make_formspec,
|
||||
on_receive_fields = object_detector_on_receive_fields,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
digiline = object_detector_digiline
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'mesecons_detector:object_detector_off',
|
||||
recipe = {
|
||||
{"default:steelblock", '', "default:steelblock"},
|
||||
{"default:steelblock", "mesecons_microcontroller:microcontroller0000", "default:steelblock"},
|
||||
{"default:steelblock", "group:mesecon_conductor_craftable", "default:steelblock"},
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "mesecons_luacontroller:luacontroller0000", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "group:mesecon_conductor_craftable", "default:steel_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
@ -37,20 +86,11 @@ minetest.register_abm(
|
||||
{nodenames = {"mesecons_detector:object_detector_off"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local objs = minetest.env:get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_entity_name()~="mesecons_pistons:piston_pusher_sticky" and obj:get_entity_name()~="mesecons_pistons:piston_pusher_normal" and obj:get_player_name()~=nil then
|
||||
if minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name=="default:sign_wall" then
|
||||
if obj:get_player_name()~=minetest.env:get_meta({x=pos.x, y=pos.y-1, z=pos.z}):get_string("text") then
|
||||
return
|
||||
end
|
||||
end
|
||||
local objpos=obj:getpos()
|
||||
minetest.env:add_node(pos, {name="mesecons_detector:object_detector_on"})
|
||||
action = function(pos)
|
||||
if object_detector_scan(pos) then
|
||||
mesecon:swap_node(pos, "mesecons_detector:object_detector_on")
|
||||
mesecon:receptor_on(pos)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
@ -58,24 +98,9 @@ minetest.register_abm(
|
||||
{nodenames = {"mesecons_detector:object_detector_on"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local objs = minetest.env:get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS)
|
||||
local objectfound=0
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_entity_name()~="mesecons_pistons:piston_pusher_sticky" and obj:get_entity_name()~="mesecons_pistons:piston_pusher_normal" and obj~=nil
|
||||
and obj:get_player_name()~=nil then
|
||||
if minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name=="default:sign_wall" then
|
||||
if minetest.env:get_meta({x=pos.x, y=pos.y-1, z=pos.z}):get_string("text")== obj:get_player_name() then
|
||||
objectfound=objectfound+1
|
||||
end
|
||||
else
|
||||
-- Detected object is not piston pusher - will be changed if every entity has a type (like entity_type=mob)
|
||||
objectfound=objectfound + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
if objectfound==0 then
|
||||
minetest.env:add_node(pos, {name="mesecons_detector:object_detector_off"})
|
||||
action = function(pos)
|
||||
if not object_detector_scan(pos) then
|
||||
mesecon:swap_node(pos, "mesecons_detector:object_detector_off")
|
||||
mesecon:receptor_off(pos)
|
||||
end
|
||||
end,
|
||||
|
1
mesecons_dispenser/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
default
|
57
mesecons_dispenser/init.lua
Normal file
@ -0,0 +1,57 @@
|
||||
minetest.register_node("mesecons_dispenser:dispenser", {
|
||||
description = "Dispenser",
|
||||
tiles = {"mesecons_dispenser_top.png" , "mesecons_dispenser_bottom.png",
|
||||
"mesecons_dispenser_side.png", "mesecons_dispenser_side.png" ,
|
||||
"mesecons_dispenser_side.png", "mesecons_dispenser_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"size[8,7]"..
|
||||
"list[current_name;main;2.5,0;3,3;]"..
|
||||
"list[current_player;main;0,3;8,4;]")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 3*3)
|
||||
end,
|
||||
mesecons = {effector={
|
||||
action_on = function (pos, node)
|
||||
local dir = {{x=1, y=0, z=0}}
|
||||
for _ = 0, node.param2 do
|
||||
dir = mesecon:rotate_rules_left(dir)
|
||||
end
|
||||
dir = dir[1]
|
||||
local objpos = mesecon:addPosRule(pos, {x=dir.x/2, y=dir.y/2, z=dir.z/2})
|
||||
--minetest.env:add_node(mesecon:addPosRule(pos, dir[1]), {name="default:wood"})
|
||||
local inv = minetest.env:get_meta(pos):get_inventory()
|
||||
local stacks = {}
|
||||
for j = 1, 9 do
|
||||
local ts = inv:get_stack("main", j)
|
||||
if not ts:is_empty() then
|
||||
table.insert(stacks, {stack = ts, id = j})
|
||||
end
|
||||
end
|
||||
print(dump(stacks))
|
||||
if #stacks > 0 then
|
||||
local sn = math.random(1, #stacks)
|
||||
local takenitem = stacks[sn].stack:take_item()
|
||||
inv:set_stack("main", stacks[sn].id, stacks[sn].stack)
|
||||
print(dump(takenitem:to_table()))
|
||||
local obj = minetest.env:add_item(objpos, takenitem:to_table())
|
||||
obj:setvelocity({ x=dir.x*5+math.random(1, 100)/50-0.5,
|
||||
y=dir.y*5+math.random(1, 100)/50-0.5,
|
||||
z=dir.z*5+math.random(1, 100)/50-0.5})
|
||||
end
|
||||
end
|
||||
}},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'mesecons_dispenser:dispenser',
|
||||
recipe = {
|
||||
{"default:cobble", "default:cobble", "default:cobble"},
|
||||
{"default:cobble", "mesecons_materials:fiber", "default:cobble"},
|
||||
{"default:cobble", "group:mesecon_conductor_craftable", "default:cobble"},
|
||||
}
|
||||
})
|
@ -38,7 +38,7 @@ minetest.register_node("mesecons_extrawires:corner_on", {
|
||||
selection_box = corner_selectionbox,
|
||||
node_box = corner_nodebox,
|
||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||
drop = "mesecons_extrawires:insulated_off",
|
||||
drop = "mesecons_extrawires:corner_off",
|
||||
mesecons = {conductor =
|
||||
{
|
||||
state = mesecon.state.on,
|
||||
@ -74,7 +74,7 @@ minetest.register_node("mesecons_extrawires:corner_off", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_extrawires:corner_off" 3',
|
||||
output = "mesecons_extrawires:corner_off 3",
|
||||
recipe = {
|
||||
{"", "", ""},
|
||||
{"mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off", ""},
|
||||
|
@ -10,7 +10,7 @@ local mesewire_rules =
|
||||
|
||||
minetest.register_node(":default:mese", {
|
||||
description = "Mese Block",
|
||||
tiles = {"default_mese_block.png"},
|
||||
tiles = {minetest.registered_nodes["default:mese"].tiles[1]},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
@ -22,7 +22,7 @@ minetest.register_node(":default:mese", {
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_extrawires:mese_powered", {
|
||||
tiles = {"default_mese_block.png^[brighten"},
|
||||
tiles = {minetest.registered_nodes["default:mese"].tiles[1].."^[brighten"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1, not_in_creative_inventory = 1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
|
@ -75,7 +75,7 @@ minetest.register_node("mesecons_extrawires:tjunction_off", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_extrawires:tjunction_off" 3',
|
||||
output = "mesecons_extrawires:tjunction_off 3",
|
||||
recipe = {
|
||||
{"", "", ""},
|
||||
{"mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off"},
|
||||
|
@ -117,7 +117,7 @@ minetest.register_node("mesecons_extrawires:vertical_off", {
|
||||
minetest.register_node("mesecons_extrawires:vertical_top_on", {
|
||||
description = "Vertical mesecon",
|
||||
drawtype = "nodebox",
|
||||
tiles = {"wires_full_on.png"},
|
||||
tiles = {"wires_full_on.png","wires_full_on.png","wires_vertical_on.png"},
|
||||
walkable = false,
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
@ -139,7 +139,7 @@ minetest.register_node("mesecons_extrawires:vertical_top_on", {
|
||||
minetest.register_node("mesecons_extrawires:vertical_top_off", {
|
||||
description = "Vertical mesecon",
|
||||
drawtype = "nodebox",
|
||||
tiles = {"wires_full_off.png"},
|
||||
tiles = {"wires_full_off.png","wires_full_off.png","wires_vertical_off.png"},
|
||||
walkable = false,
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
@ -162,7 +162,7 @@ minetest.register_node("mesecons_extrawires:vertical_top_off", {
|
||||
minetest.register_node("mesecons_extrawires:vertical_bottom_on", {
|
||||
description = "Vertical mesecon",
|
||||
drawtype = "nodebox",
|
||||
tiles = {"wires_full_on.png"},
|
||||
tiles = {"wires_full_on.png","wires_full_on.png","wires_vertical_on.png"},
|
||||
walkable = false,
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
@ -183,7 +183,7 @@ minetest.register_node("mesecons_extrawires:vertical_bottom_on", {
|
||||
minetest.register_node("mesecons_extrawires:vertical_bottom_off", {
|
||||
description = "Vertical mesecon",
|
||||
drawtype = "nodebox",
|
||||
tiles = {"wires_full_off.png"},
|
||||
tiles = {"wires_full_off.png","wires_full_off.png","wires_vertical_off.png"},
|
||||
walkable = false,
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
@ -201,3 +201,17 @@ minetest.register_node("mesecons_extrawires:vertical_bottom_off", {
|
||||
after_place_node = vertical_update,
|
||||
after_dig_node = vertical_update
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesecons_extrawires:vertical_off 3",
|
||||
recipe = {
|
||||
{"mesecons:wire_00000000_off"},
|
||||
{"mesecons:wire_00000000_off"},
|
||||
{"mesecons:wire_00000000_off"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesecons:wire_00000000_off",
|
||||
recipe = {{"mesecons_extrawires:vertical_off"}}
|
||||
})
|
||||
|
@ -156,6 +156,7 @@ for _, gate in ipairs(gates) do
|
||||
end,
|
||||
groups = groups,
|
||||
drop = drop,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons_gate = gate.name,
|
||||
mesecons =
|
||||
{
|
||||
|
@ -23,6 +23,7 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
|
||||
{-0.45, 1.15, -0.1, 0.45, 1.45, 0.1},
|
||||
{-0.1, 1.15, -0.45, 0.1, 1.45, 0.45}},
|
||||
},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off
|
||||
}}
|
||||
@ -31,7 +32,7 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
|
||||
minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {"jeija_hydro_turbine_on.png"},
|
||||
drop = '"mesecons_hydroturbine:hydro_turbine_off" 1',
|
||||
drop = "mesecons_hydroturbine:hydro_turbine_off 1",
|
||||
groups = {dig_immediate=2,not_in_creative_inventory=1},
|
||||
description="Water Turbine",
|
||||
paramtype = "light",
|
||||
@ -49,6 +50,7 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", {
|
||||
{-0.5, 1.15, -0.1, 0.5, 1.45, 0.1},
|
||||
{-0.1, 1.15, -0.5, 0.1, 1.45, 0.5}},
|
||||
},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on
|
||||
}}
|
||||
@ -84,11 +86,11 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_hydroturbine:hydro_turbine_off" 2',
|
||||
output = "mesecons_hydroturbine:hydro_turbine_off 2",
|
||||
recipe = {
|
||||
{'','"default:stick"', ''},
|
||||
{'"default:stick"', '"default:steel_ingot"', '"default:stick"'},
|
||||
{'','"default:stick"', ''},
|
||||
{"","default:stick", ""},
|
||||
{"default:stick", "default:steel_ingot", "default:stick"},
|
||||
{"","default:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -71,7 +71,7 @@ minetest.register_node("mesecons_insulated:insulated_off", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_insulated:insulated_off" 3',
|
||||
output = "mesecons_insulated:insulated_off 3",
|
||||
recipe = {
|
||||
{"mesecons_materials:fiber", "mesecons_materials:fiber", "mesecons_materials:fiber"},
|
||||
{"mesecons:wire_00000000_off", "mesecons:wire_00000000_off", "mesecons:wire_00000000_off"},
|
||||
|
@ -21,7 +21,8 @@ minetest.register_node("mesecons_lamp:lamp_on", {
|
||||
node_box = mesecon_lamp_box,
|
||||
selection_box = mesecon_lamp_box,
|
||||
groups = {dig_immediate=3,not_in_creative_inventory=1, mesecon_effector_on = 1},
|
||||
drop='"mesecons_lamp:lamp_off" 1',
|
||||
drop="mesecons_lamp:lamp_off 1",
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_off = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_lamp:lamp_off")
|
||||
@ -42,6 +43,7 @@ minetest.register_node("mesecons_lamp:lamp_off", {
|
||||
selection_box = mesecon_lamp_box,
|
||||
groups = {dig_immediate=3, mesecon_receptor_off = 1, mesecon_effector_off = 1},
|
||||
description="Meselamp",
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_lamp:lamp_on")
|
||||
@ -50,10 +52,10 @@ minetest.register_node("mesecons_lamp:lamp_off", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_lamp:lamp_off" 1',
|
||||
output = "mesecons_lamp:lamp_off 1",
|
||||
recipe = {
|
||||
{'', '"default:glass"', ''},
|
||||
{'"group:mesecon_conductor_craftable"', '"default:steel_ingot"', '"group:mesecon_conductor_craftable"'},
|
||||
{'', '"default:glass"', ''},
|
||||
{"", "default:glass", ""},
|
||||
{"group:mesecon_conductor_craftable", "default:steel_ingot", "group:mesecon_conductor_craftable"},
|
||||
{"", "default:glass", ""},
|
||||
}
|
||||
})
|
||||
|
@ -1,9 +1,9 @@
|
||||
function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
|
||||
minetest.register_node("mesecons_lightstone:lightstone_" .. name .. "_off", {
|
||||
tiles = {texture_off},
|
||||
inventory_image = minetest.inventorycube(texture_off),
|
||||
groups = {cracky=2, mesecon_effector_off = 1, mesecon = 2},
|
||||
description=name.." Lightstone",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_lightstone:lightstone_" .. name .. "_on")
|
||||
@ -12,10 +12,10 @@ function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
|
||||
})
|
||||
minetest.register_node("mesecons_lightstone:lightstone_" .. name .. "_on", {
|
||||
tiles = {texture_on},
|
||||
inventory_image = minetest.inventorycube(texture_on),
|
||||
groups = {cracky=2,not_in_creative_inventory=1, mesecon = 2},
|
||||
drop = "node mesecons_lightstone:lightstone_" .. name .. "_off 1",
|
||||
drop = "mesecons_lightstone:lightstone_" .. name .. "_off",
|
||||
light_source = LIGHT_MAX-2,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_off = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_lightstone:lightstone_" .. name .. "_off")
|
||||
@ -24,18 +24,19 @@ function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "node mesecons_lightstone:lightstone_" .. name .. "_off 1",
|
||||
output = "mesecons_lightstone:lightstone_" .. name .. "_off",
|
||||
recipe = {
|
||||
{'',base_item,''},
|
||||
{base_item,'default:torch',base_item},
|
||||
{'','group:mesecon_conductor_craftable',''},
|
||||
{"",base_item,""},
|
||||
{base_item,"default:torch",base_item},
|
||||
{"","group:mesecon_conductor_craftable",""}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
mesecon:lightstone_add("red", "craft default:clay_brick 1", "jeija_lightstone_red_off.png", "jeija_lightstone_red_on.png")
|
||||
mesecon:lightstone_add("green", "node default:cactus 1", "jeija_lightstone_green_off.png", "jeija_lightstone_green_on.png")
|
||||
mesecon:lightstone_add("blue", "node mesecons_materials:fiber 1", "jeija_lightstone_blue_off.png", "jeija_lightstone_blue_on.png")
|
||||
mesecon:lightstone_add("gray", "node default:cobble 1", "jeija_lightstone_gray_off.png", "jeija_lightstone_gray_on.png")
|
||||
mesecon:lightstone_add("darkgray", "node default:gravel 1", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_darkgray_on.png")
|
||||
mesecon:lightstone_add("red", "default:clay_brick", "jeija_lightstone_red_off.png", "jeija_lightstone_red_on.png")
|
||||
mesecon:lightstone_add("green", "default:cactus", "jeija_lightstone_green_off.png", "jeija_lightstone_green_on.png")
|
||||
mesecon:lightstone_add("blue", "mesecons_materials:fiber", "jeija_lightstone_blue_off.png", "jeija_lightstone_blue_on.png")
|
||||
mesecon:lightstone_add("gray", "default:cobble", "jeija_lightstone_gray_off.png", "jeija_lightstone_gray_on.png")
|
||||
mesecon:lightstone_add("darkgray", "default:gravel", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_darkgray_on.png")
|
||||
mesecon:lightstone_add("yellow", "default:mese_crystal_fragment", "jeija_lightstone_yellow_off.png", "jeija_lightstone_yellow_on.png")
|
||||
|
1
mesecons_luacontroller/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
mesecons
|
534
mesecons_luacontroller/init.lua
Normal file
@ -0,0 +1,534 @@
|
||||
-- Reference
|
||||
-- ports = get_real_portstates(pos): gets if inputs are powered from outside
|
||||
-- newport = merge_portstates(state1, state2): just does result = state1 or state2 for every port
|
||||
-- action_setports(pos, rule, state): activates/deactivates the mesecons according to the portstates (helper for action)
|
||||
-- action(pos, ports): Applies new portstates to a luacontroller at pos
|
||||
-- lc_update(pos): updates the controller at pos by executing the code
|
||||
-- reset_meta (pos, code, errmsg): performs a software-reset, installs new code and prints error messages
|
||||
-- reset (pos): performs a hardware reset, turns off all ports
|
||||
--
|
||||
-- The Sandbox
|
||||
-- The whole code of the controller runs in a sandbox,
|
||||
-- a very restricted environment.
|
||||
-- However, as this does not prevent you from using e.g. loops,
|
||||
-- we need to check for these prohibited commands first.
|
||||
-- Actually the only way to damage the server is to
|
||||
-- use too much memory from the sandbox.
|
||||
-- You can add more functions to the environment
|
||||
-- (see where local env is defined)
|
||||
-- Something nice to play is is appending minetest.env to it.
|
||||
|
||||
local BASENAME = "mesecons_luacontroller:luacontroller"
|
||||
|
||||
local rules = {}
|
||||
rules.a = {x = -1, y = 0, z = 0, name="A"}
|
||||
rules.b = {x = 0, y = 0, z = 1, name="B"}
|
||||
rules.c = {x = 1, y = 0, z = 0, name="C"}
|
||||
rules.d = {x = 0, y = 0, z = -1, name="D"}
|
||||
|
||||
------------------
|
||||
-- Action stuff --
|
||||
------------------
|
||||
-- These helpers are required to set the portstates of the luacontroller
|
||||
|
||||
local get_real_portstates = function(pos) -- determine if ports are powered (by itself or from outside)
|
||||
ports = {
|
||||
a = mesecon:is_power_on(mesecon:addPosRule(pos, rules.a))
|
||||
and mesecon:rules_link(mesecon:addPosRule(pos, rules.a), pos),
|
||||
b = mesecon:is_power_on(mesecon:addPosRule(pos, rules.b))
|
||||
and mesecon:rules_link(mesecon:addPosRule(pos, rules.b), pos),
|
||||
c = mesecon:is_power_on(mesecon:addPosRule(pos, rules.c))
|
||||
and mesecon:rules_link(mesecon:addPosRule(pos, rules.c), pos),
|
||||
d = mesecon:is_power_on(mesecon:addPosRule(pos, rules.d))
|
||||
and mesecon:rules_link(mesecon:addPosRule(pos, rules.d), pos),
|
||||
}
|
||||
return ports
|
||||
end
|
||||
|
||||
local merge_portstates = function (ports, vports)
|
||||
local npo = {a=false, b=false, c=false, d=false}
|
||||
npo.a = vports.a or ports.a
|
||||
npo.b = vports.b or ports.b
|
||||
npo.c = vports.c or ports.c
|
||||
npo.d = vports.d or ports.d
|
||||
return npo
|
||||
end
|
||||
|
||||
local generate_name = function (ports)
|
||||
local overwrite = overwrite or {}
|
||||
local d = ports.d and 1 or 0
|
||||
local c = ports.c and 1 or 0
|
||||
local b = ports.b and 1 or 0
|
||||
local a = ports.a and 1 or 0
|
||||
return BASENAME..d..c..b..a
|
||||
end
|
||||
|
||||
local setport = function (pos, rule, state)
|
||||
if state then
|
||||
mesecon:receptor_on(pos, {rule})
|
||||
else
|
||||
mesecon:receptor_off(pos, {rule})
|
||||
end
|
||||
end
|
||||
|
||||
local action = function (pos, ports)
|
||||
local name = minetest.env:get_node(pos).name
|
||||
local vports = minetest.registered_nodes[name].virtual_portstates
|
||||
local newname = generate_name(ports)
|
||||
|
||||
if name ~= newname and vports then
|
||||
local rules_on = {}
|
||||
local rules_off = {}
|
||||
|
||||
mesecon:swap_node(pos, newname)
|
||||
|
||||
if ports.a ~= vports.a then setport(pos, rules.a, ports.a) end
|
||||
if ports.b ~= vports.b then setport(pos, rules.b, ports.b) end
|
||||
if ports.c ~= vports.c then setport(pos, rules.c, ports.c) end
|
||||
if ports.d ~= vports.d then setport(pos, rules.d, ports.d) end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------
|
||||
-- Overheat stuff --
|
||||
--------------------
|
||||
|
||||
local heat = function (meta) -- warm up
|
||||
h = meta:get_int("heat")
|
||||
if h ~= nil then
|
||||
meta:set_int("heat", h + 1)
|
||||
end
|
||||
end
|
||||
|
||||
local cool = function (meta) -- cool down after a while
|
||||
h = meta:get_int("heat")
|
||||
if h ~= nil then
|
||||
meta:set_int("heat", h - 1)
|
||||
end
|
||||
end
|
||||
|
||||
local overheat = function (meta) -- determine if too hot
|
||||
h = meta:get_int("heat")
|
||||
if h == nil then return true end -- if nil then overheat
|
||||
if h > 20 then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local overheat_off = function(pos)
|
||||
mesecon:receptor_off(pos, mesecon.rules.flat)
|
||||
end
|
||||
|
||||
-------------------
|
||||
-- Parsing stuff --
|
||||
-------------------
|
||||
|
||||
local code_prohibited = function(code)
|
||||
-- Clean code
|
||||
local prohibited = {"while", "for", "repeat", "until", "function"}
|
||||
for _, p in ipairs(prohibited) do
|
||||
if string.find(code, p) then
|
||||
return "Prohibited command: "..p
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local safeprint = function(param)
|
||||
print(dump(param))
|
||||
end
|
||||
|
||||
local interrupt = function(params)
|
||||
lc_update(params.pos, {type="interrupt", iid = params.iid})
|
||||
end
|
||||
|
||||
local getinterrupt = function(pos)
|
||||
local interrupt = function (time, iid) -- iid = interrupt id
|
||||
if type(time) ~= "number" then return end
|
||||
local iid = iid or math.random()
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local interrupts = minetest.deserialize(meta:get_string("lc_interrupts")) or {}
|
||||
local found = false
|
||||
for _, i in ipairs(interrupts) do
|
||||
if minetest.serialize(i) == minetest.serialize(iid) then
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not found then
|
||||
table.insert(interrupts, iid)
|
||||
meta:set_string("lc_interrupts", minetest.serialize(interrupts))
|
||||
end
|
||||
minetest.after(time, interrupt, {pos=pos, iid = iid})
|
||||
end
|
||||
return interrupt
|
||||
end
|
||||
|
||||
local getdigiline_send = function (pos)
|
||||
local digiline_send = function (channel, msg)
|
||||
if digiline then
|
||||
digiline:receptor_send(pos, digiline.rules.default, channel, msg)
|
||||
end
|
||||
end
|
||||
return digiline_send
|
||||
end
|
||||
|
||||
local create_environment = function(pos, mem, event)
|
||||
-- Gather variables for the environment
|
||||
local vports = minetest.registered_nodes[minetest.env:get_node(pos).name].virtual_portstates
|
||||
vports = {a = vports.a, b = vports.b, c = vports.c, d = vports.d}
|
||||
local rports = get_real_portstates(pos)
|
||||
|
||||
return {
|
||||
print = safeprint,
|
||||
pin = merge_portstates(vports, rports),
|
||||
port = vports,
|
||||
interrupt = getinterrupt(pos),
|
||||
digiline_send = getdigiline_send(pos),
|
||||
mem = mem,
|
||||
tostring = tostring,
|
||||
tonumber = tonumber,
|
||||
string = {
|
||||
byte = string.byte,
|
||||
char = string.char,
|
||||
find = string.find,
|
||||
format = string.format,
|
||||
gmatch = string.gmatch,
|
||||
gsub = string.gsub,
|
||||
len = string.len,
|
||||
lower = string.lower,
|
||||
match = string.match,
|
||||
rep = string.rep,
|
||||
reverse = string.reverse,
|
||||
sub = string.sub,
|
||||
},
|
||||
math = {
|
||||
abs = math.abs,
|
||||
acos = math.acos,
|
||||
asin = math.asin,
|
||||
atan = math.atan,
|
||||
atan2 = math.atan2,
|
||||
ceil = math.ceil,
|
||||
cos = math.cos,
|
||||
cosh = math.cosh,
|
||||
deg = math.deg,
|
||||
exp = math.exp,
|
||||
floor = math.floor,
|
||||
fmod = math.fmod,
|
||||
frexp = math.frexp,
|
||||
huge = math.huge,
|
||||
ldexp = math.ldexp,
|
||||
log = math.log,
|
||||
log10 = math.log10,
|
||||
max = math.max,
|
||||
min = math.min,
|
||||
modf = math.modf,
|
||||
pi = math.pi,
|
||||
pow = math.pow,
|
||||
rad = math.rad,
|
||||
random = math.random,
|
||||
sin = math.sin,
|
||||
sinh = math.sinh,
|
||||
sqrt = math.sqrt,
|
||||
tan = math.tan,
|
||||
tanh = math.tanh,
|
||||
},
|
||||
table = {
|
||||
insert = table.insert,
|
||||
maxn = table.maxn,
|
||||
remove = table.remove,
|
||||
sort = table.sort
|
||||
},
|
||||
event = event,
|
||||
}
|
||||
end
|
||||
|
||||
local create_sandbox = function (code, env)
|
||||
-- Create Sandbox
|
||||
if code:byte(1) == 27 then
|
||||
return _, "You Hacker You! Don't use binary code!"
|
||||
end
|
||||
f, msg = loadstring(code)
|
||||
if not f then return _, msg end
|
||||
setfenv(f, env)
|
||||
return f
|
||||
end
|
||||
|
||||
local do_overheat = function (pos, meta)
|
||||
-- Overheat protection
|
||||
heat(meta)
|
||||
minetest.after(0.5, cool, meta)
|
||||
if overheat(meta) then
|
||||
mesecon:swap_node(pos, BASENAME.."_burnt")
|
||||
minetest.env:get_meta(pos):set_string("lc_interrupts", "")
|
||||
minetest.after(0.2, overheat_off, pos) -- wait for pending operations
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local load_memory = function(meta)
|
||||
return minetest.deserialize(meta:get_string("lc_memory")) or {}
|
||||
end
|
||||
|
||||
local save_memory = function(meta, mem)
|
||||
meta:set_string("lc_memory", minetest.serialize(mem))
|
||||
end
|
||||
|
||||
local interrupt_allow = function (meta, event)
|
||||
if event.type ~= "interrupt" then return true end
|
||||
|
||||
local interrupts = minetest.deserialize(meta:get_string("lc_interrupts")) or {}
|
||||
for _, i in ipairs(interrupts) do
|
||||
if minetest.serialize(i) == minetest.serialize(event.iid) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local ports_invalid = function (var)
|
||||
if type(var) == "table" then
|
||||
return false
|
||||
end
|
||||
return "The ports you set are invalid"
|
||||
end
|
||||
|
||||
----------------------
|
||||
-- Parsing function --
|
||||
----------------------
|
||||
|
||||
lc_update = function (pos, event)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if not interrupt_allow(meta, event) then return end
|
||||
if do_overheat(pos, meta) then return end
|
||||
|
||||
-- load code & mem from memory
|
||||
local mem = load_memory(meta)
|
||||
local code = meta:get_string("code")
|
||||
|
||||
-- make sure code is ok and create environment
|
||||
local prohibited = code_prohibited(code)
|
||||
if prohibited then return prohibited end
|
||||
local env = create_environment(pos, mem, event)
|
||||
|
||||
-- create the sandbox and execute code
|
||||
local chunk, msg = create_sandbox (code, env)
|
||||
if not chunk then return msg end
|
||||
local success, msg = pcall(f)
|
||||
if not success then return msg end
|
||||
if ports_invalid(env.port) then return ports_invalid(env.port) end
|
||||
|
||||
save_memory(meta, mem)
|
||||
|
||||
-- Actually set the ports
|
||||
minetest.after(0, action, pos, env.port)
|
||||
end
|
||||
|
||||
local reset_meta = function(pos, code, errmsg)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("code", code)
|
||||
if minetest.formspec_escape then
|
||||
code = minetest.formspec_escape(code or "")
|
||||
errmsg = minetest.formspec_escape(errmsg or "")
|
||||
else
|
||||
code = string.gsub(code or "", "%[", "(") -- would otherwise
|
||||
code = string.gsub(code, "%]", ")") -- corrupt formspec
|
||||
errmsg = string.gsub(errmsg or "", "%[", "(") -- would otherwise
|
||||
errmsg = string.gsub(errmsg, "%]", ")") -- corrupt formspec
|
||||
end
|
||||
meta:set_string("formspec", "size[10,8]"..
|
||||
"background[-0.2,-0.25;10.4,8.75;jeija_luac_background.png]"..
|
||||
"textarea[0.2,0.6;10.2,5;code;;"..code.."]"..
|
||||
"image_button[3.75,6;2.5,1;jeija_luac_runbutton.png;program;]"..
|
||||
"image_button_exit[9.72,-0.25;0.425,0.4;jeija_close_window.png;exit;]"..
|
||||
"label[0.1,5;"..errmsg.."]")
|
||||
meta:set_int("heat", 0)
|
||||
end
|
||||
|
||||
local reset = function (pos)
|
||||
minetest.env:get_meta(pos):set_string("lc_interrupts", "")
|
||||
action(pos, {a=false, b=false, c=false, d=false}, true)
|
||||
end
|
||||
|
||||
-- ______
|
||||
-- |
|
||||
-- | | |
|
||||
-- |___| | __ ___ _ __ _ _
|
||||
-- | | | | |\ | | |_| | | | | |_ |_|
|
||||
-- | |______ |__| | \| | | \ |__| |_ |_ |_ |\
|
||||
--
|
||||
|
||||
-----------------------
|
||||
-- Node Registration --
|
||||
-----------------------
|
||||
|
||||
local output_rules={}
|
||||
local input_rules={}
|
||||
|
||||
local nodebox = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 }, -- bottom slab
|
||||
{ -5/16, -7/16, -5/16, 5/16, -6/16, 5/16 }, -- circuit board
|
||||
{ -3/16, -6/16, -3/16, 3/16, -5/16, 3/16 }, -- IC
|
||||
}
|
||||
}
|
||||
|
||||
local selectionbox = {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -8/16, -8/16, 8/16, -5/16, 8/16 },
|
||||
}
|
||||
|
||||
local digiline = {
|
||||
receptor = {},
|
||||
effector = {
|
||||
action = function (pos, node, channel, msg)
|
||||
lc_update (pos, {type = "digiline", channel = channel, msg = msg})
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
for a = 0, 1 do -- 0 = off; 1 = on
|
||||
for b = 0, 1 do
|
||||
for c = 0, 1 do
|
||||
for d = 0, 1 do
|
||||
|
||||
local cid = tostring(d)..tostring(c)..tostring(b)..tostring(a)
|
||||
local nodename = BASENAME..cid
|
||||
local top = "jeija_luacontroller_top.png"
|
||||
if a == 1 then
|
||||
top = top.."^jeija_luacontroller_LED_A.png"
|
||||
end
|
||||
if b == 1 then
|
||||
top = top.."^jeija_luacontroller_LED_B.png"
|
||||
end
|
||||
if c == 1 then
|
||||
top = top.."^jeija_luacontroller_LED_C.png"
|
||||
end
|
||||
if d == 1 then
|
||||
top = top.."^jeija_luacontroller_LED_D.png"
|
||||
end
|
||||
|
||||
if a + b + c + d ~= 0 then
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1}
|
||||
else
|
||||
groups = {dig_immediate=2}
|
||||
end
|
||||
|
||||
output_rules[cid] = {}
|
||||
input_rules[cid] = {}
|
||||
if (a == 1) then table.insert(output_rules[cid], rules.a) end
|
||||
if (b == 1) then table.insert(output_rules[cid], rules.b) end
|
||||
if (c == 1) then table.insert(output_rules[cid], rules.c) end
|
||||
if (d == 1) then table.insert(output_rules[cid], rules.d) end
|
||||
|
||||
if (a == 0) then table.insert(input_rules[cid], rules.a) end
|
||||
if (b == 0) then table.insert(input_rules[cid], rules.b) end
|
||||
if (c == 0) then table.insert(input_rules[cid], rules.c) end
|
||||
if (d == 0) then table.insert(input_rules[cid], rules.d) end
|
||||
|
||||
local mesecons = {
|
||||
effector =
|
||||
{
|
||||
rules = input_rules[cid],
|
||||
action_change = function (pos, _, rulename, newstate)
|
||||
lc_update(pos, {type=newstate, pin=rulename})
|
||||
end,
|
||||
},
|
||||
receptor =
|
||||
{
|
||||
state = mesecon.state.on,
|
||||
rules = output_rules[cid]
|
||||
}
|
||||
}
|
||||
|
||||
minetest.register_node(nodename, {
|
||||
description = "Luacontroller",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
top,
|
||||
"jeija_microcontroller_bottom.png",
|
||||
"jeija_microcontroller_sides.png",
|
||||
"jeija_microcontroller_sides.png",
|
||||
"jeija_microcontroller_sides.png",
|
||||
"jeija_microcontroller_sides.png"
|
||||
},
|
||||
|
||||
inventory_image = top,
|
||||
paramtype = "light",
|
||||
groups = groups,
|
||||
drop = BASENAME.."0000",
|
||||
sunlight_propagates = true,
|
||||
selection_box = selectionbox,
|
||||
node_box = nodebox,
|
||||
on_construct = reset_meta,
|
||||
on_receive_fields = function(pos, formname, fields)
|
||||
reset(pos)
|
||||
reset_meta(pos, fields.code)
|
||||
local err = lc_update(pos, {type="program"})
|
||||
if err then print(err) end
|
||||
reset_meta(pos, fields.code, err)
|
||||
end,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = mesecons,
|
||||
digiline = digiline,
|
||||
is_luacontroller = true,
|
||||
virtual_portstates = { a = a == 1, -- virtual portstates are
|
||||
b = b == 1, -- the ports the the
|
||||
c = c == 1, -- controller powers itself
|
||||
d = d == 1},-- so those that light up
|
||||
after_dig_node = function (pos, node)
|
||||
mesecon:receptor_off(pos, output_rules)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--overheated luacontroller
|
||||
minetest.register_node(BASENAME .. "_burnt", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"jeija_luacontroller_burnt_top.png",
|
||||
"jeija_microcontroller_bottom.png",
|
||||
"jeija_microcontroller_sides.png",
|
||||
"jeija_microcontroller_sides.png",
|
||||
"jeija_microcontroller_sides.png",
|
||||
"jeija_microcontroller_sides.png"
|
||||
},
|
||||
inventory_image = "jeija_luacontroller_burnt_top.png",
|
||||
paramtype = "light",
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1},
|
||||
drop = BASENAME.."0000",
|
||||
sunlight_propagates = true,
|
||||
selection_box = selectionbox,
|
||||
node_box = nodebox,
|
||||
on_construct = reset_meta,
|
||||
on_receive_fields = function(pos, formname, fields)
|
||||
reset(pos)
|
||||
reset_meta(pos, fields.code)
|
||||
local err = lc_update(pos, {type="program"})
|
||||
if err then print(err) end
|
||||
reset_meta(pos, fields.code, err)
|
||||
end,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
is_luacontroller = true,
|
||||
virtual_portstates = {a = false, b = false, c = false, d = false},
|
||||
})
|
||||
|
||||
------------------------
|
||||
-- Craft Registration --
|
||||
------------------------
|
||||
|
||||
minetest.register_craft({
|
||||
output = BASENAME.."0000 2",
|
||||
recipe = {
|
||||
{'mesecons_materials:silicon', 'mesecons_materials:silicon', 'group:mesecon_conductor_craftable'},
|
||||
{'mesecons_materials:silicon', 'mesecons_materials:silicon', 'group:mesecon_conductor_craftable'},
|
||||
{'group:mesecon_conductor_craftable', 'group:mesecon_conductor_craftable', ''},
|
||||
}
|
||||
})
|
||||
|
@ -12,14 +12,14 @@ minetest.register_craftitem("mesecons_materials:fiber", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_materials:glue" 2',
|
||||
output = "mesecons_materials:glue 2",
|
||||
type = "cooking",
|
||||
recipe = "default:sapling",
|
||||
cooktime = 2
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_materials:fiber" 6',
|
||||
output = "mesecons_materials:fiber 6",
|
||||
type = "cooking",
|
||||
recipe = "mesecons_materials:glue",
|
||||
cooktime = 4
|
||||
@ -33,9 +33,9 @@ minetest.register_craftitem("mesecons_materials:silicon", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_materials:silicon" 4',
|
||||
output = "mesecons_materials:silicon 4",
|
||||
recipe = {
|
||||
{'"default:sand"', '"default:sand"'},
|
||||
{'"default:sand"', '"default:steel_ingot"'},
|
||||
{"default:sand", "default:sand"},
|
||||
{"default:sand", "default:steel_ingot"},
|
||||
}
|
||||
})
|
||||
|
@ -66,7 +66,7 @@ minetest.register_node(nodename, {
|
||||
paramtype = "light",
|
||||
walkable = true,
|
||||
groups = groups,
|
||||
drop = '"mesecons_microcontroller:microcontroller0000" 1',
|
||||
drop = "mesecons_microcontroller:microcontroller0000 1",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -8/16, -8/16, 8/16, -5/16, 8/16 },
|
||||
@ -128,6 +128,7 @@ minetest.register_node(nodename, {
|
||||
yc_reset (pos)
|
||||
update_yc(pos)
|
||||
end,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = mesecons,
|
||||
after_dig_node = function (pos, node)
|
||||
rules = mesecon:get_rules(node.name)
|
||||
|
@ -61,21 +61,11 @@ minetest.register_node("mesecons_movestones:movestone", {
|
||||
legacy_facedir_simple = true,
|
||||
groups = {cracky=3},
|
||||
description="Movestone",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
local direction=mesecon:get_movestone_direction(pos)
|
||||
if not direction then return end
|
||||
local checknode={}
|
||||
local collpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
repeat -- Check if it collides with a stopper
|
||||
collpos = mesecon:addPosRule(collpos, direction)
|
||||
checknode=minetest.env:get_node(collpos)
|
||||
if mesecon:is_mvps_stopper(checknode.name, direction) then
|
||||
return
|
||||
end
|
||||
until checknode.name=="air"
|
||||
or checknode.name=="ignore"
|
||||
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
|
||||
minetest.env:remove_node(pos)
|
||||
mesecon:update_autoconnect(pos)
|
||||
minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity")
|
||||
@ -89,6 +79,7 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
|
||||
textures = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_arrows.png", "jeija_movestone_arrows.png"},
|
||||
collisionbox = {-0.5,-0.5,-0.5, 0.5, 0.5, 0.5},
|
||||
visual = "cube",
|
||||
lastdir = {x=0, y=0, z=0},
|
||||
|
||||
on_punch = function(self, hitter)
|
||||
self.object:remove()
|
||||
@ -97,26 +88,42 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
|
||||
|
||||
on_step = function(self, dtime)
|
||||
local pos = self.object:getpos()
|
||||
pos.x, pos.y, pos.z = math.floor(pos.x+0.5), math.floor(pos.y+0.5), math.floor(pos.z+0.5)
|
||||
local direction = mesecon:get_movestone_direction(pos)
|
||||
|
||||
if not direction then
|
||||
if not direction then -- no mesecon power
|
||||
local name = minetest.env:get_node(pos).name
|
||||
if name ~= "air" and name ~= "ignore"
|
||||
and minetest.registered_nodes[name].liquidtype == "none" then
|
||||
mesecon:mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH)
|
||||
end
|
||||
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"})
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
self.object:setvelocity({x=direction.x*2, y=direction.y*2, z=direction.z*2})
|
||||
local success, stack, oldstack =
|
||||
mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
|
||||
if not success then -- Too large stack/stopper in the way
|
||||
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"})
|
||||
self.object:remove()
|
||||
return
|
||||
else
|
||||
mesecon:mvps_process_stack (stack)
|
||||
mesecon:mvps_move_objects (pos, direction, oldstack)
|
||||
self.lastdir = direction
|
||||
end
|
||||
|
||||
mesecon:mvps_push(pos, direction, 100)
|
||||
self.object:setvelocity({x=direction.x*2, y=direction.y*2, z=direction.z*2})
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_movestones:movestone" 2',
|
||||
output = "mesecons_movestones:movestone 2",
|
||||
recipe = {
|
||||
{'"default:stone"', '"default:stone"', '"default:stone"'},
|
||||
{'"group:mesecon_conductor_craftable"', '"group:mesecon_conductor_craftable"', '"group:mesecon_conductor_craftable"'},
|
||||
{'"default:stone"', '"default:stone"', '"default:stone"'},
|
||||
{"default:stone", "default:stone", "default:stone"},
|
||||
{"group:mesecon_conductor_craftable", "group:mesecon_conductor_craftable", "group:mesecon_conductor_craftable"},
|
||||
{"default:stone", "default:stone", "default:stone"},
|
||||
}
|
||||
})
|
||||
|
||||
@ -131,30 +138,11 @@ minetest.register_node("mesecons_movestones:sticky_movestone", {
|
||||
legacy_facedir_simple = true,
|
||||
groups = {cracky=3},
|
||||
description="Sticky Movestone",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
local direction=mesecon:get_movestone_direction(pos)
|
||||
if not direction then return end
|
||||
local checknode={}
|
||||
local collpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
repeat -- Check if it collides with a stopper
|
||||
collpos = mesecon:addPosRule(collpos, direction)
|
||||
checknode=minetest.env:get_node(collpos)
|
||||
if mesecon:is_mvps_stopper(checknode.name, direction) then
|
||||
return
|
||||
end
|
||||
until checknode.name=="air"
|
||||
or checknode.name=="ignore"
|
||||
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
|
||||
repeat -- Check if it collides with a stopper (pull direction)
|
||||
collpos={x=collpos.x-direction.x, y=collpos.y-direction.y, z=collpos.z-direction.z}
|
||||
checknode=minetest.env:get_node(collpos)
|
||||
if mesecon:is_mvps_stopper(checknode.name, direction) then
|
||||
return
|
||||
end
|
||||
until checknode.name=="air"
|
||||
or checknode.name=="ignore"
|
||||
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
|
||||
minetest.env:remove_node(pos)
|
||||
mesecon:update_autoconnect(pos)
|
||||
minetest.env:add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
|
||||
@ -163,9 +151,9 @@ minetest.register_node("mesecons_movestones:sticky_movestone", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_movestones:sticky_movestone" 2',
|
||||
output = "mesecons_movestones:sticky_movestone 2",
|
||||
recipe = {
|
||||
{'"mesecons_materials:glue"', '"mesecons_movestones:movestone"', '"mesecons_materials:glue"'},
|
||||
{"mesecons_materials:glue", "mesecons_movestones:movestone", "mesecons_materials:glue"},
|
||||
}
|
||||
})
|
||||
|
||||
@ -175,6 +163,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
|
||||
textures = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_sticky_movestone.png", "jeija_sticky_movestone.png"},
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
visual = "cube",
|
||||
lastdir = {x=0, y=0, z=0},
|
||||
|
||||
on_punch = function(self, hitter)
|
||||
self.object:remove()
|
||||
@ -183,20 +172,41 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
|
||||
|
||||
on_step = function(self, dtime)
|
||||
local pos = self.object:getpos()
|
||||
local colp = pos
|
||||
local direction=mesecon:get_movestone_direction(colp)
|
||||
pos.x, pos.y, pos.z = math.floor(pos.x+0.5), math.floor(pos.y+0.5), math.floor(pos.z+0.5)
|
||||
local direction = mesecon:get_movestone_direction(pos)
|
||||
|
||||
if not direction then
|
||||
if not direction then -- no mesecon power
|
||||
local name = minetest.env:get_node(pos).name
|
||||
if name ~= "air" and name ~= "ignore"
|
||||
and minetest.registered_nodes[name].liquidtype == "none" then
|
||||
mesecon:mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH)
|
||||
--STICKY
|
||||
mesecon:mvps_pull_all(pos, self.lastdir)
|
||||
end
|
||||
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"})
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
self.object:setvelocity({x=direction.x*2, y=direction.y*2, z=direction.z*2})
|
||||
local success, stack, oldstack =
|
||||
mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
|
||||
if not success then -- Too large stack/stopper in the way
|
||||
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"})
|
||||
self.object:remove()
|
||||
return
|
||||
else
|
||||
mesecon:mvps_process_stack (stack)
|
||||
mesecon:mvps_move_objects (pos, direction, oldstack)
|
||||
self.lastdir = direction
|
||||
end
|
||||
|
||||
mesecon:mvps_push(pos, direction, 100)
|
||||
self.object:setvelocity({x=direction.x*2, y=direction.y*2, z=direction.z*2})
|
||||
|
||||
--STICKY
|
||||
mesecon:mvps_pull_all(pos, direction)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
mesecon:register_mvps_unmov("mesecons_movestones:movestone_entity")
|
||||
mesecon:register_mvps_unmov("mesecons_movestones:sticky_movestone_entity")
|
||||
|
@ -1,6 +1,7 @@
|
||||
--register stoppers for movestones/pistons
|
||||
|
||||
mesecon.mvps_stoppers = {}
|
||||
mesecon.mvps_unmov = {}
|
||||
|
||||
function mesecon:is_mvps_stopper(node, pushdir, stack, stackid)
|
||||
local get_stopper = mesecon.mvps_stoppers[node.name]
|
||||
@ -17,6 +18,15 @@ function mesecon:register_mvps_stopper(nodename, get_stopper)
|
||||
mesecon.mvps_stoppers[nodename] = get_stopper
|
||||
end
|
||||
|
||||
-- Objects that cannot be moved (e.g. movestones)
|
||||
function mesecon:register_mvps_unmov(objectname)
|
||||
mesecon.mvps_unmov[objectname] = true;
|
||||
end
|
||||
|
||||
function mesecon:is_mvps_unmov(objectname)
|
||||
return mesecon.mvps_unmov[objectname]
|
||||
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
|
||||
@ -26,16 +36,15 @@ function mesecon:mvps_process_stack(stack)
|
||||
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}
|
||||
|
||||
function mesecon:mvps_get_stack(pos, dir, maximum)
|
||||
-- determine the number of nodes to be pushed
|
||||
local np = {x = pos.x, y = pos.y, z = pos.z}
|
||||
local nodes = {}
|
||||
while true do
|
||||
nn = minetest.env:get_node_or_nil(np)
|
||||
local nn = minetest.env: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
|
||||
return nil
|
||||
end
|
||||
|
||||
if nn.name == "air"
|
||||
@ -47,7 +56,13 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
|
||||
|
||||
np = mesecon:addPosRule(np, dir)
|
||||
end
|
||||
return nodes
|
||||
end
|
||||
|
||||
function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: direction of push; maximum: maximum nodes to be pushed
|
||||
local nodes = mesecon:mvps_get_stack(pos, dir, maximum)
|
||||
|
||||
if not nodes then return end
|
||||
-- determine if one of the nodes blocks the push
|
||||
for id, n in ipairs(nodes) do
|
||||
if mesecon:is_mvps_stopper(n.node, dir, nodes, id) then
|
||||
@ -57,6 +72,7 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
|
||||
|
||||
-- remove all nodes
|
||||
for _, n in ipairs(nodes) do
|
||||
n.meta = minetest.env:get_meta(n.pos):to_table()
|
||||
minetest.env:remove_node(n.pos)
|
||||
end
|
||||
|
||||
@ -70,13 +86,20 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
|
||||
for _, n in ipairs(nodes) do
|
||||
np = mesecon:addPosRule(n.pos, dir)
|
||||
minetest.env:add_node(np, n.node)
|
||||
minetest.env:get_meta(np):from_table(n.meta)
|
||||
end
|
||||
|
||||
local oldstack = mesecon:tablecopy(nodes)
|
||||
for i in ipairs(nodes) do
|
||||
nodes[i].pos = mesecon:addPosRule(nodes[i].pos, dir)
|
||||
end
|
||||
|
||||
return true, nodes
|
||||
for _, n in ipairs(nodes) do
|
||||
mesecon.on_placenode(n.pos, n.node)
|
||||
mesecon:update_autoconnect(n.pos)
|
||||
end
|
||||
|
||||
return true, nodes, oldstack
|
||||
end
|
||||
|
||||
function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: direction of pull (matches push direction for sticky pistons)
|
||||
@ -85,13 +108,17 @@ function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: dire
|
||||
|
||||
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.env:get_meta(np):to_table()
|
||||
minetest.env:remove_node(np)
|
||||
minetest.env:add_node(pos, nn)
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
|
||||
nodeupdate(np)
|
||||
nodeupdate(pos)
|
||||
mesecon.on_dignode(np, nn)
|
||||
mesecon:update_autoconnect(np)
|
||||
mesecon:update_autoconnect(pos)
|
||||
mesecon.on_placenode(pos, nn)
|
||||
end
|
||||
return {{pos = np, node = {param2 = 0, name = "air"}}, {pos = pos, node = nn}}
|
||||
end
|
||||
@ -107,7 +134,8 @@ function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: d
|
||||
|
||||
local oldpos = {x=lpos2.x+direction.x, y=lpos2.y+direction.y, z=lpos2.z+direction.z}
|
||||
repeat
|
||||
minetest.env:add_node(oldpos, {name=minetest.env:get_node(lpos2).name})
|
||||
lnode2 = minetest.env:get_node(lpos2)
|
||||
minetest.env:add_node(oldpos, {name=lnode2.name})
|
||||
nodeupdate(oldpos)
|
||||
oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z}
|
||||
lpos2.x = lpos2.x-direction.x
|
||||
@ -118,6 +146,44 @@ function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: d
|
||||
minetest.env:remove_node(oldpos)
|
||||
end
|
||||
|
||||
mesecon:register_mvps_stopper("default:chest")
|
||||
function mesecon:mvps_move_objects(pos, dir, nodestack)
|
||||
local objects_to_move = {}
|
||||
|
||||
-- Move object at tip of stack
|
||||
local pushpos = mesecon:addPosRule(pos, -- get pos at tip of stack
|
||||
{x = dir.x * (#nodestack),
|
||||
y = dir.y * (#nodestack),
|
||||
z = dir.z * (#nodestack)})
|
||||
|
||||
|
||||
local objects = minetest.env:get_objects_inside_radius(pushpos, 1)
|
||||
for _, obj in ipairs(objects) do
|
||||
table.insert(objects_to_move, obj)
|
||||
end
|
||||
|
||||
-- Move objects lying/standing on the stack (before it was pushed - oldstack)
|
||||
if tonumber(minetest.setting_get("movement_gravity")) > 0 and dir.y == 0 then
|
||||
-- If gravity positive and dir horizontal, push players standing on the stack
|
||||
for _, n in ipairs(nodestack) do
|
||||
local p_above = mesecon:addPosRule(n.pos, {x=0, y=1, z=0})
|
||||
local objects = minetest.env:get_objects_inside_radius(p_above, 1)
|
||||
for _, obj in ipairs(objects) do
|
||||
table.insert(objects_to_move, obj)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, obj in ipairs(objects_to_move) do
|
||||
local entity = obj:get_luaentity()
|
||||
if not entity or not mesecon:is_mvps_unmov(entity.name) then
|
||||
local np = mesecon:addPosRule(obj:getpos(), dir)
|
||||
local nn = minetest.env:get_node(np)
|
||||
if not minetest.registered_nodes[nn.name].walkable then
|
||||
obj:setpos(np)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mesecon:register_mvps_stopper("default:chest_locked")
|
||||
mesecon:register_mvps_stopper("default:furnace")
|
||||
|
@ -14,6 +14,7 @@ minetest.register_node("mesecons_noteblock:noteblock", {
|
||||
minetest.env:add_node(pos, {name = node.name, param2 = param2})
|
||||
mesecon.noteblock_play(pos, param2)
|
||||
end,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector = { -- play sound when activated
|
||||
action_on = function (pos, node)
|
||||
mesecon.noteblock_play(pos, node.param2)
|
||||
@ -22,7 +23,7 @@ minetest.register_node("mesecons_noteblock:noteblock", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_noteblock:noteblock" 1',
|
||||
output = "mesecons_noteblock:noteblock 1",
|
||||
recipe = {
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"group:mesecon_conductor_craftable", "default:steel_ingot", "group:mesecon_conductor_craftable"},
|
||||
|
@ -10,6 +10,26 @@ piston_rules =
|
||||
{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
|
||||
@ -50,13 +70,14 @@ end
|
||||
local piston_on = function (pos, node)
|
||||
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
|
||||
dir = piston_get_direction(pistonspec.dir, node)
|
||||
local dir = piston_get_direction(pistonspec.dir, node)
|
||||
local np = mesecon:addPosRule(pos, dir)
|
||||
success, stack = mesecon:mvps_push(np, dir, PISTON_MAXIMUM_PUSH)
|
||||
local success, stack, oldstack = mesecon:mvps_push(np, dir, PISTON_MAXIMUM_PUSH)
|
||||
if success then
|
||||
minetest.env:add_node(pos, {param2 = node.param2, name = pistonspec.onname})
|
||||
minetest.env:add_node(np, {param2 = node.param2, name = pistonspec.pusher})
|
||||
mesecon:mvps_process_stack (stack)
|
||||
mesecon:mvps_move_objects (np, dir, oldstack)
|
||||
end
|
||||
end
|
||||
|
||||
@ -69,7 +90,7 @@ local piston_off = function (pos, node)
|
||||
dir = piston_get_direction(pistonspec.dir, node)
|
||||
pullpos = mesecon:addPosRule(pos, dir)
|
||||
stack = mesecon:mvps_pull_single(pullpos, dir)
|
||||
mesecon:mvps_process_stack(stack)
|
||||
mesecon:mvps_process_stack(pos, dir, stack)
|
||||
end
|
||||
end
|
||||
|
||||
@ -136,6 +157,7 @@ minetest.register_node("mesecons_pistons:piston_normal_off", {
|
||||
paramtype2 = "facedir",
|
||||
after_place_node = piston_orientate,
|
||||
mesecons_piston = pistonspec_normal,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_on = piston_on,
|
||||
rules = piston_get_rules
|
||||
@ -163,6 +185,7 @@ minetest.register_node("mesecons_pistons:piston_normal_on", {
|
||||
node_box = piston_on_box,
|
||||
selection_box = piston_on_box,
|
||||
mesecons_piston = pistonspec_normal,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_off = piston_off,
|
||||
rules = piston_get_rules
|
||||
@ -215,6 +238,7 @@ minetest.register_node("mesecons_pistons:piston_sticky_off", {
|
||||
paramtype2 = "facedir",
|
||||
after_place_node = piston_orientate,
|
||||
mesecons_piston = pistonspec_sticky,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_on = piston_on,
|
||||
rules = piston_get_rules
|
||||
@ -242,6 +266,7 @@ minetest.register_node("mesecons_pistons:piston_sticky_on", {
|
||||
node_box = piston_on_box,
|
||||
selection_box = piston_on_box,
|
||||
mesecons_piston = pistonspec_sticky,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_off = piston_off,
|
||||
rules = piston_get_rules
|
||||
@ -276,7 +301,7 @@ minetest.register_node("mesecons_pistons:piston_pusher_sticky", {
|
||||
local piston_up_pusher_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-2/16, -.5 - pt, -2/16, 2/16, .5, 2/16},
|
||||
{-2/16, -.5 - pt, -2/16, 2/16, .5 - pt, 2/16},
|
||||
{-.5 , .5 - pt, -.5 , .5 , .5 , .5},
|
||||
}
|
||||
}
|
||||
@ -315,6 +340,7 @@ minetest.register_node("mesecons_pistons:piston_up_normal_off", {
|
||||
mesecons_piston = pistonspec_normal_up,
|
||||
mesecons = {effector={
|
||||
action_on = piston_on,
|
||||
rules = piston_up_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
@ -339,8 +365,10 @@ minetest.register_node("mesecons_pistons:piston_up_normal_on", {
|
||||
node_box = piston_up_on_box,
|
||||
selection_box = piston_up_on_box,
|
||||
mesecons_piston = pistonspec_normal_up,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_off = piston_off,
|
||||
rules = piston_up_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
@ -393,8 +421,10 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_off", {
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_sticky_off",
|
||||
mesecons_piston = pistonspec_sticky_up,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_on = piston_on,
|
||||
rules = piston_up_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
@ -419,8 +449,10 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_on", {
|
||||
node_box = piston_up_on_box,
|
||||
selection_box = piston_up_on_box,
|
||||
mesecons_piston = pistonspec_sticky_up,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_off = piston_off,
|
||||
rules = piston_up_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
@ -452,7 +484,7 @@ minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", {
|
||||
local piston_down_pusher_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-2/16, -.5, -2/16, 2/16, .5 + pt, 2/16},
|
||||
{-2/16, -.5 + pt, -2/16, 2/16, .5 + pt, 2/16},
|
||||
{-.5 , -.5 , -.5 , .5 , -.5 + pt, .5},
|
||||
}
|
||||
}
|
||||
@ -491,8 +523,10 @@ minetest.register_node("mesecons_pistons:piston_down_normal_off", {
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_normal_off",
|
||||
mesecons_piston = pistonspec_normal_down,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_on = piston_on,
|
||||
rules = piston_down_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
@ -517,8 +551,10 @@ minetest.register_node("mesecons_pistons:piston_down_normal_on", {
|
||||
node_box = piston_down_on_box,
|
||||
selection_box = piston_down_on_box,
|
||||
mesecons_piston = pistonspec_normal_down,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_off = piston_off,
|
||||
rules = piston_down_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
@ -567,8 +603,10 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_off", {
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_sticky_off",
|
||||
mesecons_piston = pistonspec_sticky_down,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_on = piston_on,
|
||||
rules = piston_down_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
@ -593,8 +631,10 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_on", {
|
||||
node_box = piston_down_on_box,
|
||||
selection_box = piston_down_on_box,
|
||||
mesecons_piston = pistonspec_sticky_down,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_off = piston_off,
|
||||
rules = piston_down_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
@ -690,7 +730,7 @@ mesecon:register_mvps_stopper("mesecons_pistons:piston_down_sticky_on", piston_u
|
||||
|
||||
--craft recipes
|
||||
minetest.register_craft({
|
||||
output = 'mesecons_pistons:piston_normal_off 2',
|
||||
output = "mesecons_pistons:piston_normal_off 2",
|
||||
recipe = {
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"default:cobble", "default:steel_ingot", "default:cobble"},
|
||||
|
@ -13,18 +13,19 @@ minetest.register_node("mesecons_powerplant:power_plant", {
|
||||
description="Power Plant",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_powerplant:power_plant" 1',
|
||||
output = "mesecons_powerplant:power_plant 1",
|
||||
recipe = {
|
||||
{'"group:mesecon_conductor_craftable"'},
|
||||
{'"group:mesecon_conductor_craftable"'},
|
||||
{'"default:sapling"'},
|
||||
{"group:mesecon_conductor_craftable"},
|
||||
{"group:mesecon_conductor_craftable"},
|
||||
{"default:sapling"},
|
||||
}
|
||||
})
|
||||
|
@ -5,7 +5,7 @@ local pp_box_off = {
|
||||
|
||||
local pp_box_on = {
|
||||
type = "fixed",
|
||||
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
|
||||
fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 },
|
||||
}
|
||||
|
||||
pp_on_timer = function (pos, elapsed)
|
||||
@ -17,12 +17,15 @@ pp_on_timer = function (pos, elapsed)
|
||||
if not ppspec then return end
|
||||
|
||||
local objs = minetest.env: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.env:add_node(pos, {name = ppspec.offstate})
|
||||
mesecon:receptor_off(pos)
|
||||
-- force deactivation of mesecon two blocks below (hacky)
|
||||
mesecon:turnoff(mesecon:addPosRule(pos, {x = 0, y = -2, z = 0}))
|
||||
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()
|
||||
@ -30,7 +33,7 @@ pp_on_timer = function (pos, elapsed)
|
||||
minetest.env:add_node(pos, {name=ppspec.onstate})
|
||||
mesecon:receptor_on(pos)
|
||||
-- force activation of mesecon two blocks below (hacky)
|
||||
mesecon:turnon(mesecon:addPosRule(pos, {x = 0, y = -2, z = 0}))
|
||||
mesecon:turnon(two_below)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -46,7 +49,7 @@ end
|
||||
-- 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)
|
||||
function mesecon:register_pressure_plate(offstate, onstate, description, textures_off, textures_on, image_w, image_i, recipe)
|
||||
local ppspec = {
|
||||
offstate = offstate,
|
||||
onstate = onstate
|
||||
@ -54,9 +57,9 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
|
||||
|
||||
minetest.register_node(offstate, {
|
||||
drawtype = "nodebox",
|
||||
tiles = {texture_off},
|
||||
inventory_image = texture_off,
|
||||
wield_image = image,
|
||||
tiles = textures_off,
|
||||
inventory_image = image_i,
|
||||
wield_image = image_w,
|
||||
paramtype = "light",
|
||||
selection_box = pp_box_off,
|
||||
node_box = pp_box_off,
|
||||
@ -74,7 +77,7 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
|
||||
|
||||
minetest.register_node(onstate, {
|
||||
drawtype = "nodebox",
|
||||
tiles = {texture_on},
|
||||
tiles = textures_on,
|
||||
paramtype = "light",
|
||||
selection_box = pp_box_on,
|
||||
node_box = pp_box_on,
|
||||
@ -82,12 +85,19 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
|
||||
drop = offstate,
|
||||
pressureplate = ppspec,
|
||||
on_timer = pp_on_timer,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on
|
||||
}},
|
||||
on_construct = function(pos)
|
||||
minetest.env: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({
|
||||
@ -100,14 +110,18 @@ mesecon:register_pressure_plate(
|
||||
"mesecons_pressureplates:pressure_plate_wood_off",
|
||||
"mesecons_pressureplates:pressure_plate_wood_on",
|
||||
"Wooden Pressure Plate",
|
||||
"jeija_pressure_plate_wood_off.png",
|
||||
"jeija_pressure_plate_wood_on.png",
|
||||
{"jeija_pressure_plate_wood_off.png","jeija_pressure_plate_wood_off.png","jeija_pressure_plate_wood_off_edges.png"},
|
||||
{"jeija_pressure_plate_wood_on.png","jeija_pressure_plate_wood_on.png","jeija_pressure_plate_wood_on_edges.png"},
|
||||
"jeija_pressure_plate_wood_wield.png",
|
||||
"jeija_pressure_plate_wood_inv.png",
|
||||
{{"default:wood", "default:wood"}})
|
||||
|
||||
mesecon:register_pressure_plate(
|
||||
"mesecons_pressureplates:pressure_plate_stone_off",
|
||||
"mesecons_pressureplates:pressure_plate_stone_on",
|
||||
"Stone Pressure Plate",
|
||||
"jeija_pressure_plate_stone_off.png",
|
||||
"jeija_pressure_plate_stone_on.png",
|
||||
{"jeija_pressure_plate_stone_off.png","jeija_pressure_plate_stone_off.png","jeija_pressure_plate_stone_off_edges.png"},
|
||||
{"jeija_pressure_plate_stone_on.png","jeija_pressure_plate_stone_on.png","jeija_pressure_plate_stone_on_edges.png"},
|
||||
"jeija_pressure_plate_stone_wield.png",
|
||||
"jeija_pressure_plate_stone_inv.png",
|
||||
{{"default:cobble", "default:cobble"}})
|
||||
|
@ -5,6 +5,7 @@ minetest.register_node("mesecons_random:removestone", {
|
||||
inventory_image = minetest.inventorycube("jeija_removestone_inv.png"),
|
||||
groups = {cracky=3},
|
||||
description="Removestone",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
minetest.env:remove_node(pos)
|
||||
|
@ -22,6 +22,7 @@ minetest.register_node("mesecons_solarpanel:solar_panel_on", {
|
||||
},
|
||||
drop = "mesecons_solarpanel:solar_panel_off",
|
||||
groups = {dig_immediate=3, not_in_creative_inventory = 1},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on
|
||||
}}
|
||||
@ -51,16 +52,17 @@ minetest.register_node("mesecons_solarpanel:solar_panel_off", {
|
||||
},
|
||||
groups = {dig_immediate=3},
|
||||
description="Solar Panel",
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_solarpanel:solar_panel_off" 1',
|
||||
output = "mesecons_solarpanel:solar_panel_off 1",
|
||||
recipe = {
|
||||
{'"mesecons_materials:silicon"', '"mesecons_materials:silicon"'},
|
||||
{'"mesecons_materials:silicon"', '"mesecons_materials:silicon"'},
|
||||
{"mesecons_materials:silicon", "mesecons_materials:silicon"},
|
||||
{"mesecons_materials:silicon", "mesecons_materials:silicon"},
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -5,12 +5,14 @@ minetest.register_node("mesecons_switch:mesecon_switch_off", {
|
||||
paramtype2="facedir",
|
||||
groups = {dig_immediate=2},
|
||||
description="Switch",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off
|
||||
}},
|
||||
on_punch = function(pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_switch:mesecon_switch_on")
|
||||
mesecon:receptor_on(pos)
|
||||
minetest.sound_play("mesecons_switch", {pos=pos})
|
||||
end
|
||||
})
|
||||
|
||||
@ -18,20 +20,22 @@ minetest.register_node("mesecons_switch:mesecon_switch_on", {
|
||||
tiles = {"jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_on.png"},
|
||||
paramtype2="facedir",
|
||||
groups = {dig_immediate=2,not_in_creative_inventory=1},
|
||||
drop='"mesecons_switch:mesecon_switch_off" 1',
|
||||
drop="mesecons_switch:mesecon_switch_off 1",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on
|
||||
}},
|
||||
on_punch = function(pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_switch:mesecon_switch_off")
|
||||
mesecon:receptor_off(pos)
|
||||
minetest.sound_play("mesecons_switch", {pos=pos})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_switch:mesecon_switch_off" 2',
|
||||
output = "mesecons_switch:mesecon_switch_off 2",
|
||||
recipe = {
|
||||
{'"default:steel_ingot"', '"default:cobble"', '"default:steel_ingot"'},
|
||||
{'"group:mesecon_conductor_craftable"','', '"group:mesecon_conductor_craftable"'},
|
||||
{"default:steel_ingot", "default:cobble", "default:steel_ingot"},
|
||||
{"group:mesecon_conductor_craftable","", "group:mesecon_conductor_craftable"},
|
||||
}
|
||||
})
|
||||
|
BIN
mesecons_switch/sounds/mesecons_switch.ogg
Normal file
BIN
mesecons_textures/textures/jeija_close_window.png
Normal file
After Width: | Height: | Size: 323 B |
BIN
mesecons_textures/textures/jeija_lightstone_yellow_off.png
Normal file
After Width: | Height: | Size: 291 B |
BIN
mesecons_textures/textures/jeija_lightstone_yellow_on.png
Normal file
After Width: | Height: | Size: 486 B |
BIN
mesecons_textures/textures/jeija_luac_background.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
mesecons_textures/textures/jeija_luac_runbutton.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
mesecons_textures/textures/jeija_luacontroller_LED_A.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
mesecons_textures/textures/jeija_luacontroller_LED_B.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
mesecons_textures/textures/jeija_luacontroller_LED_C.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
mesecons_textures/textures/jeija_luacontroller_LED_D.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
mesecons_textures/textures/jeija_luacontroller_burnt_top.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
mesecons_textures/textures/jeija_luacontroller_top.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
mesecons_textures/textures/jeija_pressure_plate_stone_inv.png
Normal file
After Width: | Height: | Size: 604 B |
Before Width: | Height: | Size: 648 B After Width: | Height: | Size: 555 B |
After Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 680 B After Width: | Height: | Size: 579 B |
After Width: | Height: | Size: 336 B |
BIN
mesecons_textures/textures/jeija_pressure_plate_stone_wield.png
Normal file
After Width: | Height: | Size: 604 B |
BIN
mesecons_textures/textures/jeija_pressure_plate_wood_inv.png
Normal file
After Width: | Height: | Size: 716 B |
Before Width: | Height: | Size: 750 B After Width: | Height: | Size: 663 B |
After Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 772 B After Width: | Height: | Size: 675 B |
After Width: | Height: | Size: 336 B |
BIN
mesecons_textures/textures/jeija_pressure_plate_wood_wield.png
Normal file
After Width: | Height: | Size: 716 B |
BIN
mesecons_textures/textures/mesecons_dispenser_bottom.png
Normal file
After Width: | Height: | Size: 731 B |
BIN
mesecons_textures/textures/mesecons_dispenser_front.png
Normal file
After Width: | Height: | Size: 827 B |
BIN
mesecons_textures/textures/mesecons_dispenser_side.png
Normal file
After Width: | Height: | Size: 731 B |
BIN
mesecons_textures/textures/mesecons_dispenser_top.png
Normal file
After Width: | Height: | Size: 731 B |
@ -35,7 +35,7 @@ local torch_get_input_rules = function(node)
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_torch:mesecon_torch_on" 4',
|
||||
output = "mesecons_torch:mesecon_torch_on 4",
|
||||
recipe = {
|
||||
{"group:mesecon_conductor_craftable"},
|
||||
{"default:stick"},}
|
||||
|
@ -34,7 +34,9 @@ minetest.register_node("mesecons_walllever:wall_lever_off", {
|
||||
on_punch = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_walllever:wall_lever_on")
|
||||
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||
minetest.sound_play("mesecons_lever", {pos=pos})
|
||||
end,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {receptor = {
|
||||
rules = mesecon.rules.buttonlike_get,
|
||||
state = mesecon.state.off
|
||||
@ -69,12 +71,14 @@ minetest.register_node("mesecons_walllever:wall_lever_on", {
|
||||
{ -1/16, 0, 4/16, 1/16, 8/16, 6/16 }} -- the lever itself.
|
||||
},
|
||||
groups = {dig_immediate = 2, not_in_creative_inventory = 1, mesecon_needs_receiver = 1},
|
||||
drop = '"mesecons_walllever:wall_lever_off" 1',
|
||||
drop = "mesecons_walllever:wall_lever_off 1",
|
||||
description="Lever",
|
||||
on_punch = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_walllever:wall_lever_off")
|
||||
mesecon:receptor_off(pos, mesecon.rules.buttonlike_get(node))
|
||||
minetest.sound_play("mesecons_lever", {pos=pos})
|
||||
end,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {receptor = {
|
||||
rules = mesecon.rules.buttonlike_get,
|
||||
state = mesecon.state.on
|
||||
@ -82,10 +86,10 @@ minetest.register_node("mesecons_walllever:wall_lever_on", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_walllever:wall_lever_off" 2',
|
||||
output = "mesecons_walllever:wall_lever_off 2",
|
||||
recipe = {
|
||||
{'"group:mesecon_conductor_craftable"'},
|
||||
{'"default:stone"'},
|
||||
{'"default:stick"'},
|
||||
{"group:mesecon_conductor_craftable"},
|
||||
{"default:stone"},
|
||||
{"default:stick"},
|
||||
}
|
||||
})
|
||||
|