From 3c8345da1ba394c67a4dbaee53d7012aa1d804cf Mon Sep 17 00:00:00 2001 From: ThePython <87204246+ThePython10110@users.noreply.github.com> Date: Sun, 12 Nov 2023 17:30:16 -0800 Subject: [PATCH] Technic works, hoppers don't yet --- .luacheckrc | 1 + CODE_OF_CONDUCT.md | 2 +- CONTRIBUTING.md | 4 +- README.md | 22 ++++-- _exchangeclone_energy/energy_values.lua | 97 ++++++++++++++++++++----- _exchangeclone_energy/init.lua | 15 +++- _exchangeclone_energy/mod.conf | 2 +- exchangeclone/alchemical_chest.lua | 2 +- exchangeclone/armor.lua | 6 +- exchangeclone/craftitems.lua | 10 +-- exchangeclone/deconstructor.lua | 2 +- exchangeclone/hopper_compat.lua | 29 ++++++++ exchangeclone/init.lua | 7 +- exchangeclone/lib.lua | 72 +++++++++++++----- exchangeclone/transmutation_table.lua | 2 +- settingtypes.txt | 2 +- zzzz_exchangeclone_crafthook/init.lua | 27 ++++++- 17 files changed, 234 insertions(+), 68 deletions(-) create mode 100644 exchangeclone/hopper_compat.lua diff --git a/.luacheckrc b/.luacheckrc index 5aca670..fed919d 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -30,6 +30,7 @@ read_globals = { "screwdriver", "mcl_crafting_table", "mcl_enchantments", + "technic", "Raycast", "Settings", diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index ead25cd..227d075 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,5 +1,5 @@ # Code of Conduct -Don't be evil. +Don't be evil. That's it. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 09074a0..a7ccf0b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,4 +3,6 @@ If you want to contribute, please do so, either through issues or pull requests. Feel free to report any problems or suggestions (including things as small as typos). If you know how to fix it, a PR would be even more useful. -Please follow the [Code of Conduct](CODE_OF_CONDUCT.md) when contributing. +Translations and textures are also welcome! I don't really like the textures for a lot of things. Mostly the nodes, but textures for the tools that don't look quite so similar to EE2/ProjectE would be nice. + +Please follow the [Code of Conduct](CODE_OF_CONDUCT.md) when contributing. \ No newline at end of file diff --git a/README.md b/README.md index 636a59b..9caa575 100644 --- a/README.md +++ b/README.md @@ -56,28 +56,38 @@ Dependencies: Minetest Game or MineClone.

Changelog:

