spawners ores big update, spawners mobs deco stones remake

This commit is contained in:
Juraj Vajda 2017-12-27 11:24:17 -05:00
parent 0c787ac7ab
commit 079c6486a3
22 changed files with 140 additions and 102 deletions

View File

@ -10,4 +10,4 @@ dofile(minetest.get_modpath(MOD_NAME).."/api.lua")
dofile(minetest.get_modpath(MOD_NAME).."/spawners_env.lua") dofile(minetest.get_modpath(MOD_NAME).."/spawners_env.lua")
dofile(minetest.get_modpath(MOD_NAME).."/spawners_gen.lua") dofile(minetest.get_modpath(MOD_NAME).."/spawners_gen.lua")
print ("[Mod] Spawners Environmental 0.7 Loaded.") print ("[Mod] Spawners Environmental Loaded.")

Binary file not shown.

View File

@ -70,17 +70,17 @@ function spawners_mobs.cloud_booom(pos)
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = 5, amount = 5,
time = 2, time = 2,
minpos = vector.subtract({x=pos.x-0.6, y=pos.y, z=pos.z-0.6}, 0.6), minpos = vector.subtract({x=pos.x-0.3, y=pos.y, z=pos.z-0.3}, 0.3),
maxpos = vector.add({x=pos.x+0.6, y=pos.y, z=pos.z+0.6}, 0.6), maxpos = vector.add({x=pos.x+0.3, y=pos.y, z=pos.z+0.3}, 0.3),
minvel = {x=0.1, y=0.1, z=0.1}, minvel = {x=0.1, y=0.1, z=0.1},
maxvel = {x=0.2, y=0.2, z=0.2}, maxvel = {x=0.2, y=0.2, z=0.2},
minacc = vector.new({x=-0.1, y=0.1, z=-0.1}), minacc = vector.new({x=-0.1, y=0.3, z=-0.1}),
maxacc = vector.new({x=0.1, y=0.3, z=0.1}), maxacc = vector.new({x=0.1, y=0.6, z=0.1}),
minexptime = 2, minexptime = 2,
maxexptime = 3, maxexptime = 3,
minsize = 4, minsize = 4,
maxsize = 8, maxsize = 12,
texture = "spawners_mobs_smoke2_particle.png^[transform"..math.random(0,3), texture = "spawners_mobs_smoke_particle_2.png^[transform"..math.random(0,3),
}) })
end end
@ -98,7 +98,7 @@ function spawners_mobs.add_flame_effects(pos)
maxexptime = 5, maxexptime = 5,
minsize = .5, minsize = .5,
maxsize = 2.5, maxsize = 2.5,
texture = "spawners_mobs_flame_particle.png", texture = "spawners_mobs_flame_particle_2.png",
}) })
return id return id

View File

@ -18,4 +18,4 @@ if minetest.get_modpath("mobs") then
dofile(minetest.get_modpath(MOD_NAME).."/nodes_additional.lua") dofile(minetest.get_modpath(MOD_NAME).."/nodes_additional.lua")
end end
print ("[Mod] Spawners Mobs 0.7 Loaded.") print ("[Mod] Spawners Mobs Loaded.")

View File

