Changed "energy" to "EMC," added awards

This commit is contained in:
ThePython 2024-02-13 17:12:48 -08:00
parent b4a5c2b4a6
commit 0614b399ec
18 changed files with 291 additions and 211 deletions

View File

@ -1,14 +1,14 @@
# 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.
ExchangeClone is tested with the latest release of Minetest, Minetest Game, MineClone2, and Mineclonia.
## ExchangeClone's Features:
* Energy
* EMC
* Philosopher's Stone
* Transmutation Table
* Alchemical Tome
@ -64,21 +64,22 @@ Dependencies: Minetest Game or MineClone.
### PLANS/TODO FOR v7.0 (see dev branch for current progress)
* [ ] Achievements/advancements/awards
* [x] Achievements/advancements/awards
* [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)
* [x] Wear bar for charge level
* [x] Charge levels match ProjectE (both in number and in range)
* [x] Charge level affects speed
* [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] 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] 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.
* [ ] Remove and add alias for DM/RM shields
* [ ] Upgrades affect energy value
* [x] Remove and add alias for DM/RM shields
* [ ] Upgrades affect EMC value
* [x] Multiple levels of Exchange Orbs (change to Klein Stars, adjust recipes)
* [x] Fuel storage blocks
* [ ] Divining rods

View File

