Skip to content

Commit

Permalink
Merge pull request #17 from DustyBagel/Experimental
Browse files Browse the repository at this point in the history
Fix for issue #7.
  • Loading branch information
DustyDave961 authored Dec 10, 2023
2 parents fb5e670 + e16ff74 commit a640782
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 59 deletions.
8 changes: 7 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
A collaboration project with Bob64, also known as DustyBagel, to help Technic and Elepower work together. Recipes were added for Technic machines to make some items from Elepower, and for Elepower machines to make some items from Technic. A new electric converter connects Technic and Elepower grids together when enabled. All content contained within is licensed under the GNU Lesser General Public License version 2.1.
A collaboration project with Bob64, also known as DustyBagel, to help Technic and Elepower work together. Recipes were added for Technic machines to make some items from Elepower, and for Elepower machines to make some items from Technic. A new electric converter connects Technic and Elepower grids together when enabled.

IMPORTANT INFORMATION

Please note that the power converter developed by Bob64 is not fully complete. Bugs are still possible, so please report any issues on GitHub. There are also some duplication glitches from having Elepower and Technic modpacks together. There are plans to fix these if it is possible to do so.

Copyright Information

All content contained within is licensed under the GNU Lesser General Public License version 2.1. If you have questions about the copyright of this mod, you can get into contack with us at [email protected].

Copyright (C) 2023 DumbDave961 and Bob64 aka DustyBagel [email protected]
4 changes: 2 additions & 2 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ dofile(modpath .. "/alloy_compat.lua")
dofile(modpath .. "/craft_compat.lua")
dofile(modpath .. "/compress_compat.lua")
dofile(modpath .. "/manual.lua")
dofile(modpath .. "/ore_overrides.lua")

if minetest.settings:get_bool("enable_power_converter") then
dofile(modpath .. "/power_converter.lua")
end

if minetest.settings:get_bool("enable_on_join_player_message") then
minetest.register_on_joinplayer(function(player)
minetest.register_on_newplayer(function(player)
minetest.chat_send_player(player:get_player_name(), "[Technic Elepower Compat] If you would like to test the beta power converter node, then go to settings, search 'technic_elepower_compat', and enable the converter.")
minetest.log("action", player:get_player_name() .. " joined the game")
end)
end
48 changes: 48 additions & 0 deletions ore_overrides.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--Ore overrides to clear unneeded ores.
local lead_to_use = minetest.settings:get("lead_used") or "both"

if lead_to_use == "technic" then
minetest.register_abm({
nodenames = {"elepower_dynamics:stone_with_lead"}, -- replace with the name of the ore
interval = 1, -- runs every 1 second
chance = 1, -- always fires
action = function(pos)
minetest.swap_node(pos, {name = "default:stone"})
end,
})
elseif lead_to_use == "elepower" then
minetest.register_abm({
nodenames = {"technic:mineral_lead"}, -- replace with the name of the ore
interval = 1, -- runs every 1 second
chance = 1, -- always fires
action = function(pos)
minetest.swap_node(pos, {name = "default:stone"})
end,
})
elseif lead_to_use == "both" then
return false
end

local zinc_to_use = minetest.settings:get("zinc_used") or "both"

if zinc_to_use == "technic" then
minetest.register_abm({
nodenames = {"elepower_dynamics:stone_with_zinc"}, -- replace with the name of the ore
interval = 1, -- runs every 1 second
chance = 1, -- always fires
action = function(pos)
minetest.swap_node(pos, {name = "default:stone"})
end,
})
elseif zinc_to_use == "elepower" then
minetest.register_abm({
nodenames = {"technic:mineral_zinc"}, -- replace with the name of the ore
interval = 1, -- runs every 1 second
chance = 1, -- always fires
action = function(pos)
minetest.swap_node(pos, {name = "default:stone"})
end,
})
elseif zinc_to_use == "both" then
return false
end
81 changes: 25 additions & 56 deletions overrides.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ minetest.clear_craft({
output = "elepower_dynamics:wound_silver_coil",
})

--Override fucntion to clear the recipes for technic machines
--[[Override fucntion to clear the recipes for technic machines
(It may only work for the first recipe with that input naem that
it finds so we may need ot add a better function that removes all the inputs instead.)]]
function clear_technic_recipe(recipe_type, recipe_input_name)
minetest.after(0.1, function() --This has to be called with a delay for the table to load in.
technic.recipes[recipe_type]["recipes"][recipe_input_name] = nil
Expand Down Expand Up @@ -141,23 +143,39 @@ Example:
This will clear the alloy recipe with the inputs of technic:coal_dust and technic:raw_latex
]]