@ -38,6 +38,7 @@ local mummy_def = {
{name = "spawners_mobs:deco_stone_eye", chance = 25, min = 1, max = 1}, {name = "spawners_mobs:deco_stone_eye", chance = 25, min = 1, max = 1},
{name = "spawners_mobs:deco_stone_men", chance = 25, min = 1, max = 1}, {name = "spawners_mobs:deco_stone_men", chance = 25, min = 1, max = 1},
{name = "spawners_mobs:deco_stone_sun", chance = 25, min = 1, max = 1}, {name = "spawners_mobs:deco_stone_sun", chance = 25, min = 1, max = 1},
{name = "spawners_mobs:deco_stone_bird", chance = 25, min = 1, max = 1},
{name = "default:diamond", chance = 3, min = 1, max = 2}, {name = "default:diamond", chance = 3, min = 1, max = 2},
{name = "default:mese_crystal", chance = 3, min = 1, max = 2}, {name = "default:mese_crystal", chance = 3, min = 1, max = 2},
{name = "spawners_mobs:mummy", chance = 25, min = 1, max = 1}, {name = "spawners_mobs:mummy", chance = 25, min = 1, max = 1},
@ -58,7 +59,7 @@ local mummy_def = {
punch_start = 74, punch_start = 74,
punch_end = 105, punch_end = 105,
}, },
follow = {"spawners_mobs:deco_stone_eye","spawners_mobs:deco_stone_men","spawners_mobs:deco_stone_sun"}, follow = {"spawners_mobs:deco_stone_eye","spawners_mobs:deco_stone_men","spawners_mobs:deco_stone_sun","spawners_mobs:deco_stone_bird"},
on_die = function(self, pos) on_die = function(self, pos)
minetest.sound_play("spawners_mobs_mummy_death", { minetest.sound_play("spawners_mobs_mummy_death", {
object = self.object, object = self.object,

View File

@ -1,11 +1,15 @@
local img = {"eye", "men", "sun"} --
-- Decorative Carved Sand Stones
--
for i=1,3 do local img = {"eye", "men", "sun", "bird"}
for i=1, #img do
minetest.register_node("spawners_mobs:deco_stone_"..img[i], { minetest.register_node("spawners_mobs:deco_stone_"..img[i], {
description = "Sandstone with "..img[i], description = "Sandstone with "..img[i],
tiles = {"default_sandstone.png^spawners_mobs_"..img[i]..".png"}, tiles = {"spawners_mobs_sandstone_carved_"..img[i]..".png"},
is_ground_content = true, is_ground_content = false,
groups = {crumbly=2,cracky=3}, groups = {cracky = 2},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
end end

View File

@ -203,7 +203,7 @@ function spawners_mobs.create(mob_name, mod_prefix, size, offset, mesh, texture,
groups = {cracky=1,level=2,igniter=1,not_in_creative_inventory=1}, groups = {cracky=1,level=2,igniter=1,not_in_creative_inventory=1},
drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner", drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner",
on_construct = function(pos) on_construct = function(pos)
spawners_mobs.meta_set_str("infotext", mod_prefix.." "..mob_name.." spawner (overheated)", pos) spawners_mobs.meta_set_str("infotext", mod_prefix.." "..mob_name.." spawner is overheated - too many items/entities in the area", pos)
minetest.get_node_timer(pos):start(60) minetest.get_node_timer(pos):start(60)
end, end,
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

View File

@ -1,5 +1,6 @@
-- main tables -- main tables
spawners_ores = {} spawners_ores = {}
local percent = 10
-- how often node timers for minerals will tick, +/- some random value -- how often node timers for minerals will tick, +/- some random value
function spawners_ores.tick(pos) function spawners_ores.tick(pos)
@ -8,7 +9,7 @@ end
-- how often a growth failure tick is retried (e.g. not enough place to spawn minerals) -- how often a growth failure tick is retried (e.g. not enough place to spawn minerals)
function spawners_ores.tick_short(pos) function spawners_ores.tick_short(pos)
minetest.get_node_timer(pos):start(math.random(15, 30)) minetest.get_node_timer(pos):start(math.random(15, 20))
end end
-- adds smoke particles -- adds smoke particles
@ -83,29 +84,73 @@ end
-- build form for spawners -- build form for spawners
function spawners_ores.get_formspec(pos, table) function spawners_ores.get_formspec(pos, table)
-- Inizialize metadata and variables -- Inizialize metadata and variables
local table = table or {}
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local mineral = table.ore or meta:get_string("mineral") local mineral = table.ore or meta:get_string("mineral")
local ingot = table.ore or meta:get_string("mineral")
local status = meta:get_string("status")
local inv = meta:get_inventory()
local stack = inv:get_stack("fuel", 1)
local stack_per_obj = table.stack_per_obj or {} -- fix different Ingot namings
if ingot == "iron" then
ingot = "steel"
end
-- add extra ores based on percentage
local stack_per_obj = spawners_ores.stack_per({
stack_count = stack:get_count(),
percent = percent
})
local stack_per = stack_per_obj.stack_per or 0 local stack_per = stack_per_obj.stack_per or 0
local extra_per = stack_per_obj.extra_per or 0 local extra_per = stack_per_obj.extra_per or 0
local colorize = {
gold = "^[colorize:#ffe4008C",
tin = "^[colorize:#d0d0d08C",
iron = "^[colorize:#b66d498C",
copper = "^[colorize:#b587528C",
}
local colorize_arrow = ""
local button = ""
if status == "active" then
colorize_arrow = colorize[mineral]
elseif status == "waiting" then
button = "button[1.8,2.5;2,1.5;restart;RE-START]"
end
-- dynamic form -- dynamic formspec
return "size[8,8.5]".. local formspec = "size[8,8.5]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. default.gui_slots..
"label[1.8,0.3;Input "..mineral.." Ingot]".. "label[1.8,0.3;Input "..ingot.." Ingot]"..
"list[current_name;fuel;1.8,1;1,1;]".. "list[current_name;fuel;1.8,1;1,1;]"..
"image[1.8,1;1,1;spawners_ores_ingot_slot.png]".. "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,4.25;8,1;]"..
"list[current_player;main;0,5.5;8,3;8]".. "list[current_player;main;0,5.5;8,3;8]"..
"image[2.8,1;1,1;gui_furnace_arrow_bg.png^[transformR270]".. "image[2.9,1;1,1;gui_furnace_arrow_bg.png^[transformR270"..colorize_arrow.."]"..
"label[1.8,2;"..stack_per.." minerals ("..extra_per.." extra)]".. "label[1.8,2;"..stack_per.." minerals ("..extra_per.." extra)]"..
"image[4,1;1,1;spawners_ores_stone_with_"..mineral..".png]".. "image[4,1;1,1;spawners_ores_stone_with_"..mineral..".png]"..
button..
"listring[current_name;fuel]".. "listring[current_name;fuel]"..
"listring[current_player;main]".. "listring[current_player;main]"..
default.get_hotbar_bg(0, 4.25) default.get_hotbar_bg(0, 4.25)
meta:set_string("formspec", formspec)
-- infotext
local infotext = mineral.." fuel: "..inv:get_stack("fuel", 1):get_count()
if inv:is_empty("fuel") then
infotext = mineral.." ore spawner is empty."
elseif status == "waiting" then
infotext = "Waiting - no default:stone was found near by, "..mineral.." fuel: "..inv:get_stack("fuel", 1):get_count()
end
meta:set_string("infotext", infotext)
end end
-- check if is fuel empty in the node -- check if is fuel empty in the node
@ -119,7 +164,6 @@ end
function spawners_ores.stack_per(table) function spawners_ores.stack_per(table)
local table = table or {} local table = table or {}
local stack_count = table.stack_count or nil local stack_count = table.stack_count or nil
local percent = table.percent or 10
local extra_per = (stack_count / 100) * percent local extra_per = (stack_count / 100) * percent
extra_per = math.floor(extra_per) extra_per = math.floor(extra_per)
@ -134,6 +178,7 @@ function spawners_ores.stack_per(table)
} }
end end
-- set status and update formspec/infotext
function spawners_ores.on_timer(pos, elapsed) function spawners_ores.on_timer(pos, elapsed)
local available_node = spawners_ores.get_available_node(pos, "default:stone") local available_node = spawners_ores.get_available_node(pos, "default:stone")
@ -141,16 +186,12 @@ function spawners_ores.on_timer(pos, elapsed)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local stack = inv:get_stack("fuel", 1) local stack = inv:get_stack("fuel", 1)
local formspec = ""
local infotext = ""
local stack_per_obj = {}
local percent = 10
local how_many = 1 local how_many = 1
local ore_name = meta:get_string("ore_name") local ore_name = meta:get_string("ore_name")
local mineral = meta:get_string("mineral") local mineral = meta:get_string("mineral")
local status = meta:get_string("status") local status = meta:get_string("status")
local tick = meta:get_int("tick")
-- --
-- active -- active
@ -159,41 +200,43 @@ function spawners_ores.on_timer(pos, elapsed)
-- make sure the right node status is shown -- make sure the right node status is shown
if status ~= "active" then if status ~= "active" then
meta:set_string("status", "active") meta:set_string("status", "active")
spawners_ores.get_formspec(pos)
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner_active"}) minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner_active"})
end end
-- take fuel -- start spawning only on proper 'tick'
stack:take_item() if tick ~= 0 then
inv:set_stack("fuel", 1, stack) if stack:get_count() % percent == 0 then
-- TODO: should get countent based on 'percent'
how_many = 2
end
-- update infotext -- enough place to spawn more ores
infotext = mineral.." fuel: "..stack:get_count() spawners_ores.start_spawning_ores(available_node, "default:"..ore_name, how_many)
-- take fuel
stack:take_item()
inv:set_stack("fuel", 1, stack)
-- add extra ores based on percentage spawners_ores.get_formspec(pos)
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 end
-- enough place to spawn more ores -- dont wait for proper 'tick' and change state after 1 sec.
spawners_ores.start_spawning_ores(available_node, "default:"..ore_name, how_many) local next_available_node = spawners_ores.get_available_node(pos, "default:stone")
-- update infotext and formspec if inv:is_empty("fuel") or next_available_node == false then
formspec = spawners_ores.get_formspec(pos, { minetest.get_node_timer(pos):start(1.0)
stack_per_obj = stack_per_obj, return
ore = mineral end
})
meta:set_string("formspec", formspec)
meta:set_string("infotext", mineral.." fuel: "..inv:get_stack("fuel", 1):get_count())
if tick == 0 then
-- start new proper timer
meta:set_int("tick", 1)
end
-- start new proper timer
spawners_ores.tick(pos) spawners_ores.tick(pos)
-- --
-- default -- default
-- --
@ -203,47 +246,22 @@ function spawners_ores.on_timer(pos, elapsed)
meta:set_string("status", "") meta:set_string("status", "")
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner"}) minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner"})
-- update infotext, formspec and stop the timer spawners_ores.get_formspec(pos)
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 return
-- --
-- waiting -- waiting
-- --
else else
-- stop timer and show "refresh" button in order to start timer again
-- make sure that waiting status/node is shown -- make sure that waiting status/node is shown
if status ~= "waiting" then if status ~= "waiting" then
meta:set_string("status", "waiting") meta:set_string("status", "waiting")
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner_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 end
-- update infotext and formspec spawners_ores.get_formspec(pos)
stack_per_obj = spawners_ores.stack_per({ return
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
end end

View File

@ -6,4 +6,4 @@ dofile(minetest.get_modpath(MOD_NAME).."/api.lua")
-- Spawners for ores -- Spawners for ores
dofile(minetest.get_modpath(MOD_NAME).."/spawners_ores.lua") dofile(minetest.get_modpath(MOD_NAME).."/spawners_ores.lua")
print ("[Mod] Spawners Ores 0.7 Loaded.") print ("[Mod] Spawners Ores Loaded.")

View File

@ -3,7 +3,7 @@
-- --
local colorize = { local colorize = {
stone_with_gold = "^[colorize:#ffe40030", stone_with_gold = "^[colorize:#ffe40033",
stone_with_tin = "^[colorize:#d0d0d040", stone_with_tin = "^[colorize:#d0d0d040",
stone_with_iron = "^[colorize:#b66d4940", stone_with_iron = "^[colorize:#b66d4940",
stone_with_copper = "^[colorize:#b5875240", stone_with_copper = "^[colorize:#b5875240",
@ -28,9 +28,6 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
end end
if stack:get_name() == "default:"..mineral.."_ingot" then if stack:get_name() == "default:"..mineral.."_ingot" then
minetest.get_node_timer(pos):start(1.0)
return stack:get_count() return stack:get_count()
else else
return 0 return 0
@ -43,11 +40,23 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
return 0 return 0
end end
minetest.get_node_timer(pos):start(1.0)
return stack:get_count() return stack:get_count()
end end
local function on_metadata_inventory_put(pos)
local meta = minetest.get_meta(pos)
meta:set_int("tick", 0)
spawners_ores.get_formspec(pos)
minetest.get_node_timer(pos):start(1.0)
end
local function on_metadata_inventory_take(pos)
local meta = minetest.get_meta(pos)
meta:set_int("tick", 0)
spawners_ores.get_formspec(pos)
minetest.get_node_timer(pos):start(1.0)
end
-- --
-- Spawners Ores creation function -- Spawners Ores creation function
-- --
@ -135,7 +144,8 @@ function spawners_ores.create(def)
minetest.remove_node(pos) minetest.remove_node(pos)
return drops return drops
end, end,
on_metadata_inventory_put = on_metadata_inventory_put,
on_metadata_inventory_take = on_metadata_inventory_take,
allow_metadata_inventory_put = allow_metadata_inventory_put, allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take, allow_metadata_inventory_take = allow_metadata_inventory_take,
}) })
@ -177,6 +187,17 @@ function spawners_ores.create(def)
return drops return drops
end, end,
on_receive_fields = function(pos, formname, fields, sender)
if fields.restart then
local meta = minetest.get_meta(pos)
meta:set_int("tick", 0)
spawners_ores.get_formspec(pos)
minetest.get_node_timer(pos):start(1.0)
end
end,
on_metadata_inventory_put = on_metadata_inventory_put,
on_metadata_inventory_take = on_metadata_inventory_take,
allow_metadata_inventory_put = allow_metadata_inventory_put, allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take, allow_metadata_inventory_take = allow_metadata_inventory_take,
}) })
@ -201,7 +222,7 @@ function spawners_ores.create(def)
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local formspec = spawners_ores.get_formspec(pos, {ore=ore[3]}) spawners_ores.get_formspec(pos, {ore=ore[3]})
-- Inizialize inventory -- Inizialize inventory
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -211,14 +232,11 @@ function spawners_ores.create(def)
meta:set_string("mineral", ore[3]) meta:set_string("mineral", ore[3])
meta:set_string("ore_name", ore_name) meta:set_string("ore_name", ore_name)
meta:set_string("status", "") meta:set_string("status", "")
meta:set_int("tick", 0)
-- add spinning entity inside the spawner -- add spinning entity inside the spawner
pos.y = pos.y + offset pos.y = pos.y + offset
minetest.add_entity(pos,"spawners_ores:dummy_ore_"..ore_name) 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, end,
on_blast = function(pos) on_blast = function(pos)
@ -229,10 +247,8 @@ function spawners_ores.create(def)
return drops return drops
end, end,
on_metadata_inventory_put = function(pos) on_metadata_inventory_put = on_metadata_inventory_put,
-- start timer function, it will sort out whether ingots can burn in to stone and create minerals or not. on_metadata_inventory_take = on_metadata_inventory_take,
minetest.get_node_timer(pos):start(1.0)
end,
allow_metadata_inventory_put = allow_metadata_inventory_put, allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take, allow_metadata_inventory_take = allow_metadata_inventory_take,
}) })
@ -241,8 +257,7 @@ function spawners_ores.create(def)
minetest.register_lbm({ minetest.register_lbm({
name = "spawners_ores:start_nodetimer_"..ore_name, name = "spawners_ores:start_nodetimer_"..ore_name,
nodenames = { nodenames = {
"spawners_ores:"..ore_name.."_spawner_active", "spawners_ores:"..ore_name.."_spawner_active"
"spawners_ores:"..ore_name.."_spawner_waiting"
}, },
action = function(pos, node) action = function(pos, node)
spawners_ores.tick_short(pos) spawners_ores.tick_short(pos)