forked from minetest-mods/MoreMesecons
change a bit more code
meta:get_string isn't nil, and minetest. Swap node keeps meta l think
This commit is contained in:
parent
1b68f9b8ce
commit
e0a29b1027
@ -27,9 +27,6 @@ local function object_detector_on_receive_fields(pos, formname, fields)
|
|||||||
if r then
|
if r then
|
||||||
meta:set_int("radius", r)
|
meta:set_int("radius", r)
|
||||||
end
|
end
|
||||||
if not meta:get_string("formspec") then
|
|
||||||
make_formspec(meta)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns true if player was found, false if not
|
-- returns true if player was found, false if not
|
||||||
@ -61,7 +58,7 @@ local object_detector_digiline = {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
meta:set_string("scanname", msg)
|
meta:set_string("scanname", msg)
|
||||||
if not meta:get_string("formspec") then
|
if meta:get_string("formspec") ~= "" then
|
||||||
make_formspec(meta)
|
make_formspec(meta)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -69,7 +66,7 @@ local object_detector_digiline = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
minetest.register_node("moremesecons_adjustable_player_detector:player_detector_off", {
|
minetest.register_node("moremesecons_adjustable_player_detector:player_detector_off", {
|
||||||
tiles = {"default_steel_block.png", "default_steel_block.png", "moremesecons_player_detector_off.png", "moremesecons_player_detector_off.png", "moremesecons_player_detector_off.png", "moremesecons_player_detector_off.png"},
|
tiles = {"default_steel_block.png", "default_steel_block.png", "moremesecons_player_detector_off.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
walkable = true,
|
walkable = true,
|
||||||
groups = {cracky=3},
|
groups = {cracky=3},
|
||||||
@ -85,7 +82,7 @@ minetest.register_node("moremesecons_adjustable_player_detector:player_detector_
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("moremesecons_adjustable_player_detector:player_detector_on", {
|
minetest.register_node("moremesecons_adjustable_player_detector:player_detector_on", {
|
||||||
tiles = {"default_steel_block.png", "default_steel_block.png", "moremesecons_player_detector_on.png", "moremesecons_player_detector_on.png", "moremesecons_player_detector_on.png", "moremesecons_player_detector_on.png"},
|
tiles = {"default_steel_block.png", "default_steel_block.png", "moremesecons_player_detector_on.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
walkable = true,
|
walkable = true,
|
||||||
groups = {cracky=3,not_in_creative_inventory=1},
|
groups = {cracky=3,not_in_creative_inventory=1},
|
||||||
@ -108,8 +105,8 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm(
|
minetest.register_abm({
|
||||||
{nodenames = {"moremesecons_adjustable_player_detector:player_detector_off"},
|
nodenames = {"moremesecons_adjustable_player_detector:player_detector_off"},
|
||||||
interval = 1.0,
|
interval = 1.0,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
@ -120,8 +117,8 @@ minetest.register_abm(
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm(
|
minetest.register_abm({
|
||||||
{nodenames = {"moremesecons_adjustable_player_detector:player_detector_on"},
|
nodenames = {"moremesecons_adjustable_player_detector:player_detector_on"},
|
||||||
interval = 1.0,
|
interval = 1.0,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
|
@ -1,38 +1,36 @@
|
|||||||
local MAX_DISTANCE = 8
|
local MAX_DISTANCE = 8
|
||||||
|
|
||||||
local sayer_activate = function(pos)
|
local function sayer_activate(pos)
|
||||||
local players = minetest.get_connected_players()
|
local tab = {
|
||||||
local text = minetest.get_meta(pos):get_string("text")
|
"Sayer at pos",
|
||||||
for index, player in pairs(players) do
|
nil,
|
||||||
local distance = vector.distance(pos, player:getpos())
|
"says : "..minetest.get_meta(pos):get_string("text")
|
||||||
if distance <= MAX_DISTANCE then
|
}
|
||||||
minetest.chat_send_player(player:get_player_name(), "Sayer at pos "
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
..tostring(pos.x)..","
|
if vector.distance(pos, player:getpos()) <= MAX_DISTANCE then
|
||||||
..tostring(pos.y)..","
|
tab[2] = minetest.pos_to_string(pos)
|
||||||
..tostring(pos.z)
|
minetest.chat_send_player(player:get_player_name(), table.concat(tab, " "))
|
||||||
.." says : "
|
|
||||||
..text)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("moremesecons_sayer:sayer", {
|
minetest.register_node("moremesecons_sayer:sayer", {
|
||||||
description = "sayer",
|
description = "sayer",
|
||||||
tiles = {"mesecons_noteblock.png", "default_wood.png", "default_wood.png", "default_wood.png", "default_wood.png", "default_wood.png"},
|
tiles = {"mesecons_noteblock.png", "default_wood.png"},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||||
},
|
},
|
||||||
groups = {dig_immediate = 2},
|
groups = {dig_immediate = 2},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
minetest.get_meta(pos):set_string("formspec", "field[text;text;${text}]")
|
||||||
meta:set_string("formspec", "field[text;text;${text}]")
|
|
||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
on_receive_fields = function(pos, _, fields)
|
||||||
local meta = minetest.get_meta(pos)
|
if fields.text then
|
||||||
meta:set_string("text", fields.text)
|
minetest.get_meta(pos):set_string("text", fields.text)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
mesecons = {effector = {
|
mesecons = {effector = {
|
||||||
action_on = sayer_activate
|
action_on = sayer_activate
|
||||||
|
@ -16,18 +16,20 @@ end
|
|||||||
|
|
||||||
-- Functions that are called after the delay time
|
-- Functions that are called after the delay time
|
||||||
|
|
||||||
local temporarygate_activate = function(pos, node)
|
local function temporarygate_activate(pos, node)
|
||||||
local def = minetest.registered_nodes[node.name]
|
-- using a meta string allows writing the time in hexadecimals
|
||||||
local meta = minetest.get_meta(pos)
|
local time = tonumber(minetest.get_meta(pos):get_string("time"))
|
||||||
local time = tonumber(meta:get_string("time"))
|
if not time then
|
||||||
if time ~= nil then
|
return
|
||||||
minetest.swap_node(pos, {name = "moremesecons_temporarygate:temporarygate_on", param2 = node.param2})
|
|
||||||
mesecon.receptor_on(pos)
|
|
||||||
minetest.after(time, function(pos, node)
|
|
||||||
mesecon.receptor_off(pos)
|
|
||||||
minetest.swap_node(pos, {name = "moremesecons_temporarygate:temporarygate_off", param2 = node.param2})
|
|
||||||
end, pos, node)
|
|
||||||
end
|
end
|
||||||
|
node.name = "moremesecons_temporarygate:temporarygate_on"
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
mesecon.receptor_on(pos)
|
||||||
|
minetest.after(time, function(pos, node)
|
||||||
|
mesecon.receptor_off(pos)
|
||||||
|
node.name = "moremesecons_temporarygate:temporarygate_off"
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
end, pos, node)
|
||||||
end
|
end
|
||||||
|
|
||||||
boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab
|
boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab
|
||||||
@ -62,12 +64,12 @@ mesecon.register_node("moremesecons_temporarygate:temporarygate", {
|
|||||||
is_ground_content = true,
|
is_ground_content = true,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
minetest.get_meta(pos):set_string("formspec", "field[time;time;${time}]")
|
||||||
meta:set_string("formspec", "field[time;time;${time}]")
|
|
||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
local meta = minetest.get_meta(pos)
|
if fields.time then
|
||||||
meta:set_string("time", fields.time)
|
minetest.get_meta(pos):set_string("time", fields.time)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
},{
|
},{
|
||||||
tiles = {
|
tiles = {
|
||||||
|
Loading…
Reference in New Issue
Block a user