Add Zinc, Add a spawner node that works with mobs_redo mobs
@ -266,6 +266,12 @@ minetest.register_craft({
|
||||
recipe = "elepower_dynamics:nickel_lump"
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "elepower_dynamics:zinc_ingot",
|
||||
recipe = "elepower_dynamics:zinc_lump"
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "elepower_dynamics:viridisium_ingot",
|
||||
@ -303,3 +309,33 @@ for mat, data in pairs(elepd.registered_gears) do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-----------
|
||||
-- Nodes --
|
||||
-----------
|
||||
|
||||
local function blockcraft(mat)
|
||||
local ingot = "elepower_dynamics:" .. mat .. "_ingot"
|
||||
local block = "elepower_dynamics:" .. mat .. "_block"
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = block,
|
||||
recipe = {
|
||||
ingot, ingot, ingot,
|
||||
ingot, ingot, ingot,
|
||||
ingot, ingot, ingot,
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = ingot .. " 9",
|
||||
recipe = { block },
|
||||
})
|
||||
end
|
||||
|
||||
blockcraft("viridisium")
|
||||
blockcraft("nickel")
|
||||
blockcraft("invar")
|
||||
blockcraft("lead")
|
||||
blockcraft("zinc")
|
||||
|
@ -41,6 +41,12 @@ minetest.register_craftitem("elepower_dynamics:viridisium_ingot", {
|
||||
groups = {viridisium = 1, ingot = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("elepower_dynamics:zinc_ingot", {
|
||||
description = "Zinc Ingot",
|
||||
inventory_image = "elepower_zinc_ingot.png",
|
||||
groups = {zinc = 1, ingot = 1}
|
||||
})
|
||||
|
||||
-- Lumps
|
||||
|
||||
minetest.register_craftitem("elepower_dynamics:lead_lump", {
|
||||
@ -61,6 +67,12 @@ minetest.register_craftitem("elepower_dynamics:viridisium_lump", {
|
||||
groups = {viridisium = 1, lump = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("elepower_dynamics:zinc_lump", {
|
||||
description = "Zinc Lump",
|
||||
inventory_image = "elepower_zinc_lump.png",
|
||||
groups = {zinc = 1, lump = 1}
|
||||
})
|
||||
|
||||
-- Special
|
||||
|
||||
minetest.register_craftitem("elepower_dynamics:carbon_fiber", {
|
||||
|
@ -45,6 +45,7 @@ local dusts = {
|
||||
{"invar", "Invar", "#9fa5b2"},
|
||||
{"electrum", "Electrum", "#ebeb90"},
|
||||
{"viridisium", "Viridisium", "#5b9751"},
|
||||
{"zinc", "Zinc", "#598a9e"},
|
||||
{"wood", "Sawdust", "#847454", true}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
-- Nodes --
|
||||
-----------
|
||||
|
||||
-- Ores
|
||||
|
||||
minetest.register_node("elepower_dynamics:stone_with_lead", {
|
||||
description = "Lead Ore",
|
||||
tiles = {"default_stone.png^elepower_mineral_lead.png"},
|
||||
@ -31,6 +33,16 @@ minetest.register_node("elepower_dynamics:stone_with_viridisium", {
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("elepower_dynamics:stone_with_zinc", {
|
||||
description = "Zinc Ore",
|
||||
tiles = {"default_stone.png^elepower_mineral_zinc.png"},
|
||||
groups = {cracky = 3},
|
||||
drop = 'elepower_dynamics:zinc_lump',
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
-- Other
|
||||
|
||||
minetest.register_node("elepower_dynamics:particle_board", {
|
||||
description = "Particle Board",
|
||||
tiles = {"elepower_particle_board.png"},
|
||||
@ -38,3 +50,45 @@ minetest.register_node("elepower_dynamics:particle_board", {
|
||||
drop = 'elepower_dynamics:wood_dust 4',
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
-- Blocks
|
||||
|
||||
minetest.register_node("elepower_dynamics:viridisium_block", {
|
||||
description = "Viridisium Block",
|
||||
tiles = {"elepower_viridisium_block.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 1, level = 2},
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("elepower_dynamics:lead_block", {
|
||||
description = "Lead Block",
|
||||
tiles = {"elepower_lead_block.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 1, level = 2},
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("elepower_dynamics:invar_block", {
|
||||
description = "Invar Block",
|
||||
tiles = {"elepower_invar_block.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 1, level = 3},
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("elepower_dynamics:nickel_block", {
|
||||
description = "Nickel Block",
|
||||
tiles = {"elepower_nickel_block.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 1, level = 3},
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("elepower_dynamics:zinc_block", {
|
||||
description = "Zinc Block",
|
||||
tiles = {"elepower_zinc_block.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 1, level = 3},
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
BIN
elepower_dynamics/textures/elepower_invar_block.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
elepower_dynamics/textures/elepower_lead_block.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
elepower_dynamics/textures/elepower_mineral_zinc.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
elepower_dynamics/textures/elepower_nickel_block.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
elepower_dynamics/textures/elepower_viridisium_block.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
elepower_dynamics/textures/elepower_zinc_block.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
elepower_dynamics/textures/elepower_zinc_ingot.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
elepower_dynamics/textures/elepower_zinc_lump.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
@ -96,3 +96,38 @@ minetest.register_ore({
|
||||
y_max = -12000,
|
||||
y_min = -31000,
|
||||
})
|
||||
|
||||
-- Zinc
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "elepower_dynamics:stone_with_zinc",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 25 * 25 * 25,
|
||||
clust_num_ores = 2,
|
||||
clust_size = 3,
|
||||
y_max = 31000,
|
||||
y_min = -31000,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "elepower_dynamics:stone_with_zinc",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 20 * 20 * 20,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = 0,
|
||||
y_min = -31000,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "elepower_dynamics:stone_with_zinc",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 12 * 12 * 12,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = -256,
|
||||
y_min = -31000,
|
||||
})
|
||||
|
@ -56,3 +56,20 @@ function elefarm.formspec.tree_processor(timer, power, fluid_buffer, water_buffe
|
||||
"listring[current_player;main]"..
|
||||
default.get_hotbar_bg(0, 4.25)
|
||||
end
|
||||
|
||||
function elefarm.formspec.spawner_formspec(timer, power)
|
||||
return "size[8,8.5]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
ele.formspec.power_meter(power)..
|
||||
bar(1, 0, 100-timer)..
|
||||
"list[context;src;3.5,1.5;1,1;]"..
|
||||
"image[3.5,1.5;1,1;elefarming_egg_silhouette.png]"..
|
||||
"list[current_player;main;0,4.25;8,1;]"..
|
||||
"list[current_player;main;0,5.5;8,3;8]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;src]"..
|
||||
"listring[current_player;main]"..
|
||||
default.get_hotbar_bg(0, 4.25)
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
name = elepower_farming
|
||||
description = Electric Farming Automation!
|
||||
depends = elepower_papi, elepower_tools, elepower_fapi, bucket, farming, fluid_tanks
|
||||
optional_depends = mobs, mobs_animal, mobs_monster
|
||||
|
@ -13,3 +13,8 @@ dofile(elefarm.modpath.."/nodes/planter.lua")
|
||||
dofile(elefarm.modpath.."/nodes/harvester.lua")
|
||||
dofile(elefarm.modpath.."/nodes/tree_extractor.lua")
|
||||
dofile(elefarm.modpath.."/nodes/tree_processor.lua")
|
||||
|
||||
-- Mobs redo support
|
||||
if minetest.get_modpath("mobs") ~= nil and mobs.mod and mobs.mod == "redo" then
|
||||
dofile(elefarm.modpath.."/nodes/spawner.lua")
|
||||
end
|
||||
|
174
elepower_farming/nodes/spawner.lua
Normal file
@ -0,0 +1,174 @@
|
||||
|
||||
-- How many seconds there are between runs
|
||||
local SPAWNER_TICK = 10
|
||||
|
||||
local function can_dig(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("src")
|
||||
end
|
||||
|
||||
local function spawn(pos, mob)
|
||||
-- get meta and command
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
-- TODO: ways to configure
|
||||
local mlig = 0 -- min light
|
||||
local xlig = 15 -- max light
|
||||
local num = 4 -- max number
|
||||
local pla = 24 -- player radius
|
||||
local yof = 0 -- Y offset to spawn mob
|
||||
|
||||
-- if amount is 0 then do nothing
|
||||
if num == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
-- are we spawning a registered mob?
|
||||
if not mobs.spawning_mobs[mob] then
|
||||
return
|
||||
end
|
||||
|
||||
-- check objects inside 9x9 area around spawner
|
||||
local objs = minetest.get_objects_inside_radius(pos, 9)
|
||||
local count = 0
|
||||
local ent = nil
|
||||
|
||||
-- count mob objects of same type in area
|
||||
for k, obj in ipairs(objs) do
|
||||
ent = obj:get_luaentity()
|
||||
|
||||
if ent and ent.name and ent.name == mob then
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- is there too many of same type?
|
||||
if count >= num then
|
||||
return
|
||||
end
|
||||
|
||||
-- spawn mob if player detected and in range
|
||||
if pla > 0 then
|
||||
local in_range = 0
|
||||
local objs = minetest.get_objects_inside_radius(pos, pla)
|
||||
|
||||
for _,oir in pairs(objs) do
|
||||
if oir:is_player() then
|
||||
in_range = 1
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- player not found
|
||||
if in_range == 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- find air blocks within 5 nodes of spawner
|
||||
local air = minetest.find_nodes_in_area(
|
||||
{x = pos.x - 5, y = pos.y + yof, z = pos.z - 5},
|
||||
{x = pos.x + 5, y = pos.y + yof, z = pos.z + 5},
|
||||
{"air"})
|
||||
|
||||
-- spawn in random air block
|
||||
if air and #air > 0 then
|
||||
local pos2 = air[math.random(#air)]
|
||||
local lig = minetest.get_node_light(pos2) or 0
|
||||
|
||||
pos2.y = pos2.y + 0.5
|
||||
|
||||
-- only if light levels are within range
|
||||
if lig >= mlig and lig <= xlig and minetest.registered_entities[mob] then
|
||||
minetest.add_entity(pos2, mob)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local function on_timer(pos, elapsed)
|
||||
local refresh = false
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
|
||||
local usage = ele.helpers.get_node_property(meta, pos, "usage")
|
||||
local storage = ele.helpers.get_node_property(meta, pos, "storage")
|
||||
|
||||
local work = meta:get_int("src_time")
|
||||
|
||||
local egg_slot = inv:get_stack("src", 1)
|
||||
local egg_name = egg_slot:get_name()
|
||||
local mob_desc = "None"
|
||||
local active = "Active"
|
||||
if storage > usage and not egg_slot:is_empty() and ele.helpers.get_item_group(egg_name, "spawn_egg") then
|
||||
local mob_name = egg_name:gsub("_set", "")
|
||||
|
||||
if work == SPAWNER_TICK then
|
||||
local spawned = 0
|
||||
|
||||
-- Spawn
|
||||
if spawn(pos, mob_name) then
|
||||
spawned = spawned + 1
|
||||
end
|
||||
|
||||
work = 0
|
||||
if spawned > 0 then
|
||||
storage = storage - usage
|
||||
end
|
||||
else
|
||||
work = work + 1
|
||||
end
|
||||
|
||||
refresh = true
|
||||
mob_desc = minetest.registered_items[mob_name].description
|
||||
else
|
||||
work = 0
|
||||
active = "Inactive"
|
||||
end
|
||||
|
||||
meta:set_string("infotext", ("Powered Mob Spawner %s\nMob: %s\n%s"):format(
|
||||
active, mob_desc, ele.capacity_text(capacity, storage)))
|
||||
|
||||
local power_percent = math.floor((storage / capacity)*100)
|
||||
local work_percent = math.floor((work / SPAWNER_TICK)*100)
|
||||
|
||||
meta:set_string("formspec", elefarm.formspec.spawner_formspec(work_percent, power_percent))
|
||||
meta:set_int("storage", storage)
|
||||
meta:set_int("src_time", work)
|
||||
|
||||
return refresh
|
||||
end
|
||||
|
||||
ele.register_machine("elepower_farming:spawner", {
|
||||
description = "Powered Mob Spawner",
|
||||
ele_capacity = 64000,
|
||||
ele_inrush = 800,
|
||||
ele_usage = 800,
|
||||
ele_no_automatic_ports = true,
|
||||
tiles = {
|
||||
"elefarming_machine_spawner_top.png", "elefarming_machine_base.png", "elefarming_machine_side.png",
|
||||
"elefarming_machine_side.png", "elefarming_machine_side.png", "elefarming_machine_side.png",
|
||||
},
|
||||
groups = {
|
||||
oddly_breakable_by_hand = 1,
|
||||
ele_machine = 1,
|
||||
ele_user = 1,
|
||||
cracky = 1,
|
||||
tubedevice = 1,
|
||||
tubedevice_receiver = 1,
|
||||
},
|
||||
on_construct = function (pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
|
||||
meta:set_int("src_time", 0)
|
||||
meta:set_string("formspec", elefarm.formspec.spawner_formspec(0,0))
|
||||
end,
|
||||
can_dig = can_dig,
|
||||
on_timer = on_timer,
|
||||
})
|
BIN
elepower_farming/textures/elefarming_egg_silhouette.png
Normal file
After Width: | Height: | Size: 213 B |
BIN
elepower_farming/textures/elefarming_machine_spawner_top.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
@ -89,7 +89,7 @@ local function grindstone_timer(pos, elapsed)
|
||||
meta:set_string("formspec", elepm.get_grindstone_formspec(percentile))
|
||||
meta:set_int("src_time", time)
|
||||
meta:set_int("src_time_max", target_time)
|
||||
meta:set_string("infotext", "Grindstone: ".. percentile .. "%")
|
||||
meta:set_string("infotext", "Grindstone: ".. percentile .. "%\nPunch me to progress!")
|
||||
|
||||
return refresh
|
||||
end
|
||||
|
@ -47,7 +47,8 @@ local function can_dig(pos, player)
|
||||
return inv:is_empty("dst") and inv:is_empty("src")
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
ele.default = {}
|
||||
function ele.default.allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
@ -59,14 +60,14 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
function ele.default.allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = inv:get_stack(from_list, from_index)
|
||||
return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
|
||||
return ele.default.allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
function ele.default.allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
@ -74,7 +75,7 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function metadata_inventory_changed(pos)
|
||||
function ele.default.metadata_inventory_changed(pos)
|
||||
local t = minetest.get_node_timer(pos)
|
||||
|
||||
if not t:is_started() then
|
||||
@ -258,26 +259,26 @@ function ele.register_machine(nodename, nodedef)
|
||||
|
||||
-- Default metadata handlers for "src" and "dst"
|
||||
if not nodedef.allow_metadata_inventory_put then
|
||||
nodedef.allow_metadata_inventory_put = allow_metadata_inventory_put
|
||||
nodedef.allow_metadata_inventory_move = allow_metadata_inventory_move
|
||||
nodedef.allow_metadata_inventory_put = ele.default.allow_metadata_inventory_put
|
||||
nodedef.allow_metadata_inventory_move = ele.default.allow_metadata_inventory_move
|
||||
end
|
||||
|
||||
if not nodedef.allow_metadata_inventory_take then
|
||||
nodedef.allow_metadata_inventory_take = allow_metadata_inventory_take
|
||||
nodedef.allow_metadata_inventory_take = ele.default.allow_metadata_inventory_take
|
||||
end
|
||||
|
||||
-- Default metadata changed handlers for inventories
|
||||
-- Starts the timer on the node
|
||||
if not nodedef.on_metadata_inventory_move then
|
||||
nodedef.on_metadata_inventory_move = metadata_inventory_changed
|
||||
nodedef.on_metadata_inventory_move = ele.default.metadata_inventory_changed
|
||||
end
|
||||
|
||||
if not nodedef.on_metadata_inventory_put then
|
||||
nodedef.on_metadata_inventory_put = metadata_inventory_changed
|
||||
nodedef.on_metadata_inventory_put = ele.default.metadata_inventory_changed
|
||||
end
|
||||
|
||||
if not nodedef.on_metadata_inventory_take then
|
||||
nodedef.on_metadata_inventory_take = metadata_inventory_changed
|
||||
nodedef.on_metadata_inventory_take = ele.default.metadata_inventory_changed
|
||||
end
|
||||
|
||||
ele.register_base_device(nodename, nodedef)
|
||||
|