diff options
author | root <root@mirzakhani.gpcf.eu> | 2018-05-31 17:32:07 +0200 |
---|---|---|
committer | root <root@mirzakhani.gpcf.eu> | 2018-05-31 17:32:07 +0200 |
commit | 320573cba5e549b14d081893d9ee02474d740f65 (patch) | |
tree | 3c81722b991259c1bada63e2fdca68fbcde543c8 | |
parent | 98382c0815d2e48485a49498f487f165cd721287 (diff) | |
parent | c84ceedf1eb50e5e189ac42270b9c144f21eff7e (diff) |
Merge https://github.com/h-v-smacker/technic
-rw-r--r-- | technic/machines/other/init.lua | 5 | ||||
-rw-r--r-- | technic/machines/other/water_powered_grinder.lua | 198 | ||||
-rw-r--r-- | technic/machines/register/compressor_recipes.lua | 8 | ||||
-rw-r--r-- | technic/machines/register/grindings.lua | 3 | ||||
-rw-r--r-- | technic/textures/technic_water_powered_grinder_front.png | bin | 0 -> 417 bytes | |||
-rw-r--r-- | technic/textures/technic_water_powered_grinder_front_active.png | bin | 0 -> 432 bytes | |||
-rw-r--r-- | technic/textures/technic_water_powered_grinder_front_unpowered.png | bin | 0 -> 382 bytes | |||
-rw-r--r-- | technic/textures/technic_water_powered_grinder_side.png | bin | 0 -> 336 bytes | |||
-rw-r--r-- | technic/textures/technic_water_powered_grinder_top.png | bin | 0 -> 208 bytes |
9 files changed, 212 insertions, 2 deletions
diff --git a/technic/machines/other/init.lua b/technic/machines/other/init.lua index f4a82f0..a67d1a1 100644 --- a/technic/machines/other/init.lua +++ b/technic/machines/other/init.lua @@ -8,6 +8,11 @@ if technic.config:get_bool("enable_frames") and minetest.get_modpath("mesecons_m dofile(path.."/frames.lua") end +if minetest.get_modpath("mesecons_hydroturbine") then + dofile(path.."/water_powered_grinder.lua") +end + + -- Coal-powered machines dofile(path.."/coal_alloy_furnace.lua") dofile(path.."/coal_furnace.lua") diff --git a/technic/machines/other/water_powered_grinder.lua b/technic/machines/other/water_powered_grinder.lua new file mode 100644 index 0000000..c5177cd --- /dev/null +++ b/technic/machines/other/water_powered_grinder.lua @@ -0,0 +1,198 @@ + +-- Water-powered grinder. Uses the hydro turbine from mesecons to "power" itself. +-- Can be used along the fuel-powered alloying furnace to get some minimal benefits +-- of the technic mod. Also adds a purpose for mesecon hydroturbine which, despite +-- being beautifully animated, doesn't do much practical in game. + + +local S = technic.getter + +minetest.register_craft({ + output = 'technic:water_powered_grinder', + recipe = { + {'technic:granite', 'technic:granite', 'technic:granite'}, + {'technic:granite', 'technic:wrought_iron_ingot', 'technic:granite'}, + {'default:brick', 'technic:wrought_iron_ingot', 'default:brick'}, + } +}) + +local machine_name = S("Water-powered Grinder") +local formspec = + "size[8,9]".. + "label[0,0;"..machine_name.."]".. + "image[2,2;1,1;technic_power_meter_bg.png]".. + "list[current_name;src;2,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]".. + "listring[current_name;dst]".. + "listring[current_player;main]".. + "listring[current_name;src]".. + "listring[current_player;main]" + +minetest.register_node("technic:water_powered_grinder", { + description = machine_name, + tiles = {"technic_water_powered_grinder_top.png", "technic_water_powered_grinder_side.png", + "technic_water_powered_grinder_side.png", "technic_water_powered_grinder_side.png", + "technic_water_powered_grinder_side.png", "technic_water_powered_grinder_front.png"}, + paramtype2 = "facedir", + groups = {cracky=2}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", formspec) + meta:set_string("infotext", machine_name) + local inv = meta:get_inventory() + inv:set_size("src", 1) + inv:set_size("dst", 4) + end, + can_dig = technic.machine_can_dig, + allow_metadata_inventory_put = technic.machine_inventory_put, + allow_metadata_inventory_take = technic.machine_inventory_take, + allow_metadata_inventory_move = technic.machine_inventory_move, +}) + +minetest.register_node("technic:water_powered_grinder_unpowered", { + description = machine_name, + tiles = {"technic_water_powered_grinder_top.png", "technic_water_powered_grinder_side.png", + "technic_water_powered_grinder_side.png", "technic_water_powered_grinder_side.png", + "technic_water_powered_grinder_side.png", "technic_water_powered_grinder_front_unpowered.png"}, + paramtype2 = "facedir", + drop = "technic:water_powered_grinder", + groups = {cracky=2, not_in_creative_inventory=1}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + can_dig = technic.machine_can_dig, + allow_metadata_inventory_put = technic.machine_inventory_put, + allow_metadata_inventory_take = technic.machine_inventory_take, + allow_metadata_inventory_move = technic.machine_inventory_move, +}) + +minetest.register_node("technic:water_powered_grinder_active", { + description = machine_name, + tiles = {"technic_water_powered_grinder_top.png", "technic_water_powered_grinder_side.png", + "technic_water_powered_grinder_side.png", "technic_water_powered_grinder_side.png", + "technic_water_powered_grinder_side.png", "technic_water_powered_grinder_front_active.png"}, + paramtype2 = "facedir", + light_source = 8, + drop = "technic:water_powered_grinder", + groups = {cracky=2, not_in_creative_inventory=1}, + legacy_facedir_simple = true, + sounds = default.node_sound_stone_defaults(), + can_dig = technic.machine_can_dig, + allow_metadata_inventory_put = technic.machine_inventory_put, + allow_metadata_inventory_take = technic.machine_inventory_take, + allow_metadata_inventory_move = technic.machine_inventory_move, +}) + +minetest.register_abm({ + label = "Machines: run water-powered grinder", + nodenames = {"technic:water_powered_grinder", "technic:water_powered_grinder_active", "technic:water_powered_grinder_unpowered"}, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + + local recipe = nil + + if not meta:get_int("processing") then + meta:set_int("processing", 0) + end + + local result = technic.get_recipe("grinding", inv:get_list("src")) + + local power_pos = { + {x = -1, y = 0, z = 0}, + {x = 1, y = 0, z = 0}, + {x = 0, y = -1, z = 0}, + {x = 0, y = 1, z = 0}, + {x = 0, y = 0, z = -1}, + {x = 0, y = 0, z = 1} + } + local powered = false + for _,pp in ipairs(power_pos) do + local node = minetest.get_node_or_nil({x = pos.x + pp.x, y = pos.y + pp.y, z = pos.z + pp.z}) + if node and node.name == "mesecons_hydroturbine:hydro_turbine_on" then + powered = true + break + end + end + + if powered then + + if result then + + if meta:get_int("processing") == 5 then + + local percent = 100 + meta:set_string("infotext", S("%s is active"):format(machine_name).." ("..percent.."%)") + meta:set_string("formspec", + "size[8,9]".. + "label[0,0;"..machine_name.."]".. + "image[2,2;1,1;technic_power_meter_bg.png^[lowpart:" .. percent .. ":technic_power_meter_fg.png]".. + "list[current_name;src;2,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]".. + "listring[current_name;dst]".. + "listring[current_player;main]".. + "listring[current_name;src]".. + "listring[current_player;main]") + + local result_stack = ItemStack(result.output) + if inv:room_for_item("dst", result_stack) then + inv:set_list("src", result.new_input) + inv:add_item("dst", result_stack) + end + + meta:set_int("processing", 0) + + local recipe = technic.get_recipe("grinding", inv:get_list("src")) + + if not recipe then + meta:set_string("infotext", S("%s is empty"):format(machine_name)) + technic.swap_node(pos, "technic:water_powered_grinder") + meta:set_string("formspec", formspec) + end + + else + + local percent = math.floor(meta:get_int("processing") / 5 * 100) + meta:set_string("infotext", S("%s is active"):format(machine_name).." ("..percent.."%)") + technic.swap_node(pos, "technic:water_powered_grinder_active") + meta:set_string("formspec", + "size[8,9]".. + "label[0,0;"..machine_name.."]".. + "image[2,2;1,1;technic_power_meter_bg.png^[lowpart:" .. percent .. ":technic_power_meter_fg.png]".. + "list[current_name;src;2,1;1,1;]".. + "list[current_name;dst;5,1;2,2;]".. + "list[current_player;main;0,5;8,4;]".. + "listring[current_name;dst]".. + "listring[current_player;main]".. + "listring[current_name;src]".. + "listring[current_player;main]") + return + + meta:set_int("processing", meta:get_int("processing") + 1) + end + else + meta:set_int("processing", 0) + + meta:set_string("infotext", S("%s is empty"):format(machine_name)) + technic.swap_node(pos, "technic:water_powered_grinder") + meta:set_string("formspec", formspec) + end + + else + + meta:set_int("processing", 0) + + meta:set_string("infotext", S("%s is unpowered"):format(machine_name)) + technic.swap_node(pos, "technic:water_powered_grinder_unpowered") + meta:set_string("formspec", formspec) + end + + + end, +}) + diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index b36936c..021c393 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -45,9 +45,15 @@ if minetest.get_modpath("ethereal") then if minetest.get_modpath("technic_worldgen") or minetest.get_modpath("moretrees") then table.insert(recipes, {"moretrees:rubber_tree_leaves 15", "ethereal:charcoal_lump 1"}) end - + end +if minetest.get_modpath("pathv7") then + table.insert(recipes, {"default:acacia_wood", "pathv7:bridgewood 1"}) + table.insert(recipes, {"default:junglewood", "pathv7:junglewood 1"}) +end + + -- liquid oxygen table.insert(recipes, {"vessels:steel_bottle", "technic:lox"}) diff --git a/technic/machines/register/grindings.lua b/technic/machines/register/grindings.lua index 9231166..018eed9 100644 --- a/technic/machines/register/grindings.lua +++ b/technic/machines/register/grindings.lua @@ -49,7 +49,8 @@ local default_extract = dye and "dye:brown 2" local grinding_recipes = { {"Common Tree", "group:tree", "group:wood", default_extract }, - {"Rubber Tree", "moretrees:rubber_tree_trunk", rubber_tree_planks, "technic:raw_latex"} + {"Rubber Tree", "moretrees:rubber_tree_trunk", rubber_tree_planks, "technic:raw_latex"}, + {"Rubber Tree", "moretrees:rubber_tree_trunk_empty",rubber_tree_planks, "technic:raw_latex"} } for _, data in pairs(grinding_recipes) do diff --git a/technic/textures/technic_water_powered_grinder_front.png b/technic/textures/technic_water_powered_grinder_front.png Binary files differnew file mode 100644 index 0000000..b5ec2c6 --- /dev/null +++ b/technic/textures/technic_water_powered_grinder_front.png diff --git a/technic/textures/technic_water_powered_grinder_front_active.png b/technic/textures/technic_water_powered_grinder_front_active.png Binary files differnew file mode 100644 index 0000000..6720cf8 --- /dev/null +++ b/technic/textures/technic_water_powered_grinder_front_active.png diff --git a/technic/textures/technic_water_powered_grinder_front_unpowered.png b/technic/textures/technic_water_powered_grinder_front_unpowered.png Binary files differnew file mode 100644 index 0000000..70e14c7 --- /dev/null +++ b/technic/textures/technic_water_powered_grinder_front_unpowered.png diff --git a/technic/textures/technic_water_powered_grinder_side.png b/technic/textures/technic_water_powered_grinder_side.png Binary files differnew file mode 100644 index 0000000..fafaf36 --- /dev/null +++ b/technic/textures/technic_water_powered_grinder_side.png diff --git a/technic/textures/technic_water_powered_grinder_top.png b/technic/textures/technic_water_powered_grinder_top.png Binary files differnew file mode 100644 index 0000000..df5a007 --- /dev/null +++ b/technic/textures/technic_water_powered_grinder_top.png |