Hybrid Dog wrote:I thought about making it possible to let addi's cannon shoot automatically.
You pump the gunpowder and muni into the cannon with pipeworks
then you let a piston move away the pipe
after that you have a mesecons igniter which gets digiline signals for the direction and a mesecons signal for firing the cannon
the direction is calculated by a luacontroller, which knows the target position because you used a laser pointer which sent the signal offering coordinates to a digiline receiver
and maybe you can so let a cannon fire extremely often in a second.
12Me21 wrote:you shouldn't have to use mese blocks to transmit power upwards.
Sokomine wrote:12Me21 wrote:you shouldn't have to use mese blocks to transmit power upwards.
There seem to be vertical mesecon lines. It's still not easy. Wiring up the whole machinery is usually more trouble than anything else. It's a lot trial and error...
local GET_COMMAND = "GET"
-- Object detector
-- Detects players in a certain radius
-- The radius can be specified in mesecons/settings.lua
local object_detector_make_formspec = function (pos)
local meta = minetest.get_meta(pos)
if meta:get_string("distance")==nil or meta:get_string("distance")=="" then
meta:set_string("distance", "6")
end
meta:set_string("formspec", "size[9,3.5]" ..
"field[0.3, 0;9,2;scanname;Name of player to scan for (empty for any):;${scanname}]"..
"field[0.3, 1.67;2.4,1;distance;Distance(1-6):;${distance}]"..
"field[0.3,3;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
"button_exit[7,1.75;2,3;;Save]")
end
local object_detector_on_receive_fields = function(pos, formname, fields)
if not fields.scanname and not fields.distance then return end;
local meta = minetest.get_meta(pos)
meta:set_string("scanname", fields.scanname)
--check if entered only numbers and if it not to big (max==6)
if string.lower(fields.distance)==string.upper(fields.distance) and tonumber(fields.distance)>=1 and tonumber(fields.distance)<7 then
meta:set_string("distance", math.floor(tonumber(fields.distance)))
end
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 meta = minetest.get_meta(pos)
if meta:get_string("distance")==nil or meta:get_string("distance")=="" then
meta:set_string("distance", "6")
end
local objs = minetest.get_objects_inside_radius(pos, mesecon.setting("detector_radius", meta:get_string("distance")
))
for k, obj in pairs(objs) do
local isname = obj:get_player_name() -- "" is returned if it is not a player; "" ~= nil!
local scanname = minetest.get_meta(pos):get_string("scanname")
if (isname == scanname and isname ~= "") or (isname ~= "" and scanname == "") then -- player with scanname found or not scanname specified
return true
end
end
return false
end
-- set player name when receiving a digiline signal on a specific channel
local object_detector_digiline = {
effector = {
action = function (pos, node, channel, msg)
local meta = minetest.get_meta(pos)
local active_channel = meta:get_string("digiline_channel")
if channel == active_channel then
meta:set_string("scanname", msg)
object_detector_make_formspec(pos)
end
end,
}
}
minetest.register_node("mesecons_detector:object_detector_off", {
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",
walkable = true,
groups = {cracky=3},
description="Player Detector",
mesecons = {receptor = {
state = mesecon.state.off,
rules = mesecon.rules.pplate
}},
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", {
tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png"},
paramtype = "light",
walkable = true,
groups = {cracky=3,not_in_creative_inventory=1},
drop = 'mesecons_detector:object_detector_off',
mesecons = {receptor = {
state = mesecon.state.on,
rules = mesecon.rules.pplate
}},
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: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"},
}
})
minetest.register_abm(
{nodenames = {"mesecons_detector:object_detector_off"},
interval = 1.0,
chance = 1,
action = function(pos)
if object_detector_scan(pos) then
minetest.swap_node(pos, {name = "mesecons_detector:object_detector_on"})
mesecon.receptor_on(pos, mesecon.rules.pplate)
end
end,
})
minetest.register_abm(
{nodenames = {"mesecons_detector:object_detector_on"},
interval = 1.0,
chance = 1,
action = function(pos)
if not object_detector_scan(pos) then
minetest.swap_node(pos, {name = "mesecons_detector:object_detector_off"})
mesecon.receptor_off(pos, mesecon.rules.pplate)
end
end,
})
-- Node detector
-- Detects the node in front of it
local node_detector_make_formspec = function (pos)
local meta = minetest.get_meta(pos)
if meta:get_string("distance")==nil or meta:get_string("distance")=="" then
meta:set_string("distance", "1")
end
meta:set_string("formspec", "size[9,3.5]" ..
"field[0.3, 0;9,2;scanname;Name of node to scan for (empty for any):;${scanname}]"..
"field[0.3, 1.67;2.4,1;distance;Distance(1-6):;${distance}]"..
"field[0.3,2.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
"button_exit[7,1.75;2,3;;Save]")
end
local node_detector_on_receive_fields = function(pos, formname, fields)
if not fields.scanname and not fields.distance then return end;
local meta = minetest.get_meta(pos)
meta:set_string("scanname", fields.scanname)
--check if entered only numbers and if it not to big (max==6)
if string.lower(fields.distance)==string.upper(fields.distance)
and tonumber(fields.distance)>=1 and tonumber(fields.distance)<7 then
meta:set_string("distance", math.floor(tonumber(fields.distance)))
end
meta:set_string("digiline_channel", fields.digiline_channel)
node_detector_make_formspec(pos)
end
-- returns true if player was found, false if not
local node_detector_scan = function (pos)
local meta = minetest.get_meta(pos)
local dist = meta:get_string("distance")
if dist==nil or dist=="" then
dist=1
else
dist=tonumber(dist)
end
local node = minetest.get_node(pos)
local vector = vector.subtract(pos, minetest.facedir_to_dir(node.param2))
local frontpos={x=(vector.x-pos.x)*dist+pos.x, y=(vector.y-pos.y)*dist+pos.y, z=(vector.z-pos.z)*dist+pos.z }
local frontnode = minetest.get_node(frontpos)
local meta = minetest.get_meta(pos)
return (frontnode.name == meta:get_string("scanname")) or
(frontnode.name ~= "air" and frontnode.name ~= "ignore" and meta:get_string("scanname") == "")
end
-- set player name when receiving a digiline signal on a specific channel
local node_detector_digiline = {
effector = {
action = function (pos, node, channel, msg)
local meta = minetest.get_meta(pos)
local active_channel = meta:get_string("digiline_channel")
if channel == active_channel then
if msg == GET_COMMAND then
local frontpos = vector.subtract(pos, minetest.facedir_to_dir(node.param2))
local name = minetest.get_node(frontpos).name
digiline:receptor_send(pos, digiline.rules.default, channel, name)
else
meta:set_string("scanname", msg)
node_detector_make_formspec(pos)
end
end
end,
},
receptor = {}
}
minetest.register_node("mesecons_detector:node_detector_off", {
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "jeija_node_detector_off.png"},
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
groups = {cracky=3},
description="Node Detector",
mesecons = {receptor = {
state = mesecon.state.off
}},
on_construct = node_detector_make_formspec,
on_receive_fields = node_detector_on_receive_fields,
after_place_node = function (pos, placer)
local placer_pos = placer:getpos()
--correct for the player's height
if placer:is_player() then placer_pos.y = placer_pos.y + 1.5 end
--correct for 6d facedir
if placer_pos then
local dir = {
x = pos.x - placer_pos.x,
y = pos.y - placer_pos.y,
z = pos.z - placer_pos.z
}
local node = minetest.get_node(pos)
node.param2 = minetest.dir_to_facedir(dir, true)
minetest.set_node(pos, node)
minetest.log("action", "real (6d) facedir: " .. node.param2)
end
end,
sounds = default.node_sound_stone_defaults(),
digiline = node_detector_digiline
})
minetest.register_node("mesecons_detector:node_detector_on", {
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "jeija_node_detector_on.png"},
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
groups = {cracky=3,not_in_creative_inventory=1},
drop = 'mesecons_detector:node_detector_off',
mesecons = {receptor = {
state = mesecon.state.on
}},
on_construct = node_detector_make_formspec,
on_receive_fields = node_detector_on_receive_fields,
after_place_node = function (pos, placer)
local placer_pos = placer:getpos()
--correct for the player's height
if placer:is_player() then placer_pos.y = placer_pos.y + 1.5 end
--correct for 6d facedir
if placer_pos then
local dir = {
x = pos.x - placer_pos.x,
y = pos.y - placer_pos.y,
z = pos.z - placer_pos.z
}
local node = minetest.get_node(pos)
node.param2 = minetest.dir_to_facedir(dir, true)
minetest.set_node(pos, node)
minetest.log("action", "real (6d) facedir: " .. node.param2)
end
end,
sounds = default.node_sound_stone_defaults(),
digiline = node_detector_digiline
})
minetest.register_craft({
output = 'mesecons_detector:node_detector_off',
recipe = {
{"default:steel_ingot", "group:mesecon_conductor_craftable", "default:steel_ingot"},
{"default:steel_ingot", "mesecons_luacontroller:luacontroller0000", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
}
})
minetest.register_abm(
{nodenames = {"mesecons_detector:node_detector_off"},
interval = 1.0,
chance = 1,
action = function(pos, node)
if node_detector_scan(pos) then
minetest.swap_node(pos, {name = "mesecons_detector:node_detector_on", param2 = node.param2})
mesecon.receptor_on(pos)
end
end,
})
minetest.register_abm(
{nodenames = {"mesecons_detector:node_detector_on"},
interval = 1.0,
chance = 1,
action = function(pos, node)
if not node_detector_scan(pos) then
minetest.swap_node(pos, {name = "mesecons_detector:node_detector_off", param2 = node.param2})
mesecon.receptor_off(pos)
end
end,
})
Miner59 wrote:Hi,
I changed mesecons_detector to allow the player to enter a distance, […]
addi88088 wrote:Okay... I'm slightly new to all of this, though I have gotten most of my mods to work. Until this one...
Problem I am having is when enabled, it won't fully load because of this:
22:19:04: ERROR[main]: ========== ERROR FROM LUA ===========
22:19:04: ERROR[main]: Failed to load and run script from
22:19:04: ERROR[main]: /home/addi/.minetest/mods/Jeija-minetest-mod-mesecons-fec43a3/mesecons_torch/init.lua:
22:19:04: ERROR[main]: ...ja-minetest-mod-mesecons-fec43a3/mesecons_torch/init.lua:79: attempt to perform arithmetic on field 'LIGHT_MAX' (a nil value)
22:19:04: ERROR[main]: stack traceback:
22:19:04: ERROR[main]: ...ja-minetest-mod-mesecons-fec43a3/mesecons_torch/init.lua:79: in main chunk
22:19:04: ERROR[main]: ======= END OF ERROR FROM LUA ========
(Also don't mind the file name, I tried removing and re-applying the mod folder, and decided to leave the full title because I know it doesn't much matter as it's a modpack anyhow)
And when I go to the script and hit up line 79, it brings me to:
light_source = default.LIGHT_MAX-5,
So if it's a noobish mistake I apologize, but please inform me of how this can be fixed, thanks :$
LionsDen wrote:The mod folder needs to be named mesecons. According to what I can see of you path, it should be:
/home/addi/.minetest/mods/mesecons/
I don't know if there is anything else wrong but I am using the latest mesecons with the latest minetest and am not having problems.
light_source = LIGHT_MAX-5,
addi88088 wrote:Okay... I'm slightly new to all of this, though I have gotten most of my mods to work. Until this one...
Problem I am having is when enabled, it won't fully load because of this:
--debug log--
(Also don't mind the file name, I tried removing and re-applying the mod folder, and decided to leave the full title because I know it doesn't much matter as it's a modpack anyhow)
And when I go to the script and hit up line 79, it brings me to:
light_source = default.LIGHT_MAX-5,
So if it's a noobish mistake I apologize, but please inform me of how this can be fixed, thanks :$
addi88088 wrote:EDIT: by the way.. To fix, I ended up getting rid of the 'default.LIGHT_MAX' completely, as I have back-up's, if anything were to go wrong. So ill make a quick note of the removal of just the 'default.' just in case I come across any problems from removing the section I had removed.
TenPlus1 wrote:SloMo24: I dont think that you can, it would have to be placed manually to work properly...
minetest.register_abm({
nodenames = {"mesecons_pressureplates:pressure_plate_stone_off"},
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.get_node_timer(pos):start(mesecon.setting("pplate_interval", 0.1))
end,
})
-------------
Separator
-------------
Irrlicht log: Irrlicht Engine version 1.8.1
Irrlicht log: Microsoft Windows 7 Home Premium Edition Service Pack 1 (Build 7601)
Irrlicht log: Using renderer: OpenGL 4.4.13084
Irrlicht log: AMD Radeon R7 200 Series: ATI Technologies Inc.
Irrlicht log: OpenGL driver version is 1.2 or better.
Irrlicht log: GLSL version: 4.4
Irrlicht log: Resizing window (800 600)
[OK] Mesecons
19:58:12: ACTION[main]: .__ __ __
19:58:12: ACTION[main]: _____ |__| ____ _____/ |_ ____ _______/ |_
19:58:12: ACTION[main]: / \| |/ \_/ __ \ __\/ __ \ / ___/\ __\
19:58:12: ACTION[main]: | Y Y \ | | \ ___/| | \ ___/ \___ \ | |
19:58:12: ACTION[main]: |__|_| /__|___| /\___ >__| \___ >____ > |__|
19:58:12: ACTION[main]: \/ \/ \/ \/ \/
19:58:12: ACTION[main]: World at [C:\Program Files\minetest-0.4.12\bin\..\worlds\test]
19:58:12: ACTION[main]: Server for gameid="minetest" listening on 0.0.0.0:50459.
19:58:29: ACTION[ServerThread]: singleplayer [127.0.0.1] joins game.
19:58:29: ACTION[ServerThread]: singleplayer joins game. List of players: singleplayer
Irrlicht log: Could not open file of texture: character.png
19:59:05: ACTION[ServerThread]: singleplayer takes "mesecons_detector:node_detector_off" from creative inventory
19:59:07: ACTION[ServerThread]: singleplayer takes "mesecons_detector:object_detector_off" from creative inventory
19:59:25: ACTION[ServerThread]: singleplayer takes "default:stone" from creative inventory
19:59:29: ACTION[ServerThread]: singleplayer places node mesecons_detector:node_detector_off at (31,3,-76)
19:59:29: ACTION[ServerThread]: facedir: 3
19:59:29: ACTION[ServerThread]: real (6d) facedir: 3
19:59:47: ACTION[ServerThread]: singleplayer places node default:stone at (31,3,-77)
19:59:51: ACTION[ServerThread]: singleplayer places node mesecons_detector:object_detector_off at (31,3,-73)
20:01:06: ACTION[ServerThread]: singleplayer digs default:stone at (31,3,-77)
20:01:07: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (32,2,-76)
20:01:07: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (31,2,-76)
20:01:09: ACTION[ServerThread]: singleplayer places node default:stone at (31,2,-76)
20:01:11: ACTION[ServerThread]: singleplayer places node default:stone at (31,3,-77)
20:01:12: ACTION[ServerThread]: singleplayer places node default:stone at (31,4,-77)
20:01:13: ACTION[ServerThread]: singleplayer places node default:stone at (31,4,-76)
20:01:14: ACTION[ServerThread]: singleplayer places node default:stone at (31,4,-75)
20:01:15: ACTION[ServerThread]: singleplayer places node default:stone at (31,3,-75)
20:01:17: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (32,2,-77)
20:01:17: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (31,2,-77)
20:01:18: ACTION[ServerThread]: singleplayer places node default:stone at (31,2,-77)
20:01:19: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (32,2,-75)
20:01:19: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (31,2,-75)
20:01:20: ACTION[ServerThread]: singleplayer places node default:stone at (31,2,-75)
20:01:22: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (30,2,-77)
20:01:23: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (30,2,-76)
20:01:23: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (30,2,-75)
20:01:24: ACTION[ServerThread]: singleplayer places node default:stone at (30,2,-75)
20:01:25: ACTION[ServerThread]: singleplayer places node default:stone at (30,3,-75)
20:01:26: ACTION[ServerThread]: singleplayer places node default:stone at (30,4,-75)
20:01:26: ACTION[ServerThread]: singleplayer places node default:stone at (30,4,-76)
20:01:27: ACTION[ServerThread]: singleplayer places node default:stone at (30,4,-77)
20:01:27: ACTION[ServerThread]: singleplayer places node default:stone at (30,3,-77)
20:01:28: ACTION[ServerThread]: singleplayer places node default:stone at (30,3,-76)
20:01:29: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (29,2,-75)
20:01:30: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (29,2,-76)
20:01:30: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (29,2,-77)
20:01:31: ACTION[ServerThread]: singleplayer places node default:stone at (30,2,-77)
20:01:31: ACTION[ServerThread]: singleplayer places node default:stone at (30,2,-76)
20:01:33: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (29,2,-78)
20:01:33: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (30,2,-78)
20:01:34: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (31,2,-78)
20:01:34: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (32,2,-78)
20:01:37: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (32,2,-74)
20:01:37: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (31,2,-74)
20:01:37: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (30,2,-74)
20:01:38: ACTION[ServerThread]: singleplayer digs default:dirt_with_grass at (29,2,-74)
Users browsing this forum: Bing [Bot] and 25 guests