Bunch of random things again
This commit is contained in:
parent
d5c153e45f
commit
b21c182365
49
README.md
49
README.md
|
@ -40,9 +40,10 @@ Dependencies: Minetest Game or MineClone.
|
|||
## Known issues:
|
||||
* Dark/Red Matter armor don't work they way they should, especially in MTG. I would greatly appreciate a PR that makes them work more like ProjectE.
|
||||
* The sword/katar AOE ability does not take upgrades into account. This will probably not be fixed (MCL)
|
||||
* When machines are exploded, they (and the items inside) do not drop. I can't figure out why.
|
||||
* For technical reasons (making them work with MCL hoppers), Exchange Orbs and Upgrades can be used as fuel. This isn't really a problem, but it will be removed once I decide the new hopper API is new enough that most people are using it.
|
||||
* Dark/Red matter shears will sometimes (randomly) be treated as normal shears when used by MCL dispensers. This will not be fixed.
|
||||
* Dark/Red Matter Shears will sometimes (randomly) be treated as normal shears when used by MCL dispensers. This will not be fixed.
|
||||
* In Mineclonia, when inserting items into Dark/Red Matter Furnaces with hoppers, they will not start at the correct speed, instead being limited to a maximum of 1 item/second. This will not be fixed unless Mineclonia changes how things work.
|
||||
* In Mineclonia, hoppers can put invalid items into Energy Collectors.
|
||||
|
||||
**If you have a suggestion or notice a bug, visit the [GitHub issues page](https://github.com/thepython10110/exchangeclone/issues).**
|
||||
|
||||
|
@ -66,10 +67,12 @@ Dependencies: Minetest Game or MineClone.
|
|||
|
||||
### TODO:
|
||||
* Figure out what's going to happen with Technic (the PR probably won't be merged)
|
||||
* Test everything in MTG, MCL2, and MCLA (and 5.7)
|
||||
* Finish changelog
|
||||
* Finish wiki
|
||||
* Improve covalence formspec
|
||||
* Test everything in MTG, MCL2, and MCLA (and 5.7)
|
||||
* Everything breaks properly in MTG
|
||||
* Fix Tmcl_banners thing
|
||||
* Fix Technic Beta
|
||||
|
||||
### v6.0 (The Compatibility Update)
|
||||
|
||||
|
@ -82,7 +85,9 @@ Dependencies: Minetest Game or MineClone.
|
|||
* Changed A LOT of things internally. Any mods depending on ExchangeClone (probably not very many, which is good) will probably need to update stuff.
|
||||
* **The PESA will be removed in version 7.0.**
|
||||
|
||||
**Full Changelog**
|
||||
I didn't get to everything I wanted to, mostly because the automatic energy values required quite a lot of work.
|
||||
|
||||
#### Full Changelog**
|
||||
* New Features:
|
||||
* Automatically generated energy values! Based on crafting and cooking recipes.
|
||||
* Depending on the number of crafting recipes you have, this could increase load times. This is definitely a bit of an issue in MineClone2, probably due to the number of banner/dye recipes. Eventually (hopefully), loom functionality will be added and this will improve quite a bit.
|
||||
|
@ -120,6 +125,7 @@ Dependencies: Minetest Game or MineClone.
|
|||
* Tool abilities now have no energy cost (to match ProjectE).
|
||||
* Tool abilities now take upgrades into account (silk touch, fortune, etc.) except for the sword AOE ability (which would require irritating hacky workarounds).
|
||||
* Several neutral mobs (endermen, spiders, piglins) are now affected by the dark/red matter sword in "slay hostile" mode, to match ProjectE.
|
||||
* No more mod whitelist.
|
||||
* Bugfixes:
|
||||
* Fixed potion energy values (MCL)
|
||||
* Fixed Red Matter Shield recipe (MTG)
|
||||
|
@ -127,17 +133,17 @@ Dependencies: Minetest Game or MineClone.
|
|||
* Deconstructors and Constructors will now continue trying to work instead of just stopping when there is too much or too little energy.
|
||||
* Tool abilities now update nodes that require support (torches, sand, etc.).
|
||||
* MCL raw copper, iron, and gold blocks now correctly double in DM/RM furnaces.
|
||||
* Finally fixed that bug where things don't drop when exploded.
|
||||
|
||||
### v5.4
|
||||
* Fixed a minor bug with the Energy Collector (thanks @programmerjake!)
|
||||
* Now adding v's to version numbers... because it looks nice, I guess.
|
||||
|
||||
### 5.3
|
||||
* Bugfixes
|
||||
* Fixed shearing beehives in MCL (thanks @Ranko-Saotome!)
|
||||
* Fixed shearing beehives in MCL (thanks @Ranko-Saotome!)
|
||||
|
||||
### 5.2
|
||||
* Bugfixes
|
||||
* Removed unnecessary logging every time players take damage (I was testing stuff out with the armor, thanks @Ranko-Saotome for reporting)
|
||||
* Removed unnecessary logging every time players take damage (I was testing stuff out with the armor, thanks @Ranko-Saotome for reporting)
|
||||
|
||||
### 5.1
|
||||
* New Features:
|
||||
|
@ -193,8 +199,7 @@ Dependencies: Minetest Game or MineClone.
|
|||
* Fixed an error message about the `invert` texture modifier
|
||||
|
||||
### 4.4
|
||||
* New Features
|
||||
* Mineclonia Support
|
||||
* Added Mineclonia Support (or at least, I thought I did)
|
||||
* The version numbers kind of disagree around here and I'm too lazy to fix it.
|
||||
|
||||
### 4.3
|
||||
|
@ -209,13 +214,11 @@ Dependencies: Minetest Game or MineClone.
|
|||
* 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!)
|
||||
* 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)
|
||||
* 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:
|
||||
|
@ -234,15 +237,12 @@ Dependencies: Minetest Game or MineClone.
|
|||
* 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`
|
||||
* 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
|
||||
* Added new energy values from Why (and Why's new Minetest Game energy values)
|
||||
* Fixed crash based on PESA inventory movement
|
||||
* Added `mcl_blackstone` to the mod whitelist
|
||||
|
||||
### 3.0 (the formerly most interesting release)
|
||||
* New features:
|
||||
|
@ -334,6 +334,7 @@ Dependencies: Minetest Game or MineClone.
|
|||
</details>
|
||||
|
||||
### Features that I plan on adding eventually:
|
||||
* Achievements
|
||||
* ~~As soon as Minetest 5.8 comes out, better textures for armor...~~ Don't want to limit it to 5.8
|
||||
* Divining Rods
|
||||
* Rings (I'll probably add a new PESA-like item for holding rings)
|
||||
|
@ -347,4 +348,6 @@ Dependencies: Minetest Game or MineClone.
|
|||
* Catalytic Lens
|
||||
* Mind, Life, Body, and Soul Stones
|
||||
* Mercurial Eye
|
||||
* Talisman of Repair
|
||||
* Gem of Eternal Density
|
||||
* Probably other things
|
|
@ -33,19 +33,21 @@ local function alchemical_on_construct(color)
|
|||
end
|
||||
end
|
||||
|
||||
local pipeworks_connect = exchangeclone.pipeworks and "^pipeworks_tube_connection_stony.png" or ""
|
||||
|
||||
minetest.register_node("exchangeclone:alchemical_chest", {
|
||||
description = S("Alchemical Chest"),
|
||||
groups = {container = 2, alchemical_chest = 1, cracky = 2, pickaxey = 2},
|
||||
groups = {container = 2, alchemical_chest = 1, cracky = 2, pickaxey = 2, tubedevice = 1, tubedevice_receiver = 1},
|
||||
_mcl_hardness = 3,
|
||||
_mcl_blast_resistance = 6,
|
||||
paramtype2 = "4dir",
|
||||
tiles = {
|
||||
"exchangeclone_alchemical_chest_top.png",
|
||||
"exchangeclone_alchemical_chest_bottom.png",
|
||||
"exchangeclone_alchemical_chest_side.png",
|
||||
"exchangeclone_alchemical_chest_side.png",
|
||||
"exchangeclone_alchemical_chest_side.png",
|
||||
"exchangeclone_alchemical_chest_front.png",
|
||||
"exchangeclone_alchemical_chest_top.png"..pipeworks_connect,
|
||||
"exchangeclone_alchemical_chest_bottom.png"..pipeworks_connect,
|
||||
"exchangeclone_alchemical_chest_side.png"..pipeworks_connect,
|
||||
"exchangeclone_alchemical_chest_side.png"..pipeworks_connect,
|
||||
"exchangeclone_alchemical_chest_side.png"..pipeworks_connect,
|
||||
"exchangeclone_alchemical_chest_front.png"..pipeworks_connect,
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -55,6 +57,25 @@ minetest.register_node("exchangeclone:alchemical_chest", {
|
|||
inv:set_size("main", 104)
|
||||
inv:set_width("main", 13)
|
||||
end,
|
||||
tube = exchangeclone.pipeworks and {
|
||||
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()
|
||||
local result = inv:add_item("main", stack)
|
||||
if result then
|
||||
local func = minetest.registered_items[node.name].on_metadata_inventory_put
|
||||
if func then func(pos) end
|
||||
end
|
||||
return result
|
||||
end
|
||||
},
|
||||
on_blast = exchangeclone.on_blast({"main"}),
|
||||
on_rotate = exchangeclone.pipeworks and pipeworks.on_rotate,
|
||||
after_place_node = exchangeclone.pipeworks and pipeworks.after_place,
|
||||
after_dig_node = exchangeclone.drop_after_dig({"main"}),
|
||||
can_dig = exchangeclone.can_dig,
|
||||
})
|
||||
|
||||
local stone_itemstring = exchangeclone.mcl and "mcl_core:stone" or "default:stone"
|
||||
|
@ -78,8 +99,8 @@ minetest.register_on_joinplayer(function(player, last_login)
|
|||
end)
|
||||
|
||||
for color, color_data in pairs(exchangeclone.colors) do
|
||||
local bag_itemstring = "exchangeclone:"..color.."_alchemical_bag"
|
||||
local advanced_itemstring = "exchangeclone:"..color.."_advanced_alchemical_chest"
|
||||
local bag_itemstring = "exchangeclone:alchemical_bag_"..color
|
||||
local advanced_itemstring = "exchangeclone:advanced_alchemical_chest_"..color
|
||||
local wool_itemstring = (exchangeclone.mcl and "mcl_wool:" or "wool:")..color
|
||||
local dye_itemstring = (exchangeclone.mcl and "mcl_dye:" or "dye:")..color
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
-- Currently none of this stuff actually runs (didn't get to it in v6.0)
|
||||
|
||||
local S = minetest.get_translator()
|
||||
|
||||
local storage = minetest.get_mod_storage()
|
||||
|
|
|
@ -35,13 +35,6 @@ minetest.register_lbm({
|
|||
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("fuel") and inv:is_empty("src") and inv:is_empty("dst")
|
||||
end
|
||||
|
||||
local function constructor_action(pos)
|
||||
local using_orb = true
|
||||
local player
|
||||
|
@ -135,48 +128,25 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function on_blast(pos)
|
||||
local 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:constructor"
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
end
|
||||
local pipeworks_connect = exchangeclone.pipeworks and "^pipeworks_tube_connection_metallic.png" or ""
|
||||
|
||||
minetest.register_node("exchangeclone:constructor", {
|
||||
description = S("Constructor"),
|
||||
tiles = {
|
||||
"exchangeclone_constructor_up.png",
|
||||
"exchangeclone_constructor_down.png",
|
||||
"exchangeclone_constructor_right.png",
|
||||
"exchangeclone_constructor_right.png",
|
||||
"exchangeclone_constructor_right.png",
|
||||
"exchangeclone_constructor_right.png"
|
||||
"exchangeclone_constructor_up.png"..pipeworks_connect,
|
||||
"exchangeclone_constructor_down.png"..pipeworks_connect,
|
||||
"exchangeclone_constructor_right.png"..pipeworks_connect,
|
||||
"exchangeclone_constructor_right.png"..pipeworks_connect,
|
||||
"exchangeclone_constructor_right.png"..pipeworks_connect,
|
||||
"exchangeclone_constructor_right.png"..pipeworks_connect,
|
||||
},
|
||||
groups = {cracky = 2, container = exchangeclone.mcl2 and 2 or 4, pickaxey = 2, tubedevice = 1, tubedevice_receiver = 1},
|
||||
_mcl_hardness = 3,
|
||||
_mcl_blast_resistance = 6,
|
||||
sounds = exchangeclone.sound_mod.node_sound_metal_defaults(),
|
||||
is_ground_content = false,
|
||||
can_dig = can_dig,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, player)
|
||||
if exchangeclone.mcl then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta:to_table()
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
for _, listname in pairs({"src", "dst", "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}
|
||||
minetest.add_item(p, stack)
|
||||
end
|
||||
end
|
||||
meta:from_table(meta2)
|
||||
end
|
||||
end,
|
||||
can_dig = exchangeclone.can_dig,
|
||||
after_dig_node = exchangeclone.drop_after_dig({"src", "fuel", "dst"}),
|
||||
after_place_node = function(pos, player, itemstack, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("exchangeclone_placer", player:get_player_name())
|
||||
|
@ -190,16 +160,20 @@ minetest.register_node("exchangeclone:constructor", {
|
|||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
constructor_action(pos)
|
||||
end,
|
||||
on_blast = on_blast,
|
||||
on_blast = exchangeclone.on_blast({"src", "fuel", "dst"}),
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
on_timer = constructor_action,
|
||||
_mcl_hoppers_on_try_pull = exchangeclone.hoppers_on_try_pull,
|
||||
_mcl_hoppers_on_try_push = exchangeclone.hoppers_on_try_push,
|
||||
_mcl_hoppers_on_try_pull = exchangeclone.mcl2_hoppers_on_try_pull(),
|
||||
_mcl_hoppers_on_try_push = exchangeclone.mcl2_hoppers_on_try_push(nil, function(stack) return stack:get_name() == "exchangeclone:exchange_orb" end),
|
||||
_mcl_hoppers_on_after_push = function(pos)
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
end,
|
||||
_on_hopper_in = exchangeclone.mcla_on_hopper_in(
|
||||
nil,
|
||||
function(stack) return stack:get_name() == "exchangeclone:exchange_orb" end
|
||||
),
|
||||
})
|
||||
|
||||
if exchangeclone.pipeworks then
|
||||
|
|
|
@ -32,13 +32,6 @@ minetest.register_lbm({
|
|||
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("src") and inv:is_empty("fuel") and inv:is_empty("main")
|
||||
end
|
||||
|
||||
local function deconstructor_action(pos, elapsed)
|
||||
local limit = exchangeclone.orb_max
|
||||
local using_orb = true
|
||||
|
@ -136,50 +129,25 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function on_blast(pos)
|
||||
local drops = {}
|
||||
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
|
||||
local pipeworks_connect = exchangeclone.pipeworks and "^pipeworks_tube_connection_metallic.png" or ""
|
||||
|
||||
minetest.register_node("exchangeclone:deconstructor", {
|
||||
description = S("Deconstructor"),
|
||||
tiles = {
|
||||
"exchangeclone_deconstructor_up.png",
|
||||
"exchangeclone_deconstructor_down.png",
|
||||
"exchangeclone_deconstructor_right.png",
|
||||
"exchangeclone_deconstructor_right.png",
|
||||
"exchangeclone_deconstructor_right.png",
|
||||
"exchangeclone_deconstructor_right.png"
|
||||
"exchangeclone_deconstructor_up.png"..pipeworks_connect,
|
||||
"exchangeclone_deconstructor_down.png"..pipeworks_connect,
|
||||
"exchangeclone_deconstructor_right.png"..pipeworks_connect,
|
||||
"exchangeclone_deconstructor_right.png"..pipeworks_connect,
|
||||
"exchangeclone_deconstructor_right.png"..pipeworks_connect,
|
||||
"exchangeclone_deconstructor_right.png"..pipeworks_connect,
|
||||
},
|
||||
groups = {cracky = 2, container = 4, pickaxey = 2, tubedevice = 1, tubedevice_receiver = 1},
|
||||
groups = {cracky = 2, container = exchangeclone.mcl2 and 2 or 4, pickaxey = 2, tubedevice = 1, tubedevice_receiver = 1},
|
||||
_mcl_hardness = 3,
|
||||
_mcl_blast_resistance = 6,
|
||||
sounds = exchangeclone.sound_mod.node_sound_metal_defaults(),
|
||||
is_ground_content = false,
|
||||
can_dig = can_dig,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, player)
|
||||
if exchangeclone.mcl then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta:to_table()
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
for _, listname in pairs({"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}
|
||||
minetest.add_item(p, stack)
|
||||
end
|
||||
end
|
||||
meta:from_table(meta2)
|
||||
end
|
||||
if exchangeclone.pipeworks then
|
||||
pipeworks.after_dig(pos)
|
||||
end
|
||||
end,
|
||||
can_dig = exchangeclone.can_dig,
|
||||
after_dig_node = exchangeclone.drop_after_dig({"src", "fuel"}),
|
||||
after_place_node = function(pos, player, itemstack, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("exchangeclone_placer", player:get_player_name())
|
||||
|
@ -187,22 +155,25 @@ minetest.register_node("exchangeclone:deconstructor", {
|
|||
pipeworks.after_place(pos, player, itemstack, pointed_thing)
|
||||
end
|
||||
end,
|
||||
on_timer = deconstructor_action,
|
||||
on_construct = on_construct,
|
||||
on_metadata_inventory_move = deconstructor_action,
|
||||
on_metadata_inventory_put = deconstructor_action,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
deconstructor_action(pos)
|
||||
end,
|
||||
on_blast = on_blast,
|
||||
on_blast = exchangeclone.on_blast({"src", "fuel"}),
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
_mcl_hoppers_on_try_pull = exchangeclone.hoppers_on_try_pull,
|
||||
_mcl_hoppers_on_try_push = exchangeclone.hoppers_on_try_push,
|
||||
on_timer = deconstructor_action,
|
||||
_mcl_hoppers_on_try_push = exchangeclone.mcl2_hoppers_on_try_push(nil, function(stack) return stack:get_name() == "exchangeclone:exchange_orb" end),
|
||||
_mcl_hoppers_on_after_push = function(pos)
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
end,
|
||||
_on_hopper_in = exchangeclone.mcla_on_hopper_in(
|
||||
nil,
|
||||
function(stack) return stack:get_name() == "exchangeclone:exchange_orb" end
|
||||
),
|
||||
})
|
||||
|
||||
if exchangeclone.pipeworks then
|
||||
|
@ -211,7 +182,7 @@ if exchangeclone.pipeworks then
|
|||
end
|
||||
minetest.override_item("exchangeclone:deconstructor", {
|
||||
tube = {
|
||||
input_inventory = "fuel",
|
||||
input_inventory = "src",
|
||||
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)
|
||||
|
|
|
@ -49,13 +49,6 @@ local function check_for_furnaces(pos, set_furnace, start)
|
|||
return found
|
||||
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")
|
||||
end
|
||||
|
||||
local function on_timer(pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
|
@ -135,34 +128,8 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function on_blast(pos)
|
||||
local 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, player)
|
||||
if exchangeclone.mcl then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta:to_table()
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = inv:get_stack("main", 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
|
||||
meta:from_table(meta2)
|
||||
end
|
||||
if exchangeclone.pipeworks then
|
||||
pipeworks.after_dig(pos)
|
||||
end
|
||||
end
|
||||
|
||||
function exchangeclone.register_energy_collector(itemstring, name, amount, modifier, recipe)
|
||||
if exchangeclone.pipeworks then modifier = modifier.."^pipeworks_tube_connection_stony.png" end
|
||||
minetest.register_node(itemstring, {
|
||||
description = name.."\nGenerates "..exchangeclone.format_number(amount).." energy/second",
|
||||
tiles = {
|
||||
|
@ -178,10 +145,10 @@ function exchangeclone.register_energy_collector(itemstring, name, amount, modif
|
|||
_mcl_blast_resistance = 6,
|
||||
sounds = exchangeclone.sound_mod.node_sound_metal_defaults(),
|
||||
is_ground_content = false,
|
||||
can_dig = can_dig,
|
||||
can_dig = exchangeclone.can_dig,
|
||||
on_timer = on_timer,
|
||||
on_construct = on_construct,
|
||||
after_dig_node = on_dig_node,
|
||||
after_dig_node = exchangeclone.drop_after_dig({"main"}),
|
||||
on_metadata_inventory_move = function(pos)
|
||||
minetest.get_node_timer(pos):start(1)
|
||||
end,
|
||||
|
@ -204,8 +171,7 @@ function exchangeclone.register_energy_collector(itemstring, name, amount, modif
|
|||
pipeworks.after_place(pos, player, itemstack, pointed_thing)
|
||||
end
|
||||
end,
|
||||
on_blast = on_blast,
|
||||
on_rotate = exchangeclone.pipeworks and pipeworks.on_rotate,
|
||||
on_blast = exchangeclone.on_blast({"main"}),
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
|
|
|
@ -502,15 +502,16 @@ if minetest.get_modpath("screwdriver") then
|
|||
end
|
||||
end
|
||||
end
|
||||
local pipeworks_connect = exchangeclone.pipeworks and "^pipeworks_tube_connection_stony.png" or ""
|
||||
|
||||
local inactive_def = {
|
||||
description = S("Dark Matter Furnace"),
|
||||
tiles = {
|
||||
"exchangeclone_dark_matter_block.png",
|
||||
"exchangeclone_dark_matter_block.png",
|
||||
"exchangeclone_dark_matter_block.png",
|
||||
"exchangeclone_dark_matter_block.png",
|
||||
"exchangeclone_dark_matter_block.png",
|
||||
"exchangeclone_dark_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_dark_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_dark_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_dark_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_dark_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_dark_matter_furnace.png",
|
||||
},
|
||||
paramtype2 = "4dir",
|
||||
|
@ -519,34 +520,7 @@ local inactive_def = {
|
|||
sounds = exchangeclone.sound_mod.node_sound_stone_defaults(),
|
||||
|
||||
on_timer = furnace_node_timer,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta:to_table()
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
for _, listname in pairs({"src", "dst", "fuel"}) do
|
||||
if listname == "src" or listname == "dst" then
|
||||
for i = 1,7 do
|
||||
local stack = inv:get_stack(listname, i)
|
||||
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
|
||||
else
|
||||
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
|
||||
end
|
||||
meta:from_table(meta2)
|
||||
if exchangeclone.pipeworks then
|
||||
pipeworks.after_dig(pos)
|
||||
end
|
||||
end,
|
||||
|
||||
after_dig_node = exchangeclone.drop_after_dig({"src", "fuel", "dst"}),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", inactive_formspec("Dark"))
|
||||
|
@ -591,22 +565,25 @@ local inactive_def = {
|
|||
_mcl_blast_resistance = 1500,
|
||||
_mcl_hardness = 75,
|
||||
on_rotate = on_rotate,
|
||||
can_dig = exchangeclone.can_dig,
|
||||
after_place_node = exchangeclone.pipeworks and pipeworks.after_place,
|
||||
_mcl_hoppers_on_try_pull = exchangeclone.hoppers_on_try_pull,
|
||||
_mcl_hoppers_on_try_push = exchangeclone.hoppers_on_try_push,
|
||||
_mcl_hoppers_on_try_pull = exchangeclone.mcl2_hoppers_on_try_pull(),
|
||||
_mcl_hoppers_on_try_push = exchangeclone.mcl2_hoppers_on_try_push(),
|
||||
_mcl_hoppers_on_after_push = function(pos)
|
||||
minetest.get_node_timer(pos):start(0.45)
|
||||
end,
|
||||
_on_hopper_in = exchangeclone.mcla_on_hopper_in(),
|
||||
_on_hopper_out = exchangeclone.mcla_on_hopper_out(),
|
||||
}
|
||||
|
||||
local active_def = {
|
||||
description = S("Active Dark Matter Furnace"),
|
||||
tiles = {
|
||||
"exchangeclone_dark_matter_block.png",
|
||||
"exchangeclone_dark_matter_block.png",
|
||||
"exchangeclone_dark_matter_block.png",
|
||||
"exchangeclone_dark_matter_block.png",
|
||||
"exchangeclone_dark_matter_block.png",
|
||||
"exchangeclone_dark_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_dark_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_dark_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_dark_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_dark_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_dark_matter_furnace.png",
|
||||
},
|
||||
paramtype2 = "4dir",
|
||||
|
@ -617,35 +594,7 @@ local active_def = {
|
|||
is_ground_content = false,
|
||||
sounds = exchangeclone.sound_mod.node_sound_stone_defaults(),
|
||||
on_timer = furnace_node_timer,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta:to_table()
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
for _, listname in pairs({"src", "dst", "fuel"}) do
|
||||
if listname == "src" or listname == "dst" then
|
||||
for i = 1,7 do
|
||||
local stack = inv:get_stack(listname, i)
|
||||
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
|
||||
else
|
||||
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
|
||||
end
|
||||
meta:from_table(meta2)
|
||||
if exchangeclone.pipeworks then
|
||||
pipeworks.after_dig(pos)
|
||||
end
|
||||
end,
|
||||
|
||||
after_dig_node = exchangeclone.drop_after_dig({"src", "fuel", "dst"}),
|
||||
on_construct = function(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
spawn_flames(pos, node.param2)
|
||||
|
@ -665,10 +614,13 @@ local active_def = {
|
|||
_mcl_blast_resistance = 1500,
|
||||
_mcl_hardness = 75,
|
||||
on_rotate = on_rotate,
|
||||
can_dig = exchangeclone.can_dig,
|
||||
after_rotate = after_rotate_active,
|
||||
after_place_node = exchangeclone.pipeworks and pipeworks.after_place,
|
||||
_mcl_hoppers_on_try_pull = exchangeclone.hoppers_on_try_pull,
|
||||
_mcl_hoppers_on_try_push = exchangeclone.hoppers_on_try_push,
|
||||
_mcl_hoppers_on_try_pull = exchangeclone.mcl2_hoppers_on_try_pull(),
|
||||
_mcl_hoppers_on_try_push = exchangeclone.mcl2_hoppers_on_try_push(),
|
||||
_on_hopper_in = exchangeclone.mcla_on_hopper_in(),
|
||||
_on_hopper_out = exchangeclone.mcla_on_hopper_out(),
|
||||
}
|
||||
|
||||
if exchangeclone.pipeworks then
|
||||
|
@ -706,11 +658,11 @@ minetest.register_node("exchangeclone:red_matter_furnace_active", table.copy(act
|
|||
minetest.override_item("exchangeclone:red_matter_furnace", {
|
||||
description = S("Red Matter Furnace"),
|
||||
tiles = {
|
||||
"exchangeclone_red_matter_block.png",
|
||||
"exchangeclone_red_matter_block.png",
|
||||
"exchangeclone_red_matter_block.png",
|
||||
"exchangeclone_red_matter_block.png",
|
||||
"exchangeclone_red_matter_block.png",
|
||||
"exchangeclone_red_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_red_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_red_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_red_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_red_matter_block.png"..pipeworks_connect,
|
||||
"exchangeclone_red_matter_furnace.png",
|
||||
},
|
||||
groups = {pickaxey=5, cracky = 3, container = exchangeclone.mcl2 and 2 or 4, deco_block=1, material_stone=1, level = get_level(5), exchangeclone_furnace = 2, tubedevice = 1, tubedevice_receiver = 1},
|
||||
|
@ -747,39 +699,13 @@ minetest.override_item("exchangeclone:red_matter_furnace", {
|
|||
inv:set_size("fuel", 1)
|
||||
inv:set_size("dst", 10)
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta:to_table()
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
for _, listname in pairs({"src", "dst", "fuel"}) do
|
||||
if listname == "src" or listname == "dst" then
|
||||
for i = 1,10 do
|
||||
local stack = inv:get_stack(listname, i)
|
||||
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
|
||||
else
|
||||
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
|
||||
end
|
||||
meta:from_table(meta2)
|
||||
if exchangeclone.pipeworks then
|
||||
pipeworks.after_dig(pos)
|
||||
end
|
||||
end,
|
||||
_mcl_hoppers_on_try_pull = exchangeclone.hoppers_on_try_pull,
|
||||
_mcl_hoppers_on_try_push = exchangeclone.hoppers_on_try_push,
|
||||
_mcl_hoppers_on_try_pull = exchangeclone.mcl2_hoppers_on_try_pull(),
|
||||
_mcl_hoppers_on_try_push = exchangeclone.mcl2_hoppers_on_try_push(),
|
||||
_mcl_hoppers_on_after_push = function(pos)
|
||||
minetest.get_node_timer(pos):start(0.16)
|
||||
end,
|
||||
_on_hopper_in = exchangeclone.mcla_on_hopper_in(),
|
||||
_on_hopper_out = exchangeclone.mcla_on_hopper_out(),
|
||||
|
||||
})
|
||||
|
||||
|
@ -805,34 +731,6 @@ minetest.override_item("exchangeclone:red_matter_furnace_active", {
|
|||
inv:set_size("fuel", 1)
|
||||
inv:set_size("dst", 10)
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta:to_table()
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
for _, listname in pairs({"src", "dst", "fuel"}) do
|
||||
if listname == "src" or listname == "dst" then
|
||||
for i = 1,10 do
|
||||
local stack = inv:get_stack(listname, i)
|
||||
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
|
||||
else
|
||||
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
|
||||
end
|
||||
meta:from_table(meta2)
|
||||
if exchangeclone.pipeworks then
|
||||
pipeworks.after_dig(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
|
|
@ -18,7 +18,7 @@ exchangeclone.shovel_action = {
|
|||
minetest.record_protection_violation(pos, player:get_player_name())
|
||||
else
|
||||
if data.path then
|
||||
-- TODO: Fix potential "shovel_on_place" functions that aren't paths in Mineclonia
|
||||
-- TODO: Fix potential "shovel_on_place" functions that aren't paths in Mineclonia (same with axes)
|
||||
if minetest.registered_items[node.name]._on_shovel_place or
|
||||
minetest.get_item_group(node.name, "path_creation_possible") == 1 then
|
||||
if minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name == "air" then
|
||||
|
|
|
@ -128,39 +128,6 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||
return stack:get_count()
|
||||
end
|
||||
|
||||
local after_dig_node = function(pos, oldnode, oldmetadata, player)
|
||||
if exchangeclone.mcl then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta:to_table()
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
for _, listname in pairs({"fuel", "dst", "src"}) 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
|
||||
|
||||
local function on_blast(pos)
|
||||
local drops = {}
|
||||
exchangeclone.get_inventory_drops(pos, "src", drops)
|
||||
exchangeclone.get_inventory_drops(pos, "fuel", drops)
|
||||
exchangeclone.get_inventory_drops(pos, "dst", drops)
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
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("src") and inv:is_empty("fuel") and inv:is_empty("dst")
|
||||
end
|
||||
|
||||
local function get_level(level)
|
||||
if exchangeclone.mcl then
|
||||
return nil
|
||||
|
@ -169,12 +136,14 @@ local function get_level(level)
|
|||
end
|
||||
end
|
||||
|
||||
local pipeworks_connect = exchangeclone.pipeworks and "^pipeworks_tube_connection_stony.png" or ""
|
||||
|
||||
minetest.register_node("exchangeclone:upgrader", {
|
||||
description = "Upgrader",
|
||||
tiles = {
|
||||
"exchangeclone_upgrader_top.png",
|
||||
"exchangeclone_upgrader_bottom.png",
|
||||
"exchangeclone_upgrader_side.png",
|
||||
"exchangeclone_upgrader_top.png"..pipeworks_connect,
|
||||
"exchangeclone_upgrader_bottom.png"..pipeworks_connect,
|
||||
"exchangeclone_upgrader_side.png"..pipeworks_connect,
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -192,11 +161,25 @@ minetest.register_node("exchangeclone:upgrader", {
|
|||
on_metadata_inventory_move = upgrader_action,
|
||||
on_metadata_inventory_take = upgrader_action,
|
||||
on_metadata_inventory_put = upgrader_action,
|
||||
on_blast = on_blast,
|
||||
after_dig_node = after_dig_node,
|
||||
can_dig = can_dig,
|
||||
on_blast = exchangeclone.on_blast({"src", "fuel", "dst"}),
|
||||
after_dig_node = exchangeclone.drop_after_dig({"src", "fuel", "dst"}),
|
||||
can_dig = exchangeclone.can_dig,
|
||||
_mcl_blast_resistance = 1500,
|
||||
_mcl_hardness = 75,
|
||||
_mcl_hoppers_on_try_pull = exchangeclone.mcl2_hoppers_on_try_pull(),
|
||||
_mcl_hoppers_on_try_push = exchangeclone.mcl2_hoppers_on_try_push(
|
||||
function(stack) return minetest.get_item_group(stack:get_name(), "exchangeclone_upgradable") > 0 end,
|
||||
function(stack) return minetest.get_item_group(stack:get_name(), "exchangeclone_upgrade") > 0 end,
|
||||
upgrader_action
|
||||
),
|
||||
_mcl_hoppers_on_after_push = upgrader_action,
|
||||
_mcl_hoppers_on_after_pull = upgrader_action,
|
||||
after_place_node = exchangeclone.pipeworks and pipeworks.after_place,
|
||||
_on_hopper_in = exchangeclone.mcla_on_hopper_in(
|
||||
function(stack) return minetest.get_item_group(stack:get_name(), "exchangeclone_upgradable") > 0 end,
|
||||
function(stack) return minetest.get_item_group(stack:get_name(), "exchangeclone_upgrade") > 0 end,
|
||||
upgrader_action
|
||||
),
|
||||
})
|
||||
|
||||
if exchangeclone.pipeworks then
|
||||
|
@ -221,7 +204,8 @@ if exchangeclone.pipeworks then
|
|||
return true
|
||||
end
|
||||
end
|
||||
}})
|
||||
},
|
||||
on_rotate = pipeworks.on_rotate,})
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
|
|
|
@ -24,6 +24,24 @@ function exchangeclone.get_inventory_drops(pos, listname, drops)
|
|||
end
|
||||
end
|
||||
|
||||
function exchangeclone.on_blast(lists)
|
||||
return function(pos)
|
||||
local drops = {}
|
||||
for _, list in pairs(lists) do
|
||||
exchangeclone.get_inventory_drops(pos, list, drops)
|
||||
end
|
||||
table.insert(drops, minetest.get_node(pos).name)
|
||||
minetest.remove_node(pos)
|
||||
if exchangeclone.mcl then
|
||||
for _, drop in pairs(drops) do
|
||||
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, drop)
|
||||
end
|
||||
end
|
||||
return drops
|
||||
end
|
||||
end
|
||||
|
||||
--- Gets the energy 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, ignore_wear)
|
||||
|
@ -610,26 +628,55 @@ end
|
|||
-- Chat commands:
|
||||
minetest.register_chatcommand("add_player_energy", {
|
||||
params = "[player] <value>",
|
||||
description = "Add to a player's personal energy (player is self if not included, value can be negative)",
|
||||
description = "Add to a player's personal energy (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, " ")
|
||||
local player
|
||||
local target_player
|
||||
local target_name
|
||||
local value
|
||||
if #split_param == 1 then
|
||||
player = minetest.get_player_by_name(name)
|
||||
target_name = name
|
||||
value = split_param[1]
|
||||
end
|
||||
if #split_param == 2 then
|
||||
player = minetest.get_player_by_name(split_param[1])
|
||||
elseif #split_param == 2 then
|
||||
target_name = split_param[1]
|
||||
value = split_param[2]
|
||||
end
|
||||
if not (player and value) then
|
||||
minetest.chat_send_player(name, "Bad command. Use /add_energy [player] [value] or /add_energy [value]")
|
||||
target_player = minetest.get_player_by_name(target_name)
|
||||
if (not (target_player and value)) or not tonumber(value) then
|
||||
minetest.chat_send_player(name, "Bad command. Use /add_player_energy [player] [value] or /add_player_energy [value]")
|
||||
return
|
||||
end
|
||||
exchangeclone.add_player_energy(player, tonumber(value))
|
||||
minetest.chat_send_player(name, "Added "..value.." to "..name.."'s personal energy.")
|
||||
local energy = exchangeclone.get_player_energy(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.")
|
||||
return
|
||||
end
|
||||
exchangeclone.add_player_energy(target_player, tonumber(value))
|
||||
minetest.chat_send_player(name, "Added "..exchangeclone.format_number(value).." to "..target_name.."'s personal energy.")
|
||||
end
|
||||
})
|
||||
|
||||
-- Chat commands:
|
||||
minetest.register_chatcommand("get_player_energy", {
|
||||
params = "[player]",
|
||||
description = "Gets a player's personal energy (player is self if not included).",
|
||||
privs = {privs = true},
|
||||
func = function(name, param)
|
||||
local target_player
|
||||
local target_name
|
||||
if param and param ~= "" then
|
||||
target_name = param
|
||||
else
|
||||
target_name = name
|
||||
end
|
||||
target_player = minetest.get_player_by_name(target_name)
|
||||
if not (target_player) then
|
||||
minetest.chat_send_player(name, "Bad command. Use /get_player_energy [player] or /get_player_energy")
|
||||
return
|
||||
end
|
||||
local energy = exchangeclone.get_player_energy(target_player)
|
||||
minetest.chat_send_player(name, target_name.."'s personal energy: "..exchangeclone.format_number(energy))
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -639,23 +686,30 @@ minetest.register_chatcommand("set_player_energy", {
|
|||
privs = {privs = true},
|
||||
func = function(name, param)
|
||||
local split_param = exchangeclone.split(param, " ")
|
||||
local player
|
||||
local target_player
|
||||
local target_name
|
||||
local value
|
||||
if #split_param == 1 then
|
||||
player = minetest.get_player_by_name(name)
|
||||
target_name = name
|
||||
value = split_param[1]
|
||||
end
|
||||
if #split_param == 2 then
|
||||
player = minetest.get_player_by_name(split_param[1])
|
||||
target_name = split_param[1]
|
||||
value = split_param[2]
|
||||
end
|
||||
if not (player and value) then
|
||||
minetest.chat_send_player(name, "Bad command. Use '/set_energy player value' or '/set_energy value'")
|
||||
target_player = minetest.get_player_by_name(name)
|
||||
if (not (target_player and value)) or (not (value == "limit" or tonumber(value))) then
|
||||
minetest.chat_send_player(name, "Bad command. Use /set_player_energy [player] [value] or /set_player_energy [value]")
|
||||
return
|
||||
end
|
||||
if value == "limit" then value = exchangeclone.limit end
|
||||
exchangeclone.set_player_energy(player, tonumber(value))
|
||||
minetest.chat_send_player(name, "Personal energy of "..name.." set to "..value)
|
||||
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.")
|
||||
return
|
||||
end
|
||||
exchangeclone.set_player_energy(target_player, tonumber(value))
|
||||
minetest.chat_send_player(name, "Set "..target_name.."'s personal energy to "..exchangeclone.format_number(value))
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -742,9 +796,10 @@ end
|
|||
-- Returns true if item (itemstring or ItemStack) can't be used as a furnace fuel.
|
||||
-- Returns false otherwise
|
||||
function exchangeclone.isnt_fuel(item)
|
||||
return not (minetest.get_craft_result({method = "fuel", width = 1, items = {item}}).time ~= 0)
|
||||
return not exchangeclone.is_fuel(item)
|
||||
end
|
||||
|
||||
-- Copied from MCL2
|
||||
--- Selects item stack to transfer from
|
||||
--- @param src_inventory InvRef Source innentory to pull from
|
||||
--- @param src_list string Name of source inventory list to pull from
|
||||
|
@ -764,22 +819,115 @@ function exchangeclone.select_stack(src_inventory, src_list, dst_inventory, dst_
|
|||
return nil
|
||||
end
|
||||
|
||||
function exchangeclone.hoppers_on_try_pull(pos, hop_pos, hop_inv, hop_list)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if exchangeclone.select_stack(inv, "dst", hop_inv, hop_list) then
|
||||
return inv, "dst", exchangeclone.select_stack(inv, "dst", hop_inv, hop_list)
|
||||
else
|
||||
return inv, "fuel", exchangeclone.select_stack(inv, "fuel", hop_inv, hop_list, exchangeclone.isnt_fuel)
|
||||
function exchangeclone.mcl2_hoppers_on_try_pull(dst_condition, fuel_condition)
|
||||
if not exchangeclone.mcl2 then return end
|
||||
return function(pos, hop_pos, hop_inv, hop_list)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if exchangeclone.select_stack(inv, "dst", hop_inv, hop_list) then
|
||||
return inv, "dst", exchangeclone.select_stack(inv, "dst", hop_inv, hop_list, dst_condition)
|
||||
else
|
||||
return inv, "fuel", exchangeclone.select_stack(inv, "fuel", hop_inv, hop_list, fuel_condition or exchangeclone.isnt_fuel)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function exchangeclone.mcl2_hoppers_on_try_push(src_condition, fuel_condition)
|
||||
if not exchangeclone.mcl2 then return end
|
||||
return function(pos, hop_pos, hop_inv, hop_list)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if math.abs(pos.y - hop_pos.y) > math.abs(pos.x - hop_pos.x) and math.abs(pos.y - hop_pos.y) > math.abs(pos.z - hop_pos.z) then
|
||||
return inv, "src", exchangeclone.select_stack(hop_inv, hop_list, inv, "src", src_condition)
|
||||
else
|
||||
return inv, "fuel", exchangeclone.select_stack(hop_inv, hop_list, inv, "fuel", fuel_condition or exchangeclone.is_fuel)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function exchangeclone.mcla_on_hopper_in(src_condition, fuel_condition, action)
|
||||
if not exchangeclone.mcla then return end
|
||||
return function(pos, to_pos)
|
||||
local sinv = minetest.get_inventory({type="node", pos = pos})
|
||||
local dinv = minetest.get_inventory({type="node", pos = to_pos})
|
||||
local handled
|
||||
local moved = true
|
||||
if pos.y == to_pos.y then
|
||||
-- Put fuel into fuel slot
|
||||
local slot_id,_ = mcl_util.get_eligible_transfer_item_slot(sinv, "main", dinv, "fuel", fuel_condition or mcl_furnaces.is_transferrable_fuel)
|
||||
if slot_id then
|
||||
mcl_util.move_item_container(pos, to_pos, nil, slot_id, "fuel")
|
||||
else
|
||||
moved = false
|
||||
end
|
||||
handled = true
|
||||
elseif src_condition then
|
||||
-- Check src
|
||||
local slot_id,_ = mcl_util.get_eligible_transfer_item_slot(sinv, "main", dinv, "src", src_condition)
|
||||
if slot_id then
|
||||
mcl_util.move_item_container(pos, to_pos, nil, slot_id, "src")
|
||||
else
|
||||
moved = false
|
||||
end
|
||||
handled = true
|
||||
end
|
||||
if moved and action then action(to_pos) end
|
||||
return handled
|
||||
end
|
||||
end
|
||||
|
||||
function exchangeclone.mcla_on_hopper_out(fuel_condition, action)
|
||||
fuel_condition = fuel_condition or function(stack)
|
||||
return not exchangeclone.is_fuel(stack)
|
||||
end
|
||||
return function(uppos, pos)
|
||||
local sucked = mcl_util.move_item_container(uppos, pos)
|
||||
|
||||
-- Also suck in non-fuel items from furnace fuel slot
|
||||
if not sucked then
|
||||
local finv = minetest.get_inventory({type="node", pos=uppos})
|
||||
if finv and fuel_condition(finv:get_stack("fuel", 1)) then
|
||||
sucked = mcl_util.move_item_container(uppos, pos, "fuel")
|
||||
end
|
||||
end
|
||||
if sucked and action then action(pos) end
|
||||
return sucked
|
||||
end
|
||||
end
|
||||
|
||||
function exchangeclone.hoppers_on_try_push(pos, hop_pos, hop_inv, hop_list)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if math.abs(pos.y - hop_pos.y) > math.abs(pos.x - hop_pos.x) and math.abs(pos.y - hop_pos.y) > math.abs(pos.z - hop_pos.z) then
|
||||
return inv, "src", exchangeclone.select_stack(hop_inv, hop_list, inv, "src")
|
||||
else
|
||||
return inv, "fuel", exchangeclone.select_stack(hop_inv, hop_list, inv, "fuel", exchangeclone.is_fuel)
|
||||
end
|
||||
function exchangeclone.drop_after_dig(lists)
|
||||
return function(pos, oldnode, oldmetadata, player)
|
||||
if exchangeclone.mcl then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta:to_table()
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
for _, listname in pairs(lists) do
|
||||
for i = 1, inv:get_size(listname) do
|
||||
local stack = inv:get_stack(listname, i)
|
||||
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
|
||||
end
|
||||
meta:from_table(meta2)
|
||||
end
|
||||
if exchangeclone.pipeworks then
|
||||
pipeworks.after_dig(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function exchangeclone.can_dig(pos)
|
||||
-- Always allow digging in MCL
|
||||
if exchangeclone.mcl then return true end
|
||||
-- Only allow digging of empty containers in MTG
|
||||
local inv = minetest.get_inventory({type="node", pos=pos})
|
||||
for listname, _ in pairs(inv:get_lists()) do
|
||||
if not inv:is_empty(listname) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
Loading…
Reference in New Issue