diff --git a/Licence.txt b/Licence.txt new file mode 100755 index 0000000..ae91875 --- /dev/null +++ b/Licence.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) 2016 TenPlus1 +Copyright (c) 2020 APercy + +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. + diff --git a/README.md b/README.md index 7e1394f..6ad299d 100644 --- a/README.md +++ b/README.md @@ -1 +1,15 @@ -# minetest_biofuel \ No newline at end of file +# minetest_biofuel + +Minetest 5.2 mod: Biofuel Distiller Kit +======================================== +by APercy + +License of source code: +----------------------- +Based on original Wine mod for Minetest by TenPlus1 + +License of media (textures, 3d models): +--------------------------------------- + +Distiller model and textures (including biofuel barrel icon) by APercy. See License file + diff --git a/depends.txt b/depends.txt new file mode 100755 index 0000000..25efa31 --- /dev/null +++ b/depends.txt @@ -0,0 +1,3 @@ +player_api +default? +creative? diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..0dafe00 --- /dev/null +++ b/init.lua @@ -0,0 +1,199 @@ +---------- +--biofuel +---------- + +local modname = "biofuel" + +if minetest.get_modpath("default") then + --[[minetest.register_craft({ + output = modname .. ":biofuel", + recipe = { + {"", "farming:wheat"}, + {"farming:wheat", "farming:wheat"}, + } + })]]-- + minetest.register_craft({ + output = modname .. ":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 + + +-- biofuel +minetest.register_craftitem(modname .. ":biofuel",{ + description = "Bio Fuel", + inventory_image = "biofuel_inv.png", +}) + +local ferment = { + {"default:papyrus", modname .. ":biofuel"}, + {"farming:wheat", modname .. ":biofuel"}, + {"farming:corn", modname .. ":biofuel"}, + {"farming:baked_potato", modname .. ":biofuel"} +} + +-- distiller +biofueldistiller_formspec = "size[8,9]" + .. "list[current_name;src;2,1;1,1;]" + .. "list[current_name;dst;5,1;1,1;]" + .. "list[current_player;main;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( modname .. ":biofuel_distiller", { + description = "Biofuel Distiller", + tiles = {"metal.png", "aluminum.png", "copper.png" }, + drawtype = "mesh", + mesh = "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 + + for n = 1, #ferment do + + if inv:contains_item("src", ItemStack(ferment[n][1])) then + + has_item = n + + break + end + end + + if not has_item then + return false + end + + -- is there room for additional fermentation? + if not inv:room_for_item("dst", ferment[has_item][2]) 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 + inv:remove_item("src", ferment[has_item][1]) + inv:add_item("dst", ferment[has_item][2]) + + 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, +}) diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..2a979c5 --- /dev/null +++ b/mod.conf @@ -0,0 +1,5 @@ +name = biofuel +depends = player_api +optional_depends = default, creative +description = It adds a distiller and biofuel, for running biofuel powered machines +title = Biofuel Distiller Kit diff --git a/models/biofuel_distiller.b3d b/models/biofuel_distiller.b3d new file mode 100644 index 0000000..f6d37aa Binary files /dev/null and b/models/biofuel_distiller.b3d differ diff --git a/models/pointer.b3d b/models/pointer.b3d new file mode 100644 index 0000000..c692261 Binary files /dev/null and b/models/pointer.b3d differ diff --git a/models/src/aluminum.png b/models/src/aluminum.png new file mode 100755 index 0000000..5b4e746 Binary files /dev/null and b/models/src/aluminum.png differ diff --git a/models/src/biofuel_inv.png b/models/src/biofuel_inv.png new file mode 100644 index 0000000..5b6257c Binary files /dev/null and b/models/src/biofuel_inv.png differ diff --git a/models/src/black.png b/models/src/black.png new file mode 100755 index 0000000..2e00bdf Binary files /dev/null and b/models/src/black.png differ diff --git a/models/src/copper.png b/models/src/copper.png new file mode 100755 index 0000000..f90530f Binary files /dev/null and b/models/src/copper.png differ diff --git a/models/src/distiller.blend b/models/src/distiller.blend new file mode 100644 index 0000000..95cc041 Binary files /dev/null and b/models/src/distiller.blend differ diff --git a/models/src/distiller.blend1 b/models/src/distiller.blend1 new file mode 100644 index 0000000..871f465 Binary files /dev/null and b/models/src/distiller.blend1 differ diff --git a/models/src/interior_black.png b/models/src/interior_black.png new file mode 100755 index 0000000..5d3d38c Binary files /dev/null and b/models/src/interior_black.png differ diff --git a/models/src/metal.png b/models/src/metal.png new file mode 100755 index 0000000..a779fe9 Binary files /dev/null and b/models/src/metal.png differ diff --git a/models/src/panel.png b/models/src/panel.png new file mode 100755 index 0000000..076bba7 Binary files /dev/null and b/models/src/panel.png differ diff --git a/models/src/panel.xcf b/models/src/panel.xcf new file mode 100644 index 0000000..f7ea7ae Binary files /dev/null and b/models/src/panel.xcf differ diff --git a/models/src/pointer.blend b/models/src/pointer.blend new file mode 100644 index 0000000..97b541c Binary files /dev/null and b/models/src/pointer.blend differ diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..23c1b9c Binary files /dev/null and b/screenshot.png differ diff --git a/sounds/helicopter_motor.ogg b/sounds/helicopter_motor.ogg new file mode 100644 index 0000000..298a397 Binary files /dev/null and b/sounds/helicopter_motor.ogg differ diff --git a/textures/aluminum.png b/textures/aluminum.png new file mode 100755 index 0000000..5b4e746 Binary files /dev/null and b/textures/aluminum.png differ diff --git a/textures/biofuel_inv.png b/textures/biofuel_inv.png new file mode 100644 index 0000000..5b6257c Binary files /dev/null and b/textures/biofuel_inv.png differ diff --git a/textures/black.png b/textures/black.png new file mode 100755 index 0000000..2e00bdf Binary files /dev/null and b/textures/black.png differ diff --git a/textures/copper.png b/textures/copper.png new file mode 100755 index 0000000..f90530f Binary files /dev/null and b/textures/copper.png differ diff --git a/textures/interior_black.png b/textures/interior_black.png new file mode 100755 index 0000000..5d3d38c Binary files /dev/null and b/textures/interior_black.png differ diff --git a/textures/metal.png b/textures/metal.png new file mode 100755 index 0000000..a779fe9 Binary files /dev/null and b/textures/metal.png differ diff --git a/textures/panel.png b/textures/panel.png new file mode 100755 index 0000000..076bba7 Binary files /dev/null and b/textures/panel.png differ