mirror of
https://github.com/APercy/airutils.git
synced 2025-03-15 00:01:20 +00:00
added biofuel inside airutils
This commit is contained in:
parent
4475e4210b
commit
00a4358a82
8 changed files with 285 additions and 23 deletions
257
airutils_biofuel.lua
Normal file
257
airutils_biofuel.lua
Normal file
|
@ -0,0 +1,257 @@
|
|||
----------
|
||||
--biofuel
|
||||
----------
|
||||
|
||||
local module_name = "airutils"
|
||||
|
||||
if minetest.get_modpath("technic") then
|
||||
if technic then
|
||||
technic.register_extractor_recipe({input = {"farming:wheat 33"}, output = "biofuel:biofuel 1"})
|
||||
technic.register_extractor_recipe({input = {"farming:corn 33"}, output = "biofuel:biofuel 1"})
|
||||
technic.register_extractor_recipe({input = {"farming:potato 33"}, output = "biofuel:biofuel 1"})
|
||||
technic.register_extractor_recipe({input = {"default:papyrus 99"}, output = "biofuel:biofuel 1"})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if minetest.get_modpath("basic_machines") then
|
||||
if basic_machines then
|
||||
basic_machines.grinder_recipes["farming:wheat"] = {50,"biofuel:biofuel",1}
|
||||
basic_machines.grinder_recipes["farming:corn"] = {50,"biofuel:biofuel",1}
|
||||
basic_machines.grinder_recipes["farming:potato"] = {50,"biofuel:biofuel",1}
|
||||
basic_machines.grinder_recipes["default:papyrus"] = {70,"biofuel:biofuel",1}
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.register_craft({
|
||||
output = module_name .. ":biofuel_distiller",
|
||||
recipe = {
|
||||
{"default:copper_ingot", "default:copper_ingot", "default:copper_ingot"},
|
||||
{"default:steel_ingot" , "", "default:steel_ingot"},
|
||||
{"default:steel_ingot" , "default:steel_ingot", "default:steel_ingot"},
|
||||
},
|
||||
})
|
||||
end
|
||||
if minetest.get_modpath("mcl_core") then
|
||||
minetest.register_craft({
|
||||
output = module_name .. ":biofuel_distiller",
|
||||
recipe = {
|
||||
{"mcl_copper:copper_ingot", "mcl_copper:copper_ingot", "mcl_copper:copper_ingot"},
|
||||
{"mcl_core:iron_ingot" , "", "mcl_core:iron_ingot"},
|
||||
{"mcl_core:iron_ingot" , "mcl_core:iron_ingot", "mcl_core:iron_ingot"},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
-- biofuel
|
||||
minetest.register_craftitem(":biofuel:biofuel",{
|
||||
description = "Bio Fuel",
|
||||
inventory_image = "biofuel_inv.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "biofuel:biofuel",
|
||||
burntime = 50,
|
||||
})
|
||||
|
||||
local ferment = {
|
||||
{"default:papyrus", "biofuel:biofuel"},
|
||||
{"farming:wheat", "biofuel:biofuel"},
|
||||
{"farming:corn", "biofuel:biofuel"},
|
||||
{"farming:baked_potato", "biofuel:biofuel"},
|
||||
{"farming:potato", "biofuel:biofuel"}
|
||||
}
|
||||
|
||||
local ferment_groups = {'flora', 'leaves', 'flower', 'sapling', 'tree', 'wood', 'stick', 'plant', 'seed',
|
||||
'leafdecay', 'leafdecay_drop', 'mushroom', 'vines' }
|
||||
|
||||
-- distiller
|
||||
local biofueldistiller_formspec = "size[8,9]"
|
||||
.. "list[current_name;src;2,1;1,1;]" .. airutils.get_itemslot_bg(2, 1, 1, 1)
|
||||
.. "list[current_name;dst;5,1;1,1;]" .. airutils.get_itemslot_bg(5, 1, 1, 1)
|
||||
.. "list[current_player;main;0,5;8,4;]" .. airutils.get_itemslot_bg(0, 5, 8, 4)
|
||||
.. "listring[current_name;dst]"
|
||||
.. "listring[current_player;main]"
|
||||
.. "listring[current_name;src]"
|
||||
.. "listring[current_player;main]"
|
||||
.. "image[3.5,1;1,1;gui_furnace_arrow_bg.png^[transformR270]"
|
||||
|
||||
minetest.register_node( module_name .. ":biofuel_distiller", {
|
||||
description = "Biofuel Distiller",
|
||||
tiles = {"airutils_metal.png", "airutils_aluminum.png", "airutils_copper.png" },
|
||||
drawtype = "mesh",
|
||||
mesh = "airutils_biofuel_distiller.b3d",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {
|
||||
choppy = 2, oddly_breakable_by_hand = 1, flammable = 2
|
||||
},
|
||||
legacy_facedir_simple = true,
|
||||
|
||||
on_place = minetest.rotate_node,
|
||||
|
||||
on_construct = function(pos)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
meta:set_string("formspec", biofueldistiller_formspec)
|
||||
meta:set_string("infotext", "Biofuel Distiller")
|
||||
meta:set_float("status", 0.0)
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 1)
|
||||
end,
|
||||
|
||||
can_dig = function(pos,player)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
if not inv:is_empty("dst")
|
||||
or not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
|
||||
return stack:get_count()
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
if listname == "src" then
|
||||
return stack:get_count()
|
||||
elseif listname == "dst" then
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = inv:get_stack(from_list, from_index)
|
||||
|
||||
if to_list == "src" then
|
||||
return count
|
||||
elseif to_list == "dst" then
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
|
||||
on_metadata_inventory_put = function(pos)
|
||||
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
|
||||
timer:start(5)
|
||||
end,
|
||||
|
||||
on_timer = function(pos)
|
||||
|
||||
local meta = minetest.get_meta(pos) ; if not meta then return end
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
-- is barrel empty?
|
||||
if not inv or inv:is_empty("src") then
|
||||
|
||||
meta:set_float("status", 0.0)
|
||||
meta:set_string("infotext", "Fuel Distiller")
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-- does it contain any of the source items on the list?
|
||||
local has_item
|
||||
|
||||
--normal items
|
||||
for n = 1, #ferment do
|
||||
if inv:contains_item("src", ItemStack(ferment[n][1])) then
|
||||
has_item = n
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
--groups
|
||||
local has_group
|
||||
if not has_item then
|
||||
local inv_content = inv:get_list("src")
|
||||
if inv_content then
|
||||
for k, v in pairs(inv_content) do
|
||||
local item_name = v:get_name()
|
||||
for n = 1, #ferment_groups do
|
||||
if minetest.get_item_group(item_name, ferment_groups[n]) == 1 then
|
||||
has_group = n
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not has_item and not has_group then
|
||||
return false
|
||||
end
|
||||
|
||||
-- is there room for additional fermentation?
|
||||
if has_item and not inv:room_for_item("dst", ferment[has_item][2]) then
|
||||
meta:set_string("infotext", "Fuel Distiller (FULL)")
|
||||
return true
|
||||
end
|
||||
|
||||
if has_group and not inv:room_for_item("dst", "biofuel:biofuel") then
|
||||
meta:set_string("infotext", "Fuel Distiller (FULL)")
|
||||
return true
|
||||
end
|
||||
|
||||
local status = meta:get_float("status")
|
||||
|
||||
-- fermenting (change status)
|
||||
if status < 100 then
|
||||
meta:set_string("infotext", "Fuel Distiller " .. status .. "% done")
|
||||
meta:set_float("status", status + 5)
|
||||
else
|
||||
if not has_group then
|
||||
inv:remove_item("src", ferment[has_item][1])
|
||||
inv:add_item("dst", ferment[has_item][2])
|
||||
else
|
||||
for i,itemstack in pairs(inv:get_list("src")) do
|
||||
inv:remove_item("src", ItemStack(itemstack:get_name().." 1"))
|
||||
end
|
||||
inv:add_item("dst", "biofuel:biofuel")
|
||||
end
|
||||
|
||||
meta:set_float("status", 0,0)
|
||||
end
|
||||
|
||||
if inv:is_empty("src") then
|
||||
meta:set_float("status", 0.0)
|
||||
meta:set_string("infotext", "Fuel Distiller")
|
||||
end
|
||||
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
5
init.lua
5
init.lua
|
@ -35,6 +35,7 @@ end
|
|||
if not minetest.settings:get_bool('airutils.disable_repair') then
|
||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_repair.lua")
|
||||
end
|
||||
|
||||
airutils.get_wind = dofile(minetest.get_modpath("airutils") .. DIR_DELIM ..'/wind.lua')
|
||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "common_entities.lua")
|
||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_wind.lua")
|
||||
|
@ -43,6 +44,10 @@ dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "light.lua")
|
|||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "physics_lib.lua")
|
||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "lib_planes" .. DIR_DELIM .. "init.lua")
|
||||
|
||||
if not minetest.settings:get_bool('airutils.disable_biofuel') then
|
||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_biofuel.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath("player_api") and not minetest.settings:get_bool('airutils.disable_uniforms') then
|
||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "pilot_skin_manager.lua")
|
||||
end
|
||||
|
|
|
@ -2,8 +2,8 @@ local storage = minetest.get_mod_storage()
|
|||
airutils.modname = minetest.get_current_modname()
|
||||
|
||||
--function to format formspec for mineclone. In case of minetest, just returns an empty string
|
||||
local function get_itemslot_bg(a, b, c, d)
|
||||
if airutils.is_mcl then
|
||||
function airutils.get_itemslot_bg(a, b, c, d)
|
||||
if mcl_formspec then
|
||||
return mcl_formspec.get_itemslot_bg(a,b,c,d)
|
||||
end
|
||||
return ""
|
||||
|
@ -19,54 +19,54 @@ local function get_formspec_by_size(self, size)
|
|||
end
|
||||
local default_inventory_formspecs = {
|
||||
["2"]="size[8,6]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;3.0,0;3,1;]" .. get_itemslot_bg(3.0, 0, 2, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"list[detached:" .. self._inv_id .. ";main;3.0,0;3,1;]" .. airutils.get_itemslot_bg(3.0, 0, 2, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["3"]="size[8,6]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;2.5,0;3,1;]" .. get_itemslot_bg(2.5, 0, 3, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"list[detached:" .. self._inv_id .. ";main;2.5,0;3,1;]" .. airutils.get_itemslot_bg(2.5, 0, 3, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["4"]="size[8,6]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;2,0;4,1;]" .. get_itemslot_bg(2.0, 0, 4, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"list[detached:" .. self._inv_id .. ";main;2,0;4,1;]" .. airutils.get_itemslot_bg(2.0, 0, 4, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["6"]="size[8,6]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;1,0;6,1;]".. get_itemslot_bg(1.0, 0, 6, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"list[detached:" .. self._inv_id .. ";main;1,0;6,1;]".. airutils.get_itemslot_bg(1.0, 0, 6, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["8"]="size[8,6]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0;8,1;]".. get_itemslot_bg(0, 0, 8, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0;8,1;]".. airutils.get_itemslot_bg(0, 0, 8, 1) ..
|
||||
"list[current_player;main;0,2;8,4;]" .. airutils.get_itemslot_bg(0, 2, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["12"]="size[8,7]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;1,0;6,2;]".. get_itemslot_bg(1, 0, 6, 2) ..
|
||||
"list[current_player;main;0,3;8,4;]" .. get_itemslot_bg(0, 3, 8, 4) ..
|
||||
"list[detached:" .. self._inv_id .. ";main;1,0;6,2;]".. airutils.get_itemslot_bg(1, 0, 6, 2) ..
|
||||
"list[current_player;main;0,3;8,4;]" .. airutils.get_itemslot_bg(0, 3, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["16"]="size[8,7]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0;8,2;]".. get_itemslot_bg(0, 0, 8, 2) ..
|
||||
"list[current_player;main;0,3;8,4;]" .. get_itemslot_bg(0, 3, 8, 4) ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0;8,2;]".. airutils.get_itemslot_bg(0, 0, 8, 2) ..
|
||||
"list[current_player;main;0,3;8,4;]" .. airutils.get_itemslot_bg(0, 3, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["24"]="size[8,8]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0;8,3;]".. get_itemslot_bg(0, 0, 8, 3) ..
|
||||
"list[current_player;main;0,4;8,4;]" .. get_itemslot_bg(0, 4, 8, 4) ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0;8,3;]".. airutils.get_itemslot_bg(0, 0, 8, 3) ..
|
||||
"list[current_player;main;0,4;8,4;]" .. airutils.get_itemslot_bg(0, 4, 8, 4) ..
|
||||
"listring[]",
|
||||
|
||||
["32"]="size[8,9]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0.3;8,4;]".. get_itemslot_bg(0, 0.3, 8, 4) ..
|
||||
"list[current_player;main;0,5;8,4;]".. get_itemslot_bg(0, 5, 8, 4) ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0.3;8,4;]".. airutils.get_itemslot_bg(0, 0.3, 8, 4) ..
|
||||
"list[current_player;main;0,5;8,4;]".. airutils.get_itemslot_bg(0, 5, 8, 4) ..
|
||||
"listring[]" ..
|
||||
hotbar,
|
||||
|
||||
["50"]="size[10,10]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0;10,5;]".. get_itemslot_bg(0, 0, 10, 5) ..
|
||||
"list[current_player;main;1,6;8,4;]" .. get_itemslot_bg(1, 6, 8, 4) ..
|
||||
"list[detached:" .. self._inv_id .. ";main;0,0;10,5;]".. airutils.get_itemslot_bg(0, 0, 10, 5) ..
|
||||
"list[current_player;main;1,6;8,4;]" .. airutils.get_itemslot_bg(1, 6, 8, 4) ..
|
||||
"listring[]",
|
||||
}
|
||||
|
||||
|
|
2
mod.conf
2
mod.conf
|
@ -2,4 +2,4 @@ name = airutils
|
|||
title=AirUtils
|
||||
description=A lib for airplanes and some useful tools
|
||||
author=apercy
|
||||
optional_depends=player_api, emote, climate_api
|
||||
optional_depends=player_api, emote, climate_api, biofuel
|
||||
|
|
BIN
models/airutils_biofuel_distiller.b3d
Normal file
BIN
models/airutils_biofuel_distiller.b3d
Normal file
Binary file not shown.
BIN
textures/airutils_aluminum.png
Executable file
BIN
textures/airutils_aluminum.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
BIN
textures/airutils_biofuel_inv.png
Normal file
BIN
textures/airutils_biofuel_inv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
BIN
textures/airutils_copper.png
Executable file
BIN
textures/airutils_copper.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
Loading…
Add table
Reference in a new issue