mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-29 10:33:47 +01:00
V1.05: Ceiling lamp added, further improvements
This commit is contained in:
parent
ae39d15864
commit
0eace3dff9
@ -51,7 +51,11 @@ local function switch_off(pos)
|
|||||||
local own_num = meta:get_string("own_num")
|
local own_num = meta:get_string("own_num")
|
||||||
local numbers = meta:get_string("numbers")
|
local numbers = meta:get_string("numbers")
|
||||||
local placer_name = meta:get_string("placer_name")
|
local placer_name = meta:get_string("placer_name")
|
||||||
tubelib.send_message(numbers, placer_name, nil, "off", own_num)
|
local clicker_name = nil
|
||||||
|
if meta:get_string("public") == "false" then
|
||||||
|
clicker_name = meta:get_string("clicker_name")
|
||||||
|
end
|
||||||
|
tubelib.send_message(numbers, placer_name, clicker_name, "off", own_num)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ smartline.register_action("display3", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
on_execute = function(data, environ, number)
|
on_execute = function(data, environ, number)
|
||||||
local text = string.gsub(data.text, "*", environ.name or "<unknown>")
|
local text = string.gsub(data.text, "*", environ.state or "<unknown>")
|
||||||
tubelib.send_message(data.number, data.owner, nil, "text", text)
|
tubelib.send_message(data.number, data.owner, nil, "text", text)
|
||||||
end,
|
end,
|
||||||
button_label = function(data)
|
button_label = function(data)
|
||||||
@ -652,8 +652,8 @@ smartline.register_condition("playerdetector", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
on_execute = function(data, environ)
|
on_execute = function(data, environ)
|
||||||
environ.name = tubelib.send_request(data.number, "name", nil)
|
environ.state = tubelib.send_request(data.number, "name", nil)
|
||||||
return (data.name == "*" and environ.name ~= "") or environ.name == data.name
|
return (data.name == "*" and environ.state ~= "") or environ.state == data.name
|
||||||
end,
|
end,
|
||||||
button_label = function(data)
|
button_label = function(data)
|
||||||
if string.len(data.name) > 6 then
|
if string.len(data.name) > 6 then
|
||||||
|
@ -618,7 +618,7 @@ local function start_controller(pos, number, fs_data)
|
|||||||
switch_state(pos, tubelib.RUNNING, fs_data)
|
switch_state(pos, tubelib.RUNNING, fs_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function stop_controller(pos, fs_data)
|
function smartline.stop_controller(pos, fs_data)
|
||||||
switch_state(pos, tubelib.STOPPED, fs_data)
|
switch_state(pos, tubelib.STOPPED, fs_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -694,6 +694,9 @@ local function edit_command(fs_data, text)
|
|||||||
cmnd, pos1 = text:match('^(%S)%s(%d+)$')
|
cmnd, pos1 = text:match('^(%S)%s(%d+)$')
|
||||||
end
|
end
|
||||||
if cmnd and pos1 and pos2 then
|
if cmnd and pos1 and pos2 then
|
||||||
|
pos1 = math.max(1, math.min(pos1, NUM_RULES))
|
||||||
|
pos2 = math.max(1, math.min(pos2, NUM_RULES))
|
||||||
|
|
||||||
if cmnd == "x" then
|
if cmnd == "x" then
|
||||||
exchange_rules(fs_data, pos1, pos2)
|
exchange_rules(fs_data, pos1, pos2)
|
||||||
return "rows "..pos1.." and "..pos2.." exchanged"
|
return "rows "..pos1.." and "..pos2.." exchanged"
|
||||||
@ -703,6 +706,8 @@ local function edit_command(fs_data, text)
|
|||||||
return "row "..pos1.." copied to "..pos2
|
return "row "..pos1.." copied to "..pos2
|
||||||
end
|
end
|
||||||
elseif cmnd == "d" and pos1 then
|
elseif cmnd == "d" and pos1 then
|
||||||
|
pos1 = math.max(1, math.min(pos1, NUM_RULES))
|
||||||
|
|
||||||
delete_rule(fs_data, pos1)
|
delete_rule(fs_data, pos1)
|
||||||
return "row "..pos1.." deleted"
|
return "row "..pos1.." deleted"
|
||||||
end
|
end
|
||||||
@ -724,7 +729,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
if fields.ok then
|
if fields.ok then
|
||||||
if not readonly then
|
if not readonly then
|
||||||
output = edit_command(fs_data, fields.cmnd)
|
output = edit_command(fs_data, fields.cmnd)
|
||||||
stop_controller(pos, fs_data)
|
smartline.stop_controller(pos, fs_data)
|
||||||
meta:set_string("formspec", formspec_main(tubelib.STOPPED, fs_data, output))
|
meta:set_string("formspec", formspec_main(tubelib.STOPPED, fs_data, output))
|
||||||
meta:set_string("fs_data", minetest.serialize(fs_data))
|
meta:set_string("fs_data", minetest.serialize(fs_data))
|
||||||
end
|
end
|
||||||
@ -750,7 +755,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
local number = meta:get_string("number")
|
local number = meta:get_string("number")
|
||||||
local state = meta:get_int("state")
|
local state = meta:get_int("state")
|
||||||
if state == tubelib.RUNNING then
|
if state == tubelib.RUNNING then
|
||||||
stop_controller(pos, fs_data)
|
smartline.stop_controller(pos, fs_data)
|
||||||
meta:set_string("formspec", formspec_main(tubelib.STOPPED, fs_data, sOUTPUT))
|
meta:set_string("formspec", formspec_main(tubelib.STOPPED, fs_data, sOUTPUT))
|
||||||
else
|
else
|
||||||
formspec2runtime_rule(number, owner, fs_data)
|
formspec2runtime_rule(number, owner, fs_data)
|
||||||
@ -782,7 +787,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
-- FOURTH: back to main menu
|
-- FOURTH: back to main menu
|
||||||
if fields._exit_ then
|
if fields._exit_ then
|
||||||
meta:set_string("formspec", formspec_main(state, fs_data, sOUTPUT))
|
meta:set_string("formspec", formspec_main(state, fs_data, sOUTPUT))
|
||||||
-- stop_controller(pos, fs_data)
|
-- smartline.stop_controller(pos, fs_data)
|
||||||
-- meta:set_string("fs_data", minetest.serialize(fs_data))
|
-- meta:set_string("fs_data", minetest.serialize(fs_data))
|
||||||
-- end
|
-- end
|
||||||
end
|
end
|
||||||
@ -932,17 +937,11 @@ local function maintain_dataset(number)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_lbm({
|
--
|
||||||
label = "[SmartLine] Controller update",
|
-- Update formspec data for the case that rules order has changed or new rules were added
|
||||||
name = "smartline:update",
|
--
|
||||||
nodenames = {"smartline:controller"},
|
function smartline.update_fs_data(meta, fs_data)
|
||||||
run_at_every_load = true,
|
|
||||||
action = function(pos, node)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local fs_data = minetest.deserialize(meta:get_string("fs_data"))
|
|
||||||
|
|
||||||
local tOld2NewCond, tOld2NewActn = update_node_database(meta)
|
local tOld2NewCond, tOld2NewActn = update_node_database(meta)
|
||||||
|
|
||||||
if tOld2NewCond and tOld2NewActn then
|
if tOld2NewCond and tOld2NewActn then
|
||||||
-- map from old to new indexes
|
-- map from old to new indexes
|
||||||
for idx = 1,NUM_RULES do
|
for idx = 1,NUM_RULES do
|
||||||
@ -951,8 +950,22 @@ minetest.register_lbm({
|
|||||||
fs_data["subma"..idx.."_actn"] = tOld2NewActn[fs_data["subma"..idx.."_actn"]]
|
fs_data["subma"..idx.."_actn"] = tOld2NewActn[fs_data["subma"..idx.."_actn"]]
|
||||||
end
|
end
|
||||||
|
|
||||||
meta:set_string("fs_data", minetest.serialize(fs_data))
|
|
||||||
end
|
end
|
||||||
|
return fs_data
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_lbm({
|
||||||
|
label = "[SmartLine] Controller update",
|
||||||
|
name = "smartline:update",
|
||||||
|
nodenames = {"smartline:controller"},
|
||||||
|
run_at_every_load = true,
|
||||||
|
action = function(pos, node)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
|
local fs_data = minetest.deserialize(meta:get_string("fs_data"))
|
||||||
|
fs_data = smartline.update_fs_data(meta, fs_data)
|
||||||
|
meta:set_string("fs_data", minetest.serialize(fs_data))
|
||||||
|
|
||||||
local number = meta:get_string("number")
|
local number = meta:get_string("number")
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
formspec2runtime_rule(number, owner, fs_data)
|
formspec2runtime_rule(number, owner, fs_data)
|
||||||
|
@ -52,7 +52,11 @@ local function switch_off(pos)
|
|||||||
local own_num = meta:get_string("own_num")
|
local own_num = meta:get_string("own_num")
|
||||||
local numbers = meta:get_string("numbers")
|
local numbers = meta:get_string("numbers")
|
||||||
local placer_name = meta:get_string("placer_name")
|
local placer_name = meta:get_string("placer_name")
|
||||||
tubelib.send_message(numbers, placer_name, nil, "off", own_num) -- <<=== tubelib
|
local clicker_name = nil
|
||||||
|
if meta:get_string("public") == "false" then
|
||||||
|
clicker_name = meta:get_string("clicker_name")
|
||||||
|
end
|
||||||
|
tubelib.send_message(numbers, placer_name, clicker_name, "off", own_num) -- <<=== tubelib
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -159,9 +163,10 @@ minetest.register_node("tubelib:button_active", {
|
|||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {crumbly=0, not_in_creative_inventory=1},
|
groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
drop = "tubelib:button",
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -125,6 +125,7 @@ end
|
|||||||
function tubelib.get_node_number(pos)
|
function tubelib.get_node_number(pos)
|
||||||
local key = get_key_str(pos)
|
local key = get_key_str(pos)
|
||||||
local num = Key2Number[key]
|
local num = Key2Number[key]
|
||||||
|
print("key", key, "num", num)
|
||||||
if num then
|
if num then
|
||||||
num = string.format("%.04u", num)
|
num = string.format("%.04u", num)
|
||||||
if Number2Pos[num] and Number2Pos[num].name then
|
if Number2Pos[num] and Number2Pos[num].name then
|
||||||
@ -247,6 +248,7 @@ end
|
|||||||
|
|
||||||
function tubelib.pull_items(pos, side, player_name)
|
function tubelib.pull_items(pos, side, player_name)
|
||||||
local npos, facedir = get_neighbor_pos(pos, side)
|
local npos, facedir = get_neighbor_pos(pos, side)
|
||||||
|
if npos == nil then return end
|
||||||
local nside, node = get_node_side(npos, facedir)
|
local nside, node = get_node_side(npos, facedir)
|
||||||
local name = Name2Name[node.name]
|
local name = Name2Name[node.name]
|
||||||
if tubelib_NodeDef[name] and tubelib_NodeDef[name].on_pull_item then
|
if tubelib_NodeDef[name] and tubelib_NodeDef[name].on_pull_item then
|
||||||
@ -257,6 +259,7 @@ end
|
|||||||
|
|
||||||
function tubelib.push_items(pos, side, items, player_name)
|
function tubelib.push_items(pos, side, items, player_name)
|
||||||
local npos, facedir = get_neighbor_pos(pos, side)
|
local npos, facedir = get_neighbor_pos(pos, side)
|
||||||
|
if npos == nil then return end
|
||||||
local nside, node = get_node_side(npos, facedir)
|
local nside, node = get_node_side(npos, facedir)
|
||||||
local name = Name2Name[node.name]
|
local name = Name2Name[node.name]
|
||||||
if tubelib_NodeDef[name] and tubelib_NodeDef[name].on_push_item then
|
if tubelib_NodeDef[name] and tubelib_NodeDef[name].on_push_item then
|
||||||
@ -270,6 +273,7 @@ end
|
|||||||
|
|
||||||
function tubelib.unpull_items(pos, side, items, player_name)
|
function tubelib.unpull_items(pos, side, items, player_name)
|
||||||
local npos, facedir = get_neighbor_pos(pos, side)
|
local npos, facedir = get_neighbor_pos(pos, side)
|
||||||
|
if npos == nil then return end
|
||||||
local nside, node = get_node_side(npos, facedir)
|
local nside, node = get_node_side(npos, facedir)
|
||||||
local name = Name2Name[node.name]
|
local name = Name2Name[node.name]
|
||||||
if tubelib_NodeDef[name] and tubelib_NodeDef[name].on_unpull_item then
|
if tubelib_NodeDef[name] and tubelib_NodeDef[name].on_unpull_item then
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 542 KiB |
129
tubelib_addons2/ceilinglamp.lua
Normal file
129
tubelib_addons2/ceilinglamp.lua
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
Tubelib Addons 2
|
||||||
|
================
|
||||||
|
|
||||||
|
Copyright (C) 2017-2018 Joachim Stolberg
|
||||||
|
|
||||||
|
LGPLv2.1+
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
ceilinglamp.lua:
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
|
||||||
|
local function switch_on(pos, node)
|
||||||
|
node.name = "tubelib_addons2:ceilinglamp_on"
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function switch_off(pos, node)
|
||||||
|
node.name = "tubelib_addons2:ceilinglamp"
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("tubelib_addons2:ceilinglamp", {
|
||||||
|
description = "Tubelib Ceiling Lamp",
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
'tubelib_addons2_ceilinglamp_top.png',
|
||||||
|
'tubelib_addons2_ceilinglamp_bottom.png',
|
||||||
|
'tubelib_addons2_ceilinglamp.png',
|
||||||
|
},
|
||||||
|
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-5/16, -5/16, -5/16, 5/16, -7/16, 5/16},
|
||||||
|
{-4/16, -7/16, -4/16, 4/16, -8/16, 4/16},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
selection_box = {
|
||||||
|
type = "wallmounted",
|
||||||
|
wall_top = {-5/16, 5/16, -5/16, 5/16, 8/16, 5/16},
|
||||||
|
wall_bottom = {-5/16, -8/16, -5/16, 5/16, -5/16, 5/16},
|
||||||
|
wall_side = {-8/16, -5/16, -5/16, -5/16, 5/16, 5/16}
|
||||||
|
},
|
||||||
|
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local number = tubelib.add_node(pos, "tubelib_addons2:ceilinglamp")
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", "Tubelib Ceiling Lamp "..number)
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_rightclick = function(pos, node, clicker)
|
||||||
|
if not minetest.is_protected(pos, clicker:get_player_name()) then
|
||||||
|
switch_on(pos, node)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
after_dig_node = function(pos)
|
||||||
|
tubelib.remove_node(pos)
|
||||||
|
end,
|
||||||
|
|
||||||
|
paramtype = "light",
|
||||||
|
light_source = 0,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
paramtype2 = "wallmounted",
|
||||||
|
groups = {choppy=2, cracky=2, crumbly=2},
|
||||||
|
is_ground_content = false,
|
||||||
|
sounds = default.node_sound_glass_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("tubelib_addons2:ceilinglamp_on", {
|
||||||
|
description = "Tubelib Ceiling Lamp",
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
'tubelib_addons2_ceilinglamp_top.png',
|
||||||
|
'tubelib_addons2_ceilinglamp_bottom.png',
|
||||||
|
'tubelib_addons2_ceilinglamp.png',
|
||||||
|
},
|
||||||
|
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-5/16, -5/16, -5/16, 5/16, -7/16, 5/16},
|
||||||
|
{-4/16, -7/16, -4/16, 4/16, -8/16, 4/16},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
selection_box = {
|
||||||
|
type = "wallmounted",
|
||||||
|
wall_top = {-5/16, 5/16, -5/16, 5/16, 8/16, 5/16},
|
||||||
|
wall_bottom = {-5/16, -8/16, -5/16, 5/16, -5/16, 5/16},
|
||||||
|
wall_side = {-8/16, -5/16, -5/16, -5/16, 5/16, 5/16}
|
||||||
|
},
|
||||||
|
|
||||||
|
on_rightclick = function(pos, node, clicker)
|
||||||
|
if not minetest.is_protected(pos, clicker:get_player_name()) then
|
||||||
|
switch_off(pos, node)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
paramtype = "light",
|
||||||
|
light_source = 12,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
paramtype2 = "wallmounted",
|
||||||
|
groups = {crumbly=0, not_in_creative_inventory=1},
|
||||||
|
is_ground_content = false,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
type = "shapeless",
|
||||||
|
output = "tubelib_addons2:ceilinglamp 3",
|
||||||
|
recipe = {"tubelib:lamp", "default:wood", "default:glass"},
|
||||||
|
})
|
||||||
|
|
||||||
|
tubelib.register_node("tubelib_addons2:ceilinglamp", {"tubelib_addons2:ceilinglamp_on"}, {
|
||||||
|
on_recv_message = function(pos, topic, payload)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
if topic == "on" then
|
||||||
|
switch_on(pos, node)
|
||||||
|
elseif topic == "off" then
|
||||||
|
switch_off(pos, node)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
@ -18,6 +18,7 @@ dofile(minetest.get_modpath("tubelib_addons2") .. "/repeater.lua")
|
|||||||
dofile(minetest.get_modpath("tubelib_addons2") .. "/programmer.lua")
|
dofile(minetest.get_modpath("tubelib_addons2") .. "/programmer.lua")
|
||||||
dofile(minetest.get_modpath("tubelib_addons2") .. "/accesscontrol.lua")
|
dofile(minetest.get_modpath("tubelib_addons2") .. "/accesscontrol.lua")
|
||||||
dofile(minetest.get_modpath("tubelib_addons2") .. "/streetlamp.lua")
|
dofile(minetest.get_modpath("tubelib_addons2") .. "/streetlamp.lua")
|
||||||
|
dofile(minetest.get_modpath("tubelib_addons2") .. "/ceilinglamp.lua")
|
||||||
if minetest.get_modpath("mesecons") and mesecon then
|
if minetest.get_modpath("mesecons") and mesecon then
|
||||||
dofile(minetest.get_modpath("tubelib_addons2") .. "/mesecons_converter.lua")
|
dofile(minetest.get_modpath("tubelib_addons2") .. "/mesecons_converter.lua")
|
||||||
end
|
end
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 473 KiB |
BIN
tubelib_addons2/textures/tubelib_addons2_ceilinglamp.png
Normal file
BIN
tubelib_addons2/textures/tubelib_addons2_ceilinglamp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 364 B |
BIN
tubelib_addons2/textures/tubelib_addons2_ceilinglamp_bottom.png
Normal file
BIN
tubelib_addons2/textures/tubelib_addons2_ceilinglamp_bottom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 591 B |
BIN
tubelib_addons2/textures/tubelib_addons2_ceilinglamp_top.png
Normal file
BIN
tubelib_addons2/textures/tubelib_addons2_ceilinglamp_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 547 B |
Loading…
Reference in New Issue
Block a user