Finished automatic energy values! (I hope)

This commit is contained in:
ThePython 2023-11-10 14:43:10 -08:00
parent cb0f322668
commit bb3e694f4f
11 changed files with 497 additions and 1611 deletions

View File

@ -57,28 +57,33 @@ Dependencies: Minetest Game or MineClone.
### 6.0
* New Features:
* Automatically generated energy values! Based on crafting and cooking recipes.
* For reasons beyond my control, things kind of vary a bit between loads because of which items are added to the list first (which is kind of random). For instance, the Lookup Tool in MineClone2 might sometimes have an energy value of 5 (1 stick + 1 glass) or 16 (4 sticks) depending on whether the energy value for glass is added first or not. At least, I assume that's the reason.
* Infinite food (costs 64 energy to use, equal to steak)
* Alchemical Chest
* Repair Talisman (maybe, would only work in Alchemical Chest)
* Covalence Dust (Aux1+right-click with Philosopher's Stone to open repairer, does not work with modded (non-Why) tools)
* Covalence Dust (Aux1+right-click with Philosopher's Stone to open repairer, only tools with an energy value can be repaired)
* Mind, Life, Body, and Soul Stones (although MTG only has the soul stone).
* Mercurial Eye (maybe)
* Changes:
* Energy values are now in `_exchangeclone_energy/energy_values.lua`, and are laid out differently, and aliases now work.
* ExchangeClone is now a modpack for [annoying reasons](https://forum.minetest.net/viewtopic.php?f=47&p=429775s). *Every single mod* in the modpack is required, regardless of what it says the dependencies are. Disable and then enable it for everything to work correctly.
* The default energy value is no longer 1 but none.
* The 2-billion-ish personal energy limit is has been increased to the actual maximum Lua allows. This may mean some precision is lost when your personal energy reaches a few quadrillion... but that's unlikely to happen, and at that point, it probably doesn't matter, so I'm not testing it.
* The 2-billion-ish personal energy limit is has been increased to the actual maximum Lua allows. This may mean some precision might be lost when your personal energy reaches a few quadrillion... but at that point, you don't really care about the exact number.
* Tools that break multiple nodes at once (hammer, hoe, pickaxe, morningstar, and katar) use a better method that may (?) slightly decrease lag.
* Ender pearls can now be crafted with 4 iron and the Philosopher's Stone.
* A couple changes the Philosopher's Stone's transmutation:
* Ice and obsidian can now be transmuted into water and lava, respectively.
* It is now impossible to transmute between bedrock and barriers (MCL). I don't know why I did it in the first place :D
* Bugfixes:
* Fixed potion energy values
### 5.3
* Fixed shearing beehives in MCL (thanks @Ranko-Saotome!)
* Bugfixes
* Fixed shearing beehives in MCL (thanks @Ranko-Saotome!)
### 5.2
* Bugfixes
* Removed unnecessary logging every time players take damage (I was testing stuff out with the armor)
* Removed unnecessary logging every time players take damage (I was testing stuff out with the armor, thanks @Ranko-Saotome for reporting)
### 5.1
* New Features:

View File

@ -0,0 +1,400 @@
exchangeclone.group_values = {}
exchangeclone.energy_values = {}
if exchangeclone.mcl then
--[[ Groups are organized so that order matters. Groups that are lower on the
list will have their energies applied later, making them higher priority. It's
unnecessary for single items because order doesn't matter for them. The NO_GROUP
value is for values that are not in any other group, but adding this means that
NO items will have their energy calculated by recipes. ]]
exchangeclone.group_values = {
{"flower", 8},
{"mushroom", 32},
{"smithing_template", 8192*7+1792*2},
{"decorated_pot_recipe", 4}, -- has to be 4 because of brick.
}
exchangeclone.energy_values = {
["doc_identifier:identifier_liquid"] = 5,
["fake_liquids:bucket_fake_lava"] = 832,
["fake_liquids:bucket_fake_water"] = 960,
["lava_sponge:lava_sponge_wet"] = 1160,
["mcl_amethyst:amethyst_cluster"] = 512,
["mcl_amethyst:amethyst_shard"] = 256,
["mcl_amethyst:calcite"] = 128,
["mcl_amethyst:large_amethyst_bud"] = 426,
["mcl_amethyst:medium_amethyst_bud"] = 341,
["mcl_amethyst:small_amethyst_bud"] = 256,
["mcl_anvils:anvil_damage_1"] = 5632,
["mcl_anvils:anvil_damage_2"] = 3328,
["mcl_armor:boots_chain"] = 768,
["mcl_armor:boots_chain_enchanted"] = 768,
["mcl_armor:boots_diamond_enchanted"] = 32768,
["mcl_armor:boots_gold_enchanted"] = 8192,
["mcl_armor:boots_iron_enchanted"] = 1024,
["mcl_armor:boots_leather_enchanted"] = 256,
["mcl_armor:boots_netherite"] = 106496,
["mcl_armor:boots_netherite_enchanted"] = 106496,
["mcl_armor:chestplate_chain"] = 1792,
["mcl_armor:chestplate_chain_enchanted"] = 1792,
["mcl_armor:chestplate_diamond_enchanted"] = 65536,
["mcl_armor:chestplate_gold_enchanted"] = 16384,
["mcl_armor:chestplate_iron_enchanted"] = 2048,
["mcl_armor:chestplate_leather_enchanted"] = 512,
["mcl_armor:chestplate_netherite"] = 139264,
["mcl_armor:chestplate_netherite_enchanted"] = 139264,
["mcl_armor:elytra"] = 297216,
["mcl_armor:helmet_chain"] = 1024,
["mcl_armor:helmet_chain_enchanted"] = 1024,
["mcl_armor:helmet_diamond_enchanted"] = 40960,
["mcl_armor:helmet_gold_enchanted"] = 10240,
["mcl_armor:helmet_iron_enchanted"] = 1280,
["mcl_armor:helmet_leather_enchanted"] = 320,
["mcl_armor:helmet_netherite"] = 114688,
["mcl_armor:helmet_netherite_enchanted"] = 114688,
["mcl_armor:leggings_chain"] = 1536,
["mcl_armor:leggings_chain_enchanted"] = 1536,
["mcl_armor:leggings_diamond_enchanted"] = 57344,
["mcl_armor:leggings_gold_enchanted"] = 14336,
["mcl_armor:leggings_iron_enchanted"] = 1792,
["mcl_armor:leggings_leather_enchanted"] = 448,
["mcl_armor:leggings_netherite"] = 131072,
["mcl_armor:leggings_netherite_enchanted"] = 131072,
["mcl_bamboo:bamboo"] = 2,
["mcl_bamboo:bamboo_block_stripped"] = 16,
["mcl_banners:pattern_globe"] = 360,
["mcl_banners:pattern_piglin"] = 300,
["mcl_beehives:beehive"] = 144,
["mcl_bells:bell"] = 8192,
["mcl_blackstone:basalt"] = 1,
["mcl_blackstone:blackstone"] = 1,
["mcl_blackstone:blackstone_gilded"] = 2048,
["mcl_blackstone:nether_gold"] = 2048,
["mcl_blackstone:soul_soil"] = 49,
["mcl_books:book"] = 150,
["mcl_books:written_book"] = 206,
["mcl_bows:bow_enchanted"] = 48,
["mcl_bows:crossbow_enchanted"] = 295,
["mcl_bows:crossbow_loaded"] = 298,
["mcl_bows:crossbow_loaded_enchanted"] = 298,
["mcl_buckets:bucket_axolotl"] = 1024,
["mcl_buckets:bucket_cod"] = 896,
["mcl_buckets:bucket_lava"] = 896,
["mcl_buckets:bucket_river_water"] = 768,
["mcl_buckets:bucket_salmon"] = 896,
["mcl_buckets:bucket_tropical_fish"] = 896,
["mcl_buckets:bucket_water"] = 768,
["mcl_campfires:campfire"] = 140,
["mcl_campfires:soul_campfire"] = 157,
["mcl_cocoas:cocoa_beans"] = 128,
["mcl_copper:raw_copper"] = 85,
["mcl_core:andesite"] = 1,
["mcl_core:apple"] = 128,
["mcl_core:apple_gold_enchanted"] = 147584,
["mcl_core:cactus"] = 8,
["mcl_core:charcoal_lump"] = 32,
["mcl_core:clay_lump"] = 4,
["mcl_core:coal_lump"] = 128,
["mcl_core:cobble"] = 1,
["mcl_core:cobweb"] = 12,
["mcl_core:crying_obsidian"] = 1000,
["mcl_core:dead_bush"] = 8,
["mcl_core:deadbush"] = 8,
["mcl_core:diamond"] = 8192,
["mcl_core:diorite"] = 1,
["mcl_core:dirt"] = 1,
["mcl_core:emerald"] = 4096,
["mcl_core:flint"] = 4,
["mcl_core:granite"] = 1,
["mcl_core:grass"] = 1,
["mcl_core:gravel"] = 1,
["mcl_core:ice"] = 1,
["mcl_core:lapis"] = 864,
["mcl_core:mycelium"] = 1,
["mcl_core:obsidian"] = 64,
["mcl_core:redsand"] = 1,
["mcl_core:reeds"] = 32,
["mcl_core:sand"] = 1,
["mcl_core:vine"] = 8,
["mcl_crimson:shroomlight"] = 64,
["mcl_crimson:twisting_vines"] = 8,
["mcl_crimson:warped_wart_block"] = 216,
["mcl_crimson:weeping_vines"] = 8,
["mcl_deepslate:deepslate_cobbled"] = 1,
["mcl_deepslate:tuff"] = 1,
["mcl_end:chorus_flower"] = 32,
["mcl_end:chorus_fruit"] = 16,
["mcl_end:dragon_egg"] = 139264,
["mcl_end:end_stone"] = 1,
["mcl_experience:bottle"] = 2048,
["mcl_farming:beetroot_item"] = 24,
["mcl_farming:beetroot_seeds"] = 16,
["mcl_farming:carrot_item"] = 24,
["mcl_farming:hoe_diamond_enchanted"] = 16380,
["mcl_farming:hoe_gold_enchanted"] = 4104,
["mcl_farming:hoe_iron_enchanted"] = 520,
["mcl_farming:hoe_netherite"] = 90108,
["mcl_farming:hoe_netherite_enchanted"] = 90108,
["mcl_farming:hoe_stone_enchanted"] = 10,
["mcl_farming:hoe_wood_enchanted"] = 24,
["mcl_farming:melon_item"] = 36,
["mcl_farming:potato_item"] = 24,
["mcl_farming:potato_item_poison"] = 24,
["mcl_farming:pumpkin"] = 144,
["mcl_farming:pumpkin_face"] = 144,
["mcl_farming:sweet_berry"] = 16,
["mcl_farming:wheat_item"] = 24,
["mcl_farming:wheat_seeds"] = 16,
["mcl_fishing:clownfish_raw"] = 64,
["mcl_fishing:fish_raw"] = 40,
["mcl_fishing:fishing_rod_enchanted"] = 36,
["mcl_fishing:pufferfish_raw"] = 64,
["mcl_fishing:salmon_raw"] = 48,
["mcl_flowers:waterlily"] = 16,
["mcl_flowers:wither_rose"] = 128,
["mcl_heads:creeper"] = 256,
["mcl_heads:skeleton"] = 256,
["mcl_heads:steve"] = 256,
["mcl_heads:wither_skeleton"] = 50000,
["mcl_heads:zombie"] = 256,
["mcl_honey:honey_bottle"] = 33,
["mcl_honey:honeycomb"] = 32,
["mcl_lush_caves:cave_vines"] = 8,
["mcl_lush_caves:cave_vines_lit"] = 0,
["mcl_lush_caves:glow_berry"] = 36,
["mcl_lush_caves:spore_blossom"] = 32,
["mcl_mangrove:mangrove_roots"] = 1,
["mcl_maps:filled_map"] = 1120,
["mcl_maps:filled_map_mcl_skins_base_18D471DFF_female_crea"] = 1120,
["mcl_maps:filled_map_mcl_skins_base_18D471DFF_female_surv"] = 1120,
["mcl_maps:filled_map_mcl_skins_base_18D471DFF_male_crea"] = 1120,
["mcl_maps:filled_map_mcl_skins_base_18D471DFF_male_surv"] = 1120,
["mcl_maps:filled_map_mcl_skins_base_1B47A57FF_female_crea"] = 1120,
["mcl_maps:filled_map_mcl_skins_base_1B47A57FF_female_surv"] = 1120,
["mcl_maps:filled_map_mcl_skins_base_1B47A57FF_male_crea"] = 1120,
["mcl_maps:filled_map_mcl_skins_base_1B47A57FF_male_surv"] = 1120,
["mcl_maps:filled_map_mcl_skins_base_1EEB592FF_female_crea"] = 1120,
["mcl_maps:filled_map_mcl_skins_base_1EEB592FF_female_surv"] = 1120,
["mcl_maps:filled_map_mcl_skins_base_1EEB592FF_male_crea"] = 1120,
["mcl_maps:filled_map_mcl_skins_base_1EEB592FF_male_surv"] = 1120,
["mcl_mobitems:beef"] = 64,
["mcl_mobitems:blaze_rod"] = 1536,
["mcl_mobitems:bone"] = 144,
["mcl_mobitems:chicken"] = 48,
["mcl_mobitems:diamond_horse_armor"] = 73728,
["mcl_mobitems:feather"] = 48,
["mcl_mobitems:ghast_tear"] = 4096,
["mcl_mobitems:glow_ink_sac"] = 256,
["mcl_mobitems:gold_horse_armor"] = 18432,
["mcl_mobitems:gunpowder"] = 192,
["mcl_mobitems:heart_of_the_sea"] = 50000,
["mcl_mobitems:ink_sac"] = 8,
["mcl_mobitems:iron_horse_armor"] = 2304,
["mcl_mobitems:leather"] = 64,
["mcl_mobitems:magma_cream"] = 768,
["mcl_mobitems:milk_bucket"] = 832,
["mcl_mobitems:mutton"] = 48,
["mcl_mobitems:nametag"] = 128,
["mcl_mobitems:nautilus_shell"] = 10000,
["mcl_mobitems:nether_star"] = 73728,
["mcl_mobitems:porkchop"] = 64,
["mcl_mobitems:rabbit"] = 40,
["mcl_mobitems:rabbit_foot"] = 64,
["mcl_mobitems:rabbit_hide"] = 16,
["mcl_mobitems:rotten_flesh"] = 24,
["mcl_mobitems:saddle"] = 192,
["mcl_mobitems:shulker_shell"] = 2048,
["mcl_mobitems:slimeball"] = 24,
["mcl_mobitems:spider_eye"] = 128,
["mcl_mobitems:string"] = 12,
["mcl_mobs:nametag"] = 128,
["mcl_mud:mud"] = 1,
["mcl_nether:ancient_debris"] = 16384,
["mcl_nether:glowstone_dust"] = 384,
["mcl_nether:nether_wart_item"] = 24,
["mcl_nether:netherrack"] = 1,
["mcl_nether:quartz"] = 128,
["mcl_nether:soul_sand"] = 49,
["mcl_ocean:brain_coral"] = 8,
["mcl_ocean:brain_coral_block"] = 8,
["mcl_ocean:brain_coral_fan"] = 8,
["mcl_ocean:bubble_coral"] = 8,
["mcl_ocean:bubble_coral_block"] = 8,
["mcl_ocean:bubble_coral_fan"] = 8,
["mcl_ocean:dead_brain_coral"] = 8,
["mcl_ocean:dead_brain_coral_block"] = 8,
["mcl_ocean:dead_brain_coral_fan"] = 8,
["mcl_ocean:dead_bubble_coral"] = 8,
["mcl_ocean:dead_bubble_coral_block"] = 8,
["mcl_ocean:dead_bubble_coral_fan"] = 8,
["mcl_ocean:dead_fire_coral"] = 8,
["mcl_ocean:dead_fire_coral_block"] = 8,
["mcl_ocean:dead_fire_coral_fan"] = 8,
["mcl_ocean:dead_horn_coral"] = 8,
["mcl_ocean:dead_horn_coral_block"] = 8,
["mcl_ocean:dead_horn_coral_fan"] = 8,
["mcl_ocean:dead_tube_coral"] = 8,
["mcl_ocean:dead_tube_coral_block"] = 8,
["mcl_ocean:dead_tube_coral_fan"] = 8,
["mcl_ocean:fire_coral"] = 8,
["mcl_ocean:fire_coral_block"] = 8,
["mcl_ocean:fire_coral_fan"] = 8,
["mcl_ocean:horn_coral"] = 8,
["mcl_ocean:horn_coral_block"] = 8,
["mcl_ocean:horn_coral_fan"] = 8,
["mcl_ocean:kelp"] = 32,
["mcl_ocean:prismarine_crystals"] = 2054,
["mcl_ocean:prismarine_shard"] = 2,
["mcl_ocean:sea_pickle_1_dead_brain_coral_block"] = 8,
["mcl_ocean:seagrass"] = 1,
["mcl_ocean:tube_coral"] = 8,
["mcl_ocean:tube_coral_block"] = 8,
["mcl_ocean:tube_coral_fan"] = 8,
["mcl_potions:dragon_breath"] = 8.5,
["mcl_potions:fermented_spider_eye"] = 192,
["mcl_potions:glass_bottle"] = 1,
["mcl_potions:speckled_melon"] = 1852,
["mcl_pottery_sherds:pot"] = 16,
["mcl_raw_ores:raw_gold"] = 2048,
["mcl_raw_ores:raw_iron"] = 256,
["mcl_sponges:sponge"] = 1024,
["mcl_sponges:sponge_wet"] = 1024,
["mcl_sponges:sponge_wet_river_water"] = 1024,
["mcl_throwing:egg"] = 32,
["mcl_throwing:ender_pearl"] = 1024,
["mcl_throwing:snowball"] = 0.25,
["mcl_tools:axe_stone_enchanted"] = 11,
["mcl_tools:axe_wood_enchanted"] = 32,
["mcl_tools:axe_iron_enchanted"] = 796,
["mcl_tools:axe_gold_enchanted"] = 6152,
["mcl_tools:axe_diamond_enchanted"] = 24584,
["mcl_tools:axe_netherite"] = 98312,
["mcl_tools:axe_netherite_enchanted"] = 98312,
["mcl_tools:pick_stone_enchanted"] = 11,
["mcl_tools:pick_iron_enchanted"] = 796,
["mcl_tools:pick_gold_enchanted"] = 6152,
["mcl_tools:pick_diamond_enchanted"] = 24584,
["mcl_tools:pick_netherite"] = 98312,
["mcl_tools:pick_netherite_enchanted"] = 98312,
["mcl_tools:pick_wood_enchanted"] = 32,
["mcl_tools:shovel_diamond_enchanted"] = 8200,
["mcl_tools:shovel_gold_enchanted"] = 2056,
["mcl_tools:shovel_iron_enchanted"] = 264,
["mcl_tools:shovel_netherite"] = 81928,
["mcl_tools:shovel_netherite_enchanted"] = 81928,
["mcl_tools:shovel_stone_enchanted"] = 9,
["mcl_tools:shovel_wood_enchanted"] = 16,
["mcl_tools:sword_diamond_enchanted"] = 16392,
["mcl_tools:sword_gold_enchanted"] = 5000,
["mcl_tools:sword_iron_enchanted"] = 516,
["mcl_tools:sword_netherite"] = 90120,
["mcl_tools:sword_netherite_enchanted"] = 90120,
["mcl_tools:sword_stone_enchanted"] = 6,
["mcl_tools:sword_wood_enchanted"] = 20,
["mcl_totems:totem"] = 106496,
["meat_blocks:meatball"] = 64,
["mesecons:redstone"] = 64,
["useful_green_potatoes:useful_green_potato"] = 256,
}
exchangeclone.mcl_potion_data = { -- automatically assumes base cost is awkward potion if not specified
{name = "water", ingredient_cost = 0, custom_base_cost = 0, no_arrow = true},
{name = "awkward", ingredient_cost = 0, no_arrow = true},
{name = "fire_resistance", ingredient_cost = 768, plus = true},
{name = "poison", ingredient_cost = 128, plus = true, two = true},
{name = "harming", ingredient_cost = 192, custom_base_cost = 52, two = true},
{name = "healing", ingredient_cost = 1852, two = true},
{name = "leaping", ingredient_cost = 64, plus = true, two = true},
{name = "mundane", ingredient_cost = 32, no_arrow = true, custom_base_cost = 0},
{name = "night_vision", ingredient_cost = 1840, plus = true},
{name = "regeneration", ingredient_cost = 4096, plus = true, two = true},
{name = "slowness", ingredient_cost = 192, custom_base_cost = 20, plus = true, two = true},
{name = "swiftness", ingredient_cost = 32, plus = true, two = true},
{name = "thick", ingredient_cost = 384, no_arrow = true, custom_base_cost = 0},
{name = "water_breathing", ingredient_cost = 64, plus = true},
{name = "invisibility", ingredient_cost = 192, custom_base_cost = 623, plus = true},
{name = "withering", ingredient_cost = 128, plus = true, two = true}
}
else
exchangeclone.energy_values = {
["bones:bones"] = 4,
["bucket:bucket_lava"] = 896,
["bucket:bucket_river_water"] = 768,
["bucket:bucket_water"] = 768,
["butterflies:butterfly_red"] = 0,
["butterflies:butterfly_violet"] = 0,
["butterflies:butterfly_white"] = 0,
["default:acacia_bush_leaves"] = 1,
["default:acacia_bush_sapling"] = 32,
["default:acacia_bush_stem"] = 8,
["default:apple"] = 5,
["default:blueberries"] = 8,
["default:blueberry_bush_leaves"] = 1,
["default:blueberry_bush_leaves_with_berries"] = 9,
["default:blueberry_bush_sapling"] = 32,
["default:book_written"] = 96,
["default:bush_leaves"] = 1,
["default:bush_sapling"] = 32,
["default:bush_stem"] = 8,
["default:cactus"] = 8,
["default:clay_lump"] = 4,
["default:coal_lump"] = 128,
["default:cobble"] = 1,
["default:copper_lump"] = 320,
["default:coral_brown"] = 8,
["default:coral_cyan"] = 8,
["default:coral_green"] = 8,
["default:coral_orange"] = 8,
["default:coral_pink"] = 8,
["default:coral_skeleton"] = 8,
["default:desert_cobble"] = 1,
["default:desert_sand"] = 1,
["default:diamond"] = 8192,
["default:dirt"] = 1,
["default:dirt_with_grass"] = 1,
["default:dry_dirt"] = 1,
["default:dry_dirt_with_dry_grass"] = 1,
["default:dry_dirt_with_grass"] = 1,
["default:emergent_jungle_sapling"] = 32,
["default:flint"] = 4,
["default:gold_lump"] = 2048,
["default:grass"] = 1,
["default:gravel"] = 1,
["default:ice"] = 1,
["default:iron_lump"] = 256,
["default:large_cactus_seedling"] = 32,
["default:mese_crystal"] = 4096,
["default:mossycobble"] = 32,
["default:obsidian"] = 64,
["default:papyrus"] = 32,
["default:pine_bush_needles"] = 1,
["default:pine_bush_sapling"] = 32,
["default:pine_bush_stem"] = 8,
["default:sand"] = 1,
["default:sand_with_kelp"] = 32,
["default:silver_sand"] = 1,
["default:snow"] = 0.5,
["default:snowblock"] = 5,
["default:stick"] = 4,
["default:tin_lump"] = 384,
["farming:cotton"] = 12,
["farming:cotton_wild"] = 12,
["farming:seed_cotton"] = 10,
["farming:seed_wheat"] = 16,
["farming:wheat"] = 24,
["useful_green_potatoes:useful_green_potato"] = 256
}
exchangeclone.group_values = {
{"flower", 32},
}
end
table.insert_all(exchangeclone.energy_values, {
["exchangeclone:alchemical_tome"] = 0,
})
table.insert_all(exchangeclone.group_values, {
{"tree", 32},
{"sapling", 32},
{"useless", 0},
})

File diff suppressed because it is too large Load Diff

View File

@ -111,7 +111,6 @@ if exchangeclone.mcl then
end
mcl_damage.register_modifier(function(obj, damage, reason)
minetest.log(dump({damage, reason}))
local blocked = blocked_damage_types[reason.type]
local inv = mcl_util.get_inventory(obj)
if inv then

View File

@ -229,8 +229,8 @@ minetest.register_craft({
type = "shaped",
output = "exchangeclone:constructor",
recipe = {
{"", "exchangeclone:exchange_orb",""},
{"", recipe_ingredient, ""},
{"", "exchangeclone:exchange_orb", ""}
{"exchangeclone:exchange_orb"},
{recipe_ingredient},
{"exchangeclone:exchange_orb"}
}
})

View File

@ -206,11 +206,10 @@ if exchangeclone.mcl then
end
minetest.register_craft({
type = "shaped",
output = "exchangeclone:deconstructor",
recipe = {
{"", "exchangeclone:exchange_orb",""},
{"", recipe_ingredient, ""},
{"", "exchangeclone:exchange_orb", ""}
{"exchangeclone:exchange_orb"},
{recipe_ingredient},
{"exchangeclone:exchange_orb"}
}
})

View File

@ -14,7 +14,7 @@ function exchangeclone.get_inventory_drops(pos, inventory, drops) --removes defa
end
function exchangeclone.get_item_energy(item)
if not item then return end
if (item == "") or not item then return end
if type(item) == "string" and item:sub(1,6) == "group:" and exchangeclone.group_values then
local item_group = item:sub(7,-1)
for _, group in ipairs(exchangeclone.group_values) do
@ -35,15 +35,19 @@ function exchangeclone.get_item_energy(item)
return cheapest
end
item = ItemStack(item)
local meta_energy_value = item:get_meta():get_int("exchangeclone_energy_value")
if meta_energy_value > 0 then
return meta_energy_value
end
local def = minetest.registered_items[item:get_name()]
if not def then return 0 end
if not def then return end
if item:get_name() == "exchangeclone:exchange_orb" then
return def.energy_value or 0 + exchangeclone.get_orb_itemstack_energy(item)
if def.energy_value then
return def.energy_value + exchangeclone.get_orb_itemstack_energy(item)
end
end
if def.energy_value then
return (def.energy_value) * item:get_count()
else
return
end
end
@ -66,7 +70,7 @@ end
function exchangeclone.get_orb_itemstack_energy(itemstack)
if not itemstack then return end
if itemstack:get_name() ~= "exchangeclone:exchange_orb" then return end
return itemstack:get_meta():get_float("stored_energy") or 0
return math.max(itemstack:get_meta():get_float("stored_energy"), 0)
end
-- Gets the amount of energy stored in an orb in a specific inventory slot
@ -98,7 +102,7 @@ function exchangeclone.set_orb_energy(inventory, listname, index, amount)
local sqrt_max = math.sqrt(exchangeclone.orb_max)
local r, g, b = 0, 0, 0
if amount == 0 then
if amount >= 0 then
-- do nothing
elseif sqrt_amount < (sqrt_max/4) then
r = exchangeclone.map(sqrt_amount, 0, sqrt_max/4, 0, 255)
@ -151,7 +155,6 @@ end)
minetest.register_on_joinplayer(function(player, last_login)
local meta = player:get_meta()
local energy = meta:get_int("exchangeclone_stored_energy") or 0
minetest.log(energy)
if energy > 0 then
-- Not sure at all whether this is necessary
meta:set_int("exchangeclone_stored_energy", 0)
@ -541,7 +544,7 @@ minetest.register_on_leaveplayer(function(player, timed_out)
exchangeclone.cooldowns[player:get_player_name()] = nil
end)
-- Start a <time>-second cooldown called <name> for <player>
-- Start a <time>-second cooldown called <name> for <player>
function exchangeclone.start_cooldown(player, name, time)
local player_name = player:get_player_name()
exchangeclone.cooldowns[player_name][name] = time

View File

@ -106,7 +106,6 @@ function exchangeclone.aoe_attack(info)
local punch_vec = vector.subtract(opos, pos)
local punch_dir = vector.normalize(punch_vec)
punch_dir = {x=punch_dir.x, y=punch_dir.y+0.3, z=punch_dir.z} -- knockback should be more upward
--minetest.log(dump({name=ent.name, distance=distance, damage=damage}))
local sleep_formspec_doesnt_close_mt53 = false
if obj:is_player() then

View File

@ -45,7 +45,7 @@ function exchangeclone.reload_transmutation_list(player, search)
local filtered_items = {}
for _,name in ipairs(items_to_show) do
local def = minetest.registered_items[name]
if def and (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and def.description ~= "" then
if def and def.description and def.description ~= "" then
if filter_item(string.lower(def.name), def.description, lang, search) then
table.insert(filtered_items, name)
end
@ -91,7 +91,7 @@ local function handle_inventory(player, inventory, to_list)
local i = 0
for name, def in pairs(minetest.registered_items) do
local energy_value = exchangeclone.get_item_energy(name)
if energy_value and energy_value > 0 and not def.groups.not_in_creative_inventory then
if energy_value and energy_value > 0 then
i = i + 1
list[i] = name
end
@ -165,7 +165,7 @@ local function allow_inventory_action(player, stack, to_list, count, move, inven
local energy_value = exchangeclone.get_item_energy(stack:get_name())
if not energy_value then return 0 end
local def = minetest.registered_items[name]
if energy_value <= 0 or def.groups.not_in_creative_inventory == 1 then
if energy_value <= 0 then
return 0
else
return count

View File

@ -1,10 +1,12 @@
minetest.log("Wrapping craft function")
exchangeclone = {recipes = {}}
local old_func = minetest.register_craft
function minetest.register_craft(arg)
if arg.output then
exchangeclone.recipes[arg.output] = exchangeclone.recipes[arg.output] or {}
table.insert(exchangeclone.recipes[arg.output], table.copy(arg))
function minetest.register_craft(arg, ...)
if arg and arg.output then
local itemstring = ItemStack(arg.output):get_name()
exchangeclone.recipes[itemstring] = exchangeclone.recipes[itemstring] or {}
table.insert(exchangeclone.recipes[itemstring], table.copy(arg))
end
old_func(arg)
old_func(arg, ...)
end

View File

@ -0,0 +1,3 @@
name = zzzz_exchangeclone_crafthook
title = ExchangeClone Craft Hook
description = Wraps the minetest.register_craft function to allow ExchangeClone to access crafting recipe information.