Finished furnaces, redone (de)constructors

This commit is contained in:
ThePython 2023-10-05 17:19:48 -07:00
parent c71e07eef4
commit fa58fd436b
12 changed files with 360 additions and 376 deletions

214
README.md
View File

@ -16,7 +16,6 @@ Dependencies: Minetest Game or MineClone.
See the [wiki](https://github.com/ThePython10110/ExchangeClone/wiki) for a list of features.
## Known issues:
* Dark and Red Matter armor look kind of terrible in MineClone. I might fix this eventually...
* There is an error reported in MineClone related to Red Matter armor setting health.
* In MineClone, it is impossible to heal past 20 health (10 hearts) without potions of healing (or the soul/life stones, which I haven't added yet)
* With a full set of red matter armor, you can almost instantly go back to 2000 health (1000 hearts), no matter what you health is, by removing one piece of red matter armor and putting it back on. I don't really know what to do about this, because of the previous issue. Normally, I would simply make 2000 the maximum health, and leave the player's health how it is, but that doesn't really work because the extra maximum health would be useless because it's unreachable.
@ -33,49 +32,96 @@ If you have a suggestion or notice a bug, visit the [GitHub issues page](https:/
## Sources/license:
* Code: Forked and *heavily* modified from Enchant97's mod [Element Exchange](https://github.com/enchant97/minetest_element_exchange). Both this mod and Element Exchange are licenced under GPLv3+. Based on Equivalent Exchange and ProjectE, mods for MineCraft.
* Textures:
* Energy Collector, Element Deconstructor, Element Constructor: Directly from Element Exchange, GPLv3+.
* Energy Collector, Deconstructor, Constructor: Directly from Element Exchange, GPLv3+.
* Exchange Orb: *Slightly* modified from Element Exchange (I just changed the color to white so it could change colors correctly)
* Alchemical Coal, Mobius Fuel, and Aeternalis Fuel: modified versions of MineClone's coal texture (CC-BY-SA-3.0).
* Dark and Red Matter Armor (and eventually Gem Armor): modified versions of diamond armor from 3D Armor (CC-BY-SA-3.0) and `mcl_armor` (CC-BY-SA-3.0).
* Dark and Red Matter Armor (and maybe eventually Gem Armor): modified versions of diamond armor from 3D Armor (CC-BY-SA-3.0) and `mcl_armor` (CC-BY-SA-3.0).
* All other textures (and sounds): Created by me, inspired by Equivalent Exchange and licensed under CC-BY-SA-3.0.
<details><summary><h1>Changelog:</h1></summary>
# Changelog:
### 1.0.0
* Initial release
### 5.0 (the new most insteresting release so far)
#### You MUST break and replace any existing Deconstructors when updating from any previous version.
* New features:
* MineClone support, including (sort of) hoppers
* Added the ability to add items by group
* Shift-clicking (listrings)!
* Changes:
* Completely redone recipes, now includes all items.
* Tools' energy value now depends on wear.
* Added a [wiki](https://github.com/ThePython10110/ExchangeClone/wiki)! This is where you can find more complete information on pretty much everything.
* Because the wiki exists, I won't be including anywhere near as many details about how features work in the changelog.
* Added the Transmutation Table(t): Much better than the constructor/deconstructor.
* Alchemical Tome: Instantly teaches every item with an energy value to the Transmutation Table(t).
* Dark/Red Matter Furnaces: Can be powered by Energy Collectors, much faster, and sometimes double ores.
* Personal Energy Link: Allows you to use hoppers to get items into/out of your Personal Energy (MineClone)
* Upgraded Energy Collectors: Now MK1-MK5. They use personal energy unless they have an orb.
* The ability to upgrade dark/red matter tools to give them fortune, looting, fire aspect, and silk touch
* The ability to upgrade dark/red matter armor to give it thorns and frost walker
* Mind, Life, Body, and Soul Stones
* Mod developers can now set their own energy values by setting `exchangeclone_custom_energy` in the item/node definition.
* Changes
* The changelog now has the most recent updates first, to make things easier to find.
* Energy for Dark/Red Matter tool abilities (as well as the Transmutation Table) is no longer stored in an orb, but inside the player.
* The amount of energy you currently have stored is visible in the bottom right of the screen.
* Because of this, the PESA is now useless and deprecated. It will be removed after a few releases (so probably a couple months at least). Remove any Exchange Orbs from your personal storage.
* A lot of items (including DM/RM tools and armor) will not burn in lava in MineClone2.
* Energy Collectors now send their energy to the placer's personal energy by default.
* Red Matter Armor now sets your maximum health to 200 instead of 2000
* Exchange Orbs are now 18x better as fuel than they used to be
* DM/RM Shovels will now only create paths on blocks below air.
* Bugfixes:
* Items can no longer be put in the Constructor's output slot.
* Honestly, I'm going to count the broken energy values as a bug...
* I must have skipped a row while going through MineClone's mod list. Several mods starting with `mcl_b` or `mcl_c` have been added to the whitelist.
* Fixed right-clicking with an orb not showing charge
* Removed unnecessary tool repair recipes from dark/red matter tools/armor
* Fixed a couple of armor texture issues in Minetest Game (though it still looks like diamond armor; 3D Armor doesn't support texture modifiers)
* The Red Katar is now actually craftable in Minetest Game (I just forgot that shears were only in MCL2)
### 2.0
### 4.4
* New Features
* Mineclonia Support
* The version numbers kind of disagree around here and I'm too lazy to fix it.
### 4.3
* New features:
* Added a changelog (you're reading it now!)
* Added all items from Why (a MineClone modpack I made)
* Added Philosopher's Stone (these controls are now inaccurate; changed in 3.0)
* Left click to increase range (minimum = 0, maximum = 4).
* Shift+left click to decrease range.
* Aux1+left click to open enchanting table (MineClone only).
* Right click to transmute nodes in range (mode 1).
* Shift+right click to transmute nodes in range (mode 2, has some differences).
* Aux1+right click to open crafting table (MineClone only).
* Can use to craft coal into iron, mese into diamonds, etc.
* New items from Why (flying sausage, useful green potatoes, etc.)
* Changes:
* Changed version numbers from x.x.x to x.x.
* Changed the recipe for the Exchange Orb
* New recipe is a Philosopher's Stone in the middle, diamonds in the corners, and iron/steel ingots on the sides.
* Changed the energy values of tin, copper, and bronze in Minetest Game.
* Renamed images to reflect mod name change ("exchangeclone" instead of "ee" for Element Exchange)
* Deleted unnecessary "config.lua"
* The changelog now lives here!
* Exchange Orbs now change color based on the amount of energy (black->red->green->blue->magenta).
* Exchange Orbs now have a maximum energy of 51,200,000 (to match Equivalent Exchange's Klein Star Omegas).
* Water is now worth 0 instead of 1 (since it's infinite)
* Bugfixes:
* Ghost Blocks (from Why) are now worth 0 instead of 1 (to prevent infinite energy)
* Fixed stairs and slabs not working in Minetest Game
* Exchange Orbs will now correctly display their energy value (I typed `orb` instead of `exchange_orb` in the energy value list)
### 4.2
* Bugfixes:
* Fixed a dependency error (thanks, @opfromthestart!)
### 4.1
* Bugfixes:
* Added energy values for new armor/tools
* Removed unnecessary chestplate image (not only is it unused, but I put it in the wrong folder for some reason)
### 4.0
* New features:
* The "Features that I plan on adding eventually" list below
* Cooldowns for tool abilities to limit lag
* Red Katar (combination of sword, axe, hoe, and shears)
* Red Morningstar (combination of hammer, pickaxe, and shovel)
* Dark Matter Armor (full set gives immunity to lava/fire and drowning)
* Red Matter Armor (full set gives lava/fire/drowning immunity PLUS 2000 health, although you may want HUD Bars to see it)
* Added energy values for MineClone's new items.
* Changes:
* Changed the amount of damage done by Dark/Red Matter Sword special abilities (used to be `max_damage/distance`, now is `max_damage-distance`)
* A whole bunch of things that won't be noticible when playing, mostly code reorganization. It's *possible* that tools that mine multiple nodes at a time (hammer, pickaxe, hoe, katar, and morningstar) will be slightly less laggy
* Texture/sound license changed to CC-BY-SA-3.0 (because GPLv3+ isn't really meant as a media license).
* Bugfixes:
* Fixed an issue where MineClone dispensers could ONLY be used with Dark/Red Matter Shears (whoops).
### 3.2
* Changes:
* Set MineClone mod namespace to `exchangeclone`
### 3.1
* Changes:
* Added new energy values from Why (and Why's new Minetest Game energy values)
* Bugfixes:
* Fixed crash based on PESA inventory movement
* Added `mcl_blackstone` to the mod whitelist
### 3.0 (the most interesting release so far)
* New features:
@ -127,84 +173,44 @@ If you have a suggestion or notice a bug, visit the [GitHub issues page](https:/
* The Energy Collector now drops its contents when broken (MineClone)
* Fixed Exchange Orb energy value (forgot to change it after changing the recipe)
* Changed Constructor, Deconstructor, and Collector recipes and energy values to make them cheaper.
### 3.1
* Changes:
* Added new energy values from Why (and Why's new Minetest Game energy values)
* Bugfixes:
* Fixed crash based on PESA inventory movement
* Added `mcl_blackstone` to the mod whitelist
### 3.2
* Changes:
* Set MineClone mod namespace to exchangeclone
### 4.0
### 2.0
* New features:
* The "Features that I plan on adding eventually" list below
* Cooldowns for tool abilities to limit lag
* Red Katar (combination of sword, axe, hoe, and shears)
* Red Morningstar (combination of hammer, pickaxe, and shovel)
* Dark Matter Armor (full set gives immunity to lava/fire and drowning)
* Red Matter Armor (full set gives lava/fire/drowning immunity PLUS 2000 health, although you may want HUD Bars to see it)
* Added energy values for MineClone's new items.
* Added a changelog (you're reading it now!)
* Added all items from Why (a MineClone modpack I made)
* Added Philosopher's Stone (these controls are now inaccurate as of 3.0)
* Left click to increase range (minimum = 0, maximum = 4).
* Shift+left click to decrease range.
* Aux1+left click to open enchanting table (MineClone only).
* Right click to transmute nodes in range (mode 1).
* Shift+right click to transmute nodes in range (mode 2, has some differences).
* Aux1+right click to open crafting table (MineClone only).
* Can use to craft coal into iron, mese into diamonds, etc.
* Changes:
* Changed the amount of damage done by Dark/Red Matter Sword special abilities (used to be `max_damage/distance`, now is `max_damage-distance`)
* A whole bunch of things that won't be noticible when playing, mostly code reorganization. It's *possible* that tools that mine multiple nodes at a time (hammer, pickaxe, hoe, katar, and morningstar) will be slightly less laggy
* Texture/sound license changed to CC-BY-SA-3.0 (because GPLv3+ isn't really meant as a media license).
* Changed version numbers from x.x.x to x.x.
* Changed the recipe for the Exchange Orb
* New recipe is a Philosopher's Stone in the middle, diamonds in the corners, and iron/steel ingots on the sides.
* Changed the energy values of tin, copper, and bronze in Minetest Game.
* Renamed images to reflect mod name change ("exchangeclone" instead of "ee" for Element Exchange)
* Deleted unnecessary "config.lua"
* Bugfixes:
* Fixed an issue where MineClone dispensers could ONLY be used with Dark/Red Matter Shears (whoops).
* Ghost Blocks (from Why) are now worth 0 instead of 1 (to prevent infinite energy)
* Fixed stairs and slabs not working in Minetest Game
### 4.1
* Bugfixes:
* Added energy values for new armor/tools
* Removed unnecessary chestplate image (not only is it unused, but I put it in the wrong folder for some reason)
### 4.2
* Bugfixes:
* Fixed a dependency error (thanks, @opfromthestart!)
### 4.3
### 1.0.0
* Initial release
* New features:
* New items from Why (flying sausage, useful green potatoes, etc.)
* MineClone support, including (sort of) hoppers
* Added the ability to add items by group
* Shift-clicking (listrings)!
* Changes:
* The changelog now lives here!
* Exchange Orbs now change color based on the amount of energy (black->red->green->blue->magenta).
* Exchange Orbs now have a maximum energy of 51,200,000 (to match Equivalent Exchange's Klein Star Omegas).
* Water is now worth 0 instead of 1 (since it's infinite)
* Completely redone recipes, now includes all items.
* Tools' energy value now depends on wear.
* Bugfixes:
* Exchange Orbs will now correctly display their energy value (I typed `orb` instead of `exchange_orb` in the energy value list)
### 4.3
* New Features
* Mineclonia Support
### 5.0 (the new most insteresting release so far)
* New features:
* Added a [wiki](https://github.com/ThePython10110/ExchangeClone/wiki)! This is where you can find more complete information on pretty much everything.
* Because the wiki exists, I won't be including anywhere near as many details about how features work in the changelog.
* Added the Transmutation Table(t): Much better than the constructor/deconstructor.
* Alchemical Tome: Instantly teaches every item with an energy value to the Transmutation Table(t).
* Dark/Red Matter Furnaces: Can be powered by Energy Collectors, much faster, and sometimes double ores.
* Personal Energy Link: Allows you to use hoppers to get items into/out of your Personal Energy (MineClone)
* Upgraded Energy Collectors: Now MK1-MK5. They use personal energy unless they have an orb.
* The ability to upgrade dark/red matter tools to give them fortune, looting, fire aspect, and silk touch
* The ability to upgrade dark/red matter armor to give it thorns and frost walker
* Mind, Life, Body, and Soul Stones
* Mod developers can now set their own energy values by setting `exchangeclone_custom_energy` in the item/node definition.
* Changes
* Energy for Dark/Red Matter tool abilities (as well as the Transmutation Table) is no longer stored in an orb, but inside the player.
* The amount of energy you currently have stored is visible in the top right of the screen.
* Because of this, the PESA is now useless and deprecated. It will be removed after a few releases (so probably a couple months at least). Remove any Exchange Orbs from your personal storage.
* A lot of items (including DM/RM tools and armor) will not burn in lava in MineClone2.
* Energy Collectors now send their energy to the placer's personal energy by default.
* Red Matter Armor now sets your maximum health to 200 instead of 2000
* Exchange Orbs are now 18x better as fuel than they used to be
* DM/RM Shovels will now only create paths on blocks below air.
* Bugfixes:
* I must have skipped a row while going through MineClone's mod list. Several mods starting with `mcl_b` or `mcl_c` have been added to the whitelist.
* Fixed right-clicking with an orb not showing charge
* Removed unnecessary tool repair recipes from dark/red matter tools/armor
* Fixed a couple of armor texture issues in Minetest Game (though it still looks like diamond armor; 3D Armor doesn't support texture modifiers)
* The Red Katar is now actually craftable in Minetest Game (I just forgot that shears were only in MCL2)
* Items can no longer be put in the Constructor's output slot.
* Honestly, I'm going to count the broken energy values as a bug...
</details>
### Features that I plan on adding eventually:
* Something that places nodes in a square (with varying range), possibly with a low energy cost
@ -221,5 +227,3 @@ If you have a suggestion or notice a bug, visit the [GitHub issues page](https:/
* Harvest Band?
* Ring of Arcana (possibly without the Harvest Band)
* Gem Armor
</details>

View File

@ -24,7 +24,6 @@ local function get_armor_texture(type, matter, preview)
if preview then result = result.."_preview" end
result = result..".png"..modifier
end
minetest.log(result)
return result
end
@ -46,7 +45,7 @@ function exchangeclone.check_armor_health(obj)
end
else
local name, armor_inv = armor:get_valid_player(obj, "[checking for red matter]")
if not armor_inv then minetest.log("Inventory is nil") return end
if not armor_inv then return end
local list = armor_inv:get_list("armor")
if type(list) ~= "table" then
return
@ -66,7 +65,7 @@ function exchangeclone.check_armor_health(obj)
if armor_pieces >= max_armor then
obj:set_properties({hp_max = 200})
if already_has_health == 0 then
-- TODO: fix this if MineCraft changes to max_hp instead of hardcoding 20
-- TODO: fix this if MineClone changes to max_hp instead of hardcoding 20
obj:set_hp(200-math.max(20-obj:get_hp(), 0))
obj:get_meta():set_int("exchangeclone_red_matter_armor", 1)
end

View File

@ -1,4 +1,4 @@
local function get_element_constructor_formspec()
local function get_constructor_formspec()
if not exchangeclone.mcl then
local formspec = {
"size[8,9]",
@ -44,6 +44,17 @@ local function get_element_constructor_formspec()
end
end
-- Register LBM to update constructors
minetest.register_lbm({
name = "exchangeclone:constructor_alert",
nodenames = {"exchangeclone:constructor"},
run_at_every_load = true,
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[3,1]label[0,0;BREAK AND REPLACE]")
end,
})
local function can_dig(pos, player)
if exchangeclone.mcl then return true end
local meta = minetest.get_meta(pos);
@ -51,63 +62,42 @@ local function can_dig(pos, player)
return inv:is_empty("fuel") and inv:is_empty("src") and inv:is_empty("dst")
end
local function on_timer(pos, elapsed)
local function constructor_action(pos)
local inv = minetest.get_meta(pos):get_inventory()
local update = true
while elapsed > 0 and update do
update = false
local src_stack = inv:get_stack("src", 1)
local dst_stack = inv:get_stack("dst", 1)
if not inv:is_empty("fuel") and not inv:is_empty("src") then
-- make sure the stack at dst is same as the src
-- make sure the stack at dst is same as the src (including enchantments)
if not inv:is_empty("dst") then
if not(src_stack:get_name() == dst_stack:get_name()) then
if src_stack:get_name() ~= dst_stack:get_name() then
if exchangeclone.mcl then
if not(string.sub(src_stack:get_name(), -10, -1) == "_enchanted"
and string.sub(src_stack:get_name(), 1, -11) == dst_stack:get_name()
and src_stack:get_name() ~= "mcl_core:apple_gold_enchanted") then
break
return
end
else
break
return
end
end
end
local result = src_stack:get_name()
if exchangeclone.mcl
and string.sub(result, -10, -1) == "_enchanted"
and result ~= "mcl_core:apple_gold_enchanted" then
result = string.sub(src_stack:get_name(), 1, -11)
end
-- make sure orb has enough charge
local orb_charge = exchangeclone.get_orb_energy(inv, "fuel", 1)
local energy_cost = exchangeclone.get_item_energy(src_stack:get_name())
if energy_cost > 0 then
orb_charge = orb_charge - energy_cost
if orb_charge < 0 then
break
end
-- give orb new charge value
exchangeclone.set_orb_energy(inv, "fuel", 1, orb_charge)
-- "convert" charge into a node at dst
if dst_stack:is_empty() then
-- create a new stack
if exchangeclone.mcl
and string.sub(src_stack:get_name(), -10, -1) == "_enchanted"
and src_stack:get_name() ~= "mcl_core:apple_gold_enchanted" then
dst_stack = ItemStack(string.sub(src_stack:get_name(), 1, -11))
else
dst_stack = ItemStack(src_stack:get_name())
end
elseif not dst_stack:item_fits(src_stack:get_name()) then
break
else
-- add one node into stack
dst_stack:set_count(dst_stack:get_count() + 1)
end
inv:set_stack("dst", 1, dst_stack)
update = true
local energy_value = exchangeclone.get_item_energy(src_stack:get_name())
if energy_value > 0 then
local max_amount = math.min(src_stack:get_stack_max(), math.floor(orb_charge/energy_value))
local added_amount = max_amount - inv:add_item("dst", ItemStack(result.." "..max_amount)):get_count()
exchangeclone.set_orb_energy(inv, "fuel", 1, math.min(orb_charge, orb_charge - (energy_value * added_amount))) -- not sure if "math.min()" is necessary
end
end
end
minetest.get_node_timer(pos):stop()
return false
end
local function on_construct(pos)
local meta = minetest.get_meta(pos)
@ -115,17 +105,15 @@ local function on_construct(pos)
inv:set_size("fuel", 1)
inv:set_size("src", 1)
inv:set_size("dst", 1)
meta:set_string("formspec", get_element_constructor_formspec())
meta:set_string("infotext", "Element Constructor")
on_timer(pos, 0)
meta:set_string("formspec", get_constructor_formspec())
meta:set_string("infotext", "Constructor")
constructor_action(pos)
end
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if listname == "fuel" then
if stack:get_name() == "exchangeclone:exchange_orb" then
return stack:get_count()
@ -159,13 +147,13 @@ local function on_blast(pos)
exchangeclone.get_inventory_drops(pos, "fuel", drops)
exchangeclone.get_inventory_drops(pos, "src", drops)
exchangeclone.get_inventory_drops(pos, "dst", drops)
drops[#drops+1] = "exchangeclone:element_constructor"
drops[#drops+1] = "exchangeclone:constructor"
minetest.remove_node(pos)
return drops
end
minetest.register_node("exchangeclone:element_constructor", {
description = "Element Constructor",
minetest.register_node("exchangeclone:constructor", {
description = "Constructor",
tiles = {
"exchangeclone_constructor_up.png",
"exchangeclone_constructor_down.png",
@ -196,17 +184,11 @@ minetest.register_node("exchangeclone:element_constructor", {
meta:from_table(meta2)
end
end,
on_timer = on_timer,
on_timer = constructor_action,
on_construct = on_construct,
on_metadata_inventory_move = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
on_metadata_inventory_put = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
on_metadata_inventory_take = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
on_metadata_inventory_move = constructor_action,
on_metadata_inventory_put = constructor_action,
on_metadata_inventory_take = constructor_action,
on_blast = on_blast,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,
@ -220,7 +202,7 @@ if exchangeclone.mcl then
end
minetest.register_craft({
type = "shaped",
output = "exchangeclone:element_constructor",
output = "exchangeclone:constructor",
recipe = {
{"", "exchangeclone:exchange_orb",""},
{"", recipe_ingredient, ""},

View File

@ -1,96 +1,92 @@
--Renamed "fuel" inventory to "main" to (almost) work with hoppers
local function get_element_deconstructor_formspec()
local function get_deconstructor_formspec()
if not exchangeclone.mcl then
local formspec = {
"size[8,9]",
"label[2,1;Fuel]",
"list[context;main;2,2;1,1;]",
"label[2,1;Items]",
"list[context;src;2,2;1,1;]",
"label[5,1;Orb]",
"list[context;dst;5,2;1,1;]",
"list[context;fuel;5,2;1,1;]",
"list[current_player;main;0,5;8,4;]",
"listring[current_player;main]",
"listring[context;main]",
"listring[context;src]",
"listring[current_player;main]",
"listring[context;dst]",
"listring[context;fuel]",
}
return table.concat(formspec, "")
else
local formspec = {
"size[9,10]",
"label[2,1;Fuel]",
"list[context;main;2,2;1,1;]",
"label[2,1;Items]",
"list[context;src;2,2;1,1;]",
mcl_formspec.get_itemslot_bg(2,2,1,1),
"label[5,1;Orb]",
"list[context;dst;5,2;1,1;]",
"list[context;fuel;5,2;1,1;]",
mcl_formspec.get_itemslot_bg(5,2,1,1),
"list[current_player;main;0,5;9,3;9]",
mcl_formspec.get_itemslot_bg(0,5,9,3),
"list[current_player;main;0,8.5;9,1;]",
mcl_formspec.get_itemslot_bg(0,8.5,9,1),
"listring[current_player;main]",
"listring[context;main]",
"listring[context;src]",
"listring[current_player;main]",
"listring[context;dst]"
"listring[context;fuel]"
}
return table.concat(formspec, "")
end
end
-- Register LBM to update deconstructors
minetest.register_lbm({
name = "exchangeclone:deconstructor_alert",
nodenames = {"exchangeclone:deconstructor"},
run_at_every_load = true,
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[3,1]label[0,0;BREAK AND REPLACE]")
end,
})
local function can_dig(pos, player)
if exchangeclone.mcl then return true end
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main") and inv:is_empty("dst")
return inv:is_empty("src") and inv:is_empty("fuel") and inv:is_empty("main")
end
local function on_timer(pos, elapsed)
local function deconstructor_action(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local update = true
while elapsed > 0 and update do
update = false
if not inv:is_empty("dst") and not inv:is_empty("main") then
-- remove one item from fuel inventory
local fuel_stack = inv:get_stack("main", 1)
local energy_value = 0
if fuel_stack:get_name() == "exchangeclone:exchange_orb" then
energy_value = (fuel_stack:get_meta():get_float("stored_charge") or 0) + 33792 --33792 = energy cost of orb
else
energy_value = exchangeclone.get_item_energy(fuel_stack:get_name())
end
if energy_value <= 0 then
break
else
local wear = fuel_stack:get_wear()
if inv:get_stack("fuel", 1):get_name() ~= "exchangeclone:exchange_orb" then return end
local stack = inv:get_stack("src", 1)
local individual_energy_value = exchangeclone.get_item_energy(stack:get_name())
if individual_energy_value <= 0 then return end
local wear = stack:get_wear()
if wear and wear > 1 then
energy_value = math.ceil(energy_value * (65536 / wear))
individual_energy_value = math.floor(individual_energy_value * (65536 / wear))
end
-- only get 1 orb as we can only use one
local stored = exchangeclone.get_orb_energy(inv, "dst", 1)
if stored + energy_value > exchangeclone.energy_max then
return
if stack:get_name() == "exchangeclone:exchange_orb" then
individual_energy_value = individual_energy_value + exchangeclone.get_orb_itemstack_energy(stack)
end
fuel_stack:set_count(fuel_stack:get_count() - 1)
inv:set_stack("main", 1, fuel_stack)
stored = stored + energy_value
exchangeclone.set_orb_energy(inv, "dst", 1, stored)
end
update = true
end
end
minetest.get_node_timer(pos):stop()
return false
local orb_energy = exchangeclone.get_orb_energy(inv, "fuel", 1)
local max_count = math.floor((exchangeclone.orb_max - orb_energy)/individual_energy_value)
local add_count = math.min(max_count, stack:get_count())
local energy_value = individual_energy_value * add_count
local result = orb_energy + energy_value
if result < 0 or result > exchangeclone.orb_max then return end
exchangeclone.set_orb_energy(inv, "fuel", 1, result)
stack:set_count(stack:get_count() - add_count)
if stack:get_count() == 0 then stack = ItemStack("") end
inv:set_stack("src", 1, stack)
end
local function on_construct(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:set_size("main", 1)
inv:set_size("dst", 1)
meta:set_string("formspec", get_element_deconstructor_formspec())
meta:set_string("infotext", "Element Deconstructor")
on_timer(pos, 0)
inv:set_size("src", 1)
inv:set_size("fuel", 1)
meta:set_string("formspec", get_deconstructor_formspec())
meta:set_string("infotext", "Deconstructor")
deconstructor_action(pos, 0)
end
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
@ -98,16 +94,16 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if listname == "dst" then
if listname == "fuel" then
if stack:get_name() == "exchangeclone:exchange_orb" then
return stack:get_count()
else
return 0
end
elseif listname == "main" then
elseif listname == "src" then
return stack:get_count()
else
return 0
end
end
@ -127,15 +123,15 @@ end
local function on_blast(pos)
local drops = {}
exchangeclone.get_inventory_drops(pos, "main", drops)
exchangeclone.get_inventory_drops(pos, "dst", drops)
drops[#drops+1] = "exchangeclone:element_deconstructor"
exchangeclone.get_inventory_drops(pos, "src", drops)
exchangeclone.get_inventory_drops(pos, "fuel", drops)
drops[#drops+1] = "exchangeclone:deconstructor"
minetest.remove_node(pos)
return drops
end
minetest.register_node("exchangeclone:element_deconstructor", {
description = "Element Deconstructor",
minetest.register_node("exchangeclone:deconstructor", {
description = "Deconstructor",
tiles = {
"exchangeclone_deconstructor_up.png",
"exchangeclone_deconstructor_down.png",
@ -144,7 +140,7 @@ minetest.register_node("exchangeclone:element_deconstructor", {
"exchangeclone_deconstructor_right.png",
"exchangeclone_deconstructor_right.png"
},
groups = {cracky = 2, container = 3, pickaxey = 2},
groups = {cracky = 2, container = 4, pickaxey = 2},
_mcl_hardness = 3,
_mcl_blast_resistance = 6,
sounds = exchangeclone.sound_mod.node_sound_metal_defaults(),
@ -156,7 +152,7 @@ minetest.register_node("exchangeclone:element_deconstructor", {
local meta2 = meta:to_table()
meta:from_table(oldmetadata)
local inv = meta:get_inventory()
for _, listname in ipairs({"main", "dst"}) do
for _, listname in ipairs({"src", "fuel"}) do
local stack = inv:get_stack(listname, 1)
if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
@ -166,17 +162,11 @@ minetest.register_node("exchangeclone:element_deconstructor", {
meta:from_table(meta2)
end
end,
on_timer = on_timer,
on_timer = deconstructor_action,
on_construct = on_construct,
on_metadata_inventory_move = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
on_metadata_inventory_put = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
on_metadata_inventory_take = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
on_metadata_inventory_move = deconstructor_action,
on_metadata_inventory_put = deconstructor_action,
on_metadata_inventory_take = deconstructor_action,
on_blast = on_blast,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,
@ -191,7 +181,7 @@ end
minetest.register_craft({
type = "shaped",
output = "exchangeclone:element_deconstructor",
output = "exchangeclone:deconstructor",
recipe = {
{"", "exchangeclone:exchange_orb",""},
{"", recipe_ingredient, ""},

View File

@ -1,9 +1,8 @@
-- WARNING: Do not use aliases; they will be ignored.
exchangeclone.mtg_energy_values = {
["exchangeclone"] = {
exchange_orb = 33792,
element_deconstructor = 67592,
element_constructor = 92168,
deconstructor = 67592,
constructor = 92168,
energy_collector = 23901,
philosophers_stone = 9984,
alchemical_coal = 512,
@ -392,8 +391,8 @@ I had to change some since they weren't as "equivalent" as they were supposed to
I also didn't type out the ones with a value of 1, since that's the default.]]
exchangeclone.mcl_energy_values = {
["exchangeclone"] = {
element_deconstructor = 67592,
element_constructor = 92168,
deconstructor = 67592,
constructor = 92168,
energy_collector = 23883,
exchange_orb = 33792,
philosophers_stone = 9984,
@ -1596,6 +1595,7 @@ if exchangeclone.mcl then
end
local function set_item_energy(itemstring, energy_value)
itemstring = minetest.registered_aliases[itemstring] or itemstring
local def = minetest.registered_items[itemstring]
if not def then return end
if not def.groups then return end
@ -1640,7 +1640,7 @@ local function set_item_energy(itemstring, energy_value)
})
--minetest.log(itemstring.." "..energy_value.." "..reason)
if mod_name ~= "ghost_blocks" and mod_name ~= "mcl_stairs" and mod_name ~= "stairs" then
local other_itemstrings = {}
local other_itemstrings
if exchangeclone.mcl then
other_itemstrings = {
{"mcl_stairs:slab_"..item_name, energy_value/2},

View File

@ -26,6 +26,31 @@ local function get_energy_collector_formspec()
return table.concat(formspec, "")
end
local check_positions = {
{x=0,y=0,z=1},
{x=0,y=0,z=-1},
{x=0,y=1,z=0},
{x=0,y=-1,z=0},
{x=1,y=0, z=0},
{x=-1,y=0,z=0},
}
local function check_for_furnaces(pos, set_furnace)
local found = false
for _, check_pos in ipairs(check_positions) do
local new_pos = vector.add(pos, check_pos)
local node = minetest.get_node(new_pos)
if minetest.get_item_group(node.name, "exchangeclone_furnace") > 0 then
found = true
if set_furnace ~= nil then
local meta = minetest.get_meta(new_pos)
meta:set_int("using_collector", set_furnace)
end
end
end
return found
end
local function can_dig(pos, player)
if exchangeclone.mcl then return true end
local meta = minetest.get_meta(pos);
@ -47,18 +72,19 @@ local function on_timer(pos, elapsed)
end
if minetest.get_natural_light(above) >= 14 then
meta:set_int("has_light", 1)
if meta:get_int("connected_to_furnace") == 1 then
if check_for_furnaces(pos, 1) then
-- do nothing, energy is being used for the furnace.
return
end
local amount = meta:get_int("collector_amount")
if using_orb then
local stored = exchangeclone.get_orb_energy(inv, "main", 1)
if stored + amount < exchangeclone.energy_max then
if stored + amount <= exchangeclone.orb_max then
stored = stored + amount
exchangeclone.set_orb_energy(inv, "main", 1, stored)
else
stored = math.max(stored, exchangeclone.orb_max)
end
exchangeclone.set_orb_energy(inv, "main", 1, stored)
else
local placer = meta:get_string("collector_placer")
if placer and placer ~= "" then
@ -70,7 +96,7 @@ local function on_timer(pos, elapsed)
end
end
else
meta:set_int("has_light", 0)
check_for_furnaces(pos, 0)
end
return true
end
@ -165,6 +191,9 @@ function exchangeclone.register_energy_collector(itemstring, name, amount, modif
on_metadata_inventory_take = function(pos)
minetest.get_node_timer(pos):start(1)
end,
on_destruct = function(pos, large)
check_for_furnaces(pos, 0)
end,
after_place_node = function(pos, player, itemstack, pointed_thing)
local player_name = player:get_player_name()
local meta = minetest.get_meta(pos)
@ -246,7 +275,7 @@ exchangeclone.register_energy_collector("exchangeclone:energy_collector_mk3", "E
}
})
exchangeclone.register_energy_collector("exchangeclone:energy_collector_mk4", "Energy Collector MK4", 160, "^[multiply:#000077", {
exchangeclone.register_energy_collector("exchangeclone:energy_collector_mk4", "Energy Collector MK4", 160, "^[multiply:#007700", {
output = "exchangeclone:energy_collector_mk4",
recipe = {
{iron, iron, iron},
@ -255,7 +284,7 @@ exchangeclone.register_energy_collector("exchangeclone:energy_collector_mk4", "E
}
})
exchangeclone.register_energy_collector("exchangeclone:energy_collector_mk5", "Energy Collector MK5", 640, "^[brighten", {
exchangeclone.register_energy_collector("exchangeclone:energy_collector_mk5", "Energy Collector MK5", 640, "^[multiply:#000077", {
output = "exchangeclone:energy_collector_mk5",
recipe = {
{iron, iron, iron},

View File

@ -1,23 +0,0 @@
-- next update?
local pages = {}
function exchangeclone.show_guidebook(player)
end
minetest.register_tool("exchangeclone:exchangeclone_guidebook", {
description = "Exchange Guidebook",
inventory_image = "exchangeclone_guidebook.png",
wield_image = "exchangeclone_guidebook.png",
on_place = function(itemstack, player, pointed_thing) exchangeclone.show_guidebook(player) end,
on_secondary_use = function(itemstack, player, pointed_thing) exchangeclone.show_guidebook(player) end,
})
minetest.register_chatcommand("exchangeclone_guidebook", function(name, param) exchangeclone.show_guidebook(minetest.get_player_by_name(name)) end)
minetest.register_craft{
output = "exchangeclone:exchangeclone_guidebook",
recipe = "exchangeclone:philosophers_stone",
replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}}
}

View File

@ -2,7 +2,11 @@
local ores = {
["mcl_raw_ores:raw_gold"] = true,
["mcl_raw_ores:raw_iron"] = true,
["mcl_copper:raw_copper"] = true
["mcl_copper:raw_copper"] = true,
["default:copper_lump"] = true,
["default:gold_lump"] = true,
["default:iron_lump"] = true,
["default:tin_lump"] = true,
}
local furnace_itemstring = "default:furnace"
@ -38,10 +42,9 @@ local base_formspec =
-- TODO: Add it back when the Minetest bug is fixed.
--"image_button[8,0;1,1;craftguide_book.png;craftguide;]"..
--"tooltip[craftguide;"..minetest.formspec_escape("Recipe book").."]"..
"size[9,8.75]"..
"size[10,8.75]"..
"label[0,4;Inventory]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..
exchangeclone.inventory_formspec(0,4.5)..
"list[context;src;2.75,0.5;1,1]"..
"list[context;fuel;2.75,2.5;1,1;]"..
"list[context;dst;5.75,1.5;1,1;]"..
@ -64,7 +67,7 @@ end
local function inactive_formspec(type)
local num_columns = (type == "Dark" and 2) or 3
return base_formspec..
"list[context;src;0,1;"..tostring(num_columns)..",3;2]"..
"list[context;src;0,1;"..tostring(num_columns)..",3;1]"..
"label[2.75,0;"..type.." Matter Furnace]"..
"image[2.75,1.5;1,1;default_furnace_fire_bg.png]"..
"image[4.1,1.5;1.5,1;gui_furnace_arrow_bg.png^[transformR270]"
@ -75,14 +78,14 @@ local function active_formspec(fuel_percent, item_percent, type)
return base_formspec..
"image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
(100-fuel_percent)..":default_furnace_fire_fg.png]"..
"list[context;src;0,1;"..tostring(num_columns)..",3;2]"..
"list[context;src;0,1;"..tostring(num_columns)..",3;1]"..
"image[4.1,1.5;1.5,1;gui_furnace_arrow_bg.png^[lowpart:"..
(item_percent)..":gui_furnace_arrow_fg.png^[transformR270]"..
"label[2.75,0;"..type.." Matter Furnace]"
end
local receive_fields = function(pos, formname, fields, sender)
if fields.craftguide then
if fields.craftguide and exchangeclone.mcl then
mcl_craftguide.show(sender:get_player_name())
end
end
@ -160,7 +163,7 @@ end
local function on_metadata_inventory_take(pos, listname, index, stack, player)
-- Award smelting achievements
if listname == "dst" then
if exchangeclone.mcl and listname == "dst" then
if stack:get_name() == "mcl_core:iron_ingot" then
awards.unlock(player:get_player_name(), "mcl:acquireIron")
end
@ -169,6 +172,7 @@ local function on_metadata_inventory_take(pos, listname, index, stack, player)
end
local function spawn_flames(pos, param2)
if not exchangeclone.mcl then return end
local minrelpos, maxrelpos
local dir = minetest.facedir_to_dir(param2)
if dir.x > 0 then
@ -211,7 +215,7 @@ local function swap_node(pos, name)
minetest.swap_node(pos, node)
if name == "exchangeclone:dark_matter_furnace_active" or name == "exchangeclone:red_matter_furnace_active" then
spawn_flames(pos, node.param2)
else
elseif exchangeclone.mcl then
mcl_particles.delete_node_particlespawners(pos)
end
end
@ -266,46 +270,22 @@ local function furnace_get_delta_time(pos, elapsed)
return meta, elapsed_game_time
end
local check_positions = {
{x=0,y=0,z=1},
{x=0,y=0,z=-1},
{x=0,y=1,z=0},
{x=0,y=-1,z=0},
{x=1,y=0, z=0},
{x=-1,y=0,z=0},
}
local function check_for_collector(pos, set_furnace)
local collector_found = false
for _, check_pos in ipairs(check_positions) do
minetest.log(dump(vector.add(pos, check_pos)))
local check_node = minetest.get_node(vector.add(pos, check_pos))
if minetest.get_item_group(check_node.name, "energy_collector") > 0 then
minetest.log(minetest.get_meta(check_pos):get_int("has_light"))
if set_furnace ~= nil then
minetest.get_meta(check_pos):set_int("connected_to_furnace", set_furnace)
end
if minetest.get_meta(check_pos):get_int("has_light") > 0 then
collector_found = true
end
end
end
return collector_found
end
local function check_srclist(pos)
local meta = minetest:get_meta(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if not inv:get_stack("src", 1):is_empty() then
return
return "not empty"
end
for i=2,inv:get_size("src") do
local size = inv:get_size("src")
minetest.log(size)
for i=2,size do
local stack = inv:get_stack("src", i)
minetest.log(dump(stack))
if not stack:is_empty() then
minetest.log("Setting stacks")
inv:set_stack("src", 1, stack)
inv:set_stack("src", i, ItemStack(""))
return
return true
end
end
end
@ -328,7 +308,7 @@ local function furnace_node_timer(pos, elapsed)
local active = true
local fuel
local using_collector = check_for_collector(pos, 1)
local using_collector = meta:get_int("using_collector") > 0
local type = "Dark"
local speed = 22 -- /10 to get items/second
@ -373,7 +353,6 @@ local function furnace_node_timer(pos, elapsed)
-- Check if we have enough fuel to burn
active = (fuel_time < fuel_totaltime) or (using_collector and cooked.item ~= ItemStack(""))
minetest.log(dump({using_collector, cooked.item}))
if cookable and not active then
-- We need to get new fuel
local afterfuel
@ -429,7 +408,7 @@ local function furnace_node_timer(pos, elapsed)
fuel_totaltime = fuel.time * 5.5
end
if srclist and srclist[1]:is_empty() then
check_srclist(pos)
active = check_srclist(pos)
if srclist and srclist[1]:is_empty() then
src_time = 0
end
@ -482,7 +461,9 @@ if minetest.get_modpath("screwdriver") then
on_rotate = screwdriver.rotate_simple
after_rotate_active = function(pos)
local node = minetest.get_node(pos)
if exchangeclone.mcl then
mcl_particles.delete_node_particlespawners(pos)
end
if node.name == "exchangeclone:dark_matter_furnace" or node.name == "exchangeclone:red_matter_furnace" then
return
end
@ -501,7 +482,7 @@ local inactive_def = {
"exchangeclone_dark_matter_furnace.png",
},
paramtype2 = "facedir",
groups = {pickaxey=5, cracky = 3, container=4, material_stone=1, level = get_level(4)},
groups = {pickaxey=5, cracky = 3, container=4, material_stone=1, level = get_level(4), exchangeclone_furnace = 1},
is_ground_content = false,
sounds = exchangeclone.sound_mod.node_sound_stone_defaults(),
@ -534,31 +515,34 @@ local inactive_def = {
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", inactive_formspec("Dark"))
check_for_collector(pos, 1)
local inv = meta:get_inventory()
inv:set_size("src", 7)
inv:set_size("fuel", 1)
inv:set_size("dst", 1)
end,
on_destruct = function(pos)
if exchangeclone.mcl then
mcl_particles.delete_node_particlespawners(pos)
check_for_collector(pos, 0)
--give_xp(pos)
end
end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
-- Reset accumulated game time when player works with furnace:
furnace_reset_delta_time(pos)
check_srclist(pos)
end,
on_metadata_inventory_put = function(pos)
-- Reset accumulated game time when player works with furnace:
furnace_reset_delta_time(pos)
check_srclist(pos)
-- start timer function, it will sort out whether furnace can burn or not.
minetest.get_node_timer(pos):start(0.45)
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
-- Reset accumulated game time when player works with furnace:
furnace_reset_delta_time(pos)
check_srclist(pos)
-- start timer function, it will helpful if player clears dst slot
minetest.get_node_timer(pos):start(0.45)
@ -588,7 +572,7 @@ local active_def = {
paramtype = "light",
light_source = LIGHT_ACTIVE_FURNACE,
drop = "exchangeclone:dark_matter_furnace",
groups = {pickaxey=5, not_in_creative_inventory = 1, container = 4, material_stone=1, cracky = 3, level = get_level(4)},
groups = {pickaxey=5, not_in_creative_inventory = 1, container = 4, material_stone=1, cracky = 3, level = get_level(4), exchangeclone_furnace = 1},
is_ground_content = false,
sounds = exchangeclone.sound_mod.node_sound_stone_defaults(),
on_timer = furnace_node_timer,
@ -623,9 +607,10 @@ local active_def = {
spawn_flames(pos, node.param2)
end,
on_destruct = function(pos)
if exchangeclone.mcl then
mcl_particles.delete_node_particlespawners(pos)
check_for_collector(pos, 0)
--give_xp(pos)
end
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
@ -654,23 +639,26 @@ minetest.override_item("exchangeclone:red_matter_furnace", {
"exchangeclone_red_matter_block.png",
"exchangeclone_red_matter_furnace.png",
},
groups = {pickaxey=5, cracky = 3, container=4, deco_block=1, material_stone=1, level = get_level(5)},
groups = {pickaxey=5, cracky = 3, container=4, deco_block=1, material_stone=1, level = get_level(5), exchangeclone_furnace = 2},
_mcl_hardness = 100,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
-- Reset accumulated game time when player works with furnace:
furnace_reset_delta_time(pos)
check_srclist(pos)
minetest.get_node_timer(pos):start(0.16)
end,
on_metadata_inventory_put = function(pos)
-- Reset accumulated game time when player works with furnace:
furnace_reset_delta_time(pos)
check_srclist(pos)
-- start timer function, it will sort out whether furnace can burn or not.
minetest.get_node_timer(pos):start(0.16)
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
-- Reset accumulated game time when player works with furnace:
furnace_reset_delta_time(pos)
check_srclist(pos)
-- start timer function, it will helpful if player clears dst slot
minetest.get_node_timer(pos):start(0.16)
@ -724,7 +712,7 @@ minetest.override_item("exchangeclone:red_matter_furnace_active", {
"exchangeclone_red_matter_furnace.png",
},
drop = "exchangeclone:red_matter_furnace",
groups = {pickaxey=5, cracky = 3, container=4, deco_block=1, material_stone=1, level = get_level(5)},
groups = {pickaxey=5, not_in_creative_inventory = 1, cracky = 3, container=4, deco_block=1, material_stone=1, level = get_level(5), exchangeclone_furnace = 2},
_mcl_hardness = 100,
on_construct = function(pos)
@ -776,7 +764,7 @@ minetest.register_craft({
output = "exchangeclone:red_matter_furnace",
recipe = {
{ "", "exchangeclone:red_matter_block", "" },
{ "exchangeclone:red_matter_block", "mcl_core:furnace", "exchangeclone:red_matter_block" },
{ "exchangeclone:red_matter_block", "exchangeclone:dark_matter_furnace", "exchangeclone:red_matter_block" },
}
})

View File

@ -10,7 +10,7 @@ end
exchangeclone.mineclonia = minetest.get_game_info().id == "mineclonia" -- if exchangeclone.mineclonia, exchangeclone.mcl will also be defined.
exchangeclone.energy_max = 51200000 -- Max capacity of Klein Star Omega
exchangeclone.orb_max = 51200000 -- Max capacity of Klein Star Omega
local modpath = minetest.get_modpath("exchangeclone")

17
lib.lua
View File

@ -1,3 +1,5 @@
-- Just a collection of a whole bunch of functions used here. There's very little order.
function exchangeclone.get_inventory_drops(pos, inventory, drops) --removes default dependency
local inv = minetest.get_meta(pos):get_inventory()
local n = #drops
@ -51,12 +53,12 @@ function exchangeclone.set_orb_energy(inventory, listname, index, amount)
if not itemstack then return end
if not (itemstack:get_name() and itemstack:get_name() == "exchangeclone:exchange_orb") then return end
local old_energy = exchangeclone.get_orb_itemstack_energy(itemstack)
if amount > old_energy and old_energy > exchangeclone.energy_max then return end -- don't allow more energy to be put into an over-filled orb
if amount > old_energy and old_energy > exchangeclone.orb_max then return end -- don't allow more energy to be put into an over-filled orb
-- Square roots will hopefully make it less linear
-- And if they don't, I don't really care and I don't want to think about math anymore.
local sqrt_amount = math.sqrt(amount)
local sqrt_max = math.sqrt(exchangeclone.energy_max)
local sqrt_max = math.sqrt(exchangeclone.orb_max)
local r, g, b = 0, 0, 0
if amount == 0 then
@ -87,19 +89,18 @@ local hud_elements = {}
function exchangeclone.update_hud(player)
local hud_text = hud_elements[player:get_player_name()]
if not hud_text then minetest.log("!!!") return end
player:hud_change(hud_text, "text", "Stored Energy: "..tostring(exchangeclone.get_player_energy(player)))
player:hud_change(hud_text, "text", "Personal Energy: "..tostring(exchangeclone.get_player_energy(player)))
end
minetest.register_on_joinplayer(function(player, last_login)
hud_elements[player:get_player_name()] = player:hud_add({
hud_elem_type = "text",
position = {x = 1, y = 0.01},
position = {x = 1, y = 1},
offset = {x = 0, y = 0},
text = "Stored Energy: 0",
alignment = {x = -1, y = 0},
text = "Personal Energy: 0",
alignment = {x = -1, y = -1},
scale = {x = 100, y = 100},
number = 0xFFFFFF
number = 0xDDDDDD
})
exchangeclone.update_hud(player)
end)

View File

@ -5,7 +5,7 @@ local function show_enchanting(player)
mcl_enchanting.show_enchanting_formspec(player)
end
local width = (exchangeclone.mcl and 9) or 8
--[[local width = (exchangeclone.mcl and 9) or 8
local smelting_formspec =
"size["..width..",8]"..
"label[0.25,0.25;Smelting]"..
@ -29,7 +29,7 @@ if exchangeclone.mcl then
mcl_formspec.get_itemslot_bg(width/3,1,1,1)..
mcl_formspec.get_itemslot_bg(width/3,2.5,1,1)..
mcl_formspec.get_itemslot_bg(2*width/3,1.5,1,1)
end
end]]
exchangeclone.node_transmutations = {
{ --use
@ -257,16 +257,16 @@ if exchangeclone.mcl then
if player:get_player_control().sneak then
show_enchanting(player)
else
if player:get_player_control().aux1 then
--[[if player:get_player_control().aux1 then
minetest.show_formspec(player:get_player_name(), "exchangeclone_smelting", smelting_formspec)
else
else --]]
mcl_crafting_table.show_crafting_form(player)
end
--end
end
end
end
local fuel_items = {
--[[ local fuel_items = {
["mcl_core:charcoal_lump"] = true,
["mcl_core:coal_lump"] = true,
["default:coal_lump"] = true,
@ -315,7 +315,7 @@ minetest.register_on_player_inventory_action(function(player, action, inventory,
-- TODO
end
end
end)
end) --]]
local function on_right_click(itemstack, player, pointed_thing)
local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing)
@ -641,24 +641,28 @@ minetest.register_craft({
})
minetest.register_craft({
output = "default:tin_ingot 2",
output = "default:tin_ingot 4",
type = "shapeless",
recipe = {
"exchangeclone:philosophers_stone",
"default:copper_ingot",
"default:copper_ingot",
"default:copper_ingot",
"default:copper_ingot",
"default:copper_ingot",
},
replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}}
})
minetest.register_craft({
output = "default:copper_ingot 3",
output = "default:copper_ingot 5",
type = "shapeless",
recipe = {
"exchangeclone:philosophers_stone",
"default:tin_ingot",
"default:tin_ingot",
"default:tin_ingot",
"default:tin_ingot",
},
replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}}
})

View File

@ -76,12 +76,13 @@ local function add_to_output(player, amount, show)
local max_amount = math.min(amount, stack_max, math.floor(player_energy/energy_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_energy(player, player_energy - (energy_value * added_amount))
exchangeclone.set_player_energy(player, math.min(player_energy, player_energy - (energy_value * added_amount))) -- not sure if "math.min()" is necessary
if show then exchangeclone.show_transmutation_table_formspec(player) end
end
end
local function handle_inventory(player, inventory, to_list, to_index, stack)
local function handle_inventory(player, inventory, to_list)
local stack = inventory:get_stack(to_list, 1)
if to_list == "learn" then
local list = minetest.deserialize(player:get_meta():get_string("exchangeclone_transmutation_learned_items")) or {}
if stack:get_name() == "exchangeclone:alchemical_tome" then
@ -95,35 +96,44 @@ local function handle_inventory(player, inventory, to_list, to_index, stack)
end
table.sort(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(stack:get_name())
if individual_energy_value <= 0 then return end
local energy_value = individual_energy_value * stack:get_count()
local wear = stack:get_wear()
if wear and wear > 1 then
individual_energy_value = math.floor(individual_energy_value * (65536 / wear))
end
if stack:get_name() == "exchangeclone:exchange_orb" then
energy_value = energy_value + exchangeclone.get_orb_itemstack_energy(stack)
individual_energy_value = individual_energy_value + exchangeclone.get_orb_itemstack_energy(stack)
end
local player_energy = exchangeclone.get_player_energy(player)
local max_count = math.floor((2147483647 - player_energy)/individual_energy_value)
local add_count = math.min(max_count, stack:get_count())
local energy_value = individual_energy_value * add_count
local result = player_energy + energy_value
if result < 0 or result > 2147483647 then return end
exchangeclone.set_player_energy(player, exchangeclone.get_player_energy(player) + energy_value)
exchangeclone.set_player_energy(player, result)
local item_index = table.indexof(list, stack:get_name())
if item_index == -1 then
list[#list+1] = stack:get_name()
table.sort(list)
player:get_meta():set_string("exchangeclone_transmutation_learned_items", minetest.serialize(list))
end
stack:set_count(stack:get_count() - add_count)
if stack:get_count() == 0 then stack = ItemStack("") end
inventory:set_stack(to_list, 1, stack)
end
inventory:set_stack(to_list, to_index, nil)
exchangeclone.show_transmutation_table_formspec(player)
elseif to_list == "forget" then
return
elseif to_list == "charge" then
local player_energy = exchangeclone.get_player_energy(player)
local orb_energy = exchangeclone.get_orb_itemstack_energy(stack)
local charge_amount = math.min(exchangeclone.energy_max - orb_energy, player_energy)
local charge_amount = math.min(exchangeclone.orb_max - orb_energy, player_energy)
if charge_amount > 0 then
exchangeclone.set_player_energy(player, player_energy - charge_amount)
exchangeclone.set_orb_energy(inventory, to_list, to_index, orb_energy + charge_amount)
exchangeclone.set_orb_energy(inventory, to_list, 1, orb_energy + charge_amount)
exchangeclone.show_transmutation_table_formspec(player)
end
end
@ -374,8 +384,8 @@ minetest.register_craft({
minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv)
if itemstack == ItemStack("exchangeclone:alchemical_tome") then
if exchangeclone.get_orb_itemstack_energy(old_craft_grid[4]) >= exchangeclone.energy_max
and exchangeclone.get_orb_itemstack_energy(old_craft_grid[6]) >= exchangeclone.energy_max then
if exchangeclone.get_orb_itemstack_energy(old_craft_grid[4]) >= exchangeclone.orb_max
and exchangeclone.get_orb_itemstack_energy(old_craft_grid[6]) >= exchangeclone.orb_max then
return
else
return ItemStack("")