2015-08-01 14:42:22 +02:00
|
|
|
local modname = "equivalent_exchange_energy_collectors:"
|
|
|
|
|
2015-07-31 12:47:47 +02:00
|
|
|
collector = {
|
2015-08-01 16:58:55 +02:00
|
|
|
emc_gather = function(orig_emc, mark, multiplier)
|
2015-07-31 20:08:38 +02:00
|
|
|
return orig_emc + (10^(mark - 1)) * multiplier
|
2015-07-31 12:47:47 +02:00
|
|
|
end,
|
2015-07-31 20:08:38 +02:00
|
|
|
emc_transfer = function(mark,pos,multiplier)
|
2015-07-30 16:01:23 +02:00
|
|
|
local meta = minetest.get_meta(pos)
|
2015-07-31 12:47:47 +02:00
|
|
|
local emc = meta:get_int("emc")
|
2015-07-31 12:24:47 +02:00
|
|
|
local surrounding_nodes = {
|
|
|
|
minetest.get_meta({x = pos.x + 1, y = pos.y, z = pos.z}),
|
|
|
|
minetest.get_meta({x = pos.x - 1, y = pos.y, z = pos.z}),
|
|
|
|
minetest.get_meta({x = pos.x, y = pos.y + 1, z = pos.z}),
|
|
|
|
minetest.get_meta({x = pos.x, y = pos.y - 1, z = pos.z}),
|
|
|
|
minetest.get_meta({x = pos.x, y = pos.y, z = pos.z + 1}),
|
|
|
|
minetest.get_meta({x = pos.x, y = pos.y, z = pos.z - 1})
|
|
|
|
}
|
|
|
|
local emc_transferable_nodes = {}
|
|
|
|
local emc_transferable_nodes_length = 0
|
|
|
|
for i = 1,6 do
|
|
|
|
if surrounding_nodes[i]:get_string("emc_storable") == "true" then
|
|
|
|
table.insert(emc_transferable_nodes,surrounding_nodes[i])
|
|
|
|
emc_transferable_nodes_length = emc_transferable_nodes_length + 1
|
|
|
|
end
|
|
|
|
end
|
2015-08-01 16:58:55 +02:00
|
|
|
if emc_transferable_nodes_length == 0 then
|
|
|
|
local generate_amount = math.floor(emc / 10)
|
2015-08-02 16:57:34 +02:00
|
|
|
local times_over = math.floor(generate_amount / 99)
|
2015-08-01 16:58:55 +02:00
|
|
|
local inventory = meta:get_inventory()
|
|
|
|
local size = inventory:get_size("container")
|
|
|
|
if emc >= 10 then
|
|
|
|
meta:set_int("emc", emc - 10*generate_amount)
|
|
|
|
if mark == 4 then
|
|
|
|
meta:set_string("formspec",
|
2015-08-02 16:57:34 +02:00
|
|
|
"size[8,7.4]"..
|
2015-08-01 16:58:55 +02:00
|
|
|
"label[0,0;Antimatter Collector]"..
|
|
|
|
"label[4,0;EMC Stored: "..emc - 10*generate_amount.."]"..
|
|
|
|
"list[current_name;container;0,0.5;8,7;]")
|
|
|
|
else
|
|
|
|
meta:set_string("formspec",
|
2015-08-02 16:57:34 +02:00
|
|
|
"size[8,7.4]"..
|
2015-08-01 16:58:55 +02:00
|
|
|
"label[0,0;Energy Collector Mark "..mark.."]"..
|
|
|
|
"label[4,0;EMC Stored: "..emc - 10*generate_amount.."]"..
|
|
|
|
"list[current_name;container;0,0.5;8,7;]")
|
|
|
|
end
|
2015-08-02 16:57:34 +02:00
|
|
|
for i = 1, times_over do
|
2015-08-02 15:34:59 +02:00
|
|
|
inventory:add_item("container", {name = modname.."klein_star", count = 99})
|
|
|
|
end
|
2015-08-02 16:57:34 +02:00
|
|
|
if generate_amount % 99 > 0 then
|
|
|
|
inventory:add_item("container", {name = modname.."klein_star", count = generate_amount % 99})
|
2015-08-02 15:34:59 +02:00
|
|
|
end
|
2015-08-01 16:58:55 +02:00
|
|
|
end
|
|
|
|
end
|
2015-07-31 20:08:38 +02:00
|
|
|
local newemc = (collector.emc_gather(emc, mark, multiplier))
|
2015-07-31 12:24:47 +02:00
|
|
|
local distribution = math.floor(newemc / emc_transferable_nodes_length)
|
|
|
|
for j = 1,emc_transferable_nodes_length do
|
2015-08-01 16:58:55 +02:00
|
|
|
if mark == 4 then
|
|
|
|
meta:set_string("formspec",
|
|
|
|
"size[8,7.5]"..
|
|
|
|
"label[0,0;Antimatter Collector]"..
|
|
|
|
"label[4,0;EMC Stored: "..(newemc - distribution).."]"..
|
|
|
|
"list[current_name;container;0,0.5;8,7;]")
|
|
|
|
else
|
|
|
|
meta:set_string("formspec",
|
|
|
|
"size[8,7.5]"..
|
|
|
|
"label[0,0;Energy Collector Mark "..mark.."]"..
|
|
|
|
"label[4,0;EMC Stored: "..(newemc - distribution).."]"..
|
|
|
|
"list[current_name;container;0,0.5;8,7;]")
|
|
|
|
end
|
2015-07-31 12:24:47 +02:00
|
|
|
meta:set_int("emc",(newemc - distribution))
|
|
|
|
emc_transferable_nodes[j]:set_int("emc", (emc_transferable_nodes[j]:get_int("emc") + distribution))
|
|
|
|
end
|
2015-07-30 16:01:23 +02:00
|
|
|
end,
|
2015-07-31 20:08:38 +02:00
|
|
|
check_multiplier = function(pos)
|
|
|
|
local multiplier = 1
|
|
|
|
if minetest.get_meta({x = pos.x, y = pos.y + 1, z = pos.z}):get_int("multiplier") == 2 then
|
|
|
|
multiplier = 2
|
|
|
|
end
|
|
|
|
return multiplier
|
|
|
|
end,
|
2015-07-31 12:47:47 +02:00
|
|
|
}
|
|
|
|
|
2015-08-02 16:57:34 +02:00
|
|
|
local register_name = {"mk1","mk2","mk3","antimatter_collector"}
|
|
|
|
local item_name = {"Energy Collector Mark 1","Energy Collector Mark 2","Energy Collector Mark 3", "Antimatter Collector"}
|
2015-07-30 16:01:23 +02:00
|
|
|
|
2015-08-02 16:57:34 +02:00
|
|
|
for i = 1,4 do
|
2015-07-31 19:21:08 +02:00
|
|
|
|
2015-08-02 16:57:34 +02:00
|
|
|
-- Registering ABMs --
|
2015-07-31 19:21:08 +02:00
|
|
|
|
2015-08-02 16:57:34 +02:00
|
|
|
minetest["register_abm"]({
|
|
|
|
nodenames = {modname..register_name[i]},
|
|
|
|
interval = 1.0,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local emc = meta:get_int("emc")
|
|
|
|
local multiplier = collector.check_multiplier(pos)
|
|
|
|
local emc_per = collector.emc_gather(emc,i,multiplier)
|
|
|
|
meta:set_string("formspec",
|
|
|
|
"size[8,7.4]"..
|
|
|
|
"label[0,0;"..item_name[i].."]"..
|
|
|
|
"label[4,0;EMC Stored: "..emc_per.."]"..
|
|
|
|
"list[current_name;container;0,0.5;8,7;]")
|
|
|
|
meta:set_int("emc", emc_per)
|
|
|
|
collector.emc_transfer(i,pos,multiplier)
|
|
|
|
end,
|
|
|
|
})
|
2015-07-31 21:03:30 +02:00
|
|
|
|
2015-07-30 16:01:23 +02:00
|
|
|
-- Registering Nodes --
|
|
|
|
|
2015-08-02 16:57:34 +02:00
|
|
|
minetest["register_node"](":"..modname..register_name[i], {
|
|
|
|
description = item_name[i],
|
|
|
|
tiles = {
|
|
|
|
"ee_energy_collectors_"..register_name[i].."_top.png",
|
|
|
|
"ee_energy_collectors_"..register_name[i].."_bottom.png",
|
|
|
|
"ee_energy_collectors_"..register_name[i].."_side.png",
|
|
|
|
"ee_energy_collectors_"..register_name[i].."_side.png",
|
|
|
|
"ee_energy_collectors_"..register_name[i].."_side.png",
|
|
|
|
"ee_energy_collectors_"..register_name[i].."_side.png",
|
|
|
|
},
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
groups = {cracky = 2},
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
on_construct = function(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_string("formspec",
|
|
|
|
"size[8,7.4]"..
|
|
|
|
"label[0,0;"..item_name[i].."]"..
|
|
|
|
"label[4,0;EMC Stored: 0]"..
|
|
|
|
"list[current_name;container;0,0.5;8,7;]")
|
|
|
|
meta:set_string("infotext", item_name[i])
|
|
|
|
meta:set_int("emc", 0)
|
|
|
|
local inventory = meta:get_inventory()
|
|
|
|
inventory:set_size("container", 8*7)
|
|
|
|
end,
|
|
|
|
can_dig = function(pos,player)
|
|
|
|
local meta = minetest.env:get_meta(pos);
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
return inv:is_empty("container")
|
|
|
|
end,
|
|
|
|
--emc = emc[i]
|
|
|
|
})
|
2015-07-31 20:08:38 +02:00
|
|
|
|
2015-08-02 16:57:34 +02:00
|
|
|
end
|
2015-07-31 21:03:30 +02:00
|
|
|
|
2015-08-01 14:42:22 +02:00
|
|
|
minetest.register_node(modname.."interdiction_stone", {
|
2015-07-31 20:08:38 +02:00
|
|
|
description = "Interdiction Stone",
|
|
|
|
tiles = {
|
2015-08-01 15:04:31 +02:00
|
|
|
"ee_energy_collectors_interdiction_stone.png",
|
|
|
|
"ee_energy_collectors_interdiction_stone.png",
|
|
|
|
"ee_energy_collectors_interdiction_stone.png",
|
|
|
|
"ee_energy_collectors_interdiction_stone.png",
|
|
|
|
"ee_energy_collectors_interdiction_stone.png",
|
|
|
|
"ee_energy_collectors_interdiction_stone.png"
|
2015-07-31 20:08:38 +02:00
|
|
|
},
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
groups = {cracky = 1},
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
light_source = 10,
|
|
|
|
on_construct = function(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_int("multiplier", 2)
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2015-08-01 16:58:55 +02:00
|
|
|
-- Registering Craft Items --
|
|
|
|
|
|
|
|
minetest.register_craftitem(modname.."klein_star", {
|
|
|
|
description = "Klein Star",
|
|
|
|
inventory_image = "ee_energy_collectors_klein_star.png",
|
|
|
|
emc = 100,
|
|
|
|
})
|
|
|
|
|
2015-07-30 16:01:23 +02:00
|
|
|
-- Registering Crafts --
|
2015-07-31 15:04:20 +02:00
|
|
|
|
2015-07-30 16:01:23 +02:00
|
|
|
minetest.register_craft({
|
2015-08-01 14:42:22 +02:00
|
|
|
output = modname.."mk1",
|
2015-07-30 16:01:23 +02:00
|
|
|
recipe = {
|
|
|
|
{"default:mese", "default:glass", "default:mese"},
|
|
|
|
{"default:mese", "default:diamondblock", "default:mese"},
|
|
|
|
{"default:mese", "default:furnace", "default:mese"}
|
|
|
|
}
|
2015-07-31 19:21:08 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2015-08-01 14:42:22 +02:00
|
|
|
output = modname.."mk2",
|
2015-07-31 19:21:08 +02:00
|
|
|
recipe = {
|
2015-08-01 14:42:22 +02:00
|
|
|
{"default:mese", modname.."red_matter", "default:mese"},
|
|
|
|
{"default:mese", modname.."mk1", "default:mese"},
|
2015-07-31 19:21:08 +02:00
|
|
|
{"default:mese", "default:mese", "default:mese"}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2015-08-01 14:42:22 +02:00
|
|
|
output = modname.."mk3",
|
2015-07-31 19:21:08 +02:00
|
|
|
recipe = {
|
2015-08-01 14:42:22 +02:00
|
|
|
{"default:mese", modname.."antimatter", "default:mese"},
|
|
|
|
{"default:mese", modname.."mk2", "default:mese"},
|
2015-07-31 19:21:08 +02:00
|
|
|
{"default:mese", "default:mese", "default:mese"}
|
|
|
|
}
|
2015-07-31 20:08:38 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2015-08-01 14:42:22 +02:00
|
|
|
output = modname.."interdiction_stone",
|
2015-07-31 20:08:38 +02:00
|
|
|
recipe = {
|
2015-08-01 14:42:22 +02:00
|
|
|
{"default:torch", modname.."aeternalis_fuel", "default:torch"},
|
|
|
|
{modname.."aeternalis_fuel", "equivalent_exchange:philosophers_stone", modname.."aeternalis_fuel"},
|
2015-07-31 20:08:38 +02:00
|
|
|
{"equivalent_exchange:high_covalence", "equivalent_exchange:high_covalence", "equivalent_exchange:high_covalence"}
|
2015-07-31 21:03:30 +02:00
|
|
|
},
|
|
|
|
replacements = {
|
|
|
|
{"equivalent_exchange:philosophers_stone", "equivalent_exchange:philosophers_stone"}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2015-08-01 14:42:22 +02:00
|
|
|
output = modname.."antimatter_collector",
|
2015-07-31 21:03:30 +02:00
|
|
|
recipe = {
|
2015-08-01 14:42:22 +02:00
|
|
|
{modname.."condensed_antimatter", modname.."condensed_antimatter", modname.."condensed_antimatter"},
|
2015-08-01 15:04:31 +02:00
|
|
|
{modname.."condensed_antimatter", modname.."mk3", modname.."condensed_antimatter"},
|
2015-08-01 14:42:22 +02:00
|
|
|
{modname.."condensed_antimatter", modname.."condensed_antimatter", modname.."condensed_antimatter"}
|
2015-07-31 20:08:38 +02:00
|
|
|
}
|
|
|
|
})
|