First release
This commit is contained in:
parent
8279e8b0d5
commit
d52b77e52c
30
README.md
30
README.md
|
@ -1,9 +1,10 @@
|
|||
# Element Exchange
|
||||
A [Minetest](https://www.minetest.net/) mod to exchange nodes into other nodes. This is mod is inspired by the "Equivalent Exchange" mod for MineCraft, and forked and modified from [Element Exchange](https://github.com/enchant97/minetest_element_exchange). In other words, a lot of the code is not mine.
|
||||
|
||||
![In Game Screenshot](screenshot.png)
|
||||
# ExchangeClone
|
||||
Allows players to turn nodes into energy (stored in orbs), and energy from orbs into nodes. Supports all items in Minetest Game and MineClone 2!
|
||||
|
||||
[GitHub repo](https://github.com/thepython10110/exchangeclone)
|
||||
[Forum topic](https://forum.minetest.net/viewtopic.php?f=9&t=29473)
|
||||
|
||||
Dependencies: Minetest Game or MineClone.
|
||||
|
||||
## Features
|
||||
- Orb that holds energy (left click while holding it to show charge)
|
||||
|
@ -12,19 +13,30 @@ A [Minetest](https://www.minetest.net/) mod to exchange nodes into other nodes.
|
|||
- Constructor that can create items from energy
|
||||
|
||||
## Config
|
||||
You can change the default values in the Minetest settings under `mods > exchangeclone`.
|
||||
All energy values are in `energy.lua`. You can also change the speed at which the Energy Collector collects energy (default: every 5 seconds) in `minetest.conf` or the Minetest settings.
|
||||
|
||||
## New features added by ThePython10110
|
||||
* Working on support for MineClone, including hoppers (all features work, just need to add energy values)
|
||||
* Support for MineClone
|
||||
* Better energy values (originally, you could convert a single diamond into a diamond block... incredibly OP).
|
||||
* Shift-clicking works (`listring`s)
|
||||
* Fixed a bug where items could be placed in the output slot of the Element Constructor
|
||||
* Added the ability to add energy values by group
|
||||
* Damaged tools now give less energy (based on wear)
|
||||
* Orbs now can be turned into energy (based on how much is stored)
|
||||
I plan to add more features from Equivalent Exchange (Energy Condenser, Philosopher's Stone, dark matter, etc.), but I don't actually own MineCraft, meaning I will probably make some minor mistakes, since all I have to go on is the internet. Please report any issues on the [GitHub issues page](https://github.com/thepython10110/exchangeclone/issues).
|
||||
I plan to add more features from Equivalent Exchange (Energy Condenser, Philosopher's Stone, dark matter, etc.), but I don't actually own MineCraft, meaning I will probably make some minor mistakes, since all I have to go on is the internet.
|
||||
|
||||
## Original License
|
||||
Copyright (C) 2021 Leo Spratt
|
||||
## Known issues:
|
||||
* When items are inserted into machines with MineClone hoppers, it does not trigger the machines to start.
|
||||
* When machines are exploded, they (and the items inside) do not drop.
|
||||
If you have a suggestion or notice a bug, visit the [GitHub issues page](https://github.com/thepython10110/exchangeclone/issues).
|
||||
|
||||
![MineClone Screenshot](screenshot.png)
|
||||
![Minetest Game Screenshot](screenshot_mtg.png)
|
||||
|
||||
## Sources/license:
|
||||
This mod is inspired by the "Equivalent Exchange" mod for MineCraft, and forked and modified from Enchant97's mod [Element Exchange](https://github.com/enchant97/minetest_element_exchange). Both this mod and Element Exchange are licensed under GPLv3+. The textures for the Constructor, Deconstructor, Collector, and Orb are from Element Exchange and have the same license.
|
||||
|
||||
Copyright (C) 2023 ThePython10110
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -146,9 +146,9 @@ end
|
|||
|
||||
local function on_blast(pos)
|
||||
local drops = {}
|
||||
default.get_inventory_drops(pos, "fuel", drops)
|
||||
default.get_inventory_drops(pos, "src", drops)
|
||||
default.get_inventory_drops(pos, "dst", drops)
|
||||
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"
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
|
|
|
@ -61,8 +61,8 @@ local function on_timer(pos, elapsed)
|
|||
end
|
||||
if energy_value ~= 0 then
|
||||
local wear = fuel_stack:get_wear()
|
||||
if wear and wear ~= 0 then
|
||||
energy_value = energy_value * (65536 / wear)
|
||||
if wear and wear > 1 then
|
||||
energy_value = math.floor(energy_value * (65536 / wear))
|
||||
end
|
||||
-- only get 1 orb as we can only use one
|
||||
local dest_orb = inv:get_stack("dst", 1)
|
||||
|
@ -77,7 +77,6 @@ local function on_timer(pos, elapsed)
|
|||
dest_orb:get_meta():set_string("description", "Exchange Orb\nCurrent Charge: "..tostring(stored))
|
||||
inv:set_stack("dst", 1, dest_orb)
|
||||
end
|
||||
|
||||
update = true
|
||||
end
|
||||
end
|
||||
|
@ -129,8 +128,8 @@ end
|
|||
|
||||
local function on_blast(pos)
|
||||
local drops = {}
|
||||
default.get_inventory_drops(pos, "main", drops)
|
||||
default.get_inventory_drops(pos, "dst", drops)
|
||||
exchangeclone.get_inventory_drops(pos, "main", drops)
|
||||
exchangeclone.get_inventory_drops(pos, "dst", drops)
|
||||
drops[#drops+1] = "exchangeclone:element_deconstructor"
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
|
|
1160
energy.lua
1160
energy.lua
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
function get_energy_collector_formspec()
|
||||
local function get_energy_collector_formspec()
|
||||
if not exchangeclone.mineclone then
|
||||
local formspec = {
|
||||
"size[8,9]",
|
||||
|
@ -68,6 +68,7 @@ end
|
|||
|
||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
minetest.log("blocked put")
|
||||
return 0
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -90,6 +91,7 @@ end
|
|||
|
||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
minetest.log("blocked take")
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
|
@ -97,12 +99,31 @@ end
|
|||
|
||||
local function on_blast(pos)
|
||||
local drops = {}
|
||||
default.get_inventory_drops(pos, "main", drops)
|
||||
exchangeclone.get_inventory_drops(pos, "main", drops)
|
||||
drops[#drops+1] = "exchangeclone:energy_collector"
|
||||
minetest.remove_node(pos)
|
||||
|
||||
return drops
|
||||
end
|
||||
|
||||
|
||||
local function on_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
if exchangeclone.mineclone then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta:to_table()
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
for _, listname in ipairs({"main"}) 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}
|
||||
minetest.add_item(p, stack)
|
||||
end
|
||||
end
|
||||
meta:from_table(meta2)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("exchangeclone:energy_collector", {
|
||||
description = "Energy Collector",
|
||||
tiles = {
|
||||
|
@ -116,24 +137,9 @@ minetest.register_node("exchangeclone:energy_collector", {
|
|||
groups = {cracky = 2, container = 2},
|
||||
is_ground_content = false,
|
||||
can_dig = can_dig,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if exchangeclone.mineclone then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta:to_table()
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
for _, listname in ipairs({"main"}) 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}
|
||||
minetest.add_item(p, stack)
|
||||
end
|
||||
end
|
||||
meta:from_table(meta2)
|
||||
end
|
||||
end,
|
||||
on_timer = on_timer,
|
||||
on_construct = on_construct,
|
||||
on_dig_node = on_dig_node,
|
||||
on_metadata_inventory_move = function(pos)
|
||||
minetest.get_node_timer(pos):start(exchangeclone.collector_interval)
|
||||
end,
|
||||
|
@ -149,7 +155,36 @@ minetest.register_node("exchangeclone:energy_collector", {
|
|||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
})
|
||||
|
||||
local recipe_item_1 = "default:steel_block"
|
||||
--[[if minetest.get_modpath("pipeworks") then
|
||||
minetest.override_item("exchangeclone:energy_collector", {
|
||||
tube = {
|
||||
input_inventory = "main",
|
||||
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1},
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("main", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if stack:get_name() == "exchangeclone:exchange_orb" then
|
||||
minetest.log(inv:room_for_item("main", stack))
|
||||
return inv:room_for_item("main", stack)
|
||||
else
|
||||
minetest.log("failed")
|
||||
end
|
||||
end,
|
||||
},
|
||||
after_place_node = function(pos, placer)
|
||||
pipeworks.after_place(pos)
|
||||
end,
|
||||
after_dig_node = pipeworks.after_dig,
|
||||
on_rotate = pipeworks.on_rotate,
|
||||
})
|
||||
end]]
|
||||
|
||||
local recipe_item_1 = "default:steelblock"
|
||||
local recipe_item_2 = "default:obsidian_glass"
|
||||
local recipe_item_3 = "default:chest"
|
||||
|
||||
|
|
14
init.lua
14
init.lua
|
@ -9,13 +9,25 @@ else
|
|||
minetest.log("Loading ExchangeClone with MTG configuration")
|
||||
end
|
||||
|
||||
function exchangeclone.get_inventory_drops(pos, inventory, drops) --removes default dependency
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local n = #drops
|
||||
for i = 1, inv:get_size(inventory) do
|
||||
local stack = inv:get_stack(inventory, i)
|
||||
if stack:get_count() > 0 then
|
||||
drops[n+1] = stack:to_table()
|
||||
n = n + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local default_path = minetest.get_modpath("exchangeclone")
|
||||
|
||||
function exchangeclone.get_item_energy(name)
|
||||
return minetest.registered_items[name].energy_value or 1
|
||||
end
|
||||
|
||||
exchangeclone.collector_interval = minetest.settings:get("exchangeclone.collector_interval") or 20
|
||||
exchangeclone.collector_interval = minetest.settings:get("exchangeclone.collector_interval") or 5
|
||||
|
||||
dofile(default_path.."/config.lua")
|
||||
dofile(default_path.."/constructor.lua")
|
||||
|
|
2
mod.conf
2
mod.conf
|
@ -2,5 +2,5 @@ name = exchangeclone
|
|||
title = ExchangeClone
|
||||
description = Exchange nodes into other nodes
|
||||
min_minetest_version = 5.5
|
||||
optional_depends=mcl_core, default, moreswords
|
||||
optional_depends = mcl_core, default, moreswords, mcl_stairs, pipeworks
|
||||
author = ThePython10110
|
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 612 KiB |
Binary file not shown.
After Width: | Height: | Size: 793 KiB |
|
@ -1,2 +1,2 @@
|
|||
# How fast the energy collector gathers energy from the light
|
||||
exchangeclone.collector_interval (Collector Gather Interval) int 20
|
||||
exchangeclone.collector_interval (Collector Gather Interval) int 5
|
||||
|
|
Loading…
Reference in New Issue