mods that hopefully work for a TechAge-based pack
This commit is contained in:
1 parent
4e6b08d194
commit
c27db2a537
6234 files changed
+375578
No files matched your search
@@ -0,0 +1,66 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA3/TA4 Ceiling Lamp
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
|
||||
techage.register_lamp("techage:ceilinglamp", {
|
||||
description = S("TA Ceiling Lamp"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_ceilinglamp_top.png',
|
||||
'techage_ceilinglamp_bottom.png',
|
||||
'techage_ceilinglamp.png',
|
||||
'techage_ceilinglamp.png',
|
||||
'techage_ceilinglamp.png',
|
||||
'techage_ceilinglamp.png',
|
||||
'techage_ceilinglamp.png',
|
||||
'techage_ceilinglamp.png',
|
||||
},
|
||||
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-5/16, -7/16, -5/16, 5/16, -5/16, 5/16},
|
||||
{-4/16, -8/16, -4/16, 4/16, -7/16, 4/16},
|
||||
},
|
||||
},
|
||||
|
||||
},{
|
||||
description = S("TA Ceiling Lamp"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_ceilinglamp_top.png',
|
||||
'techage_ceilinglamp_bottom.png',
|
||||
'techage_ceilinglamp.png',
|
||||
'techage_ceilinglamp.png',
|
||||
'techage_ceilinglamp.png',
|
||||
'techage_ceilinglamp.png',
|
||||
},
|
||||
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-5/16, -7/16, -5/16, 5/16, -5/16, 5/16},
|
||||
{-4/16, -8/16, -4/16, 4/16, -7/16, 4/16},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "techage:ceilinglamp_off 3",
|
||||
recipe = {"techage:simplelamp_off", "default:wood", "default:glass"},
|
||||
})
|
||||
@@ -0,0 +1,239 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2020 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA4 LED Grow Light
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
|
||||
local CYCLE_TIME = 2
|
||||
local RANDOM_VAL = 20
|
||||
local PWR_NEEDED = 1
|
||||
|
||||
local Cable = techage.ElectricCable
|
||||
local power = networks.power
|
||||
local Flowers = {}
|
||||
local Plants = {}
|
||||
-- 9 plant positions below the light
|
||||
local Positions = {
|
||||
{x = 0, y =-1, z = 0},
|
||||
{x =-1, y =-1, z = 0},
|
||||
{x = 0, y =-1, z =-1},
|
||||
{x = 1, y =-1, z = 0},
|
||||
{x = 0, y =-1, z = 1},
|
||||
{x =-1, y =-1, z =-1},
|
||||
{x = 1, y =-1, z = 1},
|
||||
{x =-1, y =-1, z = 1},
|
||||
{x = 1, y =-1, z =-1},
|
||||
}
|
||||
|
||||
local function swap_node(pos, postfix)
|
||||
local node = techage.get_node_lvm(pos)
|
||||
local parts = string.split(node.name, "_")
|
||||
if postfix == parts[2] then
|
||||
return
|
||||
end
|
||||
node.name = parts[1].."_"..postfix
|
||||
minetest.swap_node(pos, node)
|
||||
techage.light_ring(pos, postfix == "on")
|
||||
end
|
||||
|
||||
local function on_nopower(pos)
|
||||
swap_node(pos, "off")
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.turned_on = false
|
||||
end
|
||||
|
||||
local function on_power(pos)
|
||||
swap_node(pos, "on")
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.turned_on = true
|
||||
end
|
||||
|
||||
local function grow_flowers(pos)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local mem = techage.get_mem(pos)
|
||||
mem.grow_pos = mem.grow_pos or {} -- keep the pos blank for some time
|
||||
nvm.tick = nvm.tick or math.random(RANDOM_VAL, RANDOM_VAL*2)
|
||||
nvm.tick = nvm.tick - 1
|
||||
if nvm.tick == 0 then
|
||||
nvm.tick = math.random(RANDOM_VAL, RANDOM_VAL*2)
|
||||
local plant_idx = math.random(1, 9)
|
||||
local plant_pos = vector.add(pos, Positions[plant_idx])
|
||||
local soil_pos = {x = plant_pos.x, y = plant_pos.y - 1, z = plant_pos.z}
|
||||
local plant_node = minetest.get_node(plant_pos)
|
||||
local soil_node = minetest.get_node(soil_pos)
|
||||
if soil_node and soil_node.name == "compost:garden_soil" then
|
||||
if plant_node and plant_node.name == "air" then
|
||||
if mem.grow_pos[plant_idx] and #Flowers > 1 then
|
||||
local idx = math.floor(math.random(1, #Flowers))
|
||||
if Flowers[idx] then
|
||||
minetest.set_node(plant_pos, {name = Flowers[idx]})
|
||||
mem.grow_pos[plant_idx] = false
|
||||
end
|
||||
else
|
||||
mem.grow_pos[plant_idx] = true
|
||||
end
|
||||
end
|
||||
elseif plant_node and Plants[plant_node.name] then
|
||||
local ndef = minetest.registered_nodes[plant_node.name]
|
||||
if ndef.on_timer then
|
||||
ndef.on_timer(plant_pos, 200)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function node_timer_on(pos, elapsed)
|
||||
grow_flowers(pos)
|
||||
local consumed = power.consume_power(pos, Cable, nil, PWR_NEEDED)
|
||||
if consumed < PWR_NEEDED then
|
||||
on_nopower(pos)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function node_timer_off(pos, elapsed)
|
||||
local consumed = power.consume_power(pos, Cable, nil, PWR_NEEDED)
|
||||
if consumed == PWR_NEEDED then
|
||||
on_power(pos)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function on_switch_lamp(pos, on)
|
||||
techage.light_ring(pos, on)
|
||||
end
|
||||
|
||||
techage.register_lamp("techage:growlight", {
|
||||
description = S("TA4 LED Grow Light"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_growlight_off.png',
|
||||
'techage_growlight_back.png',
|
||||
'techage_growlight_off.png',
|
||||
'techage_growlight_side.png',
|
||||
'techage_growlight_side.png',
|
||||
'techage_growlight_side.png',
|
||||
'techage_growlight_side.png',
|
||||
'techage_growlight_side.png',
|
||||
},
|
||||
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-8/16, -8/16, -8/16, 8/16, -13/32, 8/16},
|
||||
},
|
||||
},
|
||||
on_timer = node_timer_off,
|
||||
on_switch_lamp = on_switch_lamp,
|
||||
high_power = true,
|
||||
},{
|
||||
description = S("TA4 LED Grow Light"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_growlight_on.png',
|
||||
'techage_growlight_back.png',
|
||||
'techage_growlight_side.png',
|
||||
'techage_growlight_side.png',
|
||||
'techage_growlight_side.png',
|
||||
'techage_growlight_side.png',
|
||||
},
|
||||
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-8/16, -8/16, -8/16, 8/16, -13/32, 8/16},
|
||||
},
|
||||
},
|
||||
on_timer = node_timer_on,
|
||||
on_switch_lamp = on_switch_lamp,
|
||||
high_power = true,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:growlight_off",
|
||||
recipe = {
|
||||
{"techage:ta4_leds", "techage:basalt_glass_thin", "techage:ta4_leds"},
|
||||
{"techage:ta4_leds", "techage:ta4_leds", "techage:ta4_leds"},
|
||||
{"techage:ta4_leds", "techage:aluminum", "techage:ta4_leds"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_lbm({
|
||||
label = "Restart Grow Light",
|
||||
name = "techage:restart_growlight",
|
||||
|
||||
nodenames = {
|
||||
"techage:growlight",
|
||||
},
|
||||
|
||||
run_at_every_load = true,
|
||||
|
||||
action = function(pos, node)
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
end,
|
||||
})
|
||||
|
||||
local function contains(table, element)
|
||||
for _, value in pairs(table) do
|
||||
if value == element then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function techage.register_flower(name)
|
||||
if contains(Flowers, name) then
|
||||
return
|
||||
end
|
||||
Flowers[#Flowers+1] = name
|
||||
end
|
||||
|
||||
function techage.register_plant(name)
|
||||
Plants[name] = true
|
||||
end
|
||||
|
||||
minetest.after(1, function()
|
||||
-- Flowers
|
||||
local function add_flower(name)
|
||||
local def = minetest.registered_nodes[name]
|
||||
if def and (def.groups.mushroom == 1 or def.groups.flower == 1) then
|
||||
if not (name:find("waterlily") or name:find("seaweed")) then -- we don't want water plants on garden soil
|
||||
techage.register_flower(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _,def in pairs(minetest.registered_decorations) do
|
||||
local name = def.decoration
|
||||
if type(name) == "string" then
|
||||
add_flower(name)
|
||||
elseif type(name) == "table" then
|
||||
for _,sub_name in ipairs(name) do
|
||||
add_flower(sub_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Plants
|
||||
for name,ndef in pairs(minetest.registered_nodes) do
|
||||
if type(name) == "string" then
|
||||
local mod = string.split(name, ":")[1]
|
||||
if mod == "farming" and ndef.on_timer then -- probably a plant that still needs to grow
|
||||
techage.register_plant(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,66 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA3/TA4 Industrial Lamp 1
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
|
||||
techage.register_lamp("techage:industriallamp1", {
|
||||
description = S("TA Industrial Lamp 1"),
|
||||
inventory_image = 'techage_industriallamp_inv1.png',
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_industriallamp1.png',
|
||||
'techage_industriallamp1.png',
|
||||
'techage_industriallamp1.png^[transformR180',
|
||||
'techage_industriallamp1.png^[transformR180',
|
||||
'techage_industriallamp1.png',
|
||||
'techage_industriallamp1.png',
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-8/16, -8/16, -3/32, -6/16, -9/32, 3/32},
|
||||
{ 6/16, -8/16, -3/32, 8/16, -9/32, 3/32},
|
||||
{-6/16, -7/16, -1/16, 6/16, -5/16, 1/16},
|
||||
},
|
||||
},
|
||||
},{
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_industriallamp1_on.png',
|
||||
'techage_industriallamp1_on.png',
|
||||
'techage_industriallamp1_on.png^[transformR180',
|
||||
'techage_industriallamp1_on.png^[transformR180',
|
||||
'techage_industriallamp1_on.png',
|
||||
'techage_industriallamp1_on.png',
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-8/16, -8/16, -3/32, -6/16, -9/32, 3/32},
|
||||
{ 6/16, -8/16, -3/32, 8/16, -9/32, 3/32},
|
||||
{-6/16, -7/16, -1/16, 6/16, -5/16, 1/16},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:industriallamp1_off 2",
|
||||
recipe = {
|
||||
{"", "", ""},
|
||||
{"default:glass", "techage:simplelamp_off", "dye:grey"},
|
||||
{"basic_materials:plastic_strip", "default:copper_ingot", "basic_materials:plastic_strip"},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,68 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA3/TA4 Industrial Lamp 2
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
|
||||
local size = {x = 8/32, y = 8/32, z = 5/32}
|
||||
|
||||
techage.register_lamp("techage:industriallamp2", {
|
||||
description = S("TA Industrial Lamp 2"),
|
||||
inventory_image = 'techage_industriallamp_inv2.png',
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_industriallamp2.png',
|
||||
'techage_industriallamp2.png',
|
||||
'techage_industriallamp2.png^[transformR180',
|
||||
'techage_industriallamp2.png^[transformR180',
|
||||
'techage_industriallamp2.png',
|
||||
'techage_industriallamp2.png',
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-8/32, -16/32, -4/32, 8/32, -9/32, 4/32},
|
||||
{-7/32, -16/32, -5/32, 7/32, -9/32, 5/32},
|
||||
{-7/32, -9/32, -4/32, 7/32, -8/32, 4/32},
|
||||
},
|
||||
},
|
||||
},{
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_industriallamp2_on.png',
|
||||
'techage_industriallamp2_on.png',
|
||||
'techage_industriallamp2_on.png^[transformR180',
|
||||
'techage_industriallamp2_on.png^[transformR180',
|
||||
'techage_industriallamp2_on.png',
|
||||
'techage_industriallamp2_on.png',
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-8/32, -16/32, -4/32, 8/32, -9/32, 4/32},
|
||||
{-7/32, -16/32, -5/32, 7/32, -9/32, 5/32},
|
||||
{-7/32, -9/32, -4/32, 7/32, -8/32, 4/32},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:industriallamp2_off 2",
|
||||
recipe = {
|
||||
{"default:glass", "default:glass", ""},
|
||||
{"techage:simplelamp_off", "dye:black", ""},
|
||||
{"basic_materials:steel_bar", "basic_materials:steel_bar", ""},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,64 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA3/TA4 Industrial Lamp 3
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
|
||||
local size = {x = 6/32, y = 4/32, z = 6/32}
|
||||
|
||||
techage.register_lamp("techage:industriallamp3", {
|
||||
description = S("TA Industrial Lamp 3"),
|
||||
inventory_image = 'techage_industriallamp_inv3.png',
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_industriallamp3.png',
|
||||
'techage_industriallamp3.png',
|
||||
'techage_industriallamp3.png^[transformR180',
|
||||
'techage_industriallamp3.png^[transformR180',
|
||||
'techage_industriallamp3.png',
|
||||
'techage_industriallamp3.png',
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.1875, -0.5, -0.1875, 0.1875, -0.375, 0.1875},
|
||||
},
|
||||
},
|
||||
},{
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_industriallamp3_on.png',
|
||||
'techage_industriallamp3_on.png',
|
||||
'techage_industriallamp3_on.png^[transformR180',
|
||||
'techage_industriallamp3_on.png^[transformR180',
|
||||
'techage_industriallamp3_on.png',
|
||||
'techage_industriallamp3_on.png',
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.1875, -0.5, -0.1875, 0.1875, -0.375, 0.1875},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:industriallamp3_off 2",
|
||||
recipe = {
|
||||
{"default:glass", "default:glass", ""},
|
||||
{"techage:simplelamp_off", "dye:red", ""},
|
||||
{"basic_materials:steel_bar", "basic_materials:steel_bar", ""},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,64 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2020 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA4 Industrial Lamp 4
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
|
||||
local function on_switch_lamp(pos, on)
|
||||
techage.light_ring({x = pos.x, y = pos.y - 3, z = pos.z}, on)
|
||||
end
|
||||
|
||||
techage.register_lamp("techage:industriallamp4", {
|
||||
description = S("TA4 LED Industrial Lamp"),
|
||||
tiles = {
|
||||
'techage_growlight_off.png',
|
||||
'techage_growlight_back.png',
|
||||
'techage_growlight_side.png',
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-8/16, -8/16, -8/16, 8/16, -13/32, 8/16},
|
||||
},
|
||||
},
|
||||
on_switch_lamp = on_switch_lamp,
|
||||
conn_sides = {"U"},
|
||||
high_power = true,
|
||||
},{
|
||||
description = S("TA4 LED Industrial Lamp"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_industlight4_on.png',
|
||||
'techage_growlight_back.png',
|
||||
'techage_growlight_side.png',
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-8/16, -8/16, -8/16, 8/16, -13/32, 8/16},
|
||||
},
|
||||
},
|
||||
on_switch_lamp = on_switch_lamp,
|
||||
high_power = true,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:industriallamp4_off",
|
||||
recipe = {
|
||||
{"basic_materials:steel_strip", "basic_materials:steel_strip", "basic_materials:steel_strip"},
|
||||
{"techage:ta4_leds", "techage:ta4_leds", "techage:ta4_leds"},
|
||||
{"techage:ta4_leds", "techage:basalt_glass_thin", "techage:ta4_leds"},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,115 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2020 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA3/4 Lamp Holder
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
|
||||
local function register_holder(name, description, png)
|
||||
minetest.register_node(name, {
|
||||
description = description,
|
||||
tiles = {png},
|
||||
paramtype2 = "facedir", -- important!
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {{ -4/32, -4/32, -4/32, 4/32, 4/32, 4/32}},
|
||||
|
||||
connect_top = {{ -3/32, -3/32, -3/32, 3/32, 16/32, 3/32}},
|
||||
connect_bottom = {{ -3/32, -16/32, -3/32, 3/32, 3/32, 3/32}},
|
||||
connect_left = {{-16/32, -3/32, -3/32, 3/32, 3/32, 3/32}},
|
||||
connect_right = {{ -3/32, -3/32, -3/32, 16/32, 3/32, 3/32}},
|
||||
connect_back = {{ -3/32, -3/32, -3/32, 3/32, 3/32, 16/32}},
|
||||
connect_front = {{ -3/32, -3/32, -16/32, 3/32, 3/32, 3/32}},
|
||||
},
|
||||
connects_to = {
|
||||
"techage:ceilinglamp_off", "techage:ceilinglamp_on",
|
||||
"techage:growlight_off", "techage:growlight_on",
|
||||
"techage:industriallamp1_off", "techage:industriallamp1_on",
|
||||
"techage:industriallamp2_off", "techage:industriallamp2_on",
|
||||
"techage:industriallamp3_off", "techage:industriallamp3_on",
|
||||
"techage:industriallamp4_off", "techage:industriallamp4_on",
|
||||
"techage:simplelamp_off", "techage:simplelamp_on",
|
||||
"techage:streetlamp_off", "techage:streetlamp_on",
|
||||
"techage:streetlamp2_off", "techage:streetlamp2_on",
|
||||
"techage:streetlamp_arm", "techage:streetlamp_pole",
|
||||
"techage:streetlamp2_off", "techage:streetlamp2_on",
|
||||
"techage:power_line", "techage:power_lineS", "techage:power_lineA"
|
||||
},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
register_holder("techage:lampholder1", S("TA Lamp Holder White"), "techage_streetlamp2_housing.png")
|
||||
register_holder("techage:lampholder2", S("TA Lamp Holder Aspen"), "default_aspen_wood.png")
|
||||
register_holder("techage:lampholder3", S("TA Lamp Holder Acacia"), "default_acacia_wood.png")
|
||||
register_holder("techage:lampholder4", S("TA Lamp Holder Apple"), "default_wood.png")
|
||||
register_holder("techage:lampholder5", S("TA Lamp Holder Copper"), "default_copper_block.png")
|
||||
register_holder("techage:lampholder6", S("TA Lamp Holder Gold"), "default_gold_block.png")
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:lampholder1 2",
|
||||
recipe = {
|
||||
{"basic_materials:steel_bar", "", "basic_materials:steel_bar"},
|
||||
{"", "dye:white", ""},
|
||||
{"basic_materials:steel_bar", "", "basic_materials:steel_bar"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:lampholder2 2",
|
||||
recipe = {
|
||||
{"basic_materials:steel_bar", "", "basic_materials:steel_bar"},
|
||||
{"", "default:fence_aspen_wood", ""},
|
||||
{"basic_materials:steel_bar", "", "basic_materials:steel_bar"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:lampholder3 2",
|
||||
recipe = {
|
||||
{"basic_materials:steel_bar", "", "basic_materials:steel_bar"},
|
||||
{"", "default:fence_acacia_wood", ""},
|
||||
{"basic_materials:steel_bar", "", "basic_materials:steel_bar"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:lampholder4 2",
|
||||
recipe = {
|
||||
{"basic_materials:steel_bar", "", "basic_materials:steel_bar"},
|
||||
{"", "default:fence_wood", ""},
|
||||
{"basic_materials:steel_bar", "", "basic_materials:steel_bar"},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "techage:lampholder5 2",
|
||||
recipe = {
|
||||
{"basic_materials:steel_bar", "", "basic_materials:steel_bar"},
|
||||
{"", "default:copper_ingot", ""},
|
||||
{"basic_materials:steel_bar", "", "basic_materials:steel_bar"},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "techage:lampholder6 2",
|
||||
recipe = {
|
||||
{"basic_materials:steel_bar", "", "basic_materials:steel_bar"},
|
||||
{"", "default:gold_ingot", ""},
|
||||
{"basic_materials:steel_bar", "", "basic_materials:steel_bar"},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,183 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
Lamp library
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||
local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
|
||||
local PWR_NEEDED = 0.5
|
||||
local CYCLE_TIME = 2
|
||||
|
||||
local Cable = techage.ElectricCable
|
||||
local power = networks.power
|
||||
|
||||
local function swap_node(pos, postfix)
|
||||
local node = techage.get_node_lvm(pos)
|
||||
local parts = string.split(node.name, "_")
|
||||
if postfix == parts[2] then
|
||||
return
|
||||
end
|
||||
node.name = parts[1].."_"..postfix
|
||||
minetest.swap_node(pos, node)
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
if ndef.on_switch_lamp then
|
||||
ndef.on_switch_lamp(pos, postfix == "on")
|
||||
end
|
||||
end
|
||||
|
||||
local function on_power(pos)
|
||||
swap_node(pos, "on")
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.turned_on = true
|
||||
end
|
||||
|
||||
local function on_nopower(pos)
|
||||
swap_node(pos, "off")
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.turned_on = false
|
||||
end
|
||||
|
||||
local function is_running(pos, nvm)
|
||||
return nvm.turned_on
|
||||
end
|
||||
|
||||
local function node_timer_off1(pos, elapsed)
|
||||
local consumed = power.consume_power(pos, Cable, nil, PWR_NEEDED)
|
||||
if consumed == PWR_NEEDED then
|
||||
on_power(pos)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function node_timer_off2(pos, elapsed)
|
||||
local consumed = power.consume_power(pos, Cable, nil, PWR_NEEDED * 2)
|
||||
if consumed == PWR_NEEDED * 2 then
|
||||
on_power(pos)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function node_timer_on1(pos, elapsed)
|
||||
local consumed = power.consume_power(pos, Cable, nil, PWR_NEEDED)
|
||||
if consumed < PWR_NEEDED then
|
||||
on_nopower(pos)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function node_timer_on2(pos, elapsed)
|
||||
local consumed = power.consume_power(pos, Cable, nil, PWR_NEEDED * 2)
|
||||
if consumed < PWR_NEEDED * 2 then
|
||||
on_nopower(pos)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function lamp_on_rightclick(pos, node, clicker)
|
||||
if minetest.is_protected(pos, clicker:get_player_name()) then
|
||||
return
|
||||
end
|
||||
|
||||
local nvm = techage.get_nvm(pos)
|
||||
if not nvm.turned_on and power.power_available(pos, Cable) then
|
||||
nvm.turned_on = true
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
swap_node(pos, "on")
|
||||
else
|
||||
nvm.turned_on = false
|
||||
minetest.get_node_timer(pos):stop()
|
||||
swap_node(pos, "off")
|
||||
end
|
||||
end
|
||||
|
||||
local function on_rotate(pos, node, user, mode, new_param2)
|
||||
if minetest.is_protected(pos, user:get_player_name()) then
|
||||
return false
|
||||
end
|
||||
node.param2 = techage.rotate_wallmounted(node.param2)
|
||||
minetest.swap_node(pos, node)
|
||||
return true
|
||||
end
|
||||
|
||||
local function on_place(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
return minetest.rotate_and_place(itemstack, placer, pointed_thing)
|
||||
end
|
||||
|
||||
local function after_place_node(pos)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
Cable:after_place_node(pos)
|
||||
end
|
||||
|
||||
local function after_dig_node(pos, oldnode)
|
||||
Cable:after_dig_node(pos)
|
||||
techage.del_mem(pos)
|
||||
end
|
||||
|
||||
local function tubelib2_on_update2(pos, outdir, tlib2, node)
|
||||
power.update_network(pos, outdir, tlib2)
|
||||
end
|
||||
|
||||
function techage.register_lamp(basename, ndef_off, ndef_on)
|
||||
if ndef_off.high_power then
|
||||
ndef_off.on_timer = ndef_off.on_timer or node_timer_off2
|
||||
else
|
||||
ndef_off.on_timer = ndef_off.on_timer or node_timer_off1
|
||||
end
|
||||
ndef_off.after_place_node = after_place_node
|
||||
ndef_off.after_dig_node = after_dig_node
|
||||
ndef_off.on_rightclick = lamp_on_rightclick
|
||||
if not ndef_off.on_rotate then
|
||||
ndef_off.on_place = on_place
|
||||
end
|
||||
ndef_off.on_rotate = ndef_off.on_rotate or on_rotate
|
||||
ndef_off.paramtype = "light"
|
||||
ndef_off.use_texture_alpha = techage.CLIP
|
||||
ndef_off.light_source = 0
|
||||
ndef_off.sunlight_propagates = true
|
||||
ndef_off.paramtype2 = "facedir"
|
||||
ndef_off.groups = {choppy=2, cracky=2, crumbly=2}
|
||||
ndef_off.is_ground_content = false
|
||||
ndef_off.sounds = default.node_sound_glass_defaults()
|
||||
|
||||
if ndef_on.high_power then
|
||||
ndef_on.on_timer = ndef_on.on_timer or node_timer_on2
|
||||
else
|
||||
ndef_on.on_timer = ndef_on.on_timer or node_timer_on1
|
||||
end
|
||||
ndef_on.after_place_node = after_place_node
|
||||
ndef_on.after_dig_node = after_dig_node
|
||||
ndef_on.on_rightclick = lamp_on_rightclick
|
||||
ndef_on.on_rotate = ndef_on.on_rotate or on_rotate
|
||||
ndef_on.paramtype = "light"
|
||||
ndef_on.use_texture_alpha = techage.CLIP
|
||||
ndef_on.light_source = minetest.LIGHT_MAX
|
||||
ndef_on.sunlight_propagates = true
|
||||
ndef_on.paramtype2 = "facedir"
|
||||
ndef_on.diggable = false
|
||||
ndef_on.groups = {not_in_creative_inventory=1}
|
||||
ndef_on.is_ground_content = false
|
||||
ndef_on.sounds = default.node_sound_glass_defaults()
|
||||
|
||||
minetest.register_node(basename.."_off", ndef_off)
|
||||
minetest.register_node(basename.."_on", ndef_on)
|
||||
|
||||
power.register_nodes({basename.."_off", basename.."_on"}, Cable, "con")
|
||||
techage.register_node_for_v1_transition({basename.."_off", basename.."_on"}, function(pos, node)
|
||||
power.update_network(pos, nil, Cable)
|
||||
end)
|
||||
end
|
||||
@@ -0,0 +1,65 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2020 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA4 Invisible Light Block
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
|
||||
-- 9 light positions in a 3x3 field
|
||||
local Positions = {
|
||||
{x =-1, y = 0, z = 0},
|
||||
{x = 0, y = 0, z =-1},
|
||||
{x = 1, y = 0, z = 0},
|
||||
{x = 0, y = 0, z = 1},
|
||||
{x =-1, y = 0, z =-1},
|
||||
{x = 1, y = 0, z = 1},
|
||||
{x =-1, y = 0, z = 1},
|
||||
{x = 1, y = 0, z =-1},
|
||||
}
|
||||
|
||||
minetest.register_node("techage:lightblock", {
|
||||
description = "Techage Light Block",
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
light_source = minetest.LIGHT_MAX,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
floodable = true,
|
||||
is_ground_content = false,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
drop = "",
|
||||
})
|
||||
|
||||
function techage.light_ring(center_pos, on, large)
|
||||
if on then
|
||||
for _,dir in ipairs(Positions) do
|
||||
if large then
|
||||
dir = vector.multiply(dir, 2)
|
||||
end
|
||||
local pos1 = vector.add(center_pos, dir)
|
||||
local node = techage.get_node_lvm(pos1)
|
||||
if node.name == "air" then
|
||||
minetest.set_node(pos1, {name = "techage:lightblock"})
|
||||
end
|
||||
end
|
||||
else
|
||||
local pos1 = {x=center_pos.x-2, y=center_pos.y-2, z=center_pos.z-2}
|
||||
local pos2 = {x=center_pos.x+2, y=center_pos.y+2, z=center_pos.z+2}
|
||||
for _,pos in ipairs(minetest.find_nodes_in_area(pos1, pos2, "techage:lightblock")) do
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
minetest.fix_light(pos1, pos2)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,53 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA3/TA4 Lamp
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
|
||||
techage.register_lamp("techage:simplelamp", {
|
||||
description = S("TA Lamp"),
|
||||
tiles = {
|
||||
'techage_electric_button.png',
|
||||
},
|
||||
conn_sides = {"L", "R", "U", "D", "F", "B"},
|
||||
paramtype = "light",
|
||||
light_source = 0,
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=2, cracky=2, crumbly=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
},{
|
||||
description = S("TA Lamp"),
|
||||
tiles = {
|
||||
'techage_electric_button.png',
|
||||
},
|
||||
conn_sides = {"L", "R", "U", "D", "F", "B"},
|
||||
paramtype = "light",
|
||||
light_source = minetest.LIGHT_MAX,
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
drop = "techage:test_lamp",
|
||||
groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:simplelamp_off 2",
|
||||
recipe = {
|
||||
{"", "", ""},
|
||||
{"", "default:glass", ""},
|
||||
{"", "basic_materials:heating_element", ""},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,70 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA3/TA4 Street Lamp
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
|
||||
techage.register_lamp("techage:streetlamp", {
|
||||
description = S("TA Street Lamp"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_streetlamp_top.png',
|
||||
'techage_streetlamp_top.png',
|
||||
'techage_streetlamp_off.png',
|
||||
},
|
||||
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-5/16, -8/16, -5/16, 5/16, 8/16, 5/16},
|
||||
{-2/16, -8/16, -2/16, 2/16, 8/16, 2/16},
|
||||
{-8/16, 4/16, -8/16, 8/16, 5/16, 8/16},
|
||||
{-5/16, -8/16, -5/16, 5/16, -7/16, 5/16},
|
||||
},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16},
|
||||
},
|
||||
on_rotate = screwdriver.disallow,
|
||||
conn_sides = {"U", "D"},
|
||||
},{
|
||||
description = S("TA Street Lamp"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
'techage_streetlamp_top.png',
|
||||
'techage_streetlamp_top.png',
|
||||
'techage_streetlamp.png',
|
||||
},
|
||||
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-5/16, -8/16, -5/16, 5/16, 8/16, 5/16},
|
||||
{-8/16, 4/16, -8/16, 8/16, 5/16, 8/16},
|
||||
},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16},
|
||||
},
|
||||
on_rotate = screwdriver.disallow,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "techage:streetlamp_off 2",
|
||||
recipe = {"techage:simplelamp_off", "default:steel_ingot", "default:glass"},
|
||||
})
|
||||
@@ -0,0 +1,128 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2020 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA4 LED Street Lamp
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
|
||||
local function on_switch_lamp(pos, on)
|
||||
techage.light_ring({x = pos.x, y = pos.y - 3, z = pos.z}, on, true)
|
||||
end
|
||||
|
||||
techage.register_lamp("techage:streetlamp2", {
|
||||
description = S("TA4 LED Street Lamp"),
|
||||
tiles = {
|
||||
"techage_streetlamp2_housing.png",
|
||||
"techage_streetlamp2_housing.png^techage_streetlamp2_off.png",
|
||||
"techage_streetlamp2_housing.png",
|
||||
},
|
||||
|
||||
paramtype2 = "facedir", -- important!
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {{ -8/32, 8/32, -16/32, 8/32, 15/32, 16/32}},
|
||||
},
|
||||
on_switch_lamp = on_switch_lamp,
|
||||
on_rotate = screwdriver.disallow,
|
||||
conn_sides = {"F", "B"},
|
||||
high_power = true,
|
||||
},{
|
||||
description = S("TA4 LED Street Lamp"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_streetlamp2_housing_on.png",
|
||||
"techage_streetlamp2_housing_on.png^techage_streetlamp2_on.png",
|
||||
"techage_streetlamp2_housing_on.png",
|
||||
},
|
||||
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {{ -8/32, 8/32, -16/32, 8/32, 15/32, 16/32}},
|
||||
},
|
||||
on_switch_lamp = on_switch_lamp,
|
||||
on_rotate = screwdriver.disallow,
|
||||
conn_sides = {"F", "B"},
|
||||
high_power = true,
|
||||
})
|
||||
|
||||
minetest.register_node("techage:streetlamp_pole", {
|
||||
description = S("TA4 LED Street Lamp Pole"),
|
||||
tiles = {
|
||||
"techage_streetlamp2_housing.png",
|
||||
},
|
||||
|
||||
paramtype2 = "facedir", -- important!
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {{ -5/32, -16/32, -5/32, 5/32, 16/32, 5/32}},
|
||||
|
||||
connect_left = {{-16/32, 8/32, -3/32, 3/32, 14/32, 3/32}},
|
||||
connect_right = {{ -3/32, 8/32, -3/32, 16/32, 14/32, 3/32}},
|
||||
connect_back = {{ -3/32, 8/32, -3/32, 3/32, 14/32, 16/32}},
|
||||
connect_front = {{ -3/32, 8/32, -16/32, 3/32, 14/32, 3/32}},
|
||||
},
|
||||
connects_to = {"techage:streetlamp_arm", "techage:streetlamp2_off", "techage:streetlamp2_on"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("techage:streetlamp_arm", {
|
||||
description = S("TA4 LED Street Lamp Arm"),
|
||||
tiles = {
|
||||
"techage_streetlamp2_housing.png",
|
||||
},
|
||||
|
||||
paramtype2 = "facedir", -- important!
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {{ -3/32, 8/32, -16/32, 3/32, 14/32, 16/32}},
|
||||
},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:streetlamp2_off",
|
||||
recipe = {
|
||||
{"basic_materials:steel_strip", "dye:white", "basic_materials:steel_strip"},
|
||||
{"techage:ta4_leds", "techage:ta4_leds", "techage:ta4_leds"},
|
||||
{"techage:ta4_leds", "techage:basalt_glass_thin", "techage:ta4_leds"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:streetlamp_pole 2",
|
||||
recipe = {
|
||||
{"", "basic_materials:steel_bar", ""},
|
||||
{"", "basic_materials:steel_bar", "dye:white"},
|
||||
{"", "basic_materials:steel_bar", ""},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:streetlamp_arm 2",
|
||||
recipe = {
|
||||
{"", "dye:white", ""},
|
||||
{"basic_materials:steel_bar", "basic_materials:steel_bar", "basic_materials:steel_bar"},
|
||||
{"", "", ""},
|
||||
},
|
||||
})
|
||||
Reference in new issue
Block a user