refactor: remove ABM - replace with LBM and timers, lot of performance improvements

master
Juraj Vajda 2017-12-25 22:55:01 -05:00
parent bda87df208
commit 66a99e6e81
21 changed files with 510 additions and 230 deletions

View File

@ -1,13 +1,165 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. You just DO WHAT THE FUCK YOU WANT TO.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,17 @@
-- main tables
spawners_ores = {}
-- how often node timers for plants will tick, +/- some random value
function spawners_ores.tick(pos)
minetest.get_node_timer(pos):start(math.random(30, 60))
end
-- how often a growth failure tick is retried (e.g. not enough place to spawn minerals)
function spawners_ores.tick_short(pos)
minetest.get_node_timer(pos):start(math.random(15, 30))
end
-- adds smoke particles
function spawners_ores.add_effects(pos, radius)
minetest.add_particlespawner({
amount = 32,
@ -11,50 +22,40 @@ function spawners_ores.add_effects(pos, radius)
maxvel = {x=0.5, y=10, z=0.5},
minacc = vector.new(),
maxacc = vector.new(),
minexptime = .5,
minexptime = 0.5,
maxexptime = 2,
minsize = .5,
minsize = 0.5,
maxsize = 8,
texture = "spawners_ores_smoke_particle.png",
texture = "spawners_ores_smoke_particle.png^[transform"..math.random(0,3)
})
end
-- start spawning ores
function spawners_ores.start_spawning_ores(pos, ore_name, sound_custom, spawners_pos)
function spawners_ores.start_spawning_ores(pos, ore_name, how_many)
if not pos or not ore_name then return end
local sound_name
local player_near = false
-- use custom sounds
if sound_custom ~= "" then
sound_name = sound_custom
else
sound_name = false
end
local how_many = math.random(1,2)
-- how_many = how_many+1
local how_many = how_many or 1
for i=1, how_many do
if i > 1 then
player_near, pos = spawners_ores.check_around_radius_ores(pos, "default:stone")
pos = spawners_ores.get_available_node(pos, "default:stone")
if not pos then return end
minetest.sound_play(sound_name, {
minetest.sound_play("spawners_ores_strike", {
pos = pos,
max_hear_distance = 32,
gain = 20,
max_hear_distance = 16,
gain = 10,
})
minetest.set_node(pos, {name=ore_name})
spawners_ores.add_effects(pos, 1)
else
minetest.sound_play(sound_name, {
minetest.sound_play("spawners_ores_strike", {
pos = pos,
max_hear_distance = 32,
gain = 20,
max_hear_distance = 16,
gain = 10,
})
minetest.set_node(pos, {name=ore_name})
@ -64,44 +65,185 @@ function spawners_ores.start_spawning_ores(pos, ore_name, sound_custom, spawners
end
function spawners_ores.check_around_radius(pos)
local player_near = false
local radius = 21
local node_ore_pos = nil
function spawners_ores.get_available_node(pos, check_node, radius)
if not pos then return end
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, radius)) do
if obj:is_player() then
player_near = true
end
end
local check_node = check_node or "default:stone"
local radius = radius or 2
return player_near
end
function spawners_ores.check_around_radius_ores(pos, check_node)
local player_near = spawners_ores.check_around_radius(pos);
local found_node = false
local node_ore_pos = nil
if check_node then
node_ore_pos = minetest.find_node_near(pos, 2, {check_node})
if node_ore_pos then
found_node = node_ore_pos
end
end
return player_near, found_node
end
function spawners_ores.check_node_status_ores(pos, ore_name, check_node)
if not check_node then return end
local player_near, found_node = spawners_ores.check_around_radius_ores(pos, check_node)
if player_near and found_node then
return true, found_node
local node_ore_pos = minetest.find_node_near(pos, radius, {check_node})
if node_ore_pos and node_ore_pos ~= nil then
return node_ore_pos
else
return true, false
return false
end
end
end
-- build form for spawners
function spawners_ores.get_formspec(pos, table)
-- Inizialize metadata and variables
local meta = minetest.get_meta(pos)
local mineral = table.ore or meta:get_string("mineral")
local stack_per_obj = table.stack_per_obj or {}
local stack_per = stack_per_obj.stack_per or 0
local extra_per = stack_per_obj.extra_per or 0
-- dynamic form
return "size[8,8.5]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"label[1.8,0.3;Input "..mineral.." Ingot]"..
"list[current_name;fuel;1.8,1;1,1;]"..
"image[1.8,1;1,1;spawners_ores_ingot_slot.png]"..
"list[current_player;main;0,4.25;8,1;]"..
"list[current_player;main;0,5.5;8,3;8]"..
"image[2.8,1;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
"label[1.8,2;"..stack_per.." minerals ("..extra_per.." extra)]"..
"image[4,1;1,1;spawners_ores_stone_with_"..mineral..".png]"..
"listring[current_name;fuel]"..
"listring[current_player;main]"..
default.get_hotbar_bg(0, 4.25)
end
-- check if is fuel empty in the node
function spawners_ores.can_dig(pos, player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("fuel")
end
-- add extra percentage on top of the stack
function spawners_ores.stack_per(table)
local table = table or {}
local stack_count = table.stack_count or nil
local percent = table.percent or 10
local extra_per = (stack_count / 100) * percent
extra_per = math.floor(extra_per)
local stack_per = extra_per + stack_count
-- print(percent.."% from stack("..stack_count..") = "..stack_per.." ("..extra_per.." extra ore(s))")
return {
stack_per = stack_per,
extra_per = extra_per
}
end
function spawners_ores.on_timer(pos, elapsed)
local available_node = spawners_ores.get_available_node(pos, "default:stone")
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local stack = inv:get_stack("fuel", 1)
local formspec = ""
local infotext = ""
local stack_per_obj = {}
local percent = 10
local how_many = 1
local ore_name = meta:get_string("ore_name")
local mineral = meta:get_string("mineral")
local status = meta:get_string("status")
--
-- active
--
if available_node and inv:is_empty("fuel") ~= true then
-- make sure the right node status is shown
if status ~= "active" then
meta:set_string("status", "active")
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner_active"})
end
-- take fuel
stack:take_item()
inv:set_stack("fuel", 1, stack)
-- update infotext
infotext = mineral.." fuel: "..stack:get_count()
-- add extra ores based on percentage
stack_per_obj = spawners_ores.stack_per({
stack_count = stack:get_count(),
percent = percent
})
if stack:get_count() % percent == 0 then
-- TODO: should get countent based on 'percent'
how_many = 2
end
-- enough place to spawn more ores
spawners_ores.start_spawning_ores(available_node, "default:"..ore_name, how_many)
-- update infotext and formspec
formspec = spawners_ores.get_formspec(pos, {
stack_per_obj = stack_per_obj,
ore = mineral
})
meta:set_string("formspec", formspec)
meta:set_string("infotext", mineral.." fuel: "..inv:get_stack("fuel", 1):get_count())
spawners_ores.tick(pos)
--
-- default
--
elseif inv:is_empty("fuel") then
-- empty / no fuel -- stop timer
-- make sure that default status/node is shown
meta:set_string("status", "")
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner"})
-- update infotext, formspec and stop the timer
stack_per_obj = spawners_ores.stack_per({
stack_count = stack:get_count()
})
formspec = spawners_ores.get_formspec(pos, {
stack_per_obj = stack_per_obj,
ore = mineral
})
meta:set_string("infotext", mineral.." ore spawner is empty.")
meta:set_string("formspec", formspec)
return
--
-- waiting
--
else
-- make sure that waiting status/node is shown
if status ~= "waiting" then
meta:set_string("status", "waiting")
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner_waiting"})
infotext = "Waiting - no default:stone was found near by, "..mineral.." fuel: "..inv:get_stack("fuel", 1):get_count()
end
-- update infotext and formspec
stack_per_obj = spawners_ores.stack_per({
stack_count = stack:get_count()
})
formspec = spawners_ores.get_formspec(pos, {
stack_per_obj = stack_per_obj,
ore = mineral
})
meta:set_string("formspec", formspec)
meta:set_string("infotext", mineral.." fuel: "..inv:get_stack("fuel", 1):get_count())
spawners_ores.tick_short(pos)
end
end

View File

@ -1,60 +1,36 @@
-- Formspecs
local ore_formspec =
"size[8,8.5]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"label[2,1.7;Input Ingot]"..
"list[current_name;fuel;3.5,1.5;1,1;]"..
"list[current_player;main;0,4.25;8,1;]"..
"list[current_player;main;0,5.5;8,3;8]"..
"button_exit[5,1.5;2,1;exit;Save]"..
"listring[current_name;fuel]"..
"listring[current_player;main]"..
default.get_hotbar_bg(0, 4.25)
--
-- Colorize HEX
--
local function can_dig(pos, player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("fuel")
end
local colorize = {
stone_with_gold = "^[colorize:#ffe40030",
stone_with_tin = "^[colorize:#d0d0d040",
stone_with_iron = "^[colorize:#b66d4940",
stone_with_copper = "^[colorize:#b5875240",
}
function spawners_ores.get_formspec(pos)
-- Inizialize metadata
local meta = minetest.get_meta(pos)
-- Inizialize inventory
local inv = meta:get_inventory()
for listname, size in pairs({
fuel = 1,
}) do
if inv:get_size(listname) ~= size then
inv:set_size(listname, size)
end
end
-- Update formspec, infotext and node
meta:set_string("formspec", ore_formspec)
end
--
-- Handle formspec and inventory management
--
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
minetest.record_protection_violation(pos, player:get_player_name())
return 0
end
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local ingot = minetest.get_node_or_nil(pos).name
local mineral = meta:get_string("mineral")
ingot = string.split(ingot, ":")
ingot = string.split(ingot[2], "_")
if ingot[3] == "iron" then
ingot[3] = "steel"
if mineral == "iron" then
mineral = "steel"
end
if stack:get_name() == "default:"..ingot[3].."_ingot" then
if stack:get_name() == "default:"..mineral.."_ingot" then
minetest.get_node_timer(pos):start(1.0)
return stack:get_count()
else
return 0
@ -66,63 +42,27 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
minetest.record_protection_violation(pos, player:get_player_name())
return 0
end
minetest.get_node_timer(pos):start(1.0)
return stack:get_count()
end
local function on_receive_fields(pos, formname, fields, sender)
local ore_node = minetest.get_node_or_nil(pos)
--
-- Spawners Ores creation function
--
if minetest.is_protected(pos, sender:get_player_name()) then
minetest.record_protection_violation(pos, sender:get_player_name())
return
function spawners_ores.create(def)
local ore_name = def.ore_name or nil
local size = def.size or {x = 0.33, y = 0.33}
local offset = def.offset or 0
-- these must be defined
if ore_name == nil then
return false
end
-- get the ore name
local ingot = ore_node.name
ingot = string.split(ingot, ":")
ingot = string.split(ingot[2], "_")
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local fuellist = inv:get_list("fuel")
if inv:is_empty("fuel") then
if ore_node.name ~= "spawners_ores:stone_with_"..ingot[3].."_spawner" then
minetest.swap_node(pos, {name="spawners_ores:stone_with_"..ingot[3].."_spawner"})
end
meta:set_string("infotext", ingot[3].." ore spawner is empty")
else
meta:set_string("infotext", ingot[3].." ore spawner fuel: "..inv:get_stack("fuel", 1):get_count())
end
-- fix iron vs. steel issue
if ingot[3] == "iron" then
ingot[3] = "steel"
end
if not fuellist[1]:is_empty() and inv:get_stack("fuel", 1):get_name() == "default:"..ingot[3].."_ingot" then
-- fix iron vs. steel issue
if ingot[3] == "steel" then
ingot[3] = "iron"
end
local waiting, found_node = spawners_ores.check_node_status_ores(pos, "stone_with_"..ingot[3], "default:stone")
if found_node then
minetest.swap_node(pos, {name="spawners_ores:stone_with_"..ingot[3].."_spawner_active"})
elseif waiting then
minetest.swap_node(pos, {name="spawners_ores:stone_with_"..ingot[3].."_spawner_waiting"})
meta:set_string("infotext", "Waiting status - player was away or no stone around, "..ingot[3].." ore spawner fuel: "..inv:get_stack("fuel", 1):get_count())
else
return
end
end
end
-- Ores creation
function spawners_ores.create_ore(ore_name, mod_prefix, size, offset, texture, sound_custom)
-- dummy inside the spawner
local dummy_ore_definition = {
hp_max = 1,
@ -171,11 +111,11 @@ function spawners_ores.create_ore(ore_name, mod_prefix, size, offset, texture, s
sunlight_propagates = true,
tiles = {
{
name = "spawners_ores_spawner_animated.png",
name = "spawners_ores_spawner_animated_magma_16.png"..colorize[ore_name],
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
aspect_w = 16,
aspect_h = 16,
length = 2.0
},
}
@ -183,10 +123,21 @@ function spawners_ores.create_ore(ore_name, mod_prefix, size, offset, texture, s
is_ground_content = true,
groups = {cracky=1,level=2,igniter=1,not_in_creative_inventory=1},
drop = "spawners_ores:"..ore_name.."_spawner",
can_dig = can_dig,
can_dig = spawners_ores.can_dig,
on_timer = spawners_ores.on_timer,
on_blast = function(pos)
local drops = {}
default.get_inventory_drops(pos, "fuel", drops)
drops[#drops+1] = "spawners_ores:"..ore_name.."_spawner_active"
minetest.remove_node(pos)
return drops
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take,
on_receive_fields = on_receive_fields,
})
-- node spawner waiting - no stone around or no fuel
@ -201,7 +152,7 @@ function spawners_ores.create_ore(ore_name, mod_prefix, size, offset, texture, s
sunlight_propagates = true,
tiles = {
{
name = "spawners_ores_spawner_waiting_animated.png",
name = "spawners_ores_spawner_waiting_animated_16.png"..colorize[ore_name],
animation = {
type = "vertical_frames",
aspect_w = 32,
@ -212,11 +163,22 @@ function spawners_ores.create_ore(ore_name, mod_prefix, size, offset, texture, s
},
is_ground_content = true,
groups = {cracky=1,level=2,not_in_creative_inventory=1},
drop = "spawners_ores:"..ore_name.."_spawner",
can_dig = can_dig,
drop = "spawners_ores:"..ore_name.."_spawner_waiting",
can_dig = spawners_ores.can_dig,
on_timer = spawners_ores.on_timer,
on_blast = function(pos)
local drops = {}
default.get_inventory_drops(pos, "fuel", drops)
drops[#drops+1] = "spawners_ores:"..ore_name.."_spawner"
minetest.remove_node(pos)
return drops
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take,
on_receive_fields = on_receive_fields,
})
-- node spawner inactive (default)
@ -228,87 +190,102 @@ function spawners_ores.create_ore(ore_name, mod_prefix, size, offset, texture, s
walkable = true,
sounds = default.node_sound_metal_defaults(),
sunlight_propagates = true,
tiles = {"spawners_ores_spawner.png"},
tiles = {"spawners_ores_spawner_16.png"..colorize[ore_name]},
is_ground_content = true,
groups = {cracky=1,level=2},
groups = {cracky = 1, level = 2},
stack_max = 1,
can_dig = spawners_ores.can_dig,
on_timer = spawners_ores.on_timer,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
spawners_ores.get_formspec(pos)
local formspec = spawners_ores.get_formspec(pos, {ore=ore[3]})
-- Inizialize inventory
local inv = meta:get_inventory()
inv:set_size('fuel', 1)
-- custom meta
meta:set_string("mineral", ore[3])
meta:set_string("ore_name", ore_name)
meta:set_string("status", "")
-- add spinning entity inside the spawner
pos.y = pos.y + offset
minetest.add_entity(pos,"spawners_ores:dummy_ore_"..ore_name)
-- Update formspec, infotext and node
meta:set_string("formspec", formspec)
meta:set_string("infotext", ore[3].." ore spawner is empty")
end,
can_dig = can_dig,
on_blast = function(pos)
local drops = {}
default.get_inventory_drops(pos, "fuel", drops)
drops[#drops+1] = "spawners_ores:"..ore_name.."_spawner"
minetest.remove_node(pos)
return drops
end,
on_metadata_inventory_put = function(pos)
-- start timer function, it will sort out whether ingots can burn in to stone and create minerals or not.
minetest.get_node_timer(pos):start(1.0)
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take,
on_receive_fields = on_receive_fields,
})
-- ABM
minetest.register_abm({
nodenames = {"spawners_ores:"..ore_name.."_spawner_active", "spawners_ores:"..ore_name.."_spawner_waiting"},
interval = 5.0,
chance = 5,
action = function(pos, node, active_object_count, active_object_count_wider)
local waiting, found_node = spawners_ores.check_node_status_ores(pos, ore_name, "default:stone")
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if found_node then
-- make sure the right node status is shown
if node.name ~= "spawners_ores:"..ore_name.."_spawner_active" then
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner_active"})
end
-- take fuel
local stack = inv:get_stack("fuel", 1)
stack:take_item()
inv:set_stack("fuel", 1, stack)
meta:set_string("infotext", ore[3].." ore spawner fuel: "..inv:get_stack("fuel", 1):get_count())
-- enough place to spawn more ores
spawners_ores.start_spawning_ores(found_node, "default:"..ore_name, sound_custom)
-- empty / no fuel
if inv:is_empty("fuel") then
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner"})
meta:set_string("infotext", ore[3].." ore spawner is empty.")
end
else
-- waiting status
if node.name ~= "spawners_ores:"..ore_name.."_spawner_waiting" then
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner_waiting"})
meta:set_string("infotext", "Waiting status - player was away or no stone around, "..ore[3].." ore spawner fuel: "..inv:get_stack("fuel", 1):get_count())
end
end
end
-- replacement LBM for pre-nodetimer plants
minetest.register_lbm({
name = "spawners_ores:start_nodetimer_"..ore_name,
nodenames = {
"spawners_ores:"..ore_name.."_spawner_active",
"spawners_ores:"..ore_name.."_spawner_waiting"
},
action = function(pos, node)
spawners_ores.tick_short(pos)
end,
})
end
--
-- Ore Spawners Definitions
--
-- default:stone_with_gold
spawners_ores.create_ore("stone_with_gold", "", {x=.33,y=.33}, 0, {"default_stone.png^default_mineral_gold.png"}, "spawners_ores_strike")
spawners_ores.create({
ore_name = "stone_with_gold",
size = {x = 0.33, y = 0.33},
offset = 0
})
-- default:stone_with_iron
spawners_ores.create_ore("stone_with_iron", "", {x=.33,y=.33}, 0, {"default_stone.png^default_mineral_gold.png"}, "spawners_ores_strike")
spawners_ores.create({
ore_name = "stone_with_iron",
size = {x = 0.33, y = 0.33},
offset = 0
})
-- default:stone_with_copper
spawners_ores.create_ore("stone_with_copper", "", {x=.33,y=.33}, 0, {"default_stone.png^default_mineral_gold.png"}, "spawners_ores_strike")
spawners_ores.create({
ore_name = "stone_with_copper",
size = {x = 0.33, y = 0.33},
offset = 0
})
-- default:stone_with_tin
spawners_ores.create({
ore_name = "stone_with_tin",
size = {x = 0.33, y = 0.33},
offset = 0
})
--
-- Recipes
--
-- recipes
minetest.register_craft({
output = "spawners_ores:stone_with_gold_spawner",
recipe = {
@ -335,3 +312,12 @@ minetest.register_craft({
{"default:diamondblock", "xpanes:bar_flat", "default:diamondblock"},
}
})
minetest.register_craft({
output = "spawners_ores:stone_with_tin_spawner",
recipe = {
{"default:diamondblock", "fire:flint_and_steel", "default:diamondblock"},
{"xpanes:bar_flat", "default:tinblock", "xpanes:bar_flat"},
{"default:diamondblock", "xpanes:bar_flat", "default:diamondblock"},
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 B

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B