waterpump added
This commit is contained in:
parent
54c7267af7
commit
d4bd5118b0
@ -8,7 +8,7 @@
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA2/TA3/TA4 Liquid Sampler
|
||||
TA2/TA3 Bucket based Liquid Sampler
|
||||
|
||||
]]--
|
||||
|
||||
@ -178,7 +178,7 @@ local tubing = {
|
||||
end,
|
||||
}
|
||||
|
||||
local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
local node_name_ta2, node_name_ta3, _ =
|
||||
techage.register_consumer("liquidsampler", S("Liquid Sampler"), tiles, {
|
||||
cycle_time = CYCLE_TIME,
|
||||
standby_ticks = STANDBY_TICKS,
|
||||
@ -202,7 +202,8 @@ local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
num_items = {0,1,2,4},
|
||||
power_consumption = {0,3,5,8},
|
||||
power_sides = {U=1},
|
||||
})
|
||||
},
|
||||
{false, true, true, false}) -- TA2/A3
|
||||
|
||||
minetest.register_craft({
|
||||
output = node_name_ta2,
|
||||
|
@ -22,8 +22,8 @@ minetest.register_craftitem("techage:ta4_fuelcellstack", {
|
||||
minetest.register_craft({
|
||||
output = "techage:ta4_fuelcellstack",
|
||||
recipe = {
|
||||
{'techage:baborium_ingot', 'techage:ta4_carbon_fiber', 'default:copper_ingot'},
|
||||
{'default:gold_ingot', 'techage:ta4_carbon_fiber', 'default:tin_ingot'},
|
||||
{"techage:baborium_ingot", 'techage:ta4_carbon_fiber', 'default:copper_ingot'},
|
||||
{'default:copper_ingot', 'techage:ta4_carbon_fiber', 'default:copper_ingot'},
|
||||
{'techage:baborium_ingot', 'techage:ta4_carbon_fiber', 'techage:baborium_ingot'},
|
||||
{"techage:lye", 'techage:ta4_carbon_fiber', 'techage:lye'},
|
||||
},
|
||||
})
|
||||
|
1
init.lua
1
init.lua
@ -111,6 +111,7 @@ else
|
||||
dofile(MP.."/liquids/filler.lua")
|
||||
dofile(MP.."/liquids/silo.lua")
|
||||
dofile(MP.."/liquids/pump.lua")
|
||||
dofile(MP.."/liquids/waterpump.lua")
|
||||
|
||||
-- Coal power station
|
||||
dofile(MP.."/coal_power_station/firebox.lua")
|
||||
|
189
liquids/waterpump.lua
Normal file
189
liquids/waterpump.lua
Normal file
@ -0,0 +1,189 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019-2020 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA4 Water Pump
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local M = minetest.get_meta
|
||||
local S = techage.S
|
||||
|
||||
local Cable = techage.ElectricCable
|
||||
local power = techage.power
|
||||
local Pipe = techage.LiquidPipe
|
||||
local liquid = techage.liquid
|
||||
|
||||
local CYCLE_TIME = 4
|
||||
local STANDBY_TICKS = 3
|
||||
local COUNTDOWN_TICKS = 3
|
||||
local PWR_NEEDED = 4
|
||||
|
||||
local function formspec(self, pos, nvm)
|
||||
return "size[3,2]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"box[0,-0.1;2.8,0.5;#c6e8ff]"..
|
||||
"label[0.5,-0.1;"..minetest.colorize( "#000000", S("Water Pump")).."]"..
|
||||
"image_button[1,1;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
|
||||
"tooltip[1,1;1,1;"..self:get_state_tooltip(nvm).."]"
|
||||
end
|
||||
|
||||
local function can_start(pos, nvm, state)
|
||||
return power.power_available(pos, Cable)
|
||||
end
|
||||
|
||||
local function start_node(pos, nvm, state)
|
||||
power.consumer_start(pos, Cable, CYCLE_TIME)
|
||||
end
|
||||
|
||||
local function stop_node(pos, nvm, state)
|
||||
nvm.running = false
|
||||
power.consumer_stop(pos, Cable)
|
||||
end
|
||||
|
||||
local State = techage.NodeStates:new({
|
||||
node_name_passive = "techage:t4_waterpump",
|
||||
infotext_name = S("TA4 Water Pump"),
|
||||
cycle_time = CYCLE_TIME,
|
||||
standby_ticks = STANDBY_TICKS,
|
||||
formspec_func = formspec,
|
||||
start_node = start_node,
|
||||
stop_node = stop_node,
|
||||
})
|
||||
|
||||
local function on_power(pos)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
State:start(pos, nvm)
|
||||
nvm.running = true
|
||||
end
|
||||
|
||||
local function on_nopower(pos)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
State:nopower(pos, nvm)
|
||||
nvm.running = false
|
||||
end
|
||||
|
||||
local function water_available(pos, nvm)
|
||||
return true
|
||||
end
|
||||
|
||||
local function pumping(pos, nvm)
|
||||
if not nvm.running then
|
||||
State:nopower(pos, nvm)
|
||||
elseif water_available(pos, nvm) then
|
||||
local leftover = liquid.put(pos, 6, "default:water_source", 1)
|
||||
if leftover and leftover > 0 then
|
||||
State:blocked(pos, nvm)
|
||||
return
|
||||
end
|
||||
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
||||
return
|
||||
end
|
||||
State:idle(pos, nvm)
|
||||
end
|
||||
|
||||
-- converts power into hydrogen
|
||||
local function node_timer(pos, elapsed)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
pumping(pos, nvm)
|
||||
return State:is_active(nvm)
|
||||
end
|
||||
|
||||
local function on_receive_fields(pos, formname, fields, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return
|
||||
end
|
||||
local nvm = techage.get_nvm(pos)
|
||||
State:state_button_event(pos, nvm, fields)
|
||||
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||
end
|
||||
|
||||
local function after_place_node(pos)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.running = false
|
||||
local number = techage.add_node(pos, "techage:t4_waterpump")
|
||||
State:node_init(pos, nvm, number)
|
||||
Pipe:after_place_node(pos)
|
||||
Cable:after_place_node(pos)
|
||||
end
|
||||
|
||||
local function after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
Pipe:after_dig_node(pos)
|
||||
Cable:after_dig_node(pos)
|
||||
techage.del_mem(pos)
|
||||
end
|
||||
|
||||
local function tubelib2_on_update2(pos, outdir, tlib2, node)
|
||||
if tlib2.tube_type == "pipe2" then
|
||||
liquid.update_network(pos, outdir, tlib2)
|
||||
else
|
||||
power.update_network(pos, outdir, tlib2)
|
||||
end
|
||||
end
|
||||
|
||||
local netw_def = {
|
||||
pipe2 = {
|
||||
sides = {U = 1}, -- Pipe connection sides
|
||||
ntype = "pump",
|
||||
},
|
||||
ele1 = {
|
||||
sides = {L = 1}, -- Cable connection sides
|
||||
ntype = "con1",
|
||||
on_power = on_power,
|
||||
on_nopower = on_nopower,
|
||||
nominal = PWR_NEEDED,
|
||||
},
|
||||
}
|
||||
|
||||
minetest.register_node("techage:t4_waterpump", {
|
||||
description = S("TA4 Water Pump"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta4.png^techage_frame_waterpump_top.png^techage_appl_hole_pipe.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_waterpump.png",
|
||||
"techage_filling_ta4.png^techage_frame_waterpump.png^techage_appl_hole_electric.png",
|
||||
"techage_filling_ta4.png^techage_frame_waterpump.png",
|
||||
"techage_filling_ta4.png^techage_frame_waterpump.png",
|
||||
},
|
||||
|
||||
after_place_node = after_place_node,
|
||||
after_dig_node = after_dig_node,
|
||||
tubelib2_on_update2 = tubelib2_on_update2,
|
||||
networks = netw_def,
|
||||
on_receive_fields = on_receive_fields,
|
||||
on_timer = node_timer,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
on_rotate = screwdriver.disallow,
|
||||
is_ground_content = false,
|
||||
})
|
||||
|
||||
Cable:add_secondary_node_names({"techage:t4_waterpump"})
|
||||
Pipe:add_secondary_node_names({"techage:t4_waterpump"})
|
||||
|
||||
techage.register_node({"techage:t4_waterpump"}, {
|
||||
on_recv_message = function(pos, src, topic, payload)
|
||||
return State:on_receive_message(pos, topic, payload)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:t4_waterpump",
|
||||
recipe = {
|
||||
{"", "default:mese_crystal", ""},
|
||||
{"", "default:mese_crystal", ""},
|
||||
{"", "techage:vacuum_tube", ""},
|
||||
},
|
||||
})
|
||||
|
BIN
textures/techage_frame_waterpump.png
Normal file
BIN
textures/techage_frame_waterpump.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 977 B |
BIN
textures/techage_frame_waterpump_top.png
Normal file
BIN
textures/techage_frame_waterpump_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 881 B |
Loading…
Reference in New Issue
Block a user