-### 6.0 +### 6.0 (interestingness depends on several things) * 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. + * For reasons beyond my control, things kind of vary a bit between loads because of which items are added to the `minetest.registered_items` 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. + * Depending on the number of items you have, this could increase loading time. + * Technic recipe types (grinding, alloying, etc.) now also work, as long as their `output_size` is 1. + * Added energy values for Basic Materials and Technic! * Infinite food (costs 64 energy to use, equal to steak) * Alchemical Chest - * Repair Talisman (maybe, would only work in Alchemical Chest) + * Support for pipeworks and (non-MCL) hoppers! + * Repair Talisman * 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) + * Chat commands to set/add/remove energy from a player (requires `privs` privilege): + * `/add_energy [player] value` (player defaults to self, value can be negative) + * `/set_energy [player] value` (player defaults to self) * 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 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. + * Tools that break multiple nodes at once (hammers, hoes, katar, and morningstar) 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 + * It is now impossible to transmute between bedrock and barriers (MCL). I thought it was funny originally, but now I'm realizing that I don't want this to be annoying to people who run servers (are there any servers with this mod?) + * It now costs 4 dark/red matter to make a block, which is great news if you already have some (because they're now worth more), but not so great if you don't. + * Tool abilities now cost nothing (to match ProjectE). * Bugfixes: * Fixed potion energy values + * Fixed Red Matter Shield recipe ### 5.3 * Bugfixes @@ -99,7 +109,7 @@ Dependencies: Minetest Game or MineClone. * Bugfixes: * Fixed Mineclonia energy values (I foolishly assumed that all items would have the same itemstrings and groups, thanks @Ranko-Saotome for reporting this). -### 5.0 (the most insteresting release so far) +### 5.0 (bigger release than any before it) **You MUST break and replace any existing Constructors, Deconstructors, and Energy Collectors when updating from any previous version. Nothing will be lost (hopefully). In Minetest Game, this is a bit of a problem (try blowing it up maybe? I don't know, sorry).** * New features: * Added a [wiki](https://github.com/ThePython10110/ExchangeClone/wiki)! This is where you can find more complete information on pretty much everything. diff --git a/_exchangeclone_energy/energy_values.lua b/_exchangeclone_energy/energy_values.lua index 11e9f83..14f55e8 100644 --- a/_exchangeclone_energy/energy_values.lua +++ b/_exchangeclone_energy/energy_values.lua @@ -1,5 +1,7 @@ -exchangeclone.group_values = {} -exchangeclone.energy_values = {} +-- Just in case people want to add stuff to these lists in their mods... +exchangeclone.group_values = exchangeclone.group_values or {} +exchangeclone.energy_values = exchangeclone.energy_values or {} + 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 @@ -14,18 +16,24 @@ if exchangeclone.mcl then } exchangeclone.energy_values = { + -- TODO ["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, @@ -59,23 +67,31 @@ if exchangeclone.mcl then ["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, @@ -83,10 +99,14 @@ if exchangeclone.mcl then ["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, @@ -115,17 +135,22 @@ if exchangeclone.mcl then ["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, @@ -144,25 +169,32 @@ if exchangeclone.mcl then ["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, @@ -176,6 +208,7 @@ if exchangeclone.mcl then ["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, @@ -206,14 +239,18 @@ if exchangeclone.mcl then ["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, @@ -249,47 +286,54 @@ if exchangeclone.mcl then ["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_netherite"] = 98312, ["mcl_tools:axe_wood_enchanted"] = 32, + ["mcl_tools:axe_stone_enchanted"] = 11, ["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_netherite"] = 98312, + ["mcl_tools:pick_wood_enchanted"] = 32, ["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:shovel_stone_enchanted"] = 9, + ["mcl_tools:shovel_iron_enchanted"] = 264, + ["mcl_tools:shovel_gold_enchanted"] = 2056, + ["mcl_tools:shovel_diamond_enchanted"] = 8200, + ["mcl_tools:shovel_netherite_enchanted"] = 81928, ["mcl_tools:sword_netherite"] = 90120, - ["mcl_tools:sword_netherite_enchanted"] = 90120, - ["mcl_tools:sword_stone_enchanted"] = 6, ["mcl_tools:sword_wood_enchanted"] = 20, + ["mcl_tools:sword_stone_enchanted"] = 6, + ["mcl_tools:sword_iron_enchanted"] = 516, + ["mcl_tools:sword_gold_enchanted"] = 5000, + ["mcl_tools:sword_diamond_enchanted"] = 16392, + ["mcl_tools:sword_netherite_enchanted"] = 90120, + ["mcl_totems:totem"] = 106496, ["meat_blocks:meatball"] = 64, ["mesecons:redstone"] = 64, @@ -316,17 +360,16 @@ if exchangeclone.mcl then 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:blueberries"] = 16, ["default:blueberry_bush_leaves"] = 1, ["default:blueberry_bush_leaves_with_berries"] = 9, ["default:blueberry_bush_sapling"] = 32, @@ -375,16 +418,30 @@ else ["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, + + ["moreores:mithril_lump"] = 16384, + ["moreores:silver_lump"] = 4000, + + ["technic:chromium_lump"] = 4096, + ["technic:granite"] = 1, + ["technic:lead_lump"] = 256, + ["technic:marble"] = 1, + ["technic:sulfur_lump"] = 128, + ["technic:uranium_lump"] = 8192, + ["technic:zinc_lump"] = 512, + ["useful_green_potatoes:useful_green_potato"] = 256 } exchangeclone.group_values = { {"flower", 32}, + --{"dye", 8}, } end diff --git a/_exchangeclone_energy/init.lua b/_exchangeclone_energy/init.lua index e910c3c..eccc609 100644 --- a/_exchangeclone_energy/init.lua +++ b/_exchangeclone_energy/init.lua @@ -20,7 +20,7 @@ local function get_cheapest_recipe(recipes) end end end - elseif recipe.type == "shapeless" then + elseif (recipe.type == "shapeless") or (recipe.type == "technic") then for _, item in ipairs(recipe.recipe) do local cost = exchangeclone.get_item_energy(item) if (not cost) or cost == 0 then @@ -52,8 +52,6 @@ local function get_cheapest_recipe(recipes) if (not cheapest) or (cheapest[1] > ingredient_cost) then cheapest = {ingredient_cost, recipe} end - else - minetest.log("info", "\tMissing "..dump(skip)) end end return cheapest and cheapest[1] @@ -184,7 +182,7 @@ minetest.register_on_mods_loaded(function() end end for i = 1, exchangeclone.num_passes do - minetest.log("info", "PASS #"..i..":") + minetest.log("action", "PASS #"..i..":") if auto == {} then break end for itemstring, _ in pairs(auto) do local cheapest = get_cheapest_recipe(exchangeclone.recipes[itemstring]) @@ -206,6 +204,15 @@ minetest.register_on_mods_loaded(function() set_item_energy("mcl_shields:shield_"..color, (exchangeclone.get_item_energy("mcl_banners:banner_item_"..color) or 340) + (exchangeclone.get_item_energy("mcl_shields:shield") or 304)) end end + + for output, recipes in pairs(exchangeclone.recipes) do + if output:find("silicon") then + for _, recipe in ipairs(recipes) do + minetest.log(dump(recipe)) + end + end + end + -- Free up memory (I assume this will do that?) exchangeclone.recipes = nil exchangeclone.energy_values = nil diff --git a/_exchangeclone_energy/mod.conf b/_exchangeclone_energy/mod.conf index cb239b2..fc297a0 100644 --- a/_exchangeclone_energy/mod.conf +++ b/_exchangeclone_energy/mod.conf @@ -1,4 +1,4 @@ name = _exchangeclone_energy title = ExchangeClone Energy depends = exchangeclone, zzzz_exchangeclone_crafthook -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, _mcl_autogroup \ No newline at end of file +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, _mcl_autogroup, unified_inventory \ No newline at end of file diff --git a/exchangeclone/alchemical_chest.lua b/exchangeclone/alchemical_chest.lua index 1e9ac38..edb6877 100644 --- a/exchangeclone/alchemical_chest.lua +++ b/exchangeclone/alchemical_chest.lua @@ -17,7 +17,7 @@ for _, color in colors do local itemstring = "exchangeclone:"..lower_color.."_advanced_alchemical_chest" minetest.register_node(itemstring, { description = color.." Alchemical Chest", - groups = {container = 1, alchemical_chest = 1}, + groups = {container = 2, alchemical_chest = 1}, after_place_node = function(pos, player, itemstack, pointed_thing) local meta = minetest.get_meta(pos) meta:set_string("formspec", alchemical_formspec(color)) diff --git a/exchangeclone/armor.lua b/exchangeclone/armor.lua index 051d933..8595e80 100644 --- a/exchangeclone/armor.lua +++ b/exchangeclone/armor.lua @@ -294,9 +294,9 @@ if minetest.get_modpath("3d_armor") then minetest.register_craft({ output = "exchangeclone:shield_red_matter", recipe = { - {d,d,d}, - {d,d,d}, - {"exchangeclone:shield_dark_matter",d,""}, + {r,r,r}, + {r,r,r}, + {"exchangeclone:shield_dark_matter",r,""}, } }) end \ No newline at end of file diff --git a/exchangeclone/craftitems.lua b/exchangeclone/craftitems.lua index 6cc3d7b..8f63df0 100644 --- a/exchangeclone/craftitems.lua +++ b/exchangeclone/craftitems.lua @@ -109,7 +109,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = "exchangeclone:dark_matter_block 4", + output = "exchangeclone:dark_matter_block", recipe = { {"exchangeclone:dark_matter", "exchangeclone:dark_matter"}, {"exchangeclone:dark_matter", "exchangeclone:dark_matter"} @@ -117,7 +117,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = "exchangeclone:red_matter_block 4", + output = "exchangeclone:red_matter_block", recipe = { {"exchangeclone:red_matter", "exchangeclone:red_matter"}, {"exchangeclone:red_matter", "exchangeclone:red_matter"} @@ -127,15 +127,13 @@ minetest.register_craft({ minetest.register_craft({ output = "exchangeclone:dark_matter 4", recipe = { - {"exchangeclone:dark_matter_block","exchangeclone:dark_matter_block"}, - {"exchangeclone:dark_matter_block","exchangeclone:dark_matter_block"} + {"exchangeclone:dark_matter_block"} } }) minetest.register_craft({ output = "exchangeclone:red_matter 4", recipe = { - {"exchangeclone:red_matter_block","exchangeclone:red_matter_block"}, - {"exchangeclone:red_matter_block","exchangeclone:red_matter_block"} + {"exchangeclone:red_matter_block",} } }) \ No newline at end of file diff --git a/exchangeclone/deconstructor.lua b/exchangeclone/deconstructor.lua index 793222a..954231d 100644 --- a/exchangeclone/deconstructor.lua +++ b/exchangeclone/deconstructor.lua @@ -69,7 +69,7 @@ local function deconstructor_action(pos) end local stack = inv:get_stack("src", 1) local individual_energy_value = exchangeclone.get_item_energy(stack:get_name()) - if individual_energy_value and individual_energy_value <= 0 then return end + if not (individual_energy_value and individual_energy_value > 0) then return end local wear = stack:get_wear() if wear and wear > 1 then individual_energy_value = math.floor(individual_energy_value * (65536 / wear)) diff --git a/exchangeclone/hopper_compat.lua b/exchangeclone/hopper_compat.lua new file mode 100644 index 0000000..9e41df4 --- /dev/null +++ b/exchangeclone/hopper_compat.lua @@ -0,0 +1,29 @@ +-- Runs only if the hopper mod is detected. This pretty much makes it so that anything that works with +-- MineClone hoppers will automatically work with other hoppers. + +hopper:add_container({ + {"top", "group:container=2", "main"}, + {"bottom", "group:container=2", "main"}, + {"side", "group:container=2", "main"}, +}) + +-- Intentionally skipping 3, because I don't know if it would still block shulkers + +-- If this doesn't start the node timer for the furnace, it won't work. +hopper:add_container({ + {"top", "group:container=4", "src"}, + {"side", "group:container=4", "fuel"}, + {"bottom", "group:container=4", "dst"}, +}) + +-- Hoppers will only be able to insert into one side of a double chest (unless you have 1 hopper per side) +hopper:add_container({ + {"top", "group:container=5", "main"}, + {"bottom", "group:container=5", "main"}, + {"side", "group:container=5", "main"}, +}) +hopper:add_container({ + {"top", "group:container=6", "main"}, + {"bottom", "group:container=6", "main"}, + {"side", "group:container=6", "main"}, +}) \ No newline at end of file diff --git a/exchangeclone/init.lua b/exchangeclone/init.lua index ceb8e59..53efd1c 100644 --- a/exchangeclone/init.lua +++ b/exchangeclone/init.lua @@ -14,7 +14,7 @@ exchangeclone.orb_max = 51200000 -- Max capacity of Klein Star Omega in ProjectE local modpath = minetest.get_modpath("exchangeclone") -exchangeclone.orb_max = minetest.settings:get("exchangeclone.orb_max") or 5 +exchangeclone.orb_max = minetest.settings:get("exchangeclone.orb_max") or 51200000 exchangeclone.num_passes = minetest.settings:get("exchangeclone.num_passes") or 10 dofile(modpath.."/lib.lua") @@ -29,6 +29,7 @@ end if exchangeclone.mcl then mcl_item_id.set_mod_namespace("exchangeclone") dofile(modpath.."/shears.lua") + dofile(modpath.."/tool_upgrades.lua") end dofile(modpath.."/multidig.lua") dofile(modpath.."/swords.lua") @@ -38,8 +39,8 @@ dofile(modpath.."/pickaxes.lua") dofile(modpath.."/hammers.lua") dofile(modpath.."/shovels.lua") dofile(modpath.."/red_matter_multitools.lua") -if exchangeclone.mcl then - dofile(modpath.."/tool_upgrades.lua") +if minetest.get_modpath("hopper") then + dofile(modpath.."/hopper_compat.lua") end dofile(modpath.."/philosophers_stone.lua") dofile(modpath.."/pesa.lua") diff --git a/exchangeclone/lib.lua b/exchangeclone/lib.lua index 17edd86..e460c49 100644 --- a/exchangeclone/lib.lua +++ b/exchangeclone/lib.lua @@ -15,6 +15,7 @@ end function exchangeclone.get_item_energy(item) if (item == "") or not item then return end + -- handle groups 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 @@ -34,9 +35,10 @@ function exchangeclone.get_item_energy(item) end return cheapest end + -- handle items/itemstacks item = ItemStack(item) - local meta_energy_value = item:get_meta():get_int("exchangeclone_energy_value") - if meta_energy_value > 0 then + local meta_energy_value = tonumber(item:get_meta():get_string("exchangeclone_energy_value")) + if meta_energy_value and meta_energy_value > 0 then return meta_energy_value end local def = minetest.registered_items[item:get_name()] @@ -85,16 +87,11 @@ end -- Decides what mod to use for sounds if exchangeclone.mcl then exchangeclone.sound_mod = mcl_sounds else exchangeclone.sound_mod = default end --- Sets the amount of energy in an orb in a specific inventory slot -function exchangeclone.set_orb_energy(inventory, listname, index, amount) - if not inventory or amount < 0 then return end - if not listname then listname = "main" end - if not index then index = 1 end - local itemstack = inventory:get_stack(listname, index) - if not itemstack then return end - if itemstack:get_name() ~= "exchangeclone:exchange_orb" then return end +function exchangeclone.set_orb_itemstack_energy(itemstack, amount) + if not itemstack or not amount then return minetest.log(">:(") end + if itemstack:get_name() ~= "exchangeclone:exchange_orb" then minetest.log(":O") return end local old_energy = exchangeclone.get_orb_itemstack_energy(itemstack) - if amount > old_energy and old_energy > exchangeclone.orb_max then return end -- don't allow more energy to be put into an over-filled orb + if amount > old_energy and old_energy > exchangeclone.orb_max then minetest.log(":(") return end -- don't allow more energy to be put into an over-filled orb -- Square roots will hopefully make it less linear -- And if they don't, I don't really care and I don't want to think about math anymore. @@ -102,7 +99,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) @@ -118,12 +115,23 @@ function exchangeclone.set_orb_energy(inventory, listname, index, amount) end local colorstring = minetest.rgba(r,g,b) - + minetest.log(colorstring) local meta = itemstack:get_meta() meta:set_float("stored_energy", amount) meta:set_string("description", "Exchange Orb\nCurrent Charge: "..amount) meta:set_string("color", colorstring) - inventory:set_stack(listname, index, itemstack) + return itemstack +end + +-- Sets the amount of energy in an orb in a specific inventory slot +function exchangeclone.set_orb_energy(inventory, listname, index, amount) + if not inventory or not amount or amount < 0 then return end + if not listname then listname = "main" end + if not index then index = 1 end + local itemstack = inventory:get_stack(listname, index) + local new_stack = exchangeclone.set_orb_itemstack_energy(itemstack, amount) + if not new_stack then minetest.log("D:") return end + inventory:set_stack(listname, index, new_stack) end -- HUD stuff (show energy value in bottom right) @@ -170,10 +178,17 @@ end -- Set a player's personal energy function exchangeclone.set_player_energy(player, amount) if not (player and amount) then return end + if amount < 0 or amount > exchangeclone.limit then return end player:get_meta():set_string("exchangeclone_stored_energy", tonumber(amount)) exchangeclone.update_hud(player) end +-- Add to a player's personal energy (amount can be negative) +function exchangeclone.add_player_energy(player, amount) + if not (player and amount) then return end + exchangeclone.set_player_energy(exchangeclone.get_player_energy(player) + amount) +end + -- copied from http://lua-users.org/wiki/IntegerDomain -- Basically gets the highest number Lua supports @@ -198,6 +213,19 @@ while step > 0 do step = math.floor(step/2) end +exchangeclone.limit = exchangeclone.limit/100 -- (to account for .25) + +function exchangeclone.split (input, sep) + if sep == nil then + sep = "%s" + end + local result={} + for str in string.gmatch(input, "([^"..sep.."]+)") do + table.insert(result, str) + end + return result +end + -- Returns a table of all items in the specified group(s). function exchangeclone.get_group_items(groups, allow_duplicates, include_no_group) if type(groups) ~= "table" then @@ -211,10 +239,10 @@ function exchangeclone.get_group_items(groups, allow_duplicates, include_no_grou allow_duplicates = allow_duplicates or false include_no_group = include_no_group or false - local g_cnt = #groups + local num_groups = #groups local result = {} - for i = 1, g_cnt do + for i = 1, num_groups do result[groups[i]] = {} end if include_no_group then @@ -224,9 +252,17 @@ function exchangeclone.get_group_items(groups, allow_duplicates, include_no_grou for name, def in pairs(minetest.registered_items) do in_group = false - for i = 1, g_cnt do + for i = 1, num_groups do local grp = groups[i] - if def.groups[grp] ~= nil then + local subgroups = exchangeclone.split(grp, ",") + local success = true + for _, subgroup in ipairs(subgroups) do + if not def.groups[subgroup] then + success = false + break + end + end + if success then result[grp][#result[grp]+1] = name in_group = true if allow_duplicates == false then diff --git a/exchangeclone/transmutation_table.lua b/exchangeclone/transmutation_table.lua index 59a73d3..9e0ecdd 100644 --- a/exchangeclone/transmutation_table.lua +++ b/exchangeclone/transmutation_table.lua @@ -134,7 +134,7 @@ local function handle_inventory(player, inventory, to_list) local orb_energy = exchangeclone.get_orb_itemstack_energy(stack) local charge_amount = math.min(exchangeclone.orb_max - orb_energy, player_energy) if charge_amount > 0 then - exchangeclone.set_player_energy(player, player_energy - charge_amount) + exchangeclone.add_player_energy(player, 0-charge_amount) exchangeclone.set_orb_energy(inventory, to_list, 1, orb_energy + charge_amount) exchangeclone.show_transmutation_table_formspec(player) end diff --git a/settingtypes.txt b/settingtypes.txt index 576fc2a..5b8aff0 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -1,5 +1,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) +# The number of times ExchangeClone goes through the list of items. More means slightly longer load times, but also means that more items are likely to have energy values. exchangeclone.num_passes (Energy value number of passes) int 10 \ No newline at end of file diff --git a/zzzz_exchangeclone_crafthook/init.lua b/zzzz_exchangeclone_crafthook/init.lua index c8c4acd..e4020a1 100644 --- a/zzzz_exchangeclone_crafthook/init.lua +++ b/zzzz_exchangeclone_crafthook/init.lua @@ -1,4 +1,3 @@ -minetest.log("Wrapping craft function") exchangeclone = {recipes = {}} local old_func = minetest.register_craft @@ -7,6 +6,32 @@ function minetest.register_craft(arg, ...) local itemstring = ItemStack(arg.output):get_name() exchangeclone.recipes[itemstring] = exchangeclone.recipes[itemstring] or {} table.insert(exchangeclone.recipes[itemstring], table.copy(arg)) + --[[ -- reverse cooking recipes too + if arg.type == "cooking" then + itemstring = ItemStack(arg.recipe):get_name() + local reverse_arg = table.copy(arg) + reverse_arg.recipe, reverse_arg.output = reverse_arg.output, reverse_arg.recipe + exchangeclone.recipes[itemstring] = exchangeclone.recipes[itemstring] or {} + table.insert(exchangeclone.recipes[itemstring], table.copy(reverse_arg)) + end --]] end old_func(arg, ...) +end + +if minetest.get_modpath("technic") then + local function register_technic_recipe(recipe) + local result = {recipe = recipe.input, output = recipe.output, type = "technic"} + --minetest.log(dump(result)) + local output_itemstring = ItemStack(recipe.output):get_name() + exchangeclone.recipes[output_itemstring] = exchangeclone.recipes[output_itemstring] or {} + table.insert(exchangeclone.recipes[output_itemstring], result) + end + function exchangeclone.register_technic_recipe(typename, recipe) + local data = technic.recipes[typename] + if (data.output_size == 1) then + if data.output_size == 1 then + register_technic_recipe(table.copy(recipe)) + end + end + end end \ No newline at end of file