2019-03-02 14:24:48 +03:00
|
|
|
--[[
|
|
|
|
|
|
|
|
TechAge
|
|
|
|
=======
|
|
|
|
|
|
|
|
Copyright (C) 2019 Joachim Stolberg
|
|
|
|
|
2019-08-22 21:49:47 +03:00
|
|
|
GPL v3
|
2019-03-02 14:24:48 +03:00
|
|
|
See LICENSE.txt for more information
|
|
|
|
|
|
|
|
TA2 Steam Engine Cylinder
|
|
|
|
|
|
|
|
]]--
|
|
|
|
|
|
|
|
-- for lazy programmers
|
|
|
|
local P = minetest.string_to_pos
|
|
|
|
local M = minetest.get_meta
|
2019-07-02 22:33:12 +03:00
|
|
|
local S = techage.S
|
2019-03-02 14:24:48 +03:00
|
|
|
|
2019-03-08 23:18:55 +03:00
|
|
|
local Pipe = techage.SteamPipe
|
2019-03-02 14:24:48 +03:00
|
|
|
|
|
|
|
local function swap_node(pos, name)
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
if node.name == name then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
node.name = name
|
|
|
|
minetest.swap_node(pos, node)
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_node("techage:cylinder", {
|
2019-07-02 22:33:12 +03:00
|
|
|
description = S("TA2 Cylinder"),
|
2019-03-02 14:24:48 +03:00
|
|
|
tiles = {
|
|
|
|
-- up, down, right, left, back, front
|
|
|
|
"techage_filling_ta2.png^techage_frame_ta2.png",
|
|
|
|
"techage_filling_ta2.png^techage_frame_ta2.png",
|
2019-03-02 22:51:16 +03:00
|
|
|
"techage_filling_ta2.png^techage_appl_open.png^techage_frame_ta2.png",
|
|
|
|
"techage_filling_ta2.png^techage_frame_ta2.png^techage_steam_hole.png",
|
2019-03-02 14:24:48 +03:00
|
|
|
"techage_filling_ta2.png^techage_cylinder.png^techage_frame_ta2.png",
|
|
|
|
"techage_filling_ta2.png^techage_cylinder.png^techage_frame_ta2.png",
|
|
|
|
},
|
|
|
|
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
groups = {cracky=2, crumbly=2, choppy=2},
|
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("techage:cylinder_on", {
|
2019-07-02 22:33:12 +03:00
|
|
|
description = S("TA2 Cylinder"),
|
2019-03-02 14:24:48 +03:00
|
|
|
tiles = {
|
|
|
|
-- up, down, right, left, back, front
|
|
|
|
"techage_filling_ta2.png^techage_frame_ta2.png",
|
|
|
|
"techage_filling_ta2.png^techage_frame_ta2.png",
|
2019-03-02 22:51:16 +03:00
|
|
|
"techage_filling_ta2.png^techage_appl_open.png^techage_frame_ta2.png",
|
|
|
|
"techage_filling_ta2.png^techage_frame_ta2.png^techage_steam_hole.png",
|
2019-03-02 14:24:48 +03:00
|
|
|
{
|
|
|
|
image = "techage_filling4_ta2.png^techage_cylinder4.png^techage_frame4_ta2.png",
|
|
|
|
backface_culling = false,
|
|
|
|
animation = {
|
|
|
|
type = "vertical_frames",
|
|
|
|
aspect_w = 32,
|
|
|
|
aspect_h = 32,
|
|
|
|
length = 0.4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
image = "techage_filling4_ta2.png^techage_cylinder4.png^techage_frame4_ta2.png",
|
|
|
|
backface_culling = false,
|
|
|
|
animation = {
|
|
|
|
type = "vertical_frames",
|
|
|
|
aspect_w = 32,
|
|
|
|
aspect_h = 32,
|
|
|
|
length = 0.4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-03-02 22:51:16 +03:00
|
|
|
|
2019-03-02 14:24:48 +03:00
|
|
|
paramtype2 = "facedir",
|
2019-03-02 22:51:16 +03:00
|
|
|
groups = {not_in_creative_inventory=1},
|
|
|
|
diggable = false,
|
2019-03-02 14:24:48 +03:00
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
is_ground_content = false,
|
2019-03-02 22:51:16 +03:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
2019-03-02 14:24:48 +03:00
|
|
|
})
|
|
|
|
|
2019-05-21 01:05:53 +03:00
|
|
|
techage.power.register_node({"techage:cylinder", "techage:cylinder_on"}, {
|
|
|
|
conn_sides = {"L"},
|
|
|
|
power_network = Pipe,
|
2019-10-05 20:19:18 +03:00
|
|
|
after_tube_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
|
|
|
|
local mem = tubelib2.get_mem(pos)
|
|
|
|
mem.running = false
|
|
|
|
swap_node(pos, "techage:cylinder")
|
|
|
|
end,
|
2019-05-21 01:05:53 +03:00
|
|
|
})
|
|
|
|
|
2019-06-08 23:57:01 +03:00
|
|
|
-- used by firebox
|
|
|
|
techage.register_node({"techage:cylinder", "techage:cylinder_on"}, {
|
|
|
|
on_transfer = function(pos, in_dir, topic, payload)
|
|
|
|
local mem = tubelib2.get_mem(pos)
|
2019-06-16 22:06:16 +03:00
|
|
|
if topic == "trigger" then
|
|
|
|
local power = techage.transfer(pos, "R", "trigger", nil, nil, {
|
|
|
|
"techage:flywheel", "techage:flywheel_on"}) or 0
|
2019-07-02 22:33:12 +03:00
|
|
|
|
2019-06-16 22:06:16 +03:00
|
|
|
if not power then
|
|
|
|
return 0
|
|
|
|
elseif power > 0 and not mem.running then
|
|
|
|
swap_node(pos, "techage:cylinder_on")
|
|
|
|
mem.running = true
|
|
|
|
return power
|
|
|
|
elseif power <= 0 and mem.running then
|
|
|
|
swap_node(pos, "techage:cylinder")
|
|
|
|
mem.running = false
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return power
|
|
|
|
end
|
2019-06-08 23:57:01 +03:00
|
|
|
elseif topic == "stop" then
|
2019-06-16 22:06:16 +03:00
|
|
|
swap_node(pos, "techage:cylinder")
|
2019-06-08 23:57:01 +03:00
|
|
|
mem.running = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2019-04-28 17:04:45 +03:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "techage:cylinder",
|
|
|
|
recipe = {
|
|
|
|
{"basic_materials:steel_bar", "techage:iron_ingot", "default:wood"},
|
|
|
|
{"techage:steam_pipeS", "basic_materials:gear_steel", ""},
|
|
|
|
{"default:wood", "techage:iron_ingot", "basic_materials:steel_bar"},
|
|
|
|
},
|
|
|
|
})
|
2019-05-02 00:01:14 +03:00
|
|
|
|