2021-08-16 18:57:04 +03:00
|
|
|
--[[
|
|
|
|
|
|
|
|
TechAge
|
|
|
|
=======
|
|
|
|
|
|
|
|
Copyright (C) 2019-2021 Joachim Stolberg
|
|
|
|
|
|
|
|
AGPL v3
|
|
|
|
See LICENSE.txt for more information
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2021-08-16 18:57:04 +03:00
|
|
|
TA1 Axles for the Watermill
|
|
|
|
|
|
|
|
]]--
|
|
|
|
|
|
|
|
-- for lazy programmers
|
|
|
|
local P = minetest.string_to_pos
|
|
|
|
local M = minetest.get_meta
|
|
|
|
local S = techage.S
|
|
|
|
|
|
|
|
local Axle = tubelib2.Tube:new({
|
|
|
|
dirs_to_check = {1,2,3,4,5,6},
|
2021-08-18 18:04:14 +03:00
|
|
|
max_tube_length = 10,
|
2021-08-16 18:57:04 +03:00
|
|
|
show_infotext = false,
|
|
|
|
tube_type = "axle1",
|
2022-01-03 23:40:31 +03:00
|
|
|
primary_node_names = {"techage:ta1_axle"},
|
2021-08-16 18:57:04 +03:00
|
|
|
secondary_node_names = {"techage:ta1_mill_gear", "techage:ta1_axle_bearing1", "techage:ta1_axle_bearing2"},
|
|
|
|
after_place_tube = function(pos, param2, tube_type, num_tubes, state)
|
|
|
|
minetest.swap_node(pos, {name = "techage:ta1_axle", param2 = param2})
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
Axle:set_valid_sides("techage:ta1_mill_gear", {"F", "B"})
|
|
|
|
Axle:set_valid_sides("techage:ta1_axle_bearing1", {"F", "B"})
|
|
|
|
Axle:set_valid_sides("techage:ta1_axle_bearing2", {"F", "B"})
|
|
|
|
|
|
|
|
minetest.register_node("techage:ta1_axle", {
|
|
|
|
description = S("TA1 Axle"),
|
|
|
|
tiles = {
|
|
|
|
"techage_axle_bearing.png^[transformR90",
|
|
|
|
"techage_axle_bearing.png^[transformR90",
|
|
|
|
"techage_axle_bearing.png",
|
|
|
|
"techage_axle_bearing.png",
|
|
|
|
"techage_axle_bearing.png",
|
|
|
|
"techage_axle_bearing.png",
|
|
|
|
},
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-1/8, -1/8, -4/8, 1/8, 1/8, 4/8},
|
|
|
|
},
|
|
|
|
},
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2021-08-16 18:57:04 +03:00
|
|
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
|
|
|
if not Axle:after_place_tube(pos, placer, pointed_thing) then
|
|
|
|
minetest.remove_node(pos)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end,
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2021-08-16 18:57:04 +03:00
|
|
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
|
|
Axle:after_dig_tube(pos, oldnode, oldmetadata)
|
|
|
|
end,
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2021-08-16 18:57:04 +03:00
|
|
|
paramtype2 = "facedir", -- important!
|
|
|
|
on_rotate = screwdriver.disallow, -- important!
|
|
|
|
paramtype = "light",
|
|
|
|
use_texture_alpha = techage.CLIP,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
is_ground_content = false,
|
|
|
|
groups = {crumbly = 3, cracky = 3, snappy = 3},
|
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Bearings are defined as secondary nodes which forward received 'on_transfer' commands
|
|
|
|
minetest.register_node("techage:ta1_axle_bearing1", {
|
|
|
|
description = S("TA1 Axle Bearing"),
|
|
|
|
tiles = {
|
|
|
|
"default_stone_brick.png^techage_axle_bearing.png^[transformR90",
|
|
|
|
"default_stone_brick.png^techage_axle_bearing.png",
|
|
|
|
},
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-1/2, -1/2, -1/2, 1/2, -1/8, 1/2},
|
|
|
|
{-1/8, -1/8, -1/2, 1/8, 1/8, 1/2},
|
|
|
|
},
|
|
|
|
},
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2021-08-16 18:57:04 +03:00
|
|
|
after_place_node = function(pos, placer)
|
2022-01-03 23:40:31 +03:00
|
|
|
Axle:after_place_node(pos)
|
2021-08-16 18:57:04 +03:00
|
|
|
end,
|
|
|
|
|
|
|
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
|
|
Axle:after_dig_node(pos)
|
|
|
|
end,
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2021-08-16 18:57:04 +03:00
|
|
|
paramtype2 = "facedir",
|
|
|
|
paramtype = "light",
|
|
|
|
use_texture_alpha = techage.CLIP,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
is_ground_content = false,
|
|
|
|
groups = {cracky = 2, crumbly = 2, choppy = 2},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("techage:ta1_axle_bearing2", {
|
|
|
|
description = S("TA1 Axle Bearing"),
|
|
|
|
tiles = {
|
|
|
|
-- up, down, right, left, back, front
|
|
|
|
"default_stone_brick.png",
|
|
|
|
"default_stone_brick.png",
|
|
|
|
"default_stone_brick.png",
|
|
|
|
"default_stone_brick.png",
|
|
|
|
"default_stone_brick.png^techage_axle_bearing_front.png",
|
|
|
|
"default_stone_brick.png^techage_axle_bearing_front.png",
|
|
|
|
},
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2021-08-16 18:57:04 +03:00
|
|
|
after_place_node = function(pos, placer)
|
2022-01-03 23:40:31 +03:00
|
|
|
Axle:after_place_node(pos)
|
2021-08-16 18:57:04 +03:00
|
|
|
end,
|
|
|
|
|
|
|
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
|
|
Axle:after_dig_node(pos)
|
|
|
|
end,
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2021-08-16 18:57:04 +03:00
|
|
|
paramtype2 = "facedir",
|
|
|
|
paramtype = "light",
|
|
|
|
use_texture_alpha = techage.CLIP,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
is_ground_content = false,
|
|
|
|
groups = {cracky = 2, crumbly = 2, choppy = 2},
|
|
|
|
})
|
|
|
|
|
|
|
|
techage.register_node({"techage:ta1_axle_bearing1", "techage:ta1_axle_bearing2"}, {
|
|
|
|
on_transfer = function(pos, in_dir, topic, payload)
|
|
|
|
return techage.transfer(
|
2022-01-03 23:40:31 +03:00
|
|
|
pos,
|
2021-08-16 18:57:04 +03:00
|
|
|
in_dir, -- outdir
|
|
|
|
topic,
|
|
|
|
payload,
|
|
|
|
Axle, -- network
|
|
|
|
nil) -- valid nodes
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "techage:ta1_axle",
|
|
|
|
recipe = {
|
|
|
|
{"", "", ""},
|
|
|
|
{"techage:iron_ingot", "dye:black", "techage:iron_ingot"},
|
|
|
|
{"", "", ""},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "techage:ta1_axle_bearing1",
|
|
|
|
recipe = {
|
|
|
|
{"", "", ""},
|
|
|
|
{"", "techage:ta1_axle", ""},
|
|
|
|
{"", "stairs:slab_stonebrick", ""},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "techage:ta1_axle_bearing2",
|
|
|
|
recipe = {
|
|
|
|
{"", "", ""},
|
|
|
|
{"", "techage:ta1_axle", ""},
|
|
|
|
{"", "default:stonebrick", ""},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2022-01-04 21:40:27 +03:00
|
|
|
techage.TA1Axle = Axle
|