mirror of
https://github.com/AFCMS/mesecons_onlinedetector.git
synced 2024-11-21 22:53:53 +01:00
fix crash and add mcl2 support
This commit is contained in:
parent
9a985ede61
commit
27286e2298
129
init.lua
129
init.lua
@ -3,6 +3,8 @@ minetest.log("action", "[mesecons_onlinedetector] loading...")
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
local F = minetest.formspec_escape
|
||||
|
||||
local has_mcl_core = minetest.get_modpath("mcl_core")
|
||||
|
||||
local table = table
|
||||
|
||||
local function get_detector_form(default)
|
||||
@ -38,56 +40,74 @@ local function update_detector_off(pos, target)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("mesecons_onlinedetector:online_detector_off", {
|
||||
local nodedef = {
|
||||
description = S("Online Detector"),
|
||||
_doc_items_longdesc = S("Allows you to know if a player is connected."),
|
||||
tiles = {"mesecons_onlinedetector_online_detector_off.png"},
|
||||
groups = {cracky = 2, mesecon_detector_off = 1, mesecon = 2},
|
||||
mesecons = {
|
||||
receptor = {
|
||||
state = mesecon.state.off,
|
||||
rules = mesecon.rules.alldirs,
|
||||
},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", get_detector_form(meta:get_string("name")))
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
if fields.name then
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("name", fields.name)
|
||||
meta:set_string("formspec", get_detector_form(fields.name))
|
||||
update_detector_off(pos, fields.name)
|
||||
end
|
||||
end,
|
||||
})
|
||||
}
|
||||
|
||||
minetest.register_node("mesecons_onlinedetector:online_detector_on", {
|
||||
description = S("Online Detector"),
|
||||
_doc_items_longdesc = S("Allows you to know if a player is connected."),
|
||||
tiles = {"mesecons_onlinedetector_online_detector_on.png"},
|
||||
groups = {cracky = 2, mesecon_detector_on = 1, mesecon = 2, not_in_creative_inventory = 1},
|
||||
drop = "mesecons_onlinedetector:online_detector_off",
|
||||
mesecons = {
|
||||
receptor = {
|
||||
state = mesecon.state.on,
|
||||
rules = mesecon.rules.alldirs,
|
||||
},
|
||||
|
||||
local off_def = table.copy(nodedef)
|
||||
|
||||
off_def.tiles = {"mesecons_onlinedetector_online_detector_off.png"}
|
||||
|
||||
off_def.mesecons = {
|
||||
receptor = {
|
||||
state = mesecon.state.off,
|
||||
rules = mesecon.rules.alldirs,
|
||||
},
|
||||
on_construct = function(pos)
|
||||
}
|
||||
|
||||
function off_def.on_receive_fields(pos, formname, fields, sender)
|
||||
if fields.name then
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", get_detector_form(meta:get_string("name")))
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
if fields.name then
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("name", fields.name)
|
||||
meta:set_string("formspec", get_detector_form(fields.name))
|
||||
update_detector_on(pos, fields.name)
|
||||
end
|
||||
end,
|
||||
})
|
||||
meta:set_string("name", fields.name)
|
||||
meta:set_string("formspec", get_detector_form(fields.name))
|
||||
update_detector_off(pos, fields.name)
|
||||
end
|
||||
end
|
||||
|
||||
if has_mcl_core then
|
||||
--off_def.groups = {cracky = 2, mesecon_detector_off = 1, mesecon = 2}
|
||||
off_def.groups = {handy = 1, mesecon_detector_off = 1, mesecon = 2}
|
||||
else
|
||||
off_def.groups = {cracky = 2, mesecon_detector_off = 1, mesecon = 2}
|
||||
end
|
||||
|
||||
minetest.register_node("mesecons_onlinedetector:online_detector_off", off_def)
|
||||
|
||||
|
||||
local on_def = table.copy(nodedef)
|
||||
|
||||
on_def.tiles = {"mesecons_onlinedetector_online_detector_on.png"}
|
||||
|
||||
on_def.mesecons = {
|
||||
receptor = {
|
||||
state = mesecon.state.on,
|
||||
rules = mesecon.rules.alldirs,
|
||||
},
|
||||
}
|
||||
|
||||
function on_def.on_receive_fields(pos, formname, fields, sender)
|
||||
if fields.name then
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("name", fields.name)
|
||||
meta:set_string("formspec", get_detector_form(fields.name))
|
||||
update_detector_on(pos, fields.name)
|
||||
end
|
||||
end
|
||||
|
||||
if has_mcl_core then
|
||||
--on_def.groups = {cracky = 2, mesecon_detector_off = 1, mesecon = 2}
|
||||
on_def.groups = {handy = 1, mesecon_detector_on = 1, mesecon = 2}
|
||||
else
|
||||
on_def.groups = {cracky = 2, mesecon_detector_on = 1, mesecon = 2}
|
||||
end
|
||||
|
||||
minetest.register_node("mesecons_onlinedetector:online_detector_on", on_def)
|
||||
|
||||
minetest.register_abm({
|
||||
label = "mesecons_onlinedetector:online_detector_off",
|
||||
@ -109,13 +129,24 @@ minetest.register_abm({
|
||||
end,
|
||||
})
|
||||
|
||||
--[[minetest.register_craft({
|
||||
output = "mesecons_onlinedetector:online_detector_off",
|
||||
recipe = {
|
||||
{'mcl_dye:black', 'mcl_dye:black', 'mcl_dye:black'},
|
||||
{'mcl_dye:black', 'pala_paladium:paladium_ingot', 'mcl_dye:black'},
|
||||
{'pala_paladium:titanium_ingot', 'pala_paladium:titanium_ingot', 'pala_paladium:titanium_ingot'},
|
||||
}
|
||||
})]]
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.register_craft({
|
||||
output = "mesecons_onlinedetector:online_detector_off",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "mesecons_luacontroller:luacontroller0000", "default:steel_ingot"},
|
||||
{"default:stone", "default:stone", "default:stone"},
|
||||
},
|
||||
})
|
||||
elseif has_mcl_core then
|
||||
minetest.register_craft({
|
||||
output = "mesecons_onlinedetector:online_detector_off",
|
||||
recipe = {
|
||||
{"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"},
|
||||
{"mcl_core:iron_ingot", "mesecons:wire_00000000_off", "mcl_core:iron_ingot"},
|
||||
{"mcl_core:stone", "mcl_core:stone", "mcl_core:stone"},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
minetest.log("action", "[mesecons_onlinedetector] loaded succesfully")
|
||||
|
1
mod.conf
1
mod.conf
@ -1,4 +1,5 @@
|
||||
name = mesecons_onlinedetector
|
||||
description = Add online detector to mesecons
|
||||
depends = mesecons
|
||||
optional_depends = default, mcl_core, mesecons_luacontroller
|
||||
author = AFCMS
|
||||
|
Loading…
Reference in New Issue
Block a user