--[[New function that does what the abouve one does but for all inputs in the
given table name and not just the first one it finds.]]

--TO DO:This function needs to be tested.
function clear_technic_recipe_all_inputs(recipe_type, recipe_input_name)
minetest.after(0.1, function()
local recipe_table = technic.recipes[recipe_type]["recipes"]
for key, recipe in pairs(recipe_table) do
if recipe.input == recipe_input_name then
recipe_table[key] = nil
end
end
end)
end

--Ovverrides elpower machine recipes
function clear_elepower_recipe(craft_type, output_to_remove)
minetest.after(0.5, function()
minetest.after(0.5, function() --TO DO:Find out if this function will still work if we set it to run at 0.1 instead of 0.5 to prevent unwanted recipes from being used when a player first joins a world.
local craft_table = elepm.craft[craft_type]
local output_to_remove_itemstack = ItemStack(output_to_remove)
for i = 1, #craft_table do
for i = #craft_table, 1, -1 do
-- Check if the output of the recipe at index i matches with output_to_remove
if craft_table[i].output == output_to_remove_itemstack then
local output_itemstack = ItemStack(craft_table[i].output)
if output_itemstack:get_name() == output_to_remove_itemstack:get_name() and output_itemstack:get_count() == output_to_remove_itemstack:get_count() then
-- Remove the recipe from the table
table.remove(craft_table, i)
-- Since we've modified the table, break the loop to avoid skipping the next element
break
end
end
end)
end



--[[
This function accepts two parameters, the recipe type and the output of the recipe you want to clear.
Recipe types:
Expand All @@ -173,53 +191,4 @@ Example:
This example function goes into the table compress and gets the first thing in the table with an index number of 1 and checks if it has
the specified output if it does it removes the item with that index number. If not then it goes to the next item in the list and checks again.
This function doesn't clear recipes with multiple outputs because it only tests for one input.
]]

--Ore overrides to clear unneeded ores.
local lead_to_use = minetest.settings:get("lead_used")

if lead_to_use == "technic" then
minetest.register_abm({
nodenames = {"elepower_dynamics:stone_with_lead"}, -- replace with the name of the ore
interval = 1, -- runs every 1 second
chance = 1, -- always fires
action = function(pos)
minetest.swap_node(pos, {name = "default:stone"})
end,
})
elseif lead_to_use == "elepower" then
minetest.register_abm({
nodenames = {"technic:mineral_lead"}, -- replace with the name of the ore
interval = 1, -- runs every 1 second
chance = 1, -- always fires
action = function(pos)
minetest.swap_node(pos, {name = "default:stone"})
end,
})
elseif lead_to_use == "both" then
return false
end

local zinc_to_use = minetest.settings:get("zinc_used")

if zinc_to_use == "technic" then
minetest.register_abm({
nodenames = {"elepower_dynamics:stone_with_zinc"}, -- replace with the name of the ore
interval = 1, -- runs every 1 second
chance = 1, -- always fires
action = function(pos)
minetest.swap_node(pos, {name = "default:stone"})
end,
})
elseif zinc_to_use == "elepower" then
minetest.register_abm({
nodenames = {"technic:mineral_zinc"}, -- replace with the name of the ore
interval = 1, -- runs every 1 second
chance = 1, -- always fires
action = function(pos)
minetest.swap_node(pos, {name = "default:stone"})
end,
})
elseif zinc_to_use == "both" then
return false
end
]]

0 comments on commit a640782

Please sign in to comment.