-- Object detector
-- Detects all entities in a certain radius
-- The radius can be specified in mesecons/settings.lua
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
}}
})
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
}}
})
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"},
}
})
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~=nil then
if obj:get_is_player()==true then
minetest.env:add_node(pos, {name="mesecons_detector:object_detector_on"})
mesecon:receptor_on(pos)
end
end
end
end,
})
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 ~= nil then
if obj:get_is_player()==true then
objectfound=objectfound+1
end
end
end
if objectfound==0 then
minetest.env:add_node(pos, {name="mesecons_detector:object_detector_off"})
mesecon:receptor_off(pos)
end
end,
})
10:40:16: ERROR[main]: ERROR: An unhandled exception occurred: ServerError: LuaError: error: .../bin/../mods/gl
o/mesecons/mesecons_detector/init.lua:44: attempt to call method 'get_is_player' (a nil value)
10:40:16: ERROR[main]: stack traceback:
In thread 7fca6f406720:
/home/minetest/celeron55-minetest-5d18dc3/src/main.cpp:1760: int main(int, char**): Assertion '0' failed.
Debug stacks:
DEBUG STACK FOR THREAD 7fca6f406720:
#0 int main(int, char**)
(Leftover data: #1 Dedicated server branch)
(Leftover data: #2 virtual void ServerMap::save(ModifiedState))
(Leftover data: #3 virtual void ServerMap::saveBlock(MapBlock*))
(Leftover data: #4 void ItemStack::serialize(std::ostream&) const)
Abandon
Jeija wrote:I think it should be is_player() not get_is_player()
x = function() x() end; x()
w_h_i_l_e = function(condition, body)
if condition() then
body()
return w_h_i_l_e(condition, body)
end
end
x = 0
w_h_i_l_e(function() return x < 5 end, function()
x = x + 1
print("Iteration number " + tostring(x))
end)
w_h_i_l_e(function() return true end, function() end)
i = 0
x = function(i)
if i == 100 then return end
x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);x(i+1);
end
function fib(n) return n<2 and n or fib(n-1)+fib(n-2) end
fib(100)
dimitry wrote:it would be nice to add as distributor in minecraft
thank you
neron wrote:I vote for Option 1. I'd even like to see maybe a fork of minetest that clones minecraft.
Nore wrote:Could you add functions like tostring, tonumber, string.gsub, ... to the luacontroller? It would be so helpful.
Inocudom wrote:Go with option number 2, but find a way to fix those limitations if you can. It would also be a good idea to try to improve compatibility with mods that rely on mesecons (like technic and bobblocks) since the newest version of it is not compatible with them.
Jeija wrote:The compatibility with other mods that use mesecons is the mod owners responsibility. I announced the API change a long time before it actually took place, and that change was basically there to improve depending stuff, so compatibility.
Jeija wrote:Sorry, RabbiBob for not telling you. The problem is just that there are many mods using mesecons and I also don't know all of them, that's why I didn't post in all the topics.
But true, I could have told the ones I know and I will do that in case a second update is required (there are no plans however).
Users browsing this forum: No registered users and 11 guests