Compare commits

...

4 Commits

Author SHA1 Message Date
ThePython 0017430f8f Fix wrong texture 2024-02-13 17:19:43 -08:00
ThePython 0614b399ec Changed "energy" to "EMC," added awards 2024-02-13 17:12:48 -08:00
ThePython10110 b4a5c2b4a6
Started changing "energy" to "EMC" 2024-02-13 13:51:51 -08:00
ThePython10110 09724f2464
Added awards (untested) 2024-02-13 13:33:56 -08:00
19 changed files with 467 additions and 216 deletions

View File

@ -1,18 +1,18 @@
# ExchangeClone # ExchangeClone
[![ContentDB](https://content.minetest.net/packages/ThePython/exchangeclone/shields/downloads/)](https://content.minetest.net/packages/ThePython/exchangeclone/) [![ContentDB](https://content.minetest.net/packages/ThePython/exchangeclone/shields/downloads/)](https://content.minetest.net/packages/ThePython/exchangeclone/)
Allows players to turn items into energy, and energy into items. Supports all items in Minetest Game, Technic, More Ores, and MineClone2/Mineclonia, as well as anything that can be made from them! Also adds a whole bunch of other stuff. Allows players to turn items into energy (known as EMC, or Energy Matter Covalence), and energy into items. Supports all items in Minetest Game, Technic, More Ores, and MineClone2/Mineclonia, as well as anything that can be made from them! Also adds a whole bunch of other stuff.
If you would like to see the latest changes, check out (pun) the dev branch! Beware of bugs. If you would like to see the latest changes, check out (pun) the dev branch! Beware of bugs.
ExchangeClone is tested with the latest release of Minetest, Minetest Game, MineClone2, and Mineclonia. ExchangeClone is tested with the latest release of Minetest, Minetest Game, MineClone2, and Mineclonia.
## ExchangeClone's Features: ## ExchangeClone's Features:
* Energy * EMC
* Philosopher's Stone * Philosopher's Stone
* Transmutation Table * Transmutation Table
* Alchemical Tome * Alchemical Tome
* Exchange Orb * Klein Stars
* Deconstructor * Deconstructor
* Constructor * Constructor
* Energy Collectors * Energy Collectors
@ -21,7 +21,6 @@ ExchangeClone is tested with the latest release of Minetest, Minetest Game, Mine
* Dark and Red Matter Tools * Dark and Red Matter Tools
* Dark and Red Matter Armor * Dark and Red Matter Armor
* Dark and Red Matter Furnaces * Dark and Red Matter Furnaces
* PESA (deprecated, WILL BE REMOVED in 7.0)
See the [wiki](https://github.com/ThePython10110/ExchangeClone/wiki) for more information See the [wiki](https://github.com/ThePython10110/ExchangeClone/wiki) for more information
@ -65,21 +64,22 @@ Dependencies: Minetest Game or MineClone.
### PLANS/TODO FOR v7.0 (see dev branch for current progress) ### PLANS/TODO FOR v7.0 (see dev branch for current progress)
* [ ] Achievements/advancements/awards * [x] Achievements/advancements/awards
* [ ] Textures/sounds from ProjectE/ProjectExpansion (I wanted this for a while, but I couldn't figure out how to get permission until I saw [this tweet](https://twitter.com/MercuriusXeno/status/1662203934713212932) from the creator of Equivalent Exchange) * [x] Textures/sounds from ProjectE/ProjectExpansion (I wanted this for a while, but I couldn't figure out how to get permission until I saw [this tweet](https://twitter.com/MercuriusXeno/status/1662203934713212932) from the creator of Equivalent Exchange)
* [x] Change "energy" to EMC
* [ ] Improvements to tools (mostly only in MCL at the moment) * [ ] Improvements to tools (mostly only in MCL at the moment)
* [x] Wear bar for charge level * [x] Wear bar for charge level
* [x] Charge levels match ProjectE (both in number and in range) * [x] Charge levels match ProjectE (both in number and in range)
* [x] Charge level affects speed * [x] Charge level affects speed
* [x] Correct/accurate speeds compared to ProjectE (hopefully) * [x] Correct/accurate speeds compared to ProjectE (hopefully)
* [x] Wear bar on Exchange Orbs for energy * [x] Wear bar on Exchange Orbs for EMC
* [x] Only one item per tool (not a separate 3x3 tool) * [x] Only one item per tool (not a separate 3x3 tool)
* [x] Make Philosopher's Stone only affect the node type you click on (and also not work when not pointed at anything), so clicking on a grass block will only transmute grass blocks in range (not everything else) * [x] Make Philosopher's Stone only affect the node type you click on (and also not work when not pointed at anything), so clicking on a grass block will only transmute grass blocks in range (not everything else)
* [x] Shovels can remove paths (MCL2) * [x] Shovels can remove paths (MCL2)
* [x] Changes to armor (but it's so hard to get it right) * [x] Changes to armor (but it's so hard to get it right)
* Unfortunately, due to an [engine bug](https://github.com/minetest/minetest/issues/14344), this means that players are kind of invincible most of the time. * Unfortunately, due to an [engine bug](https://github.com/minetest/minetest/issues/14344), this means that players are kind of invincible most of the time.
* [ ] Remove and add alias for DM/RM shields * [x] Remove and add alias for DM/RM shields
* [ ] Upgrades affect energy value * [ ] Upgrades affect EMC value
* [x] Multiple levels of Exchange Orbs (change to Klein Stars, adjust recipes) * [x] Multiple levels of Exchange Orbs (change to Klein Stars, adjust recipes)
* [x] Fuel storage blocks * [x] Fuel storage blocks
* [ ] Divining rods * [ ] Divining rods
@ -89,6 +89,7 @@ Dependencies: Minetest Game or MineClone.
* [ ] Gem of Eternal Density (will only work in player inventory, not Alchemical Chests like ProjectE) * [ ] Gem of Eternal Density (will only work in player inventory, not Alchemical Chests like ProjectE)
* [ ] DM/RM blocks can only be broken by correct (or higher) type. * [ ] DM/RM blocks can only be broken by correct (or higher) type.
* [ ] Change energy collector recipes to match ProjectE * [ ] Change energy collector recipes to match ProjectE
* [ ] Update screenshots
* [ ] Edit wiki: * [ ] Edit wiki:
* [ ] Achievements? * [ ] Achievements?
* [ ] Divining rods * [ ] Divining rods
@ -99,6 +100,7 @@ Dependencies: Minetest Game or MineClone.
* [ ] Modify tools page * [ ] Modify tools page
* [ ] Klein Stars * [ ] Klein Stars
* [ ] Remove page for PESA * [ ] Remove page for PESA
* [ ] Update screenshots
## Changelog ## Changelog
<details><summary>Look at this fancy expanding changelog</summary> <details><summary>Look at this fancy expanding changelog</summary>

View File

@ -363,7 +363,7 @@ minetest.register_craft({
if exchangeclone.mtg then if exchangeclone.mtg then
minetest.register_tool("exchangeclone:shield_dark_matter", { minetest.register_tool("exchangeclone:shield_dark_matter", {
description = "Dark Matter Shield (deprecated)\nYou still have this so you can turn it into energy.\nAnd no, it's not supposed to have a texture.", description = "Dark Matter Shield (deprecated)\nYou still have this so you can turn it into EMC.\nAnd no, it's not supposed to have a texture.",
groups = {disable_repair = 1, not_in_creative_inventory = 1} groups = {disable_repair = 1, not_in_creative_inventory = 1}
}) })
exchangeclone.register_craft({ exchangeclone.register_craft({
@ -381,7 +381,7 @@ if exchangeclone.mtg then
}) })
minetest.register_tool("exchangeclone:shield_red_matter", { minetest.register_tool("exchangeclone:shield_red_matter", {
description = "Red Matter Shield (deprecated)\nYou still have this so you can turn it into energy.\nAnd no, it's not supposed to have a texture.", description = "Red Matter Shield (deprecated)\nYou still have this so you can turn it into EMC.\nAnd no, it's not supposed to have a texture.",
groups = {disable_repair = 1, not_in_creative_inventory = 1} groups = {disable_repair = 1, not_in_creative_inventory = 1}
}) })
exchangeclone.register_craft({ exchangeclone.register_craft({

246
exchangeclone/awards.lua Normal file
View File

@ -0,0 +1,246 @@
local register_award = exchangeclone.mcl and awards.register_achievement or awards.register_award
register_award("exchangeclone:best_friend", {
title = "An alchemist's best friend",
description = "Let's get things started! Craft a Philosopher's Stone",
icon = "exchangeclone_philosophers_stone.png",
trigger = {
type = "craft",
item = "exchangeclone:philosophers_stone",
target = 1,
}
})
register_award("exchangeclone:this_into_that", {
title = "Transmute this into that!",
description = "The beginning (and end) of everything.",
icon = "exchangeclone_transmutation_table_top.png",
trigger = {
type = "craft",
item = "exchangeclone:transmutation_table",
target = 1,
}
})
register_award("exchangeclone:on_the_go", {
title = "Transmutation on the go!",
description = "And then you thought things couldn't get better.",
icon = "exchangeclone_transmutation_tablet.png",
trigger = {
type = "craft",
item = "exchangeclone:transmutation_tablet",
target = 1,
}
})
register_award("exchangeclone:emc_batteries", {
title = "EMC Batteries",
description = "Storing EMC for a rainy day.",
icon = "exchangeclone_klein_star_ein.png",
trigger = {
type = "craft",
item = "exchangeclone:klein_star_ein",
target = 1,
}
})
register_award("exchangeclone:big_emc_batteries", {
title = "BIG EMC Batteries",
description = "Holding the universe in your pocket.",
icon = "exchangeclone_klein_star_omega.png",
trigger = {
type = "craft",
item = "exchangeclone:klein_star_omega",
target = 1,
}
})
register_award("exchangeclone:massive_emc_batteries", {
title = "MASSIVE EMC Batteries",
description = "Holding... uhh... the multiverse in your pocket.",
icon = "exchangeclone_magnum_star_omega.png",
trigger = {
type = "craft",
item = "exchangeclone:magnum_star_omega",
target = 1,
}
})
register_award("exchangeclone:storage_upgrade", {
title = "Storage Upgrade!",
description = 'A "little" chest upgrade.',
icon = "exchangeclone_alchemical_chest_top.png",
trigger = {
type = "craft",
item = "exchangeclone:alchemical_chest",
target = 1,
}
})
register_award("exchangeclone:matter_on_matter", {
title = "Using Matter on Matter?",
description = "Because why not?",
icon = "exchangeclone_dark_matter_pickaxe.png",
target = 1,
trigger = {
type = "craft",
item = "exchangeclone:dark_matter_pickaxe",
target = 1,
}
})
register_award("exchangeclone:is_this_safe", {
title = "Is this thing safe?",
description = "Probably not.",
icon = "exchangeclone_red_matter_pickaxe.png",
trigger = {
type = "craft",
item = "exchangeclone:red_matter_pickaxe",
target = 1,
}
})
register_award("exchangeclone:hot_matter", {
title = "Hot matter!",
description = "A furnace is even better when made from dark matter.",
icon = "exchangeclone_dark_matter_furnace_active.png",
trigger = {
type = "craft",
item = "exchangeclone:dark_matter_furnace",
target = 1,
}
})
register_award("exchangeclone:even_hotter_matter", {
title = "Even hotter matter!",
description = "Wow, that thing is fast.",
icon = "exchangeclone_red_matter_furnace_active.png",
trigger = {
type = "craft",
item = "exchangeclone:red_matter_furnace",
target = 1,
}
})
-- MCL2 does not support groups in awards for some reason.
-- https://git.minetest.land/MineClone2/MineClone2/issues/4191
if not exchangeclone.mcl2 then
register_award("exchangeclone:pocket_storage", {
title = "Pocket storage!",
description = "All the wonders of an alchemical chest, in your pocket.",
icon = "exchangeclone_alchemical_bag.png",
trigger = {
type = "craft",
item = "group:alchemical_bag",
target = 1,
}
})
register_award("exchangeclone:power_of_sun", {
title = "The power of the sun!",
description = "Now the fun begins.",
icon = "exchangeclone_energy_collector_base.png^exchangeclone_energy_collector_overlay.png",
trigger = "craft",
item = "group:energy_collector",
target = 1,
})
end
register_award("exchangeclone:all_that_matters", {
title = "All that Matters.",
description = "It looks... weird....",
icon = "exchangeclone_dark_matter.png",
trigger = {
type = "craft",
item = "exchangeclone:dark_matter",
target = 1,
}
})
register_award("exchangeclone:even_better_matter", {
title = "Even better Matter!",
description = "The space time continuum may be broken.",
icon = "exchangeclone_red_matter.png",
trigger = {
type = "craft",
item = "exchangeclone:red_matter",
target = 1,
}
})
register_award("exchangeclone:red_and_shiny", {
title = "Red and shiny!",
description = "Now you're getting somewhere!",
icon = "exchangeclone_red_matter_block.png",
trigger = {
type = "craft",
item = "exchangeclone:red_matter_block",
target = 1,
}
})
register_award("exchangeclone:block_that_matters", {
title = "A block that Matters!",
description = "Stuffing matter together. Because that's a good idea.",
icon = "exchangeclone_dark_matter_block.png",
trigger = {
type = "craft",
item = "exchangeclone:dark_matter_block",
target = 1,
}
})
register_award("exchangeclone:artificial_enchantment", {
title = "Artificial enchantment!",
description = "Why use magic when alchemy works just as well?",
icon = "exchangeclone_upgrader_side.png",
trigger = {
type = "craft",
item = "exchangeclone:upgrader",
target = 1,
}
})
register_award("exchangeclone:things_into_emc", {
title = "Turn things into EMC!",
description = "A trash can, but useful.",
icon = "exchangeclone_deconstructor_up.png",
trigger = {
type = "craft",
item = "exchangeclone:deconstructor",
target = 1,
}
})
register_award("exchangeclone:energetic_duplication", {
title = "Energetic duplication!",
description = "Not a trash can, but useful.",
icon = "exchangeclone_constructor_up.png",
trigger = {
type = "craft",
item = "exchangeclone:constructor",
target = 1
}
})
register_award("exchangeclone:one_thousand_damage", {
title = "One thousand damage!",
description = "Now that's overpowered.",
icon = "exchangeclone_red_katar.png",
trigger = {
type = "craft",
item = "exchangeclone:red_katar",
target = 1
}
})
register_award("exchangeclone:better_matter_miner", {
title = "Better matter miner!",
description = "Even better than all other miners made of matter.",
icon = "exchangeclone_red_morningstar.png",
trigger = {
type = "craft",
item = "exchangeclone:red_morningstar",
target = 1
}
})

View File

@ -45,22 +45,22 @@ local function constructor_action(pos)
end end
end end
local result = exchangeclone.handle_alias(src_stack) local result = exchangeclone.handle_alias(src_stack)
-- make sure star/player has enough energy -- make sure star/player has enough EMC
local current_energy local current_emc
if using_star then if using_star then
current_energy = exchangeclone.get_star_energy(inv, "fuel", 1) current_emc = exchangeclone.get_star_emc(inv, "fuel", 1)
else else
current_energy = exchangeclone.get_player_energy(player) current_emc = exchangeclone.get_player_emc(player)
end end
local energy_value = exchangeclone.get_item_energy(src_stack:get_name()) local emc_value = exchangeclone.get_item_emc(src_stack:get_name())
if energy_value and energy_value > 0 then if emc_value and emc_value > 0 then
local max_amount = math.min(src_stack:get_stack_max(), math.floor(current_energy/energy_value)) local max_amount = math.min(src_stack:get_stack_max(), math.floor(current_emc/emc_value))
local added_amount = max_amount - inv:add_item("dst", ItemStack(result.." "..max_amount)):get_count() local added_amount = max_amount - inv:add_item("dst", ItemStack(result.." "..max_amount)):get_count()
local result_energy = math.min(current_energy, current_energy - (energy_value * added_amount)) -- not sure if "math.min()" is necessary local result_emc = math.min(current_emc, current_emc - (emc_value * added_amount)) -- not sure if "math.min()" is necessary
if using_star then if using_star then
exchangeclone.set_star_energy(inv, "fuel", 1, result_energy) exchangeclone.set_star_emc(inv, "fuel", 1, result_emc)
else else
exchangeclone.set_player_energy(player, result_energy) exchangeclone.set_player_emc(player, result_emc)
end end
end end
end end

View File

@ -80,7 +80,7 @@ local function is_repairable_gear(item)
item = ItemStack(item) item = ItemStack(item)
if item:get_wear() <= 0 then return end if item:get_wear() <= 0 then return end
if minetest.get_item_group(item:get_name(), "disable_repair") > 0 then return end if minetest.get_item_group(item:get_name(), "disable_repair") > 0 then return end
if (exchangeclone.get_item_energy(item) or 0) <= 0 then return end if (exchangeclone.get_item_emc(item) or 0) <= 0 then return end
local result = 0 local result = 0
for group, amount in pairs(exchangeclone.tool_types) do for group, amount in pairs(exchangeclone.tool_types) do
@ -125,11 +125,11 @@ minetest.register_on_player_inventory_action(function(player, action, inventory,
if gear_stack:is_empty() or dust_stack:is_empty() then return end if gear_stack:is_empty() or dust_stack:is_empty() then return end
if not inventory:room_for_item("exchangeclone_covalence_output", gear_stack) then return end if not inventory:room_for_item("exchangeclone_covalence_output", gear_stack) then return end
local amount = is_repairable_gear(gear_stack) local amount = is_repairable_gear(gear_stack)
local energy_value = exchangeclone.get_item_energy(gear_stack) local emc_value = exchangeclone.get_item_emc(gear_stack)
local tier = 3 local tier = 3
if energy_value/amount < 50 then if emc_value/amount < 50 then
tier = 1 tier = 1
elseif energy_value/amount < 6000 then elseif emc_value/amount < 6000 then
tier = 2 tier = 2
end end
if minetest.get_item_group(dust_stack:get_name(), "covalence_dust") >= tier and dust_stack:get_count() >= amount then if minetest.get_item_group(dust_stack:get_name(), "covalence_dust") >= tier and dust_stack:get_count() >= amount then

View File

@ -38,32 +38,32 @@ local function deconstructor_action(pos, elapsed)
end end
local stack = inv:get_stack("src", 1) local stack = inv:get_stack("src", 1)
local individual_energy_value = exchangeclone.get_item_energy(stack:get_name()) local individual_emc_value = exchangeclone.get_item_emc(stack:get_name())
if not (individual_energy_value and individual_energy_value > 0) then return end if not (individual_emc_value and individual_emc_value > 0) then return end
local wear = stack:get_wear() local wear = stack:get_wear()
if wear and wear > 0 then if wear and wear > 0 then
individual_energy_value = math.max(math.floor(individual_energy_value * ((65536 - wear)/65536)), 1) individual_emc_value = math.max(math.floor(individual_emc_value * ((65536 - wear)/65536)), 1)
end end
if minetest.get_item_group(stack:get_name(), "klein_star") > 0 then if minetest.get_item_group(stack:get_name(), "klein_star") > 0 then
individual_energy_value = individual_energy_value + exchangeclone.get_star_itemstack_energy(stack) individual_emc_value = individual_emc_value + exchangeclone.get_star_itemstack_emc(stack)
end end
local current_energy local current_emc
if using_star then if using_star then
current_energy = exchangeclone.get_star_energy(inv, "fuel", 1) current_emc = exchangeclone.get_star_emc(inv, "fuel", 1)
else else
current_energy = exchangeclone.get_player_energy(player) current_emc = exchangeclone.get_player_emc(player)
end end
local max_count = math.floor((limit - current_energy)/individual_energy_value) local max_count = math.floor((limit - current_emc)/individual_emc_value)
local add_count = math.min(max_count, stack:get_count()) local add_count = math.min(max_count, stack:get_count())
local energy_value = individual_energy_value * add_count local emc = individual_emc_value * add_count
local result = current_energy + energy_value local result = current_emc + emc
if result < 0 or result > limit then return end if result < 0 or result > limit then return end
if using_star then if using_star then
exchangeclone.set_star_energy(inv, "fuel", 1, result) exchangeclone.set_star_emc(inv, "fuel", 1, result)
else else
exchangeclone.set_player_energy(player, result) exchangeclone.set_player_emc(player, result)
end end
stack:set_count(stack:get_count() - add_count) stack:set_count(stack:get_count() - add_count)
if stack:get_count() == 0 then stack = ItemStack("") end if stack:get_count() == 0 then stack = ItemStack("") end

View File

@ -55,25 +55,25 @@ local function on_timer(pos, elapsed)
if light and light >= 14 then if light and light >= 14 then
if check_for_furnaces(pos, 1, true) then if check_for_furnaces(pos, 1, true) then
-- do nothing, energy is being used for the furnace. -- do nothing, emc is being used for the furnace.
return true return true
end end
local amount = meta:get_int("collector_amount") local amount = meta:get_int("collector_amount")
if using_star then if using_star then
local max = exchangeclone.get_star_max(inv:get_stack("main", 1)) local max = exchangeclone.get_star_max(inv:get_stack("main", 1))
local stored = exchangeclone.get_star_energy(inv, "main", 1) local stored = exchangeclone.get_star_emc(inv, "main", 1)
if stored + amount <= max then if stored + amount <= max then
stored = stored + amount stored = stored + amount
else else
stored = math.max(stored, max) stored = math.max(stored, max)
end end
exchangeclone.set_star_energy(inv, "main", 1, stored) exchangeclone.set_star_emc(inv, "main", 1, stored)
else else
local placer = meta:get_string("exchangeclone_placer") local placer = meta:get_string("exchangeclone_placer")
if placer and placer ~= "" then if placer and placer ~= "" then
local player = minetest.get_player_by_name(placer) local player = minetest.get_player_by_name(placer)
if player then if player then
exchangeclone.add_player_energy(player, amount) exchangeclone.add_player_emc(player, amount)
end end
end end
end end
@ -120,7 +120,7 @@ end
function exchangeclone.register_energy_collector(itemstring, name, amount, modifier, recipe) function exchangeclone.register_energy_collector(itemstring, name, amount, modifier, recipe)
minetest.register_node(itemstring, { minetest.register_node(itemstring, {
description = name.."\nGenerates "..exchangeclone.format_number(amount).." energy/second", description = name.."\nGenerates "..exchangeclone.format_number(amount).." EMC/second",
tiles = { tiles = {
"exchangeclone_energy_collector_base.png^(exchangeclone_energy_collector_overlay.png"..modifier..")", "exchangeclone_energy_collector_base.png^(exchangeclone_energy_collector_overlay.png"..modifier..")",
"exchangeclone_energy_collector_base.png", "exchangeclone_energy_collector_base.png",
@ -129,7 +129,7 @@ function exchangeclone.register_energy_collector(itemstring, name, amount, modif
"exchangeclone_energy_collector_base.png", "exchangeclone_energy_collector_base.png",
"exchangeclone_energy_collector_base.png", "exchangeclone_energy_collector_base.png",
}, },
groups = {cracky = 2, container = 2, pickaxey = 2, energy_collector = amount, tubedevice = 1, tubedevice_receiver = 1}, groups = {cracky = 2, container = 2, pickaxey = 2, energy_collector = 1, tubedevice = 1, tubedevice_receiver = 1},
_mcl_hardness = 3, _mcl_hardness = 3,
_mcl_blast_resistance = 6, _mcl_blast_resistance = 6,
sounds = exchangeclone.sound_mod.node_sound_metal_defaults(), sounds = exchangeclone.sound_mod.node_sound_metal_defaults(),

View File

@ -9,8 +9,8 @@ local function infinite_food_function(itemstack, player, pointed_thing)
if click_test ~= false then if click_test ~= false then
return click_test return click_test
end end
local player_energy = exchangeclone.get_player_energy(player) local player_emc = exchangeclone.get_player_emc(player)
if player_energy >= 64 then if player_emc >= 64 then
if stamina_exists then if stamina_exists then
if stamina.get_saturation(player) >= stamina_max then if stamina.get_saturation(player) >= stamina_max then
return nil return nil
@ -26,20 +26,20 @@ local function infinite_food_function(itemstack, player, pointed_thing)
end end
minetest.register_tool("exchangeclone:infinite_food", { minetest.register_tool("exchangeclone:infinite_food", {
description = S("Infinite Food").."\n"..S("Consumes 64 energy when eaten"), description = S("Infinite Food").."\n"..S("Consumes 64 EMC when eaten"),
wield_image = "farming_bread.png^[colorize:#ffff00:128", wield_image = "farming_bread.png^[colorize:#ffff00:128",
inventory_image = "farming_bread.png^[colorize:#ffff00:128", inventory_image = "farming_bread.png^[colorize:#ffff00:128",
groups = { food = 2, eatable = 8, disable_repair = 1, fire_immune = 1}, groups = { food = 2, eatable = 8, disable_repair = 1, fire_immune = 1},
on_place = exchangeclone.mcl and infinite_food_function, on_place = exchangeclone.mcl and infinite_food_function,
on_secondary_use = exchangeclone.mcl and infinite_food_function, on_secondary_use = exchangeclone.mcl and infinite_food_function,
on_use = exchangeclone.mcl and infinite_food_function, on_use = exchangeclone.mtg and infinite_food_function,
_mcl_saturation = 12.8, _mcl_saturation = 12.8,
}) })
minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, player, pointed_thing) minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, player, pointed_thing)
local player_energy = exchangeclone.get_player_energy(player) local player_emc = exchangeclone.get_player_emc(player)
if itemstack:get_name() == "exchangeclone:infinite_food" then if itemstack:get_name() == "exchangeclone:infinite_food" then
exchangeclone.set_player_energy(player, player_energy - 64) exchangeclone.set_player_emc(player, player_emc - 64)
end end
end) end)

View File

@ -136,12 +136,15 @@ dofile(modpath.."/infinite_food.lua")
dofile(modpath.."/alchemical_chests.lua") dofile(modpath.."/alchemical_chests.lua")
dofile(modpath.."/transmutation_table.lua") dofile(modpath.."/transmutation_table.lua")
dofile(modpath.."/furnaces.lua") dofile(modpath.."/furnaces.lua")
if minetest.get_modpath("awards") then
dofile(modpath.."/awards.lua")
end
minetest.register_on_mods_loaded(function() minetest.register_on_mods_loaded(function()
local energy_start_time = minetest.get_us_time() local emc_start_time = minetest.get_us_time()
minetest.log("action", "[ExchangeClone] Registering energy values") minetest.log("action", "[ExchangeClone] Registering EMC values")
dofile(modpath.."/register_energy.lua") dofile(modpath.."/register_emc.lua")
minetest.log("action", "[ExchangeClone] Done registering energy values ("..((minetest.get_us_time() - energy_start_time)/1000000).." seconds)") minetest.log("action", "[ExchangeClone] Done registering EMC values ("..((minetest.get_us_time() - emc_start_time)/1000000).." seconds)")
end) end)
minetest.log("action", "[ExchangeClone] Done ("..((minetest.get_us_time() - start_time)/1000).." milliseconds)") minetest.log("action", "[ExchangeClone] Done ("..((minetest.get_us_time() - start_time)/1000).." milliseconds)")

View File

@ -6,7 +6,7 @@ local function read_star_charge(itemstack, player, pointed_thing)
return click_test return click_test
end end
local stored = exchangeclone.get_star_itemstack_energy(itemstack) local stored = exchangeclone.get_star_itemstack_emc(itemstack)
minetest.chat_send_player(player:get_player_name(), S("Current Charge: @1", exchangeclone.format_number(stored))) minetest.chat_send_player(player:get_player_name(), S("Current Charge: @1", exchangeclone.format_number(stored)))
return itemstack return itemstack
end end
@ -42,7 +42,7 @@ for i, name in ipairs(names) do
_mcl_generate_description = function(itemstack) _mcl_generate_description = function(itemstack)
return name.."\n"..S( return name.."\n"..S(
"Current Charge: @1/@2", "Current Charge: @1/@2",
exchangeclone.format_number(exchangeclone.get_star_itemstack_energy(itemstack)), exchangeclone.format_number(exchangeclone.get_star_itemstack_emc(itemstack)),
exchangeclone.format_number(capacity) exchangeclone.format_number(capacity)
) )
end end

View File

@ -2,5 +2,5 @@ name = exchangeclone
title = ExchangeClone title = ExchangeClone
description = The main part of the modpack (depends on both the other mods) description = The main part of the modpack (depends on both the other mods)
depends = zzzz_exchangeclone_init depends = zzzz_exchangeclone_init
optional_depends = mcl_core, default, mcl_armor, 3d_armor, mcl_item_id, mobs_mc, hopper, pipeworks, mcl_dispensers optional_depends = mcl_core, default, mcl_armor, 3d_armor, mcl_item_id, mobs_mc, hopper, pipeworks, mcl_dispensers, awards
author = ThePython10110 author = ThePython10110

View File

@ -70,8 +70,8 @@ local function pickaxe_on_use(itemstack, player, pointed_thing)
exchangeclone.start_cooldown(player, "pickaxe", 0.5) exchangeclone.start_cooldown(player, "pickaxe", 0.5)
elseif itemstack:get_name():find("red_") then elseif itemstack:get_name():find("red_") then
exchangeclone.place_torch(player, pointed_thing) exchangeclone.place_torch(player, pointed_thing)
exchangeclone.add_player_energy(player, -math.max(exchangeclone.get_item_energy(exchangeclone.itemstrings.torch) or 0, 8)) exchangeclone.add_player_emc(player, -math.max(exchangeclone.get_item_emc(exchangeclone.itemstrings.torch) or 0, 8))
-- If the torch could not be placed, it still costs energy... not sure how to fix that -- If the torch could not be placed, it still costs EMC... not sure how to fix that
end end
end end
end end

View File

@ -172,8 +172,8 @@ local function morningstar_on_use(itemstack, player, pointed_thing)
exchangeclone.hammer_action(itemstack, player, pointed_thing.under) exchangeclone.hammer_action(itemstack, player, pointed_thing.under)
else else
exchangeclone.place_torch(player, pointed_thing) exchangeclone.place_torch(player, pointed_thing)
exchangeclone.add_player_energy(player, -math.max(exchangeclone.get_item_energy(exchangeclone.itemstrings.torch) or 0, 8)) exchangeclone.add_player_emc(player, -math.max(exchangeclone.get_item_emc(exchangeclone.itemstrings.torch) or 0, 8))
-- If the torch could not be placed, it still costs energy... not sure how to fix that -- If the torch could not be placed, it still costs EMC... not sure how to fix that
return return
end end
elseif sneaking then elseif sneaking then

View File

@ -30,7 +30,7 @@ local function get_cheapest_recipe(itemstring, log)
if replaced and replaced > 0 then if replaced and replaced > 0 then
identical_replacements[item] = replaced - 1 identical_replacements[item] = replaced - 1
else else
local cost = exchangeclone.get_item_energy(item) local cost = exchangeclone.get_item_emc(item)
if (not cost) or cost == 0 then if (not cost) or cost == 0 then
skip = item skip = item
else else
@ -51,7 +51,7 @@ local function get_cheapest_recipe(itemstring, log)
if replaced and replaced > 0 then if replaced and replaced > 0 then
identical_replacements[item] = replaced - 1 identical_replacements[item] = replaced - 1
else else
local cost = exchangeclone.get_item_energy(item) local cost = exchangeclone.get_item_emc(item)
if (not cost) or cost == 0 then if (not cost) or cost == 0 then
skip = item skip = item
else else
@ -71,7 +71,7 @@ local function get_cheapest_recipe(itemstring, log)
if replaced and replaced > 0 then if replaced and replaced > 0 then
identical_replacements[item] = replaced - 1 identical_replacements[item] = replaced - 1
else else
local cost = exchangeclone.get_item_energy(item) local cost = exchangeclone.get_item_emc(item)
if (not cost) or cost == 0 then if (not cost) or cost == 0 then
skip = item skip = item
else else
@ -80,13 +80,13 @@ local function get_cheapest_recipe(itemstring, log)
end end
end end
end end
elseif exchangeclone.craft_types[recipe.type].type == "energy" then elseif exchangeclone.craft_types[recipe.type].type == "emc" then
ingredient_cost = recipe.recipe ingredient_cost = recipe.recipe
end end
if recipe.replacements and not skip then if recipe.replacements and not skip then
for _, item in pairs(recipe.replacements) do for _, item in pairs(recipe.replacements) do
if item[1] ~= item[2] then if item[1] ~= item[2] then
local cost = exchangeclone.get_item_energy(item[2]) local cost = exchangeclone.get_item_emc(item[2])
if (not cost) or cost == 0 then if (not cost) or cost == 0 then
skip = item[2] skip = item[2]
else else
@ -111,35 +111,35 @@ local function get_cheapest_recipe(itemstring, log)
return cheapest and cheapest[1] return cheapest and cheapest[1]
end end
exchangeclone.energy_values = {} exchangeclone.emc_values = {}
-- Sets the energy value of an item, must be called during load time. -- Sets the EMC value of an item, must be called during load time.
local function set_item_energy(itemstring, energy_value) local function set_item_emc(itemstring, emc_value)
if not (energy_value and itemstring) then return end if not (emc_value and itemstring) then return end
energy_value = math.floor(energy_value*20)/20 -- floor to nearest .05 emc_value = math.floor(emc_value*20)/20 -- floor to nearest .05
if energy_value < 0 then return end if emc_value < 0 then return end
local def = minetest.registered_items[itemstring] local def = minetest.registered_items[itemstring]
if not def then return end if not def then return end
local description = def.description or "" local description = def.description or ""
-- Override energy value if it already exists -- Override EMC value if it already exists
local existing_energy_value = description:find("Energy Value: ([%d%.,]+)") local existing_emc_value = description:find("EMC Value: ([%d%.,]+)")
if existing_energy_value then if existing_emc_value then
description = description:gsub("Energy Value: ([%d%.,]+)", "Energy Value: "..exchangeclone.format_number(energy_value)) description = description:gsub("EMC Value: ([%d%.,]+)", "EMC Value: "..exchangeclone.format_number(emc_value))
else else
if description[#description] ~= "\n" then if description[#description] ~= "\n" then
description = description.."\n" description = description.."\n"
end end
description = description.."Energy Value: "..exchangeclone.format_number(energy_value) description = description.."EMC Value: "..exchangeclone.format_number(emc_value)
end end
minetest.override_item(itemstring, { minetest.override_item(itemstring, {
description = description, description = description,
energy_value = energy_value, emc_value = emc_value,
}) })
if energy_value > 0 then if emc_value > 0 then
exchangeclone.energy_values[itemstring] = energy_value exchangeclone.emc_values[itemstring] = emc_value
else else
exchangeclone.energy_values[itemstring] = nil exchangeclone.emc_values[itemstring] = nil
end end
end end
@ -183,7 +183,7 @@ if exchangeclone.mcla then
end end
end end
-- Register clock/compass aliases, handle enchanted/netherite stuff, potions, and concrete, and register coral energy values -- Register clock/compass aliases, handle enchanted/netherite stuff, potions, and concrete, and register coral EMC values
if exchangeclone.mcl then if exchangeclone.mcl then
for i = 0, 31 do for i = 0, 31 do
exchangeclone.register_alias("mcl_compass:18", "mcl_compass:"..i) exchangeclone.register_alias("mcl_compass:18", "mcl_compass:"..i)
@ -261,7 +261,7 @@ if exchangeclone.mcl then
exchangeclone.register_alias("mcl_sponges:sponge", "mcl_sponges:sponge_wet_river_water") exchangeclone.register_alias("mcl_sponges:sponge", "mcl_sponges:sponge_wet_river_water")
end end
-- Register copper block/stonecutting energy recipes in MineClone2 -- Register copper block/stonecutting EMC recipes in MineClone2
if exchangeclone.mcl2 then if exchangeclone.mcl2 then
exchangeclone.register_craft_type("oxidation", "cooking") exchangeclone.register_craft_type("oxidation", "cooking")
local states = {"", "_exposed", "_weathered", "_oxidized"} local states = {"", "_exposed", "_weathered", "_oxidized"}
@ -283,12 +283,11 @@ end
-- Up to this point, no energy values have actually been set. -- Up to this point, no EMC values have actually been set.
-- Register group EMC values
-- Register group energy values
local groupnames = {} local groupnames = {}
for index, group in ipairs(exchangeclone.group_values) do for index, group in ipairs(exchangeclone.group_values) do
groupnames[#groupnames + 1] = group[1] --Get list of group names groupnames[#groupnames + 1] = group[1] --Get list of group names
@ -296,19 +295,19 @@ end
local grouped_items = exchangeclone.get_group_items(groupnames, true, true) local grouped_items = exchangeclone.get_group_items(groupnames, true, true)
for index, group in ipairs(exchangeclone.group_values) do for index, group in ipairs(exchangeclone.group_values) do
for i, item in pairs(grouped_items[group[1]]) do for i, item in pairs(grouped_items[group[1]]) do
set_item_energy(item, group[2]) set_item_emc(item, group[2])
end end
end end
-- Register base energy values -- Register base EMC values
for itemstring, energy_value in pairs(exchangeclone.base_energy_values) do for itemstring, emc_value in pairs(exchangeclone.base_emc_values) do
set_item_energy(itemstring, energy_value) set_item_emc(itemstring, emc_value)
end end
-- Register `exchangeclone_custom_energy` values and decide whether to automatically register energy values -- Register `exchangeclone_custom_emc` values and decide whether to automatically register EMC values
for itemstring, def in pairs(minetest.registered_items) do for itemstring, def in pairs(minetest.registered_items) do
if def.exchangeclone_custom_energy then if def.exchangeclone_custom_emc then
set_item_energy(itemstring, def.exchangeclone_custom_energy) set_item_emc(itemstring, def.exchangeclone_custom_emc)
else else
itemstring = exchangeclone.handle_alias(itemstring) or itemstring itemstring = exchangeclone.handle_alias(itemstring) or itemstring
def = minetest.registered_items[itemstring] -- in case itemstring changed def = minetest.registered_items[itemstring] -- in case itemstring changed
@ -320,7 +319,7 @@ for itemstring, def in pairs(minetest.registered_items) do
and def.description and def.description
and def.description ~= "" and def.description ~= ""
and ((minetest.get_item_group(item_name, "not_in_creative_inventory") < 1) or mod_name == "mcl_compass") and ((minetest.get_item_group(item_name, "not_in_creative_inventory") < 1) or mod_name == "mcl_compass")
and (not exchangeclone.get_item_energy(itemstring)) and (not exchangeclone.get_item_emc(itemstring))
and exchangeclone.recipes[itemstring] and exchangeclone.recipes[itemstring]
) then ) then
auto[itemstring] = true auto[itemstring] = true
@ -342,7 +341,7 @@ end
local old_auto local old_auto
local same = false local same = false
local i = 1 local i = 1
-- Automatically register energy values -- Automatically register EMC values
while not same do while not same do
minetest.log("action", "[ExchangeClone] \tIteration #"..i) minetest.log("action", "[ExchangeClone] \tIteration #"..i)
if auto == {} then break end if auto == {} then break end
@ -363,7 +362,7 @@ while not same do
for itemstring, _ in pairs(auto) do for itemstring, _ in pairs(auto) do
local cheapest = get_cheapest_recipe(itemstring) local cheapest = get_cheapest_recipe(itemstring)
if cheapest then if cheapest then
set_item_energy(itemstring, cheapest) set_item_emc(itemstring, cheapest)
auto[itemstring] = nil auto[itemstring] = nil
end end
end end
@ -371,11 +370,11 @@ while not same do
end end
if exchangeclone.mcl then if exchangeclone.mcl then
set_item_energy("mcl_campfires:campfire", exchangeclone.get_item_energy("mcl_campfires:campfire_lit")) set_item_emc("mcl_campfires:campfire", exchangeclone.get_item_emc("mcl_campfires:campfire_lit"))
set_item_energy("mcl_campfires:soul_campfire", exchangeclone.get_item_energy("mcl_campfires:soul_campfire_lit")) set_item_emc("mcl_campfires:soul_campfire", exchangeclone.get_item_emc("mcl_campfires:soul_campfire_lit"))
-- Recovery compasses use a random compass frame for the crafting recipe... Incredibly irritating. -- Recovery compasses use a random compass frame for the crafting recipe... Incredibly irritating.
for i = 0, 31 do for i = 0, 31 do
if exchangeclone.get_item_energy("mcl_compass:"..i.."_recovery") then if exchangeclone.get_item_emc("mcl_compass:"..i.."_recovery") then
for j = 0, 31 do for j = 0, 31 do
exchangeclone.register_alias("mcl_compass:"..i.."_recovery", "mcl_compass:"..j.."_recovery") exchangeclone.register_alias("mcl_compass:"..i.."_recovery", "mcl_compass:"..j.."_recovery")
end end
@ -388,11 +387,11 @@ local cheapest_color = {""}
for color, color_data in pairs(exchangeclone.colors) do for color, color_data in pairs(exchangeclone.colors) do
local dye_itemstring = (exchangeclone.mcl and "mcl_dye:" or "dye:")..color local dye_itemstring = (exchangeclone.mcl and "mcl_dye:" or "dye:")..color
local dye_energy = exchangeclone.get_item_energy(dye_itemstring) local dye_emc = exchangeclone.get_item_emc(dye_itemstring)
if dye_energy then if dye_emc then
if (not cheapest_color[2]) or (dye_energy < cheapest_color[2]) then if (not cheapest_color[2]) or (dye_emc < cheapest_color[2]) then
cheapest_color[1] = color cheapest_color[1] = color
cheapest_color[2] = dye_energy cheapest_color[2] = dye_emc
end end
end end
end end
@ -403,16 +402,16 @@ local cheapest_advanced_itemstring = "exchangeclone:advanced_alchemical_chest_".
for color, color_data in pairs(exchangeclone.colors) do for color, color_data in pairs(exchangeclone.colors) do
local advanced_itemstring = "exchangeclone:advanced_alchemical_chest_"..color local advanced_itemstring = "exchangeclone:advanced_alchemical_chest_"..color
set_item_energy(advanced_itemstring, exchangeclone.get_item_energy(cheapest_advanced_itemstring)) set_item_emc(advanced_itemstring, exchangeclone.get_item_emc(cheapest_advanced_itemstring))
end end
-- Adds energy values to aliased items, even though they're not used (just so it's displayed) -- Adds EMC values to aliased items, even though they're not used (just so it's displayed)
for alias, itemstring in pairs(exchangeclone.energy_aliases) do for alias, itemstring in pairs(exchangeclone.emc_aliases) do
set_item_energy(itemstring, exchangeclone.get_item_energy(alias)) set_item_emc(itemstring, exchangeclone.get_item_emc(alias))
end end
-- Delete unnecessary data (waste of memory) -- Delete unnecessary data (waste of memory)
if not exchangeclone.keep_data then if not exchangeclone.keep_data then
exchangeclone.recipes = nil exchangeclone.recipes = nil
exchangeclone.base_energy_values = nil exchangeclone.base_emc_values = nil
end end

View File

@ -1,11 +1,11 @@
local suffixes = {"", "K", "M", "B", "T"} local suffixes = {"", "K", "M", "B", "T"}
local function get_amount_label(itemstring, player_energy) local function get_amount_label(itemstring, player_emc)
if not minetest.registered_items[itemstring] then return "" end if not minetest.registered_items[itemstring] then return "" end
if player_energy <= 0 then return "0" end if player_emc <= 0 then return "0" end
local item_energy = exchangeclone.get_item_energy(itemstring) local item_emc = exchangeclone.get_item_emc(itemstring)
local amount = math.floor(player_energy/item_energy) local amount = math.floor(player_emc/item_emc)
if player_energy <= 0 then return "0" end if player_emc <= 0 then return "0" end
for _, suffix in ipairs(suffixes) do for _, suffix in ipairs(suffixes) do
if amount < 1000 then if amount < 1000 then
return amount..suffix return amount..suffix
@ -16,7 +16,7 @@ local function get_amount_label(itemstring, player_energy)
end end
local function get_transmutation_buttons(player, page, x, y) local function get_transmutation_buttons(player, page, x, y)
local player_energy = exchangeclone.get_player_energy(player) local player_emc = exchangeclone.get_player_emc(player)
local pages = minetest.deserialize(player:get_meta():get_string("exchangeclone_transmutation")) or {} local pages = minetest.deserialize(player:get_meta():get_string("exchangeclone_transmutation")) or {}
if page < 1 then page = 1 end if page < 1 then page = 1 end
if not pages[1] then if not pages[1] then
@ -29,7 +29,7 @@ local function get_transmutation_buttons(player, page, x, y)
local column = (i%4) local column = (i%4)
local row = math.floor(i/4) local row = math.floor(i/4)
if itemstring then if itemstring then
buttons = buttons.."item_image_button["..tostring(x+column)..","..tostring(y+row)..";1,1;"..itemstring..";"..itemstring..";"..get_amount_label(itemstring, player_energy).."]" buttons = buttons.."item_image_button["..tostring(x+column)..","..tostring(y+row)..";1,1;"..itemstring..";"..itemstring..";"..get_amount_label(itemstring, player_emc).."]"
else else
buttons = buttons.."image_button["..tostring(x+column)..","..tostring(y+row)..";1,1;blank.png;empty_button"..tostring(i)..";]" buttons = buttons.."image_button["..tostring(x+column)..","..tostring(y+row)..";1,1;blank.png;empty_button"..tostring(i)..";]"
end end
@ -52,7 +52,7 @@ end
function exchangeclone.reload_transmutation_list(player, search) function exchangeclone.reload_transmutation_list(player, search)
local meta = player:get_meta() local meta = player:get_meta()
local player_energy = exchangeclone.get_player_energy(player) local player_emc = exchangeclone.get_player_emc(player)
local items_to_show = minetest.deserialize(meta:get_string("exchangeclone_transmutation_learned_items")) or {} local items_to_show = minetest.deserialize(meta:get_string("exchangeclone_transmutation_learned_items")) or {}
local lang = minetest.get_player_information(player:get_player_name()).lang_code local lang = minetest.get_player_information(player:get_player_name()).lang_code
local pages = {} local pages = {}
@ -74,8 +74,8 @@ function exchangeclone.reload_transmutation_list(player, search)
local no_duplicates = {} local no_duplicates = {}
for _, item in pairs(items_to_show) do for _, item in pairs(items_to_show) do
if type(item) == "string" then if type(item) == "string" then
local energy_value = exchangeclone.get_item_energy(item) local emc_value = exchangeclone.get_item_emc(item)
if energy_value and energy_value <= player_energy and energy_value > 0 then if emc_value and emc_value <= player_emc and emc_value > 0 then
no_duplicates[exchangeclone.handle_alias(item)] = true -- gets rid of duplicates no_duplicates[exchangeclone.handle_alias(item)] = true -- gets rid of duplicates
end end
end end
@ -100,15 +100,15 @@ end
local function add_to_output(player, amount, show) local function add_to_output(player, amount, show)
local item = player:get_meta():get_string("exchangeclone_transmutation_selection") local item = player:get_meta():get_string("exchangeclone_transmutation_selection")
if minetest.registered_items[item] then if minetest.registered_items[item] then
local energy_value = exchangeclone.get_item_energy(item) local emc_value = exchangeclone.get_item_emc(item)
if not energy_value then return end if not emc_value then return end
local player_energy = exchangeclone.get_player_energy(player) local player_emc = exchangeclone.get_player_emc(player)
local stack_max = ItemStack(item):get_stack_max() local stack_max = ItemStack(item):get_stack_max()
if amount == true then amount = stack_max end if amount == true then amount = stack_max end
local max_amount = math.min(amount, stack_max, math.floor(player_energy/energy_value)) local max_amount = math.min(amount, stack_max, math.floor(player_emc/emc_value))
local inventory = minetest.get_inventory({type = "detached", name = "exchangeclone_transmutation_"..player:get_player_name()}) local inventory = minetest.get_inventory({type = "detached", name = "exchangeclone_transmutation_"..player:get_player_name()})
local added_amount = max_amount - inventory:add_item("output", ItemStack(item.." "..max_amount)):get_count() local added_amount = max_amount - inventory:add_item("output", ItemStack(item.." "..max_amount)):get_count()
exchangeclone.set_player_energy(player, math.min(player_energy, player_energy - (energy_value * added_amount))) -- not sure if "math.min()" is necessary exchangeclone.set_player_emc(player, math.min(player_emc, player_emc - (emc_value * added_amount))) -- not sure if "math.min()" is necessary
if show then exchangeclone.show_transmutation_table_formspec(player) end if show then exchangeclone.show_transmutation_table_formspec(player) end
end end
end end
@ -116,15 +116,15 @@ end
local function handle_inventory(player, inventory, to_list) local function handle_inventory(player, inventory, to_list)
local stack = inventory:get_stack(to_list, 1) local stack = inventory:get_stack(to_list, 1)
local itemstring = stack:get_name() local itemstring = stack:get_name()
itemstring = exchangeclone.energy_aliases[itemstring] or itemstring itemstring = exchangeclone.emc_aliases[itemstring] or itemstring
if to_list == "learn" then if to_list == "learn" then
local list = minetest.deserialize(player:get_meta():get_string("exchangeclone_transmutation_learned_items")) or {} local list = minetest.deserialize(player:get_meta():get_string("exchangeclone_transmutation_learned_items")) or {}
if itemstring == "exchangeclone:alchemical_tome" then if itemstring == "exchangeclone:alchemical_tome" then
list = {} list = {}
local i = 0 local i = 0
for name, def in pairs(minetest.registered_items) do for name, def in pairs(minetest.registered_items) do
local energy_value = exchangeclone.get_item_energy(name) local emc_value = exchangeclone.get_item_emc(name)
if energy_value and energy_value > 0 then if emc_value and emc_value > 0 then
i = i + 1 i = i + 1
list[i] = name list[i] = name
end end
@ -133,22 +133,22 @@ local function handle_inventory(player, inventory, to_list)
player:get_meta():set_string("exchangeclone_transmutation_learned_items", minetest.serialize(list)) player:get_meta():set_string("exchangeclone_transmutation_learned_items", minetest.serialize(list))
inventory:set_stack(to_list, 1, nil) inventory:set_stack(to_list, 1, nil)
else else
local individual_energy_value = exchangeclone.get_item_energy(itemstring) local individual_emc_value = exchangeclone.get_item_emc(itemstring)
if not individual_energy_value or individual_energy_value <= 0 then return end if not individual_emc_value or individual_emc_value <= 0 then return end
local wear = stack:get_wear() local wear = stack:get_wear()
if wear and wear > 1 then if wear and wear > 1 then
individual_energy_value = math.max(math.floor(individual_energy_value * ((65536 - wear)/65536)), 1) individual_emc_value = math.max(math.floor(individual_emc_value * ((65536 - wear)/65536)), 1)
end end
if minetest.get_item_group(itemstring, "klein_star") > 0 then if minetest.get_item_group(itemstring, "klein_star") > 0 then
individual_energy_value = individual_energy_value + exchangeclone.get_star_itemstack_energy(stack) individual_emc_value = individual_emc_value + exchangeclone.get_star_itemstack_emc(stack)
end end
local player_energy = exchangeclone.get_player_energy(player) local player_emc = exchangeclone.get_player_emc(player)
local max_count = math.floor((exchangeclone.limit - player_energy)/individual_energy_value) local max_count = math.floor((exchangeclone.limit - player_emc)/individual_emc_value)
local add_count = math.min(max_count, stack:get_count()) local add_count = math.min(max_count, stack:get_count())
local energy_value = individual_energy_value * add_count local emc_value = individual_emc_value * add_count
local result = player_energy + energy_value local result = player_emc + emc_value
if result < 0 or result > exchangeclone.limit then return end if result < 0 or result > exchangeclone.limit then return end
exchangeclone.set_player_energy(player, result) exchangeclone.set_player_emc(player, result)
local item_index = table.indexof(list, itemstring) local item_index = table.indexof(list, itemstring)
if item_index == -1 then if item_index == -1 then
list[#list+1] = itemstring list[#list+1] = itemstring
@ -163,12 +163,12 @@ local function handle_inventory(player, inventory, to_list)
elseif to_list == "forget" then elseif to_list == "forget" then
return return
elseif to_list == "charge" then elseif to_list == "charge" then
local player_energy = exchangeclone.get_player_energy(player) local player_emc = exchangeclone.get_player_emc(player)
local star_energy = exchangeclone.get_star_itemstack_energy(stack) local star_emc = exchangeclone.get_star_itemstack_emc(stack)
local charge_amount = math.min(exchangeclone.get_star_max(stack) - star_energy, player_energy) local charge_amount = math.min(exchangeclone.get_star_max(stack) - star_emc, player_emc)
if charge_amount > 0 then if charge_amount > 0 then
exchangeclone.add_player_energy(player, 0-charge_amount) exchangeclone.add_player_emc(player, 0-charge_amount)
exchangeclone.set_star_energy(inventory, to_list, 1, star_energy + charge_amount) exchangeclone.set_star_emc(inventory, to_list, 1, star_emc + charge_amount)
exchangeclone.show_transmutation_table_formspec(player) exchangeclone.show_transmutation_table_formspec(player)
end end
end end
@ -197,9 +197,9 @@ local function allow_inventory_action(player, stack, to_list, count, move, inven
return 0 return 0
elseif to_list == "learn" then elseif to_list == "learn" then
if stack:get_name() == "exchangeclone:alchemical_tome" then return count end if stack:get_name() == "exchangeclone:alchemical_tome" then return count end
local energy_value = exchangeclone.get_item_energy(exchangeclone.handle_alias(stack)) local emc_value = exchangeclone.get_item_emc(exchangeclone.handle_alias(stack))
if not energy_value then return 0 end if not emc_value then return 0 end
if energy_value <= 0 then if emc_value <= 0 then
return 0 return 0
else else
return count return count
@ -228,11 +228,11 @@ end
function exchangeclone.show_transmutation_table_formspec(player, data) function exchangeclone.show_transmutation_table_formspec(player, data)
exchangeclone.reload_transmutation_list(player, data and data.search) exchangeclone.reload_transmutation_list(player, data and data.search)
if not data then data = {} end if not data then data = {} end
local player_energy = exchangeclone.get_player_energy(player) local player_emc = exchangeclone.get_player_emc(player)
local selection = data.selection or player:get_meta():get_string("exchangeclone_transmutation_selection") local selection = data.selection or player:get_meta():get_string("exchangeclone_transmutation_selection")
local player_name = player:get_player_name() local player_name = player:get_player_name()
local inventory_name = "detached:exchangeclone_transmutation_"..player_name local inventory_name = "detached:exchangeclone_transmutation_"..player_name
local label = "Transmutation\n"..exchangeclone.format_number(player_energy).." energy" local label = "Transmutation\n"..exchangeclone.format_number(player_emc).." EMC"
local formspec = local formspec =
"size[9,11]".. "size[9,11]"..
@ -429,7 +429,7 @@ minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craf
if itemstack == ItemStack("exchangeclone:alchemical_tome") then if itemstack == ItemStack("exchangeclone:alchemical_tome") then
for _, i in {4,6} do for _, i in {4,6} do
local stack = old_craft_grid[i] local stack = old_craft_grid[i]
if exchangeclone.get_star_itemstack_energy(stack) < exchangeclone.get_star_max(stack) then if exchangeclone.get_star_itemstack_emc(stack) < exchangeclone.get_star_max(stack) then
return ItemStack("") return ItemStack("")
end end
end end

View File

@ -1,3 +1,3 @@
name = exchangeclone name = exchangeclone
title = ExchangeClone title = ExchangeClone
description = Equivalent Exchange/ProjectE for Minetest Game and MineClone! Turn items into energy and energy into items, craft OP tools and armor, and more! description = Equivalent Exchange/ProjectE for Minetest Game and MineClone! Turn items into EMC and EMC into items, craft OP tools and armor, and more!

View File

@ -1,12 +1,12 @@
exchangeclone.group_values = {} exchangeclone.group_values = {}
exchangeclone.base_energy_values = {} exchangeclone.base_emc_values = {}
if exchangeclone.mcl then if exchangeclone.mcl then
--[[ Groups are organized so that order matters. Groups that are lower on the --[[ 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 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 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 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. ]] NO items will have their EMC calculated by recipes. ]]
table.insert_all(exchangeclone.group_values, { table.insert_all(exchangeclone.group_values, {
{"flower", 8}, {"flower", 8},
{"mushroom", 32}, {"mushroom", 32},
@ -20,7 +20,7 @@ if exchangeclone.mcl then
{"coral_fan=2", 1}, {"coral_fan=2", 1},
}) })
for itemstring, energy_value in pairs({ for itemstring, emc_value in pairs({
["fake_liquids:bucket_fake_lava"] = 832, ["fake_liquids:bucket_fake_lava"] = 832,
["fake_liquids:bucket_fake_water"] = 960, ["fake_liquids:bucket_fake_water"] = 960,
@ -206,7 +206,7 @@ if exchangeclone.mcl then
["mesecons:redstone"] = 64, ["mesecons:redstone"] = 64,
}) do }) do
exchangeclone.base_energy_values[itemstring] = exchangeclone.base_energy_values[itemstring] or energy_value exchangeclone.base_emc_values[itemstring] = exchangeclone.base_emc_values[itemstring] or emc_value
end end
-- TODO: Check after every update -- TODO: Check after every update
exchangeclone.mcl_potion_data = { -- automatically assumes base is awkward potion if not specified exchangeclone.mcl_potion_data = { -- automatically assumes base is awkward potion if not specified
@ -233,7 +233,7 @@ else
{"flower", 32}, {"flower", 32},
}) })
for itemstring, energy_value in pairs({ for itemstring, emc_value in pairs({
["bones:bones"] = 288, ["bones:bones"] = 288,
["bucket:bucket_lava"] = 832, ["bucket:bucket_lava"] = 832,
@ -276,14 +276,14 @@ else
["farming:seed_wheat"] = 16, ["farming:seed_wheat"] = 16,
["farming:wheat"] = 24, ["farming:wheat"] = 24,
}) do }) do
exchangeclone.base_energy_values[itemstring] = exchangeclone.base_energy_values[itemstring] or energy_value exchangeclone.base_emc_values[itemstring] = exchangeclone.base_emc_values[itemstring] or emc_value
end end
end end
-- For things that are the same in both games: -- For things that are the same in both games:
for itemstring, energy_value in pairs ({ for itemstring, emc_value in pairs ({
["exchangeclone:alchemical_tome"] = 0, ["exchangeclone:alchemical_tome"] = 0,
["moreores:mithril_ingot"] = 16384, ["moreores:mithril_ingot"] = 16384,
@ -300,7 +300,7 @@ for itemstring, energy_value in pairs ({
["useful_green_potatoes:useful_green_potato"] = 256 ["useful_green_potatoes:useful_green_potato"] = 256
}) do }) do
exchangeclone.base_energy_values[itemstring] = energy_value exchangeclone.base_emc_values[itemstring] = emc_value
end end
table.insert_all(exchangeclone.group_values, { table.insert_all(exchangeclone.group_values, {

View File

@ -65,4 +65,4 @@ if minetest.get_modpath("technic") then
end end
end end
dofile(modpath.."/base_energy_values.lua") dofile(modpath.."/base_emc_values.lua")

View File

@ -43,9 +43,9 @@ function exchangeclone.on_blast(lists)
end end
end end
--- Gets the energy value of an itemstring or ItemStack --- Gets the EMC value of an itemstring or ItemStack
--- Handles "group:group_name" syntax (although it goes through every item), returns cheapest item in group --- Handles "group:group_name" syntax (although it goes through every item), returns cheapest item in group
function exchangeclone.get_item_energy(item) function exchangeclone.get_item_emc(item)
if (item == "") or not item then return end if (item == "") or not item then return end
-- handle groups -- handle groups
if type(item) == "string" and item:sub(1,6) == "group:" and exchangeclone.group_values then if type(item) == "string" and item:sub(1,6) == "group:" and exchangeclone.group_values then
@ -57,10 +57,10 @@ function exchangeclone.get_item_energy(item)
local cheapest local cheapest
for _, group_item in pairs(group_items[item_group]) do for _, group_item in pairs(group_items[item_group]) do
if group_item then if group_item then
local energy_value = exchangeclone.get_item_energy(group_item) local emc_value = exchangeclone.get_item_emc(group_item)
if energy_value then if emc_value then
if energy_value > 0 and ((not cheapest) or energy_value < cheapest) then if emc_value > 0 and ((not cheapest) or emc_value < cheapest) then
cheapest = energy_value cheapest = emc_value
end end
end end
end end
@ -71,20 +71,20 @@ function exchangeclone.get_item_energy(item)
item = ItemStack(item) item = ItemStack(item)
if item == ItemStack("") then return end if item == ItemStack("") then return end
item:set_name(exchangeclone.handle_alias(item)) item:set_name(exchangeclone.handle_alias(item))
local meta_energy_value = tonumber(item:get_meta():get_string("exchangeclone_energy_value")) local meta_emc_value = tonumber(item:get_meta():get_string("exchangeclone_emc_value"))
if meta_energy_value then if meta_emc_value then
if meta_energy_value < 0 then return 0 end if meta_emc_value < 0 then return 0 end
if meta_energy_value > 0 then return meta_energy_value end if meta_emc_value > 0 then return meta_emc_value end
end end
local def = minetest.registered_items[item:get_name()] local def = minetest.registered_items[item:get_name()]
if not def then return end if not def then return end
if minetest.get_item_group(item:get_name(), "klein_star") > 0 then if minetest.get_item_group(item:get_name(), "klein_star") > 0 then
if def.energy_value then if def.emc_value then
return def.energy_value + exchangeclone.get_star_itemstack_energy(item) return def.emc_value + exchangeclone.get_star_itemstack_emc(item)
end end
end end
if def.energy_value then if def.emc_value then
return (def.energy_value) * item:get_count() return (def.emc_value) * item:get_count()
end end
end end
@ -94,31 +94,31 @@ function exchangeclone.map(input, min1, max1, min2, max2)
return (input - min1) / (max1 - min1) * (max2 - min2) + min2 return (input - min1) / (max1 - min1) * (max2 - min2) + min2
end end
-- Gets the energy stored in a specified star itemstack. -- Gets the EMC stored in a specified Klein/Magnum Star itemstack.
function exchangeclone.get_star_itemstack_energy(itemstack) function exchangeclone.get_star_itemstack_emc(itemstack)
if not itemstack then return end if not itemstack then return end
if minetest.get_item_group(itemstack:get_name(), "klein_star") < 1 then return end if minetest.get_item_group(itemstack:get_name(), "klein_star") < 1 then return end
return math.max(itemstack:get_meta():get_float("stored_energy"), 0) return math.max(itemstack:get_meta():get_float("stored_energy"), 0)
end end
-- Gets the amount of energy stored in a star in a specific inventory slot -- Gets the amount of EMC stored in a star in a specific inventory slot
function exchangeclone.get_star_energy(inventory, listname, index) function exchangeclone.get_star_emc(inventory, listname, index)
if not inventory then return end if not inventory then return end
if not listname then listname = "main" end if not listname then listname = "main" end
if not index then index = 1 end if not index then index = 1 end
local itemstack = inventory:get_stack(listname, index) local itemstack = inventory:get_stack(listname, index)
return exchangeclone.get_star_itemstack_energy(itemstack) return exchangeclone.get_star_itemstack_emc(itemstack)
end end
function exchangeclone.set_star_itemstack_energy(itemstack, amount) function exchangeclone.set_star_itemstack_emc(itemstack, amount)
if not itemstack or not amount then return end if not itemstack or not amount then return end
if minetest.get_item_group(itemstack:get_name(), "klein_star") < 1 then return end if minetest.get_item_group(itemstack:get_name(), "klein_star") < 1 then return end
local old_energy = exchangeclone.get_star_itemstack_energy(itemstack) local old_emc = exchangeclone.get_star_itemstack_emc(itemstack)
local max = exchangeclone.get_star_max(itemstack) local max = exchangeclone.get_star_max(itemstack)
if amount > old_energy and old_energy > max then return end -- don't allow more energy to be put into an over-filled star if amount > old_emc and old_emc > max then return end -- don't allow more EMC to be put into an over-filled star
local meta = itemstack:get_meta() local meta = itemstack:get_meta()
meta:set_float("stored_energy", amount) meta:set_float("stored_energy", amount) -- Unfortunately, this is still "energy" not EMC
meta:set_string("description", itemstack:get_definition()._mcl_generate_description(itemstack)) meta:set_string("description", itemstack:get_definition()._mcl_generate_description(itemstack))
local wear = math.max(1, math.min(65535, 65535 - 65535*amount/max)) local wear = math.max(1, math.min(65535, 65535 - 65535*amount/max))
minetest.log(65535 - 65535*amount/max) minetest.log(65535 - 65535*amount/max)
@ -126,13 +126,13 @@ function exchangeclone.set_star_itemstack_energy(itemstack, amount)
return itemstack return itemstack
end end
-- Sets the amount of energy in a star in a specific inventory slot -- Sets the amount of EMC in a star in a specific inventory slot
function exchangeclone.set_star_energy(inventory, listname, index, amount) function exchangeclone.set_star_emc(inventory, listname, index, amount)
if not inventory or not amount or amount < 0 then return end if not inventory or not amount or amount < 0 then return end
if not listname then listname = "main" end if not listname then listname = "main" end
if not index then index = 1 end if not index then index = 1 end
local itemstack = inventory:get_stack(listname, index) local itemstack = inventory:get_stack(listname, index)
local new_stack = exchangeclone.set_star_itemstack_energy(itemstack, amount) local new_stack = exchangeclone.set_star_itemstack_emc(itemstack, amount)
if not new_stack then return end if not new_stack then return end
inventory:set_stack(listname, index, new_stack) inventory:set_stack(listname, index, new_stack)
end end
@ -142,12 +142,12 @@ function exchangeclone.get_star_max(item)
return item:get_definition().max_capacity or 0 return item:get_definition().max_capacity or 0
end end
-- HUD stuff (show energy value in bottom right) -- HUD stuff (show EMC value in bottom right)
local hud_elements = {} local hud_elements = {}
function exchangeclone.update_hud(player) function exchangeclone.update_hud(player)
local hud_text = hud_elements[player:get_player_name()] local hud_text = hud_elements[player:get_player_name()]
player:hud_change(hud_text, "text", S("Personal Energy: @1", exchangeclone.format_number(exchangeclone.get_player_energy(player)))) player:hud_change(hud_text, "text", S("Personal EMC: @1", exchangeclone.format_number(exchangeclone.get_player_emc(player))))
end end
minetest.register_on_joinplayer(function(player, last_login) minetest.register_on_joinplayer(function(player, last_login)
@ -155,7 +155,7 @@ minetest.register_on_joinplayer(function(player, last_login)
hud_elem_type = "text", hud_elem_type = "text",
position = {x = 1, y = 1}, position = {x = 1, y = 1},
offset = {x = 0, y = 0}, offset = {x = 0, y = 0},
text = S("Personal Energy: @1", 0), text = S("Personal EMC: @1", 0),
alignment = {x = -1, y = -1}, alignment = {x = -1, y = -1},
scale = {x = 100, y = 100}, scale = {x = 100, y = 100},
number = 0xDDDDDD number = 0xDDDDDD
@ -167,13 +167,14 @@ minetest.register_on_leaveplayer(function(player, timed_out)
hud_elements[player:get_player_name()] = nil hud_elements[player:get_player_name()] = nil
end) end)
-- Get a player's personal energy -- Get a player's personal EMC
function exchangeclone.get_player_energy(player) function exchangeclone.get_player_emc(player)
-- Can't really change it to "EMC" without everyone losing everything
return tonumber(player:get_meta():get_string("exchangeclone_stored_energy")) or 0 return tonumber(player:get_meta():get_string("exchangeclone_stored_energy")) or 0
end end
-- Set a player's personal energy -- Set a player's personal EMC
function exchangeclone.set_player_energy(player, amount) function exchangeclone.set_player_emc(player, amount)
amount = tonumber(amount) amount = tonumber(amount)
if not (player and amount) then return end if not (player and amount) then return end
if amount < 0 or amount > exchangeclone.limit then return end if amount < 0 or amount > exchangeclone.limit then return end
@ -181,15 +182,15 @@ function exchangeclone.set_player_energy(player, amount)
exchangeclone.update_hud(player) exchangeclone.update_hud(player)
end end
-- Add to a player's personal energy (amount can be negative) -- Add to a player's personal EMC (amount can be negative)
function exchangeclone.add_player_energy(player, amount) function exchangeclone.add_player_emc(player, amount)
if not (player and amount) then return end if not (player and amount) then return end
exchangeclone.set_player_energy(player, (exchangeclone.get_player_energy(player) or 0) + amount) exchangeclone.set_player_emc(player, (exchangeclone.get_player_emc(player) or 0) + amount)
end end
-- Through trial and error, I have found that this number (1 trillion) works the best. -- Through trial and error, I have found that this number (1 trillion) works the best.
-- When a player has any more energy (as in ANY more), precision-based exploits such as creating infinite glass panes are possible. -- When a player has any more EMC (as in ANY more), precision-based exploits such as creating infinite glass panes are possible.
-- I temporarily considered finding some Lua library that allowed for arbitrary precision (and therefore infinite maximum energy) -- I temporarily considered finding some Lua library that allowed for arbitrary precision (and therefore infinite maximum EMC)
-- but I decided not to. -- but I decided not to.
exchangeclone.limit = 1000000000000 exchangeclone.limit = 1000000000000
@ -344,17 +345,17 @@ exchangeclone.itemstrings = {
torch = exchangeclone.mcl and "mcl_torches:torch" or "default:torch" torch = exchangeclone.mcl and "mcl_torches:torch" or "default:torch"
} }
exchangeclone.energy_aliases = {} exchangeclone.emc_aliases = {}
-- <itemstring> will be treated as <alias> in Deconstructors, Constructors, Transmutation Table(t)s, etc. -- <itemstring> will be treated as <alias> in Deconstructors, Constructors, Transmutation Table(t)s, etc.
-- When you put <itemstring> into a TT, you will learn <alias> instead. -- When you put <itemstring> into a TT, you will learn <alias> instead.
function exchangeclone.register_alias_force(alias, itemstring) function exchangeclone.register_alias_force(alias, itemstring)
if alias == itemstring then return end if alias == itemstring then return end
exchangeclone.energy_aliases[itemstring] = alias exchangeclone.emc_aliases[itemstring] = alias
end end
function exchangeclone.register_alias(alias, itemstring) function exchangeclone.register_alias(alias, itemstring)
if not exchangeclone.energy_aliases[alias] then if not exchangeclone.emc_aliases[alias] then
exchangeclone.register_alias_force(alias, itemstring) exchangeclone.register_alias_force(alias, itemstring)
end end
end end
@ -363,7 +364,7 @@ end
function exchangeclone.handle_alias(item) function exchangeclone.handle_alias(item)
item = ItemStack(item) item = ItemStack(item)
if not item:is_empty() then if not item:is_empty() then
local de_aliased = exchangeclone.energy_aliases[item:get_name()] or item:get_name() -- Resolve ExchangeClone aliases local de_aliased = exchangeclone.emc_aliases[item:get_name()] or item:get_name() -- Resolve ExchangeClone aliases
return ItemStack(de_aliased):get_name() or item:get_name() -- Resolve MT aliases return ItemStack(de_aliased):get_name() or item:get_name() -- Resolve MT aliases
end end
end end
@ -597,9 +598,9 @@ function exchangeclone.check_cooldown(player, name)
end end
-- Chat commands: -- Chat commands:
minetest.register_chatcommand("add_player_energy", { minetest.register_chatcommand("add_player_emc", {
params = "[player] <value>", params = "[player] <value>",
description = "Add to a player's personal energy (player is self if not included, value can be negative to subtract)", description = "Add to a player's personal EMC (player is self if not included, value can be negative to subtract)",
privs = {privs = true}, privs = {privs = true},
func = function(name, param) func = function(name, param)
local split_param = exchangeclone.split(param, " ") local split_param = exchangeclone.split(param, " ")
@ -615,23 +616,23 @@ minetest.register_chatcommand("add_player_energy", {
end end
target_player = minetest.get_player_by_name(target_name) target_player = minetest.get_player_by_name(target_name)
if (not (target_player and value)) or not tonumber(value) then if (not (target_player and value)) or not tonumber(value) then
minetest.chat_send_player(name, "Bad command. Use /add_player_energy [player] [value] or /add_player_energy [value]") minetest.chat_send_player(name, "Bad command. Use /add_player_emc [player] [value] or /add_player_emc [value]")
return return
end end
local energy = exchangeclone.get_player_energy(target_player) local emc = exchangeclone.get_player_emc(target_player)
if (energy + value > exchangeclone.limit) or (energy + value < 0) then if (emc + value > exchangeclone.limit) or (emc + value < 0) then
minetest.chat_send_player(name, "Out of bounds; personal energy must be between 0 and 1 trillion.") minetest.chat_send_player(name, "Out of bounds; personal EMC must be between 0 and 1 trillion.")
return return
end end
exchangeclone.add_player_energy(target_player, tonumber(value)) exchangeclone.add_player_emc(target_player, tonumber(value))
minetest.chat_send_player(name, "Added "..exchangeclone.format_number(value).." to "..target_name.."'s personal energy.") minetest.chat_send_player(name, "Added "..exchangeclone.format_number(value).." to "..target_name.."'s personal EMC.")
end end
}) })
-- Chat commands: -- Chat commands:
minetest.register_chatcommand("get_player_energy", { minetest.register_chatcommand("get_player_emc", {
params = "[player]", params = "[player]",
description = "Gets a player's personal energy (player is self if not included).", description = "Gets a player's personal EMC (player is self if not included).",
privs = {privs = true}, privs = {privs = true},
func = function(name, param) func = function(name, param)
local target_player local target_player
@ -643,17 +644,17 @@ minetest.register_chatcommand("get_player_energy", {
end end
target_player = minetest.get_player_by_name(target_name) target_player = minetest.get_player_by_name(target_name)
if not (target_player) then if not (target_player) then
minetest.chat_send_player(name, "Bad command. Use /get_player_energy [player] or /get_player_energy") minetest.chat_send_player(name, "Bad command. Use /get_player_emc [player] or /get_player_emc")
return return
end end
local energy = exchangeclone.get_player_energy(target_player) local emc = exchangeclone.get_player_emc(target_player)
minetest.chat_send_player(name, target_name.."'s personal energy: "..exchangeclone.format_number(energy)) minetest.chat_send_player(name, target_name.."'s personal EMC: "..exchangeclone.format_number(emc))
end end
}) })
minetest.register_chatcommand("set_player_energy", { minetest.register_chatcommand("set_player_emc", {
params = "[player] <value>", params = "[player] <value>",
description = "Set a player's personal energy (player is self if not included; use 'limit' as value to set it to maximum)", description = "Set a player's personal EMC (player is self if not included; use 'limit' as value to set it to maximum)",
privs = {privs = true}, privs = {privs = true},
func = function(name, param) func = function(name, param)
local split_param = exchangeclone.split(param, " ") local split_param = exchangeclone.split(param, " ")
@ -670,17 +671,17 @@ minetest.register_chatcommand("set_player_energy", {
end end
target_player = minetest.get_player_by_name(name) target_player = minetest.get_player_by_name(name)
if (not (target_player and value)) or (not (value == "limit" or tonumber(value))) then if (not (target_player and value)) or (not (value == "limit" or tonumber(value))) then
minetest.chat_send_player(name, "Bad command. Use /set_player_energy [player] [value] or /set_player_energy [value]") minetest.chat_send_player(name, "Bad command. Use /set_player_emc [player] [value] or /set_player_emc [value]")
return return
end end
if value:lower() == "limit" then if value:lower() == "limit" then
value = exchangeclone.limit value = exchangeclone.limit
elseif (tonumber(value) > exchangeclone.limit) or (tonumber(value) < 0) then elseif (tonumber(value) > exchangeclone.limit) or (tonumber(value) < 0) then
minetest.chat_send_player(name, "Failed to set energy; must be between 0 and 1 trillion.") minetest.chat_send_player(name, "Failed to set EMC; must be between 0 and 1 trillion.")
return return
end end
exchangeclone.set_player_energy(target_player, tonumber(value)) exchangeclone.set_player_emc(target_player, tonumber(value))
minetest.chat_send_player(name, "Set "..target_name.."'s personal energy to "..exchangeclone.format_number(value)) minetest.chat_send_player(name, "Set "..target_name.."'s personal EMC to "..exchangeclone.format_number(value))
end end
}) })