Firs version with only one power generator.
73
LICENSE
Normal file
@ -0,0 +1,73 @@
|
||||
License of source code
|
||||
======================
|
||||
|
||||
The MIT License (MIT)
|
||||
---------------------
|
||||
Copyright (C) 2021 SFENCE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
software and associated documentation files (the "Software"), to deal in the Software
|
||||
without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more details:
|
||||
https://opensource.org/licenses/MIT
|
||||
|
||||
Licenses of media
|
||||
=================
|
||||
|
||||
Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
-------------------------------------------------------
|
||||
|
||||
This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
|
||||
|
||||
Attribution 3.0 Unported (CC BY 3.0)
|
||||
------------------------------------
|
||||
|
||||
This work is licensed under the Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
|
||||
|
||||
CC0 1.0 Universal (CC0 1.0)
|
||||
---------------------------
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following:
|
||||
|
||||
the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work;
|
||||
moral rights retained by the original author(s) and/or performer(s);
|
||||
publicity and privacy rights pertaining to a person's image or likeness depicted in a Work;
|
||||
rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below;
|
||||
rights protecting the extraction, dissemination, use and reuse of data in a Work;
|
||||
database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and
|
||||
other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document.
|
||||
Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law.
|
||||
Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work.
|
||||
Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work.
|
||||
|
32
README.md
Normal file
@ -0,0 +1,32 @@
|
||||
Minetest Game mod: power_generators
|
||||
==================================
|
||||
|
||||
This mod add liquid fuel powered generators into minetest worls.
|
||||
Generatos supports Minetest default game and Hades Revisited.
|
||||
Generators are powered by appliances mod API. So, on appliances APi based machines can easy access the power from generator.
|
||||
|
||||
Authors of source code
|
||||
----------------------
|
||||
Copyright (c) 2021 SFENCE
|
||||
MIT - check LICENSE file
|
||||
|
||||
Authors of media
|
||||
----------------
|
||||
|
||||
Models
|
||||
------
|
||||
|
||||
Copyright (c) 2021 SFENCE
|
||||
CC BY-SA 4.0 - check LICENSE file
|
||||
|
||||
Textures
|
||||
--------
|
||||
|
||||
Copyright (c) 2021 SFENCE
|
||||
CC BY-SA 4.0 - check LICENSE file
|
||||
|
||||
Sounds
|
||||
------
|
||||
|
||||
power_generators_emergency_generator_* - delivered from Generator StartUp, Run, Shutdown.wav sound (https://freesound.org/people/JeffWojo/sounds/169940/) by JeffWojo, license CC0 1.0
|
||||
|
162
crafting.lua
Normal file
@ -0,0 +1,162 @@
|
||||
|
||||
local items = {
|
||||
strong_ingot = "default:steel_ingot",
|
||||
metal_ingot = "default:steel_ingot",
|
||||
copper_ingot = "default:copper_ingot",
|
||||
mese_fragment = "default:mese_crystal_fragment",
|
||||
|
||||
copper_wire = "basic_materials:copper_wire",
|
||||
empty_spool = "basic_materials:empty_spool",
|
||||
controller = "basic_materials:ic",
|
||||
|
||||
gear = "basic_materials:gear_steel",
|
||||
electric_motor = "basic_materials:motor",
|
||||
transforemr = "basic_materials:gold_wire",
|
||||
|
||||
bar = "basic_materials:steel_bar",
|
||||
}
|
||||
|
||||
if minetest.get_modpath("hades_core") then
|
||||
items.strong_ingot = "hades_core:steel_ingot"
|
||||
items.metal_ingot = "hades_core:steel_ingot"
|
||||
items.copper_ingot = "hades_core:copper_ingot"
|
||||
items.mese_fragment = "hades_core:mese_crystal_fragment"
|
||||
|
||||
items.copper_wire = "hades_extramaterials:copper_wire"
|
||||
items.empty_spool = "hades_extramaterials:empty_spool"
|
||||
items.controller = "hades_extramaterials:ic"
|
||||
|
||||
items.gear = "hades_extramaterials:gear_steel"
|
||||
items.electric_motor = "hades_extramaterials:motor"
|
||||
items.transformer = "hades_extramaterials:gold_wire"
|
||||
|
||||
items.bar = "hades_extramaterials:steel_bar"
|
||||
end
|
||||
|
||||
if minetest.get_modpath("technic") then
|
||||
items.strong_ingot = "technic:stainless_steel_ingot"
|
||||
items.metal_ingot = "technic:carbon_steel_ingot"
|
||||
items.controller = "technic:control_logic_unit"
|
||||
|
||||
items.transformer = "technic:lv_transformer"
|
||||
end
|
||||
|
||||
if minetest.get_modpath("hades_technic") then
|
||||
items.strong_ingot = "hades_technic:stainless_steel_ingot"
|
||||
items.metal_ingot = "hades_technic:carbon_steel_ingot"
|
||||
items.controller = "hades_technic:control_logic_unit"
|
||||
|
||||
items.transformer = "hades_technic:lv_transformer"
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
output = "power_generators:combustion_engine_piston",
|
||||
recipe = {
|
||||
{items.strong_ingot, items.strong_ingot, items.strong_ingot},
|
||||
{"", items.strong_ingot, ""},
|
||||
{"", items.strong_ingot, ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "power_generators:combustion_engine_cylinder_body",
|
||||
recipe = {
|
||||
{items.strong_ingot, "", items.strong_ingot},
|
||||
{items.strong_ingot, "", items.strong_ingot},
|
||||
{items.strong_ingot, items.strong_ingot, items.strong_ingot},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "power_generators:combustion_engine_crankshaft 2",
|
||||
recipe = {
|
||||
{"", items.strong_ingot, items.strong_ingot},
|
||||
{"", items.strong_ingot, ""},
|
||||
{items.strong_ingot, items.strong_ingot, ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "power_generators:combustion_engine_spark_plug",
|
||||
recipe = {
|
||||
{items.copper_ingot, items.copper_wire, items.copper_ingot},
|
||||
{"", items.mese_fragment, ""},
|
||||
},
|
||||
replacements = {{items.copper_wire,items.empty_spool}},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "power_generators:combustion_engine_body_2",
|
||||
recipe = {
|
||||
{"power_generators:combustion_engine_spark_plug", items.metal_ingot, "power_generators:combustion_engine_spark_plug"},
|
||||
{"power_generators:combustion_engine_piston", items.controller, "power_generators:combustion_engine_piston"},
|
||||
{"power_generators:combustion_engine_cylinder_body", "power_generators:combustion_engine_crankshaft", "power_generators:combustion_engine_cylinder_body"},
|
||||
}
|
||||
})
|
||||
|
||||
--[[
|
||||
minetest.register_craft({
|
||||
output = "power_generators:combustion_engine_body_4",
|
||||
recipe = {
|
||||
{items.metal_ingot, items.metal_ingot, items.metal_ingot},
|
||||
{"power_generators:combustion_engine_body_2","power_generators:combustion_engine_body_2"},
|
||||
{"power_generators:combustion_engine_crankshaft","power_generators:combustion_engine_crankshaft"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "power_generators:combustion_engine_body_6",
|
||||
recipe = {
|
||||
{items.metal_ingot, items.metal_ingot, items.metal_ingot},
|
||||
{"power_generators:combustion_engine_body_2","power_generators:combustion_engine_body_2", "power_generators:combustion_engine_body_2"},
|
||||
{"power_generators:combustion_engine_crankshaft","power_generators:combustion_engine_crankshaft","power_generators:combustion_engine_crankshaft"},
|
||||
}
|
||||
})
|
||||
--]]
|
||||
|
||||
minetest.register_craft({
|
||||
output = "power_generators:combustion_engine_two_cylinders",
|
||||
recipe = {
|
||||
{items.metal_ingot, items.controller, items.metal_ingot},
|
||||
{items.copper_wire, "power_generators:combustion_engine_body_2", items.copper_wire},
|
||||
{items.metal_ingot, items.bar, items.metal_ingot},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "power_generators:combustion_engine_gearbox",
|
||||
recipe = {
|
||||
{items.metal_ingot, items.gear, items.metal_ingot},
|
||||
{items.metal_ingot, items.gear, items.metal_ingot},
|
||||
{items.metal_ingot, items.gear, items.metal_ingot},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "power_generators:combustion_engine_alternator",
|
||||
recipe = {
|
||||
{"", items.transformer, ""},
|
||||
{"", items.electric_motor, ""},
|
||||
{items.metal_ingot, "", items.metal_ingot},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "power_generators:combustion_engine_fuel_tank",
|
||||
recipe = {
|
||||
{items.metal_ingot, items.metal_ingot, items.metal_ingot},
|
||||
{items.metal_ingot, "", items.metal_ingot},
|
||||
{items.metal_ingot, items.metal_ingot, items.metal_ingot},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "power_generators:emergency_generator",
|
||||
recipe = {
|
||||
{items.metal_ingot, "power_generators:combustion_engine_fuel_tank", items.metal_ingot},
|
||||
{"power_generators:combustion_engine_two_cylinders", "power_generators:combustion_engine_gearbox", "power_generators:combustion_engine_alternator"},
|
||||
{items.metal_ingot, "", items.metal_ingot},
|
||||
},
|
||||
replacements = {{items.copper_wire,items.empty_spool}},
|
||||
})
|
||||
|
65
craftitems.lua
Normal file
@ -0,0 +1,65 @@
|
||||
|
||||
local S = power_generators.translator
|
||||
|
||||
minetest.register_craftitem("power_generators:combustion_engine_piston", {
|
||||
description = S("Combustion Engine Piston"),
|
||||
inventory_image = "power_generators_combustion_engine_piston.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("power_generators:combustion_engine_cylinder_body", {
|
||||
description = S("Combustion Engine Cylinder Body"),
|
||||
inventory_image = "power_generators_combustion_engine_cylinder.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("power_generators:combustion_engine_crankshaft", {
|
||||
description = S("Combustion Engine Crankshaft"),
|
||||
inventory_image = "power_generators_combustion_engine_crankshaft.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("power_generators:combustion_engine_spark_plug", {
|
||||
description = S("Combustion Engine Spark"),
|
||||
inventory_image = "power_generators_combustion_engine_spark.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("power_generators:combustion_engine_body_2", {
|
||||
description = S("Combustion Engine Body 2"),
|
||||
inventory_image = "power_generators_combustion_engine_body_2.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("power_generators:combustion_engine_body_4", {
|
||||
description = S("Combustion Engine Body 4"),
|
||||
inventory_image = "power_generators_combustion_engine_body_4.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("power_generators:combustion_engine_body_6", {
|
||||
description = S("Combustion Engine Body 6"),
|
||||
inventory_image = "power_generators_combustion_engine_body_6.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("power_generators:combustion_engine_two_cylinders", {
|
||||
description = S("Combustion Engine Two Cylinders"),
|
||||
inventory_image = "power_generators_combustion_engine_two_cylinders.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("power_generators:combustion_engine_gearbox", {
|
||||
description = S("Combustion Engine Gearbox"),
|
||||
inventory_image = "power_generators_combustion_engine_gearbox.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("power_generators:combustion_engine_alternator", {
|
||||
description = S("Combustion Engine Alternator"),
|
||||
inventory_image = "power_generators_combustion_engine_alternator.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("power_generators:combustion_engine_fuel_tank", {
|
||||
description = S("Combustion Engine Fuel Tank"),
|
||||
inventory_image = "power_generators_combustion_engine_fuel_tank.png",
|
||||
})
|
||||
|
||||
--[[
|
||||
minetest.register_craftitem("power_generators:combustion_engine_", {
|
||||
description = S("Combustion Engine "),
|
||||
inventory_image = "power_generators_combustion_engine_.png",
|
||||
})
|
||||
--]]
|
||||
|
265
emergency_generator.lua
Normal file
@ -0,0 +1,265 @@
|
||||
-------------------------
|
||||
-- Emergency Generator --
|
||||
-------------------------
|
||||
----- Ver 1.0 ---------
|
||||
-----------------------
|
||||
-- Initial Functions --
|
||||
-----------------------
|
||||
local S = power_generators.translator;
|
||||
|
||||
power_generators.emergency_generator = appliances.appliance:new(
|
||||
{
|
||||
node_name_inactive = "power_generators:emergency_generator",
|
||||
node_name_active = "power_generators:emergency_generator_active",
|
||||
|
||||
node_description = S("Emergency generator"),
|
||||
node_help = S("Fill it with liquid fuel.").."\n"..S("Use this for generate energy.").."\n"..S("Startup and Shutdown by punch."),
|
||||
|
||||
input_stack_size = 0,
|
||||
have_input = false,
|
||||
|
||||
power_connect_sides = {"front","back","right","left"},
|
||||
|
||||
have_control = true,
|
||||
|
||||
sounds = {
|
||||
active_running = {
|
||||
sound = "power_generators_emergency_generator_startup",
|
||||
sound_param = {max_hear_distance = 32, gain = 1},
|
||||
repeat_timer = 3,
|
||||
},
|
||||
waiting_running = {
|
||||
sound = "power_generators_emergency_generator_startup",
|
||||
sound_param = {max_hear_distance = 32, gain = 1},
|
||||
repeat_timer = 3,
|
||||
},
|
||||
running = {
|
||||
sound = "power_generators_emergency_generator_running",
|
||||
sound_param = {max_hear_distance = 32, gain = 1},
|
||||
repeat_timer = 1,
|
||||
},
|
||||
running_idle = {
|
||||
sound = "power_generators_emergency_generator_shutdown",
|
||||
sound_param = {max_hear_distance = 32, gain = 1},
|
||||
},
|
||||
running_nopower = {
|
||||
sound = "power_generators_emergency_generator_shutdown",
|
||||
sound_param = {max_hear_distance = 32, gain = 1},
|
||||
},
|
||||
running_waiting = {
|
||||
sound = "power_generators_emergency_generator_shutdown",
|
||||
sound_param = {max_hear_distance = 32, gain = 1},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
local emergency_generator = power_generators.emergency_generator
|
||||
|
||||
emergency_generator:power_data_register(
|
||||
{
|
||||
["time_power"] = {
|
||||
run_speed = 1,
|
||||
disable = {}
|
||||
},
|
||||
})
|
||||
emergency_generator:control_data_register(
|
||||
{
|
||||
["punch_control"] = {
|
||||
},
|
||||
})
|
||||
|
||||
--------------
|
||||
-- Formspec --
|
||||
--------------
|
||||
|
||||
function emergency_generator:get_formspec(meta, production_percent, consumption_percent)
|
||||
local progress = "";
|
||||
|
||||
progress = "image[3.6,0.9;5.5,0.95;appliances_consumption_progress_bar.png^[transformR270]]";
|
||||
if consumption_percent then
|
||||
progress = "image[3.6,0.9;5.5,0.95;appliances_consumption_progress_bar.png^[lowpart:" ..
|
||||
(consumption_percent) ..
|
||||
":appliances_consumption_progress_bar_full.png^[transformR270]]";
|
||||
end
|
||||
|
||||
|
||||
|
||||
local formspec = "formspec_version[3]" .. "size[12.75,8.5]" ..
|
||||
"background[-1.25,-1.25;15,10;appliances_appliance_formspec.png]" ..
|
||||
progress..
|
||||
"list[current_player;main;1.5,3;8,4;]" ..
|
||||
"list[context;"..self.use_stack..";2,0.8;1,1;]"..
|
||||
"list[context;"..self.output_stack..";9.75,0.25;2,2;]" ..
|
||||
"listring[current_player;main]" ..
|
||||
"listring[context;"..self.use_stack.."]" ..
|
||||
"listring[current_player;main]" ..
|
||||
"listring[context;"..self.output_stack.."]" ..
|
||||
"listring[current_player;main]";
|
||||
return formspec;
|
||||
end
|
||||
|
||||
---------------
|
||||
-- Callbacks --
|
||||
---------------
|
||||
|
||||
local function update_generator_supply(self, pos, use_usage)
|
||||
local side_data = {};
|
||||
local total_demand = 0;
|
||||
for _,side in pairs(self.power_connect_sides) do
|
||||
local side_pos = appliances.get_side_pos(pos, side);
|
||||
local side_node = minetest.get_node(side_pos);
|
||||
local side_def = minetest.registered_nodes[side_node.name];
|
||||
if side_def and side_def._generator_connect_sides then
|
||||
if appliances.is_connected_to(side_pos, pos, side_def._generator_connect_sides) then
|
||||
local meta = minetest.get_meta(side_pos);
|
||||
local demand = meta:get_int("generator_demand") or 0
|
||||
if (demand>0) then
|
||||
total_demand = total_demand + demand;
|
||||
table.insert(side_data, {meta=meta,demand=demand});
|
||||
else
|
||||
meta:set_int("generator_input", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (total_demand>0) then
|
||||
local generator_output = 0;
|
||||
if use_usage then
|
||||
generator_output = use_usage.generator_output or 150;
|
||||
end
|
||||
local part = generator_output/total_demand;
|
||||
|
||||
for _,side in pairs(side_data) do
|
||||
side.meta:set_int("generator_input", math.floor(side.demand*part))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function emergency_generator:cb_on_production(timer_step)
|
||||
update_generator_supply(self, timer_step.pos, timer_step.use_usage)
|
||||
end
|
||||
|
||||
function emergency_generator:cb_deactivate(pos, meta)
|
||||
update_generator_supply(self, pos, nil)
|
||||
end
|
||||
|
||||
----------
|
||||
-- Node --
|
||||
----------
|
||||
|
||||
local node_sounds = nil
|
||||
if minetest.get_modpath("default") then
|
||||
node_sounds = default.node_sound_metal_defaults()
|
||||
end
|
||||
if minetest.get_modpath("hades_sounds") then
|
||||
node_sounds = hades_sounds.node_sound_metal_defaults()
|
||||
end
|
||||
if minetest.get_modpath("sounds") then
|
||||
node_sounds = sounds.node_metal()
|
||||
end
|
||||
|
||||
local node_def = {
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky = 2},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = node_sounds,
|
||||
drawtype = "mesh",
|
||||
mesh = "power_generators_emergency_generator.obj",
|
||||
use_texture_alpha = "clip",
|
||||
}
|
||||
|
||||
local node_inactive = {
|
||||
tiles = {
|
||||
"power_generators_emergency_generator_frame_lid_hose.png",
|
||||
"power_generators_emergency_generator_front_panel_body.png",
|
||||
"power_generators_emergency_generator_back_body.png",
|
||||
"power_generators_emergency_generator_tank.png",
|
||||
"power_generators_emergency_generator_cable.png",
|
||||
"power_generators_emergency_generator_moving_parts.png",
|
||||
},
|
||||
}
|
||||
|
||||
local node_active = {
|
||||
tiles = {
|
||||
"power_generators_emergency_generator_frame_lid_hose.png",
|
||||
"power_generators_emergency_generator_front_panel_body.png",
|
||||
"power_generators_emergency_generator_back_body.png",
|
||||
"power_generators_emergency_generator_tank.png",
|
||||
"power_generators_emergency_generator_cable.png",
|
||||
{
|
||||
image = "power_generators_emergency_generator_moving_parts_active.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1.5
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
emergency_generator:register_nodes(node_def, node_inactive, node_active)
|
||||
|
||||
-------------------------
|
||||
-- Recipe Registration --
|
||||
-------------------------
|
||||
|
||||
local items = {
|
||||
phial_fuel = "biofuel:phial_fuel",
|
||||
phial_empty = "biofuel:phial",
|
||||
bottle_fuel = "biofuel:bottle_fuel",
|
||||
bottle_empty = "vessles:glass_bottle",
|
||||
can_fuel = "biofuel:can_fuel",
|
||||
can_empty = "biofuel:can",
|
||||
}
|
||||
|
||||
if minetest.get_modpath("hades_biofuel") then
|
||||
items.phial_fuel = "hades_biofuel:phial_fuel"
|
||||
items.phial_empty = "hades_biofuel:phial"
|
||||
items.bottle_fuel = "hades_biofuel:bottle_fuel"
|
||||
items.bottle_empty = "vessles:glass_bottle"
|
||||
items.can_fuel = "hades_biofuel:can_fuel"
|
||||
items.can_empty = "hades_biofuel:can"
|
||||
end
|
||||
|
||||
-- hope, temporary only support for biofuel withou vessels manageent
|
||||
if not minetest.registered_items[items.phial_empty] then
|
||||
items.phial_empty = nil
|
||||
items.bottle_empty = nil
|
||||
items.can_empty = nil
|
||||
end
|
||||
|
||||
emergency_generator:recipe_register_usage(
|
||||
items.phial_fuel,
|
||||
{
|
||||
inputs = 1,
|
||||
outputs = {items.phial_empty},
|
||||
consumption_time = 2,
|
||||
consumption_step_size = 1,
|
||||
generator_output = 150,
|
||||
});
|
||||
emergency_generator:recipe_register_usage(
|
||||
items.bottle_fuel,
|
||||
{
|
||||
inputs = 1,
|
||||
outputs = {items.bottle_empty},
|
||||
consumption_time = 20,
|
||||
consumption_step_size = 1,
|
||||
generator_output = 150,
|
||||
});
|
||||
emergency_generator:recipe_register_usage(
|
||||
items.can_fuel,
|
||||
{
|
||||
inputs = 1,
|
||||
outputs = {items.can_empty},
|
||||
consumption_time = 160,
|
||||
consumption_step_size = 1,
|
||||
generator_output = 150,
|
||||
});
|
||||
|
||||
emergency_generator:register_recipes("power_generators_fuel", "")
|
||||
|
20
init.lua
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
power_generators = {
|
||||
translator = minetest.get_translator("power_generators")
|
||||
}
|
||||
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
dofile(modpath.."/power_supply.lua")
|
||||
|
||||
appliances.register_craft_type("power_generators_fuel", {
|
||||
description = "Generator fuel",
|
||||
width = 1,
|
||||
height = 1,
|
||||
})
|
||||
|
||||
dofile(modpath.."/emergency_generator.lua")
|
||||
|
||||
dofile(modpath.."/craftitems.lua")
|
||||
dofile(modpath.."/crafting.lua")
|
||||
|
5
mod.conf
Normal file
@ -0,0 +1,5 @@
|
||||
name = power_generators
|
||||
title = Add some power generators
|
||||
description = Add power generators based on appliances API.
|
||||
depends = appliances
|
||||
optional_depends = default, biofuel, basic_materials, hades_sounds, hades_biofuel, hades_extramaterials, sounds
|
62
models/power_generators_emergency_generator.mtl
Normal file
@ -0,0 +1,62 @@
|
||||
# Blender MTL File: 'None'
|
||||
# Material Count: 6
|
||||
|
||||
newmtl back_body
|
||||
Ns 225.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 0.800000 0.800000 0.800000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.450000
|
||||
d 1.000000
|
||||
illum 2
|
||||
|
||||
newmtl cable
|
||||
Ns 225.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 0.800000 0.800000 0.800000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.450000
|
||||
d 1.000000
|
||||
illum 2
|
||||
|
||||
newmtl frame_lid_hose
|
||||
Ns 225.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 0.800000 0.800000 0.800000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.450000
|
||||
d 1.000000
|
||||
illum 2
|
||||
|
||||
newmtl front_panel_body
|
||||
Ns 225.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 0.800000 0.800000 0.800000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.450000
|
||||
d 1.000000
|
||||
illum 2
|
||||
|
||||
newmtl moving_parts
|
||||
Ns 225.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 0.800000 0.800000 0.800000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.450000
|
||||
d 1.000000
|
||||
illum 2
|
||||
|
||||
newmtl tank
|
||||
Ns 225.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 0.800000 0.800000 0.800000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.450000
|
||||
d 1.000000
|
||||
illum 2
|
7585
models/power_generators_emergency_generator.obj
Normal file
33
power_supply.lua
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
-- register power supply to power generators
|
||||
|
||||
local power_supply = {
|
||||
is_powered = function (self, power_data, pos, meta)
|
||||
local eu_input = meta:get_int("generator_input");
|
||||
if (eu_input>=power_data.demand) then
|
||||
return power_data.run_speed;
|
||||
end
|
||||
return 0;
|
||||
end,
|
||||
power_need = function (self, power_data, pos, meta)
|
||||
meta:set_int("generator_demand", power_data.demand)
|
||||
end,
|
||||
power_idle = function (self, power_data, pos, meta)
|
||||
meta:set_int("generator_demand", 0)
|
||||
end,
|
||||
update_node_def = function(self, power_data, node_def)
|
||||
node_def.groups.generator_powered = 1;
|
||||
node_def._generator_connect_sides = self.power_connect_sides;
|
||||
end,
|
||||
}
|
||||
appliances.add_power_supply("power_generators_power", power_supply)
|
||||
|
||||
function power_generators.need_power(pos, gen_pos)
|
||||
local node = minetest.get_node(pos);
|
||||
if (minetest.get_item_group(node.name, "generator_powered")>0) then
|
||||
|
||||
end
|
||||
return 0;
|
||||
end
|
||||
|
||||
|
BIN
sounds/power_generators_emergency_generator_running.ogg
Normal file
BIN
sounds/power_generators_emergency_generator_shutdown.ogg
Normal file
BIN
sounds/power_generators_emergency_generator_startup.ogg
Normal file
BIN
textures/power_generators_combustion_engine_alternator.png
Normal file
After Width: | Height: | Size: 243 B |
BIN
textures/power_generators_combustion_engine_body_2.png
Normal file
After Width: | Height: | Size: 189 B |
BIN
textures/power_generators_combustion_engine_body_4.png
Normal file
After Width: | Height: | Size: 184 B |
BIN
textures/power_generators_combustion_engine_body_6.png
Normal file
After Width: | Height: | Size: 219 B |
BIN
textures/power_generators_combustion_engine_crankshaft.png
Normal file
After Width: | Height: | Size: 219 B |
BIN
textures/power_generators_combustion_engine_cylinder.png
Normal file
After Width: | Height: | Size: 468 B |
BIN
textures/power_generators_combustion_engine_fuel_tank.png
Normal file
After Width: | Height: | Size: 155 B |
BIN
textures/power_generators_combustion_engine_gearbox.png
Normal file
After Width: | Height: | Size: 170 B |
BIN
textures/power_generators_combustion_engine_piston.png
Normal file
After Width: | Height: | Size: 372 B |
BIN
textures/power_generators_combustion_engine_spark.png
Normal file
After Width: | Height: | Size: 201 B |
BIN
textures/power_generators_combustion_engine_two_cylinders.png
Normal file
After Width: | Height: | Size: 164 B |
BIN
textures/power_generators_emergency_generator_back_body.png
Normal file
After Width: | Height: | Size: 594 B |
BIN
textures/power_generators_emergency_generator_cable.png
Normal file
After Width: | Height: | Size: 564 B |
BIN
textures/power_generators_emergency_generator_frame_lid_hose.png
Normal file
After Width: | Height: | Size: 152 B |
After Width: | Height: | Size: 124 B |
BIN
textures/power_generators_emergency_generator_moving_parts.png
Normal file
After Width: | Height: | Size: 547 B |
After Width: | Height: | Size: 606 B |
BIN
textures/power_generators_emergency_generator_tank.png
Normal file
After Width: | Height: | Size: 564 B |