@ -1,167 +1,246 @@
awards.register_award("exchangeclone:best_friend", {
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,
}
})
awards.register_award("exchangeclone:this_into_that", {
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,
}
})
awards.register_award("exchangeclone:on_the_go", {
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,
}
})
awards.register_award("exchangeclone:emc_batteries", {
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,
}
})
awards.register_award("exchangeclone:big_emc_batteries", {
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,
}
})
awards.register_award("exchangeclone:massive_emc_batteries", {
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,
}
})
awards.register_award("exchangeclone:storage_upgrade", {
register_award("exchangeclone:storage_upgrade", {
title = "Storage Upgrade!",
description = 'A "little" chest upgrade.'
description = 'A "little" chest upgrade.',
icon = "exchangeclone_alchemical_chest_top.png",
trigger = {
type = "craft",
item = "exchangeclone:alchemical_chest"
item = "exchangeclone:alchemical_chest",
target = 1,
}
})
awards.register_award("exchangeclone:matter_on_matter", {
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"
item = "exchangeclone:dark_matter_pickaxe",
target = 1,
}
})
awards.register_award("exchangeclone:is_this_safe", {
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"
item = "exchangeclone:red_matter_pickaxe",
target = 1,
}
})
awards.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"
}
})
awards.register_award("exchangeclone:hot_matter", {
register_award("exchangeclone:hot_matter", {
title = "Hot matter!",
description = "A furnace is even better when made from dark matter.",
icon = "exchangeclone_red_matter_furnace_active.png",
trigger = {
type = "craft",
item = "exchangeclone:red_matter_furnace"
item = "exchangeclone:dark_matter_furnace",
target = 1,
}
})
awards.register_award("exchangeclone:pocket_storage", {
title = "Pocket storage!",
description = "All the wonders of an alchemical chest, in your pocket.",
icon = "exchangeclone_alchemical_bag.png",
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 = "group:alchemical_bag"
item = "exchangeclone:red_matter_furnace",
target = 1,
}
})
awards.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"
})
-- 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,
}
})
awards.register_award("exchangeclone:all_that_matters", {
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"
item = "exchangeclone:dark_matter",
target = 1,
}
})
awards.register_award("exchangeclone:even_better_matter", {
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"
item = "exchangeclone:red_matter",
target = 1,
}
})
awards.register_award("exchangeclone:red_and_shiny", {
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"
item = "exchangeclone:red_matter_block",
target = 1,
}
})
awards.register_award("exchangeclone:block_that_matters", {
title = "A block that Matters!!",
register_award("exchangeclone:block_that_matters", {
title = "A block that Matters!",
description = "Stuffing matter together. Because that's a good idea.",
icon = "exchangeclone_darkmatter_block.png",
icon = "exchangeclone_dark_matter_block.png",
trigger = {
type = "craft",
item = "exchangeclone:dark_matter_block"
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

@ -52,7 +52,7 @@ local function constructor_action(pos)
else
current_emc = exchangeclone.get_player_emc(player)
end
local emc_value = exchangeclone.get_item_energy(src_stack:get_name())
local emc_value = exchangeclone.get_item_emc(src_stack:get_name())
if emc_value and emc_value > 0 then
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()

View File

@ -80,7 +80,7 @@ local function is_repairable_gear(item)
item = ItemStack(item)
if item:get_wear() <= 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
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 not inventory:room_for_item("exchangeclone_covalence_output", gear_stack) then return end
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
if energy_value/amount < 50 then
if emc_value/amount < 50 then
tier = 1
elseif energy_value/amount < 6000 then
elseif emc_value/amount < 6000 then
tier = 2
end
if minetest.get_item_group(dust_stack:get_name(), "covalence_dust") >= tier and dust_stack:get_count() >= amount then

View File

@ -38,26 +38,26 @@ local function deconstructor_action(pos, elapsed)
end
local stack = inv:get_stack("src", 1)
local individual_energy_value = exchangeclone.get_item_energy(stack:get_name())
if not (individual_energy_value and individual_energy_value > 0) then return end
local individual_emc_value = exchangeclone.get_item_emc(stack:get_name())
if not (individual_emc_value and individual_emc_value > 0) then return end
local wear = stack:get_wear()
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
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
local current_energy
local current_emc
if using_star then
current_energy = exchangeclone.get_star_emc(inv, "fuel", 1)
current_emc = exchangeclone.get_star_emc(inv, "fuel", 1)
else
current_energy = exchangeclone.get_player_emc(player)
current_emc = exchangeclone.get_player_emc(player)
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 energy_value = individual_energy_value * add_count
local result = current_energy + energy_value
local emc = individual_emc_value * add_count
local result = current_emc + emc
if result < 0 or result > limit then return end
if using_star then

View File

@ -55,7 +55,7 @@ local function on_timer(pos, elapsed)
if light and light >= 14 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
end
local amount = meta:get_int("collector_amount")
@ -120,7 +120,7 @@ end
function exchangeclone.register_energy_collector(itemstring, name, amount, modifier, recipe)
minetest.register_node(itemstring, {
description = name.."\nGenerates "..exchangeclone.format_number(amount).." energy/second",
description = name.."\nGenerates "..exchangeclone.format_number(amount).." EMC/second",
tiles = {
"exchangeclone_energy_collector_base.png^(exchangeclone_energy_collector_overlay.png"..modifier..")",
"exchangeclone_energy_collector_base.png",

View File

@ -26,13 +26,13 @@ local function infinite_food_function(itemstack, player, pointed_thing)
end
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",
inventory_image = "farming_bread.png^[colorize:#ffff00:128",
groups = { food = 2, eatable = 8, disable_repair = 1, fire_immune = 1},
on_place = 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,
})

View File

@ -141,10 +141,10 @@ if minetest.get_modpath("awards") then
end
minetest.register_on_mods_loaded(function()
local energy_start_time = minetest.get_us_time()
minetest.log("action", "[ExchangeClone] Registering energy values")
dofile(modpath.."/register_energy.lua")
minetest.log("action", "[ExchangeClone] Done registering energy values ("..((minetest.get_us_time() - energy_start_time)/1000000).." seconds)")
local emc_start_time = minetest.get_us_time()
minetest.log("action", "[ExchangeClone] Registering EMC values")
dofile(modpath.."/register_emc.lua")
minetest.log("action", "[ExchangeClone] Done registering EMC values ("..((minetest.get_us_time() - emc_start_time)/1000000).." seconds)")
end)
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
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)))
return itemstack
end
@ -42,7 +42,7 @@ for i, name in ipairs(names) do
_mcl_generate_description = function(itemstack)
return name.."\n"..S(
"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)
)
end

View File

@ -2,5 +2,5 @@ name = exchangeclone
title = ExchangeClone
description = The main part of the modpack (depends on both the other mods)
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

View File

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

View File

@ -30,7 +30,7 @@ local function get_cheapest_recipe(itemstring, log)
if replaced and replaced > 0 then
identical_replacements[item] = replaced - 1
else
local cost = exchangeclone.get_item_energy(item)
local cost = exchangeclone.get_item_emc(item)
if (not cost) or cost == 0 then
skip = item
else
@ -51,7 +51,7 @@ local function get_cheapest_recipe(itemstring, log)
if replaced and replaced > 0 then
identical_replacements[item] = replaced - 1
else
local cost = exchangeclone.get_item_energy(item)
local cost = exchangeclone.get_item_emc(item)
if (not cost) or cost == 0 then
skip = item
else
@ -71,7 +71,7 @@ local function get_cheapest_recipe(itemstring, log)
if replaced and replaced > 0 then
identical_replacements[item] = replaced - 1
else
local cost = exchangeclone.get_item_energy(item)
local cost = exchangeclone.get_item_emc(item)
if (not cost) or cost == 0 then
skip = item
else
@ -80,13 +80,13 @@ local function get_cheapest_recipe(itemstring, log)
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
end
if recipe.replacements and not skip then
for _, item in pairs(recipe.replacements) do
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
skip = item[2]
else
@ -111,35 +111,35 @@ local function get_cheapest_recipe(itemstring, log)
return cheapest and cheapest[1]
end
exchangeclone.energy_values = {}
exchangeclone.emc_values = {}
-- Sets the energy value of an item, must be called during load time.
local function set_item_energy(itemstring, energy_value)
if not (energy_value and itemstring) then return end
energy_value = math.floor(energy_value*20)/20 -- floor to nearest .05
if energy_value < 0 then return end
-- Sets the EMC value of an item, must be called during load time.
local function set_item_emc(itemstring, emc_value)
if not (emc_value and itemstring) then return end
emc_value = math.floor(emc_value*20)/20 -- floor to nearest .05
if emc_value < 0 then return end
local def = minetest.registered_items[itemstring]
if not def then return end
local description = def.description or ""
-- Override energy value if it already exists
local existing_energy_value = description:find("Energy Value: ([%d%.,]+)")
if existing_energy_value then
description = description:gsub("Energy Value: ([%d%.,]+)", "Energy Value: "..exchangeclone.format_number(energy_value))
-- Override EMC value if it already exists
local existing_emc_value = description:find("EMC Value: ([%d%.,]+)")
if existing_emc_value then
description = description:gsub("EMC Value: ([%d%.,]+)", "EMC Value: "..exchangeclone.format_number(emc_value))
else
if description[#description] ~= "\n" then
description = description.."\n"
end
description = description.."Energy Value: "..exchangeclone.format_number(energy_value)
description = description.."EMC Value: "..exchangeclone.format_number(emc_value)
end
minetest.override_item(itemstring, {
description = description,
energy_value = energy_value,
emc_value = emc_value,
})
if energy_value > 0 then
exchangeclone.energy_values[itemstring] = energy_value
if emc_value > 0 then
exchangeclone.emc_values[itemstring] = emc_value
else
exchangeclone.energy_values[itemstring] = nil
exchangeclone.emc_values[itemstring] = nil
end
end
@ -183,7 +183,7 @@ if exchangeclone.mcla then
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
for i = 0, 31 do
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")
end
-- Register copper block/stonecutting energy recipes in MineClone2
-- Register copper block/stonecutting EMC recipes in MineClone2
if exchangeclone.mcl2 then
exchangeclone.register_craft_type("oxidation", "cooking")
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 energy values
-- Register group EMC values
local groupnames = {}
for index, group in ipairs(exchangeclone.group_values) do
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)
for index, group in ipairs(exchangeclone.group_values) 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
-- Register base energy values
for itemstring, energy_value in pairs(exchangeclone.base_energy_values) do
set_item_energy(itemstring, energy_value)
-- Register base EMC values
for itemstring, emc_value in pairs(exchangeclone.base_emc_values) do
set_item_emc(itemstring, emc_value)
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
if def.exchangeclone_custom_energy then
set_item_energy(itemstring, def.exchangeclone_custom_energy)
if def.exchangeclone_custom_emc then
set_item_emc(itemstring, def.exchangeclone_custom_emc)
else
itemstring = exchangeclone.handle_alias(itemstring) or itemstring
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 ((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]
) then
auto[itemstring] = true
@ -342,7 +341,7 @@ end
local old_auto
local same = false
local i = 1
-- Automatically register energy values
-- Automatically register EMC values
while not same do
minetest.log("action", "[ExchangeClone] \tIteration #"..i)
if auto == {} then break end
@ -363,7 +362,7 @@ while not same do
for itemstring, _ in pairs(auto) do
local cheapest = get_cheapest_recipe(itemstring)
if cheapest then
set_item_energy(itemstring, cheapest)
set_item_emc(itemstring, cheapest)
auto[itemstring] = nil
end
end
@ -371,11 +370,11 @@ while not same do
end
if exchangeclone.mcl then
set_item_energy("mcl_campfires:campfire", exchangeclone.get_item_energy("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:campfire", exchangeclone.get_item_emc("mcl_campfires: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.
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
exchangeclone.register_alias("mcl_compass:"..i.."_recovery", "mcl_compass:"..j.."_recovery")
end
@ -388,11 +387,11 @@ local cheapest_color = {""}
for color, color_data in pairs(exchangeclone.colors) do
local dye_itemstring = (exchangeclone.mcl and "mcl_dye:" or "dye:")..color
local dye_energy = exchangeclone.get_item_energy(dye_itemstring)
if dye_energy then
if (not cheapest_color[2]) or (dye_energy < cheapest_color[2]) then
local dye_emc = exchangeclone.get_item_emc(dye_itemstring)
if dye_emc then
if (not cheapest_color[2]) or (dye_emc < cheapest_color[2]) then
cheapest_color[1] = color
cheapest_color[2] = dye_energy
cheapest_color[2] = dye_emc
end
end
end
@ -403,16 +402,16 @@ local cheapest_advanced_itemstring = "exchangeclone:advanced_alchemical_chest_".
for color, color_data in pairs(exchangeclone.colors) do
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
-- Adds energy values to aliased items, even though they're not used (just so it's displayed)
for alias, itemstring in pairs(exchangeclone.energy_aliases) do
set_item_energy(itemstring, exchangeclone.get_item_energy(alias))
-- Adds EMC values to aliased items, even though they're not used (just so it's displayed)
for alias, itemstring in pairs(exchangeclone.emc_aliases) do
set_item_emc(itemstring, exchangeclone.get_item_emc(alias))
end
-- Delete unnecessary data (waste of memory)
if not exchangeclone.keep_data then
exchangeclone.recipes = nil
exchangeclone.base_energy_values = nil
exchangeclone.base_emc_values = nil
end

View File

@ -3,8 +3,8 @@ local suffixes = {"", "K", "M", "B", "T"}
local function get_amount_label(itemstring, player_emc)
if not minetest.registered_items[itemstring] then return "" end
if player_emc <= 0 then return "0" end
local item_energy = exchangeclone.get_item_energy(itemstring)
local amount = math.floor(player_emc/item_energy)
local item_emc = exchangeclone.get_item_emc(itemstring)
local amount = math.floor(player_emc/item_emc)
if player_emc <= 0 then return "0" end
for _, suffix in ipairs(suffixes) do
if amount < 1000 then
@ -74,8 +74,8 @@ function exchangeclone.reload_transmutation_list(player, search)
local no_duplicates = {}
for _, item in pairs(items_to_show) do
if type(item) == "string" then
local energy_value = exchangeclone.get_item_energy(item)
if energy_value and energy_value <= player_emc and energy_value > 0 then
local emc_value = exchangeclone.get_item_emc(item)
if emc_value and emc_value <= player_emc and emc_value > 0 then
no_duplicates[exchangeclone.handle_alias(item)] = true -- gets rid of duplicates
end
end
@ -100,15 +100,15 @@ end
local function add_to_output(player, amount, show)
local item = player:get_meta():get_string("exchangeclone_transmutation_selection")
if minetest.registered_items[item] then
local energy_value = exchangeclone.get_item_energy(item)
if not energy_value then return end
local emc_value = exchangeclone.get_item_emc(item)
if not emc_value then return end
local player_emc = exchangeclone.get_player_emc(player)
local stack_max = ItemStack(item):get_stack_max()
if amount == true then amount = stack_max end
local max_amount = math.min(amount, stack_max, math.floor(player_emc/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 added_amount = max_amount - inventory:add_item("output", ItemStack(item.." "..max_amount)):get_count()
exchangeclone.set_player_emc(player, math.min(player_emc, player_emc - (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
end
end
@ -116,15 +116,15 @@ end
local function handle_inventory(player, inventory, to_list)
local stack = inventory:get_stack(to_list, 1)
local itemstring = stack:get_name()
itemstring = exchangeclone.energy_aliases[itemstring] or itemstring
itemstring = exchangeclone.emc_aliases[itemstring] or itemstring
if to_list == "learn" then
local list = minetest.deserialize(player:get_meta():get_string("exchangeclone_transmutation_learned_items")) or {}
if itemstring == "exchangeclone:alchemical_tome" then
list = {}
local i = 0
for name, def in pairs(minetest.registered_items) do
local energy_value = exchangeclone.get_item_energy(name)
if energy_value and energy_value > 0 then
local emc_value = exchangeclone.get_item_emc(name)
if emc_value and emc_value > 0 then
i = i + 1
list[i] = name
end
@ -133,20 +133,20 @@ local function handle_inventory(player, inventory, to_list)
player:get_meta():set_string("exchangeclone_transmutation_learned_items", minetest.serialize(list))
inventory:set_stack(to_list, 1, nil)
else
local individual_energy_value = exchangeclone.get_item_energy(itemstring)
if not individual_energy_value or individual_energy_value <= 0 then return end
local individual_emc_value = exchangeclone.get_item_emc(itemstring)
if not individual_emc_value or individual_emc_value <= 0 then return end
local wear = stack:get_wear()
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
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
local player_emc = exchangeclone.get_player_emc(player)
local max_count = math.floor((exchangeclone.limit - player_emc)/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 energy_value = individual_energy_value * add_count
local result = player_emc + energy_value
local emc_value = individual_emc_value * add_count
local result = player_emc + emc_value
if result < 0 or result > exchangeclone.limit then return end
exchangeclone.set_player_emc(player, result)
local item_index = table.indexof(list, itemstring)
@ -164,7 +164,7 @@ local function handle_inventory(player, inventory, to_list)
return
elseif to_list == "charge" then
local player_emc = exchangeclone.get_player_emc(player)
local star_emc = 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_emc, player_emc)
if charge_amount > 0 then
exchangeclone.add_player_emc(player, 0-charge_amount)
@ -197,9 +197,9 @@ local function allow_inventory_action(player, stack, to_list, count, move, inven
return 0
elseif to_list == "learn" then
if stack:get_name() == "exchangeclone:alchemical_tome" then return count end
local energy_value = exchangeclone.get_item_energy(exchangeclone.handle_alias(stack))
if not energy_value then return 0 end
if energy_value <= 0 then
local emc_value = exchangeclone.get_item_emc(exchangeclone.handle_alias(stack))
if not emc_value then return 0 end
if emc_value <= 0 then
return 0
else
return count
@ -232,7 +232,7 @@ function exchangeclone.show_transmutation_table_formspec(player, data)
local selection = data.selection or player:get_meta():get_string("exchangeclone_transmutation_selection")
local player_name = player:get_player_name()
local inventory_name = "detached:exchangeclone_transmutation_"..player_name
local label = "Transmutation\n"..exchangeclone.format_number(player_emc).." energy"
local label = "Transmutation\n"..exchangeclone.format_number(player_emc).." EMC"
local formspec =
"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
for _, i in {4,6} do
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("")
end
end

View File

@ -1,3 +1,3 @@
name = 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.base_energy_values = {}
exchangeclone.base_emc_values = {}
if exchangeclone.mcl then
--[[ Groups are organized so that order matters. Groups that are lower on the
list will have their energies applied later, making them higher priority. It's
unnecessary for single items because order doesn't matter for them. The NO_GROUP
value is for values that are not in any other group, but adding this means that
NO items will have their energy calculated by recipes. ]]
NO items will have their EMC calculated by recipes. ]]
table.insert_all(exchangeclone.group_values, {
{"flower", 8},
{"mushroom", 32},
@ -20,7 +20,7 @@ if exchangeclone.mcl then
{"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_water"] = 960,
@ -206,7 +206,7 @@ if exchangeclone.mcl then
["mesecons:redstone"] = 64,
}) 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
-- TODO: Check after every update
exchangeclone.mcl_potion_data = { -- automatically assumes base is awkward potion if not specified
@ -233,7 +233,7 @@ else
{"flower", 32},
})
for itemstring, energy_value in pairs({
for itemstring, emc_value in pairs({
["bones:bones"] = 288,
["bucket:bucket_lava"] = 832,
@ -276,14 +276,14 @@ else
["farming:seed_wheat"] = 16,
["farming:wheat"] = 24,
}) 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
-- 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,
["moreores:mithril_ingot"] = 16384,
@ -300,7 +300,7 @@ for itemstring, energy_value in pairs ({
["useful_green_potatoes:useful_green_potato"] = 256
}) do
exchangeclone.base_energy_values[itemstring] = energy_value
exchangeclone.base_emc_values[itemstring] = emc_value
end
table.insert_all(exchangeclone.group_values, {

View File

@ -65,4 +65,4 @@ if minetest.get_modpath("technic") then
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
--- 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
function exchangeclone.get_item_energy(item)
function exchangeclone.get_item_emc(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
@ -57,10 +57,10 @@ function exchangeclone.get_item_energy(item)
local cheapest
for _, group_item in pairs(group_items[item_group]) do
if group_item then
local energy_value = exchangeclone.get_item_energy(group_item)
if energy_value then
if energy_value > 0 and ((not cheapest) or energy_value < cheapest) then
cheapest = energy_value
local emc_value = exchangeclone.get_item_emc(group_item)
if emc_value then
if emc_value > 0 and ((not cheapest) or emc_value < cheapest) then
cheapest = emc_value
end
end
end
@ -71,20 +71,20 @@ function exchangeclone.get_item_energy(item)
item = ItemStack(item)
if item == ItemStack("") then return end
item:set_name(exchangeclone.handle_alias(item))
local meta_energy_value = tonumber(item:get_meta():get_string("exchangeclone_energy_value"))
if meta_energy_value then
if meta_energy_value < 0 then return 0 end
if meta_energy_value > 0 then return meta_energy_value end
local meta_emc_value = tonumber(item:get_meta():get_string("exchangeclone_emc_value"))
if meta_emc_value then
if meta_emc_value < 0 then return 0 end
if meta_emc_value > 0 then return meta_emc_value end
end
local def = minetest.registered_items[item:get_name()]
if not def then return end
if minetest.get_item_group(item:get_name(), "klein_star") > 0 then
if def.energy_value then
return def.energy_value + exchangeclone.get_star_itemstack_energy(item)
if def.emc_value then
return def.emc_value + exchangeclone.get_star_itemstack_emc(item)
end
end
if def.energy_value then
return (def.energy_value) * item:get_count()
if def.emc_value then
return (def.emc_value) * item:get_count()
end
end
@ -94,31 +94,31 @@ function exchangeclone.map(input, min1, max1, min2, max2)
return (input - min1) / (max1 - min1) * (max2 - min2) + min2
end
-- Gets the energy stored in a specified star itemstack.
function exchangeclone.get_star_itemstack_energy(itemstack)
-- Gets the EMC stored in a specified Klein/Magnum Star itemstack.
function exchangeclone.get_star_itemstack_emc(itemstack)
if not itemstack 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)
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_emc(inventory, listname, index)
if not inventory then return end
if not listname then listname = "main" end
if not index then index = 1 end
local itemstack = inventory:get_stack(listname, index)
return exchangeclone.get_star_itemstack_energy(itemstack)
return exchangeclone.get_star_itemstack_emc(itemstack)
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 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)
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()
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))
local wear = math.max(1, math.min(65535, 65535 - 65535*amount/max))
minetest.log(65535 - 65535*amount/max)
@ -126,13 +126,13 @@ function exchangeclone.set_star_itemstack_energy(itemstack, amount)
return itemstack
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_emc(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_star_itemstack_energy(itemstack, amount)
local new_stack = exchangeclone.set_star_itemstack_emc(itemstack, amount)
if not new_stack then return end
inventory:set_stack(listname, index, new_stack)
end
@ -142,12 +142,12 @@ function exchangeclone.get_star_max(item)
return item:get_definition().max_capacity or 0
end
-- HUD stuff (show energy value in bottom right)
-- HUD stuff (show EMC value in bottom right)
local hud_elements = {}
function exchangeclone.update_hud(player)
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_emc(player))))
player:hud_change(hud_text, "text", S("Personal EMC: @1", exchangeclone.format_number(exchangeclone.get_player_emc(player))))
end
minetest.register_on_joinplayer(function(player, last_login)
@ -155,7 +155,7 @@ minetest.register_on_joinplayer(function(player, last_login)
hud_elem_type = "text",
position = {x = 1, y = 1},
offset = {x = 0, y = 0},
text = S("Personal Energy: @1", 0),
text = S("Personal EMC: @1", 0),
alignment = {x = -1, y = -1},
scale = {x = 100, y = 100},
number = 0xDDDDDD
@ -167,12 +167,13 @@ minetest.register_on_leaveplayer(function(player, timed_out)
hud_elements[player:get_player_name()] = nil
end)
-- Get a player's personal energy
-- Get a player's personal EMC
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
end
-- Set a player's personal energy
-- Set a player's personal EMC
function exchangeclone.set_player_emc(player, amount)
amount = tonumber(amount)
if not (player and amount) then return end
@ -181,15 +182,15 @@ function exchangeclone.set_player_emc(player, amount)
exchangeclone.update_hud(player)
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_emc(player, amount)
if not (player and amount) then return end
exchangeclone.set_player_emc(player, (exchangeclone.get_player_emc(player) or 0) + amount)
end
-- 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.
-- I temporarily considered finding some Lua library that allowed for arbitrary precision (and therefore infinite maximum energy)
-- 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 EMC)
-- but I decided not to.
exchangeclone.limit = 1000000000000
@ -344,17 +345,17 @@ exchangeclone.itemstrings = {
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.
-- When you put <itemstring> into a TT, you will learn <alias> instead.
function exchangeclone.register_alias_force(alias, itemstring)
if alias == itemstring then return end
exchangeclone.energy_aliases[itemstring] = alias
exchangeclone.emc_aliases[itemstring] = alias
end
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)
end
end
@ -363,7 +364,7 @@ end
function exchangeclone.handle_alias(item)
item = ItemStack(item)
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
end
end
@ -599,7 +600,7 @@ end
-- Chat commands:
minetest.register_chatcommand("add_player_emc", {
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},
func = function(name, param)
local split_param = exchangeclone.split(param, " ")
@ -618,20 +619,20 @@ minetest.register_chatcommand("add_player_emc", {
minetest.chat_send_player(name, "Bad command. Use /add_player_emc [player] [value] or /add_player_emc [value]")
return
end
local energy = exchangeclone.get_player_emc(target_player)
if (energy + value > exchangeclone.limit) or (energy + value < 0) then
minetest.chat_send_player(name, "Out of bounds; personal energy must be between 0 and 1 trillion.")
local emc = exchangeclone.get_player_emc(target_player)
if (emc + value > exchangeclone.limit) or (emc + value < 0) then
minetest.chat_send_player(name, "Out of bounds; personal EMC must be between 0 and 1 trillion.")
return
end
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
})
-- Chat commands:
minetest.register_chatcommand("get_player_emc", {
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},
func = function(name, param)
local target_player
@ -646,14 +647,14 @@ minetest.register_chatcommand("get_player_emc", {
minetest.chat_send_player(name, "Bad command. Use /get_player_emc [player] or /get_player_emc")
return
end
local energy = exchangeclone.get_player_emc(target_player)
minetest.chat_send_player(name, target_name.."'s personal energy: "..exchangeclone.format_number(energy))
local emc = exchangeclone.get_player_emc(target_player)
minetest.chat_send_player(name, target_name.."'s personal EMC: "..exchangeclone.format_number(emc))
end
})
minetest.register_chatcommand("set_player_emc", {
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},
func = function(name, param)
local split_param = exchangeclone.split(param, " ")
@ -676,11 +677,11 @@ minetest.register_chatcommand("set_player_emc", {
if value:lower() == "limit" then
value = exchangeclone.limit
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
end
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
})