Automatic energy values MOSTLY work.

This commit is contained in:
ThePython 2023-11-09 18:35:23 -08:00
parent 37d30ebe65
commit 81b374223b
14 changed files with 96 additions and 125 deletions

View File

@ -32,7 +32,6 @@ value is for values that are not in any other group. ]]
light_13 = 0,
light_14 = 0,
cobble = 1,
stone = 1,
andesite = 1,
diorite = 1,
granite = 1,
@ -597,27 +596,6 @@ value is for values that are not in any other group. ]]
totem = 106496,
},
["mcl_tools"] = {
shears = 512,
shovel_stone = 9,
sword_stone = 6,
pick_stone = 11,
axe_stone = 11,
shovel_wood = 16,
sword_wood = 20,
pick_wood = 32,
axe_wood = 32,
shovel_gold = 2056,
sword_gold = 5000,
pick_gold = 6152,
axe_gold = 6152,
shovel_iron = 264,
sword_iron = 516,
pick_iron = 796,
axe_iron = 796,
shovel_diamond = 8200,
sword_diamond = 16392,
pick_diamond = 24584,
axe_diamond = 24584,
shovel_netherite = 81928,
sword_netherite = 90120,
pick_netherite = 98312,
@ -1124,38 +1102,16 @@ value is for values that are not in any other group. ]]
}
exchangeclone.group_values = {
{"not_in_creative_inventory", 0},
{"banner", 292},
{"sandstone", 4},
{"wood", 8},
{"button", 8},
{"dye", 8},
{"fence_wood", 13},
{"flower", 8},
{"pane", 0.5},
{"pressure_plate", 16},
{"trapdoor", 24},
{"door", 16},
{"fence_gate", 32},
{"sapling", 32},
{"mushroom", 32},
{"tree", 32},
{"boat", 40},
{"wool", 48},
{"bed", 168},
{"shulker_box", 4198},
{"bark", 43},
{"glass", 2}, --undyed glass is 1
{"huge_mushroom", 0}, --if you want energy, break it into mushrooms; doesn't always drop.
{"carpet", 32},
{"spawn_egg", 0},
{"hardened_clay", 16},
{"wood_slab", 4},
{"wood_stairs", 12},
{"smithing_template", 8192*7+1792*2},
{"concrete", 2},
{"concrete_powder", 2},
{"useless", 0},
{"decorated_pot_recipe", 4}, -- has to be 4 because of brick.
}
@ -1549,13 +1505,10 @@ else
exchangeclone.group_values = {
{"tree", 16},
{"wood", 8},
{"sapling", 32},
{"fence", 10},
{"wool", 48},
{"dye", 8},
{"flower", 32},
{"useless", 0},
}
end
@ -1635,8 +1588,6 @@ local function get_cheapest_recipe(recipes)
end
end
end
--minetest.log(dump(cheapest))
--if cheapest and cheapest[2].output:find("stair") then minetest.log(dump(cheapest)) end
return cheapest and cheapest[1]
end
@ -1656,8 +1607,8 @@ local function set_item_energy(itemstring, energy_value)
end
description = description.."Energy Value: "..(energy_value)
end
if def.exchangeclone_custom_energy then
energy_value = def.exchangeclone_custom_energy
if itemstring == "mcl_core:stone" then
minetest.log(description)
end
minetest.override_item(itemstring, {
description = description,
@ -1705,6 +1656,7 @@ end
-- Wait until all mods are loaded (to make sure all nodes have been registered)
-- This is much easier than making it depend on every single mod.
-- Actually, I'm kind of surprised that override_item still works...
minetest.register_on_mods_loaded(function()
local waiting = {}
local groupnames = {}
@ -1737,36 +1689,35 @@ minetest.register_on_mods_loaded(function()
end
end
for itemstring, def in pairs(minetest.registered_items) do
local _, _, mod_name, item_name = itemstring:find("([%d_%l]+):([%d_%l]+)")
if (
def
and item_name
and mod_name
and def.description
and def.description ~= ""
and (minetest.get_item_group(itemstring, "not_in_creative_inventory") <= 0)
and (not def.energy_value)
) then
if def.exchangeclone_custom_energy then
set_item_energy(itemstring, def.exchangeclone_custom_energy)
elseif energy_values[mod_name] and energy_values[mod_name][item_name] then
if def.exchangeclone_custom_energy then
set_item_energy(itemstring, def.exchangeclone_custom_energy)
else
local _, _, mod_name, item_name = itemstring:find("([%d_%l]+):([%d_%l]+)")
if energy_values[mod_name] and energy_values[mod_name][item_name] then
set_item_energy(itemstring, energy_values[mod_name][item_name])
else
-- This does mean that other items in mcl_potions will be ignored unless explicitly specified above...
if itemstring:sub(1,12) ~= "mcl_potions:" then
waiting[itemstring] = def
end
elseif (
def
and item_name
and mod_name
and def.description
and def.description ~= ""
and (minetest.get_item_group(itemstring, "not_in_creative_inventory") <= 0)
and (not def.energy_value)
and (itemstring:sub(1,12) ~= "mcl_potions:")
-- This does mean that other items in mcl_potions will be ignored unless explicitly specified,
-- and items that are in groups mentioned above.
) then
waiting[itemstring] = true
end
end
end
for i = 1,10 do
for i = 1,exchangeclone.num_passes do
if waiting == {} then break end
for itemstring, def in pairs(waiting) do
minetest.log(itemstring)
for itemstring, _ in pairs(waiting) do
local cheapest = get_cheapest_recipe(exchangeclone.recipes[itemstring])
if cheapest then
--waiting[itemstring] = nil
set_item_energy(itemstring, cheapest)
waiting[itemstring] = nil
end
end
end

View File

@ -118,8 +118,8 @@ minetest.register_craft({
output = "exchangeclone:dark_matter_axe",
recipe = {
{"exchangeclone:dark_matter", "exchangeclone:dark_matter"},
{"exchangeclone:dark_matter", exchangeclone.diamond_itemstring},
{"", exchangeclone.diamond_itemstring}
{"exchangeclone:dark_matter", exchangeclone.itemstrings.diamond},
{"", exchangeclone.itemstrings.diamond}
}
})

View File

@ -1,9 +1,5 @@
local cobble_itemstring = exchangeclone.mcl and "mcl_core:cobble" or "default:cobble"
local charcoal_itemstring = exchangeclone.mcl and "mcl_core:charcoal" or "group:tree"
local iron_itemstring = exchangeclone.mcl and "mcl_core:iron_ingot" or "default:steel_ingot"
local redstone_itemstring = exchangeclone.mcl and "mcl_core:redstone" or "default:obsidian"
local diamond_itemstring = exchangeclone.mcl and "mcl_core:diamond" or "default:diamond"
local coal_itemstring = exchangeclone.mcl and "mcl_core:coal_lump" or "default:coal_lump"
minetest.register_craftitem("exchangeclone:low_covalence_dust", {
description = "Low Covalence Dust"
@ -21,14 +17,14 @@ minetest.register_craft({
output = "exchangeclone:low_covalence_dust 40",
type = "shapeless",
recipe = {
cobble_itemstring,
cobble_itemstring,
cobble_itemstring,
cobble_itemstring,
cobble_itemstring,
cobble_itemstring,
cobble_itemstring,
cobble_itemstring,
exchangeclone.itemstrings.cobble,
exchangeclone.itemstrings.cobble,
exchangeclone.itemstrings.cobble,
exchangeclone.itemstrings.cobble,
exchangeclone.itemstrings.cobble,
exchangeclone.itemstrings.cobble,
exchangeclone.itemstrings.cobble,
exchangeclone.itemstrings.cobble,
charcoal_itemstring,
}
})
@ -37,7 +33,7 @@ minetest.register_craft({
output = "exchangeclone:medium_covalence_dust 40",
type = "shapeless",
recipe = {
iron_itemstring, redstone_itemstring
exchangeclone.itemstrings.iron, redstone_itemstring
}
})
@ -45,6 +41,6 @@ minetest.register_craft({
output = "exchangeclone:high_covalence_dust 40",
type = "shapeless",
recipe = {
diamond_itemstring, coal_itemstring
exchangeclone.itemstrings.diamond, exchangeclone.itemstrings.coal
}
})

View File

@ -171,9 +171,9 @@ minetest.register_tool("exchangeclone:red_matter_hammer_3x3", {
minetest.register_craft({
output = "exchangeclone:dark_matter_hammer",
recipe = {
{"exchangeclone:dark_matter", exchangeclone.diamond_itemstring, "exchangeclone:dark_matter"},
{"", exchangeclone.diamond_itemstring, ""},
{"", exchangeclone.diamond_itemstring, ""}
{"exchangeclone:dark_matter", exchangeclone.itemstrings.diamond, "exchangeclone:dark_matter"},
{"", exchangeclone.itemstrings.diamond, ""},
{"", exchangeclone.itemstrings.diamond, ""}
}
})

View File

@ -168,8 +168,8 @@ minetest.register_craft({
output = "exchangeclone:dark_matter_hoe",
recipe = {
{"exchangeclone:dark_matter", "exchangeclone:dark_matter"},
{"", exchangeclone.diamond_itemstring},
{"", exchangeclone.diamond_itemstring}
{"", exchangeclone.itemstrings.diamond},
{"", exchangeclone.itemstrings.diamond}
}
})

View File

@ -1,18 +1,21 @@
exchangeclone = {}
if not (exchangeclone and minetest.get_modpath("_exchangeclone_energy")) then
error("Disable and re-enable the ExchangeClone modpack.")
end
if (not minetest.get_modpath("mcl_core")) and (not minetest.get_modpath("default")) then
error("ExchangeClone requires 'default' or 'mcl_core,' but Minetest doesn't let me mark one or the other as a dependency.")
else
exchangeclone.mcl = minetest.get_modpath("mcl_core")
end
exchangeclone.mineclonia = minetest.get_game_info().id == "mineclonia" -- if exchangeclone.mineclonia, exchangeclone.mcl will also be defined.
exchangeclone.mineclonia = minetest.get_game_info().id == "mineclonia" -- if exchangeclone.mineclonia, exchangeclone.mcl is also defined.
exchangeclone.orb_max = 51200000 -- Max capacity of Klein Star Omega in ProjectE
local modpath = minetest.get_modpath("exchangeclone")
exchangeclone.collector_speed = minetest.settings:get("exchangeclone.energy_collector_speed") or 5
exchangeclone.orb_max = minetest.settings:get("exchangeclone.orb_max") or 5
exchangeclone.num_passes = minetest.settings:get("exchangeclone.num_passes") or 10
dofile(modpath.."/lib.lua")
dofile(modpath.."/constructor.lua")

View File

@ -71,7 +71,7 @@ end
-- Gets the amount of energy stored in an orb in a specific inventory slot
function exchangeclone.get_orb_energy(inventory, listname, index)
if not inventory then return 0 end
if not inventory then return end
if not listname then listname = "main" end
if not index then index = 1 end
local itemstack = inventory:get_stack(listname, index)
@ -166,6 +166,7 @@ end
-- Set a player's personal energy
function exchangeclone.set_player_energy(player, amount)
if not (player and amount) then return end
player:get_meta():set_string("exchangeclone_stored_energy", tonumber(amount))
exchangeclone.update_hud(player)
end
@ -291,11 +292,14 @@ exchangeclone.wield_scale = vector.multiply(exchangeclone.wield_scale, 1.4)
-- Itemstrings for various items
exchangeclone.itemstrings = {
diamond = exchangeclone.mcl and "mcl_core:diamond" or "default:diamond",
gold = exchangeclone.mcl and "mcl_core:gold_ingot" or "default:gold_ingot",
iron = exchangeclone.mcl and "mcl_core:iron_ingot" or "default:steel_ingot",
cobble = exchangeclone.mcl and "mcl_core:cobble" or "default:cobble",
redstoneworth = exchangeclone.mcl and "mesecons:redstone" or "default:obsidian",
glowstoneworth = exchangeclone.mcl and "mcl_nether:glowstone_dust" or "default:tin_ingot",
coal = exchangeclone.mcl and "mcl_core:coal_lump" or "default:coal_lump",
meseworth = exchangeclone.mcl and "mcl_core:emerald" or "default:mese_crystal"
iron = exchangeclone.mcl and "mcl_core:iron_ingot" or "default:steel_ingot",
gold = exchangeclone.mcl and "mcl_core:gold_ingot" or "default:gold_ingot",
emeraldworth = exchangeclone.mcl and "mcl_core:emerald" or "default:mese_crystal",
diamond = exchangeclone.mcl and "mcl_core:diamond" or "default:diamond",
}
-- Returns a player's inventory formspec with the correct width and hotbar position for the current game

View File

@ -2,6 +2,6 @@ name = exchangeclone
title = ExchangeClone
description = The main part of the modpack (depends on both the other mods)
min_minetest_version = 5.5
depends = item_tracking
#depends = item_tracking
optional_depends = 3d_armor, mcl_item_id, mcl_core, default, moreswords, mcl_stairs, meat_blocks, sticky_things, fake_liquids, sound_machine, stairs, mcl_dispensers, farming, mobs_mc, screwdriver
author = ThePython10110

View File

@ -436,6 +436,7 @@ minetest.register_craft({
minetest.register_craft({
output = "mcl_throwing:ender_pearl",
type = "shapeless",
recipe = {
"exchangeclone:philosophers_stone",
"mcl_core:iron_ingot",
@ -529,7 +530,7 @@ minetest.register_craft({
})
minetest.register_craft({
output = exchangeclone.itemstrings.meseworth,
output = exchangeclone.itemstrings.emeraldworth,
type = "shapeless",
recipe = {
"exchangeclone:philosophers_stone",
@ -544,7 +545,7 @@ minetest.register_craft({
type = "shapeless",
recipe = {
"exchangeclone:philosophers_stone",
exchangeclone.itemstrings.meseworth,
exchangeclone.itemstrings.emeraldworth,
},
replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}}
})
@ -554,14 +555,14 @@ minetest.register_craft({
type = "shapeless",
recipe = {
"exchangeclone:philosophers_stone",
exchangeclone.itemstrings.meseworth,
exchangeclone.itemstrings.meseworth,
exchangeclone.itemstrings.emeraldworth,
exchangeclone.itemstrings.emeraldworth,
},
replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}}
})
minetest.register_craft({
output = exchangeclone.itemstrings.meseworth.." 2",
output = exchangeclone.itemstrings.emeraldworth.." 2",
type = "shapeless",
recipe = {
"exchangeclone:philosophers_stone",
@ -622,34 +623,46 @@ minetest.register_craft({
})
minetest.register_craft({
output = "mcl_core:lapis 2",
output = "mcl_nether:glowstone_dust",
type = "shapeless",
recipe = {
"exchangeclone:philosophers_stone",
"mesecons_torch:redstoneblock",
"mesecons_torch:redstoneblock",
"mesecons_torch:redstoneblock",
"mesecons:redstone",
"mesecons:redstone",
"mesecons:redstone",
"mesecons:redstone",
"mesecons:redstone",
"mesecons:redstone",
},
replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}}
})
minetest.register_craft({
output = "mesecons:redstone 27",
output = "mesecons:redstone 6",
type = "shapeless",
recipe = {
"exchangeclone:philosophers_stone",
"mcl_core:lapis",
"mcl_core:lapis",
"mcl_nether:glowstone_dust",
},
replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}}
})
minetest.register_craft({
output = "mesecons:redstone 27",
output = "mcl_core:lapis",
type = "shapeless",
recipe = {
"exchangeclone:philosophers_stone",
"mcl_nether:glowstone_dust",
"mcl_nether:glowstone_dust"
},
replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}}
})
minetest.register_craft({
output = "mcl_nether:glowstone_dust 2",
type = "shapeless",
recipe = {
"exchangeclone:philosophers_stone",
"mcl_core:lapis",
"mcl_core:lapis",
},
replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}}

View File

@ -163,8 +163,8 @@ minetest.register_craft({
output = "exchangeclone:dark_matter_pickaxe",
recipe = {
{"exchangeclone:dark_matter", "exchangeclone:dark_matter", "exchangeclone:dark_matter"},
{"", exchangeclone.diamond_itemstring, ""},
{"", exchangeclone.diamond_itemstring, ""}
{"", exchangeclone.itemstrings.diamond, ""},
{"", exchangeclone.itemstrings.diamond, ""}
}
})

View File

@ -423,7 +423,7 @@ minetest.register_craft({
output = "exchangeclone:dark_matter_shears",
recipe = {
{"", "exchangeclone:dark_matter"},
{exchangeclone.diamond_itemstring, ""},
{exchangeclone.itemstrings.diamond, ""},
}
})

View File

@ -129,8 +129,8 @@ minetest.register_craft({
output = "exchangeclone:dark_matter_shovel",
recipe = {
{"exchangeclone:dark_matter"},
{exchangeclone.diamond_itemstring},
{exchangeclone.diamond_itemstring}
{exchangeclone.itemstrings.diamond},
{exchangeclone.itemstrings.diamond}
}
})

View File

@ -55,7 +55,7 @@ minetest.register_on_mods_loaded(function()
end
end)
exchangeclone.aoe_attack = function(info)
function exchangeclone.aoe_attack(info)
if not info then return end
local damage = info.damage or 12 -- 12 = DM sword AOE
local knockback = info.knockback
@ -222,7 +222,7 @@ minetest.register_craft({
recipe = {
{"exchangeclone:dark_matter"},
{"exchangeclone:dark_matter"},
{exchangeclone.diamond_itemstring}
{exchangeclone.itemstrings.diamond}
}
})

View File

@ -1 +1,5 @@
exchangeclone.energy_collector_speed (Energy Collector energy/second) int 5
# Exchange Orb maximum energy (default 51200000)
exchangeclone.orb_max (Exchange Orb maximum energy) int 51200000
# The number of times ExchangeClone goes through the items (more = longer load, but it's more likely that more energy values will be registered)
exchangeclone.num_passes (Energy value number of passes) int 10