parent
323de518fe
commit
c46d25deb5
|
@ -7,22 +7,45 @@ local plate = {}
|
|||
screwdriver = screwdriver or {}
|
||||
|
||||
local function door_toggle(pos_actuator, pos_door, player)
|
||||
local actuator = minetest.get_node(pos_actuator)
|
||||
local rating = minetest.get_item_group(minetest.get_node_or_nil(pos_door).name)
|
||||
local door = doors.get(pos_door)
|
||||
|
||||
if actuator.name:sub(-4) == "_off" then
|
||||
minetest.set_node(pos_actuator,
|
||||
{name=actuator.name:gsub("_off", "_on"), param2=actuator.param2})
|
||||
end
|
||||
door:open(player)
|
||||
|
||||
minetest.after(2, function()
|
||||
if minetest.get_node(pos_actuator).name:sub(-3) == "_on" then
|
||||
minetest.set_node(pos_actuator,
|
||||
{name=actuator.name, param2=actuator.param2})
|
||||
if rating < 1 and door then
|
||||
local actuator = minetest.get_node(pos_actuator)
|
||||
if actuator.name:sub(-4) == "_off" then
|
||||
minetest.set_node(pos_actuator, {
|
||||
name = actuator.name:gsub("_off", "_on"),
|
||||
param2 = actuator.param2
|
||||
})
|
||||
end
|
||||
door:close()
|
||||
end)
|
||||
door:open(player)
|
||||
minetest.after(2, function()
|
||||
if minetest.get_node(pos_actuator).name:sub(-3) == "_on" then
|
||||
minetest.set_node(pos_actuator, {
|
||||
name = actuator.name,
|
||||
param2 = actuator.param2
|
||||
})
|
||||
end
|
||||
door:close()
|
||||
end)
|
||||
return
|
||||
end
|
||||
local f = minetest.get_node_or_nil(pos_door)
|
||||
if f and f.name == "walkie:intercomm" then
|
||||
f = minetest.registered_nodes[f.name]._on_function
|
||||
f = f(pos_door)
|
||||
if f then
|
||||
for i = 2, #f do
|
||||
local word = f[i]
|
||||
-- TODO check against terminal.commands[f]
|
||||
if word == "warp" then
|
||||
local warp = beds.beds[player:get_player_name()][f[i + 1]]
|
||||
if warp then
|
||||
player:set_pos(warp)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function plate.construct(pos)
|
||||
|
@ -32,12 +55,12 @@ end
|
|||
|
||||
function plate.timer(pos)
|
||||
local objs = minetest.get_objects_inside_radius(pos, 0.8)
|
||||
if objs == {} or not doors.get then
|
||||
if objs == {} then --or not doors.get then
|
||||
return true
|
||||
end
|
||||
local minp = {x = pos.x - 2, y = pos.y, z = pos.z - 2}
|
||||
local maxp = {x = pos.x + 2, y = pos.y, z = pos.z + 2}
|
||||
local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
|
||||
local doors = minetest.find_nodes_in_area(minp, maxp, {"group:door", "group:actuator"})
|
||||
|
||||
for _, player in pairs(objs) do
|
||||
if player:is_player() then
|
||||
|
@ -92,7 +115,7 @@ plate.register("wood", "Wooden", {
|
|||
]]
|
||||
plate.register("stone", "Stone", {
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
groups = {cracky=3, oddly_breakable_by_hand=2}
|
||||
groups = {cracky=3, oddly_breakable_by_hand=2, actuator = 1}
|
||||
})
|
||||
|
||||
minetest.register_node("mechanisms:lever_off", {
|
||||
|
@ -103,17 +126,21 @@ minetest.register_node("mechanisms:lever_off", {
|
|||
type = "fixed",
|
||||
fixed = {{-0.375, -0.4375, 0.4375, 0.375, 0.4375, 0.5}}
|
||||
},
|
||||
groups = {cracky=3, oddly_breakable_by_hand=2},
|
||||
groups = {cracky=3, oddly_breakable_by_hand=2, actuator = 1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
on_rotate = screwdriver.rotate_simple,
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
if not doors.get then return end
|
||||
--[[
|
||||
if not doors.get then
|
||||
return
|
||||
end
|
||||
--]]
|
||||
local minp = {x=pos.x-2, y=pos.y-1, z=pos.z-2}
|
||||
local maxp = {x=pos.x+2, y=pos.y+1, z=pos.z+2}
|
||||
local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
|
||||
local doors = minetest.find_nodes_in_area(minp, maxp, {"group:door", "group:actuator"})
|
||||
|
||||
for i = 1, #doors do
|
||||
door_toggle(pos, doors[i], clicker)
|
||||
|
@ -128,7 +155,7 @@ minetest.register_node("mechanisms:lever_on", {
|
|||
type = "fixed",
|
||||
fixed = {{-0.375, -0.4375, 0.4375, 0.375, 0.4375, 0.5}}
|
||||
},
|
||||
groups = {cracky=3, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
|
||||
groups = {cracky=3, oddly_breakable_by_hand=2, not_in_creative_inventory=1, actuator = 1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
|
|
|
@ -62,6 +62,11 @@ terminal.display = function(source, user, pos, input)
|
|||
command = "Yes Master?"
|
||||
output = ""
|
||||
feedback = ""
|
||||
elseif command == "f" and source == "node" then
|
||||
local nnn = minetest.get_node_or_nil(pos)
|
||||
if nnn and nnn.name == "walkie:intercomm" then
|
||||
meta:set_string("_on_function", minetest.serialize(args))
|
||||
end
|
||||
elseif command == "+" then
|
||||
local new_args = {}
|
||||
for i = 2, #args do
|
||||
|
@ -101,10 +106,8 @@ terminal.display = function(source, user, pos, input)
|
|||
elseif command == "channel" then
|
||||
local ch = tonumber(args[2])
|
||||
if type(ch) == "number" then
|
||||
--dcbl.channels[name].channel = ch
|
||||
end
|
||||
--feedback = "You are on channel " .. tostring(dcbl.channels[name].channel)
|
||||
feedback = "TODO: Implement chat channels."
|
||||
feedback = ""
|
||||
elseif command == "echo" then
|
||||
if type(args[2]) == "string" then
|
||||
for i = 2, #args do
|
||||
|
@ -144,20 +147,6 @@ terminal.display = function(source, user, pos, input)
|
|||
output = minetest.formspec_escape(info)
|
||||
feedback = ""
|
||||
elseif command == "list" then
|
||||
--[[
|
||||
local chatters = ""
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
if player:get_inventory():contains_item("main", "walkie:talkie") then
|
||||
chatters = chatters .. player:get_player_name() .. " "
|
||||
end
|
||||
end
|
||||
if chatters == "" then
|
||||
output = "No one seems to have a walkie talkie."
|
||||
else
|
||||
output = chatters
|
||||
end
|
||||
feedback = "Players on channel 1 or near intercomm listed."
|
||||
--]]
|
||||
if args[2] and args[2] == "warps" then
|
||||
if not args[3] then
|
||||
output = "`public' or `private'"
|
||||
|
@ -198,25 +187,6 @@ terminal.display = function(source, user, pos, input)
|
|||
end
|
||||
feedback = ""
|
||||
elseif command == "set" then
|
||||
--[[
|
||||
if args[2] == "warp" then
|
||||
local pt_under = meta:get_string("pt_under")
|
||||
if not pt_under or pt_under == "" then
|
||||
return
|
||||
end
|
||||
if not args[3] then
|
||||
return
|
||||
end
|
||||
local nn = minetest.string_to_pos(pt_under)
|
||||
if minetest.get_node(nn).name ~= "warps:warpgoo_amethyst" or
|
||||
minetest.is_protected(nn, name) then
|
||||
return
|
||||
end
|
||||
minetest.get_meta(nn):set_string("warps_destination", args[3])
|
||||
meta:set_string("pt_under", nil)
|
||||
feedback = "TODO"
|
||||
end
|
||||
--]]
|
||||
if args[2] and args[2] == "spawn_switch" then
|
||||
local pm = user:get_meta()
|
||||
local ss = pm:get_int("spawn_switch")
|
||||
|
@ -315,24 +285,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
source = s[source]
|
||||
terminal.display(source, player, pos, fields.input)
|
||||
end)
|
||||
-- TODO Make hide_chat setting. Send all chat to walkie mod.
|
||||
-- But make setting hide top-left chat in present.
|
||||
--[[
|
||||
minetest.register_on_chat_message(function(name, message)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local pp = {}
|
||||
for _, p in ipairs(minetest.get_connected_players()) do
|
||||
local n = p:get_player_name()
|
||||
pp[n] = {}
|
||||
print(#pp[n])
|
||||
end
|
||||
terminal.display("mod", player, player:get_pos(), "say " .. message)
|
||||
return true
|
||||
end)
|
||||
--]]
|
||||
|
||||
minetest.register_privilege("terminal", {
|
||||
description = "Can use /terminal command",
|
||||
give_to_singleplayer = false,
|
||||
|
|
|
@ -240,7 +240,7 @@ minetest.register_node("walkie:intercomm", {
|
|||
wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
|
||||
wall_side = {-0.5, -0.375, -0.4375, -0.4375, 0.375, 0.4375},
|
||||
},
|
||||
groups = {cracky = 3, oddly_breakable_by_hand = 1, attached_node = 1},
|
||||
groups = {cracky = 3, oddly_breakable_by_hand = 1, attached_node = 1, actuator = 2},
|
||||
legacy_wallmounted = true,
|
||||
sounds = {
|
||||
footstep = {name = "default_hard_footstep", gain = 0.5},
|
||||
|
@ -250,7 +250,11 @@ minetest.register_node("walkie:intercomm", {
|
|||
place_failed = {name = "walkie_blip", gain = 1.0}
|
||||
},
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
terminal.display("node", clicker)
|
||||
terminal.display("node", clicker, pos)
|
||||
end,
|
||||
_on_function = function(pos)
|
||||
local args = minetest.deserialize(minetest.get_meta(pos):get_string("_on_function"))
|
||||
return args
|
||||
end,
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue