spawners ores big update, spawners mobs deco stones remake
@ -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_gen.lua")
|
||||
|
||||
print ("[Mod] Spawners Environmental 0.7 Loaded.")
|
||||
print ("[Mod] Spawners Environmental Loaded.")
|
BIN
spawners_mobs/_material/deco_stones.xcf
Normal file
@ -70,17 +70,17 @@ function spawners_mobs.cloud_booom(pos)
|
||||
minetest.add_particlespawner({
|
||||
amount = 5,
|
||||
time = 2,
|
||||
minpos = vector.subtract({x=pos.x-0.6, y=pos.y, z=pos.z-0.6}, 0.6),
|
||||
maxpos = vector.add({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.3, y=pos.y, z=pos.z+0.3}, 0.3),
|
||||
minvel = {x=0.1, y=0.1, z=0.1},
|
||||
maxvel = {x=0.2, y=0.2, z=0.2},
|
||||
minacc = vector.new({x=-0.1, y=0.1, z=-0.1}),
|
||||
maxacc = vector.new({x=0.1, y=0.3, z=0.1}),
|
||||
minacc = 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,
|
||||
maxexptime = 3,
|
||||
minsize = 4,
|
||||
maxsize = 8,
|
||||
texture = "spawners_mobs_smoke2_particle.png^[transform"..math.random(0,3),
|
||||
maxsize = 12,
|
||||
texture = "spawners_mobs_smoke_particle_2.png^[transform"..math.random(0,3),
|
||||
})
|
||||
end
|
||||
|
||||
@ -98,7 +98,7 @@ function spawners_mobs.add_flame_effects(pos)
|
||||
maxexptime = 5,
|
||||
minsize = .5,
|
||||
maxsize = 2.5,
|
||||
texture = "spawners_mobs_flame_particle.png",
|
||||
texture = "spawners_mobs_flame_particle_2.png",
|
||||
})
|
||||
|
||||
return id
|
||||
|
@ -18,4 +18,4 @@ if minetest.get_modpath("mobs") then
|
||||
dofile(minetest.get_modpath(MOD_NAME).."/nodes_additional.lua")
|
||||
end
|
||||
|
||||
print ("[Mod] Spawners Mobs 0.7 Loaded.")
|
||||
print ("[Mod] Spawners Mobs Loaded.")
|
||||
|
@ -38,6 +38,7 @@ local mummy_def = {
|
||||
{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_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:mese_crystal", chance = 3, min = 1, max = 2},
|
||||
{name = "spawners_mobs:mummy", chance = 25, min = 1, max = 1},
|
||||
@ -58,7 +59,7 @@ local mummy_def = {
|
||||
punch_start = 74,
|
||||
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)
|
||||
minetest.sound_play("spawners_mobs_mummy_death", {
|
||||
object = self.object,
|
||||
|
@ -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], {
|
||||
description = "Sandstone with "..img[i],
|
||||
tiles = {"default_sandstone.png^spawners_mobs_"..img[i]..".png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=2,cracky=3},
|
||||
tiles = {"spawners_mobs_sandstone_carved_"..img[i]..".png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 2},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
end
|
||||
end
|
||||
|
@ -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},
|
||||
drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner",
|
||||
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)
|
||||
end,
|
||||
on_timer = function(pos, elapsed)
|
||||
|
Before Width: | Height: | Size: 390 B |
Before Width: | Height: | Size: 248 B |
BIN
spawners_mobs/textures/spawners_mobs_flame_particle_2.png
Normal file
After Width: | Height: | Size: 241 B |
Before Width: | Height: | Size: 240 B |
BIN
spawners_mobs/textures/spawners_mobs_sandstone_carved_bird.png
Normal file
After Width: | Height: | Size: 437 B |
BIN
spawners_mobs/textures/spawners_mobs_sandstone_carved_eye.png
Normal file
After Width: | Height: | Size: 656 B |
BIN
spawners_mobs/textures/spawners_mobs_sandstone_carved_men.png
Normal file
After Width: | Height: | Size: 645 B |
BIN
spawners_mobs/textures/spawners_mobs_sandstone_carved_sun.png
Normal file
After Width: | Height: | Size: 546 B |
Before Width: | Height: | Size: 233 B |
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 170 B |
BIN
spawners_mobs/textures/spawners_mobs_smoke_particle_2.png
Normal file
After Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 231 B |
@ -1,5 +1,6 @@
|
||||
-- main tables
|
||||
spawners_ores = {}
|
||||
local percent = 10
|
||||
|
||||
-- how often node timers for minerals will tick, +/- some random value
|
||||
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)
|
||||
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
|
||||
|
||||
-- adds smoke particles
|
||||
@ -83,29 +84,73 @@ end
|
||||
-- build form for spawners
|
||||
function spawners_ores.get_formspec(pos, table)
|
||||
-- Inizialize metadata and variables
|
||||
local table = table or {}
|
||||
local meta = minetest.get_meta(pos)
|
||||
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 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
|
||||
return "size[8,8.5]"..
|
||||
-- dynamic formspec
|
||||
local formspec = "size[8,8.5]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
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;]"..
|
||||
"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]"..
|
||||
"image[2.9,1;1,1;gui_furnace_arrow_bg.png^[transformR270"..colorize_arrow.."]"..
|
||||
"label[1.8,2;"..stack_per.." minerals ("..extra_per.." extra)]"..
|
||||
"image[4,1;1,1;spawners_ores_stone_with_"..mineral..".png]"..
|
||||
button..
|
||||
"listring[current_name;fuel]"..
|
||||
"listring[current_player;main]"..
|
||||
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
|
||||
|
||||
-- check if is fuel empty in the node
|
||||
@ -119,7 +164,6 @@ end
|
||||
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)
|
||||
@ -134,6 +178,7 @@ function spawners_ores.stack_per(table)
|
||||
}
|
||||
end
|
||||
|
||||
-- set status and update formspec/infotext
|
||||
function spawners_ores.on_timer(pos, elapsed)
|
||||
|
||||
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 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")
|
||||
local tick = meta:get_int("tick")
|
||||
|
||||
--
|
||||
-- active
|
||||
@ -159,41 +200,43 @@ function spawners_ores.on_timer(pos, elapsed)
|
||||
-- make sure the right node status is shown
|
||||
if status ~= "active" then
|
||||
meta:set_string("status", "active")
|
||||
|
||||
spawners_ores.get_formspec(pos)
|
||||
minetest.swap_node(pos, {name="spawners_ores:"..ore_name.."_spawner_active"})
|
||||
end
|
||||
|
||||
-- take fuel
|
||||
stack:take_item()
|
||||
inv:set_stack("fuel", 1, stack)
|
||||
-- start spawning only on proper 'tick'
|
||||
if tick ~= 0 then
|
||||
if stack:get_count() % percent == 0 then
|
||||
-- TODO: should get countent based on 'percent'
|
||||
how_many = 2
|
||||
end
|
||||
|
||||
-- update infotext
|
||||
infotext = mineral.." fuel: "..stack:get_count()
|
||||
-- enough place to spawn more ores
|
||||
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
|
||||
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
|
||||
spawners_ores.get_formspec(pos)
|
||||
end
|
||||
|
||||
-- enough place to spawn more ores
|
||||
spawners_ores.start_spawning_ores(available_node, "default:"..ore_name, how_many)
|
||||
-- dont wait for proper 'tick' and change state after 1 sec.
|
||||
local next_available_node = spawners_ores.get_available_node(pos, "default:stone")
|
||||
|
||||
-- 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())
|
||||
if inv:is_empty("fuel") or next_available_node == false then
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
return
|
||||
end
|
||||
|
||||
if tick == 0 then
|
||||
-- start new proper timer
|
||||
meta:set_int("tick", 1)
|
||||
end
|
||||
|
||||
-- start new proper timer
|
||||
spawners_ores.tick(pos)
|
||||
|
||||
--
|
||||
-- default
|
||||
--
|
||||
@ -203,47 +246,22 @@ function spawners_ores.on_timer(pos, elapsed)
|
||||
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)
|
||||
|
||||
spawners_ores.get_formspec(pos)
|
||||
return
|
||||
|
||||
--
|
||||
-- waiting
|
||||
--
|
||||
else
|
||||
-- stop timer and show "refresh" button in order to start timer again
|
||||
-- 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)
|
||||
spawners_ores.get_formspec(pos)
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -6,4 +6,4 @@ dofile(minetest.get_modpath(MOD_NAME).."/api.lua")
|
||||
-- Spawners for ores
|
||||
dofile(minetest.get_modpath(MOD_NAME).."/spawners_ores.lua")
|
||||
|
||||
print ("[Mod] Spawners Ores 0.7 Loaded.")
|
||||
print ("[Mod] Spawners Ores Loaded.")
|
||||
|
@ -3,7 +3,7 @@
|
||||
--
|
||||
|
||||
local colorize = {
|
||||
stone_with_gold = "^[colorize:#ffe40030",
|
||||
stone_with_gold = "^[colorize:#ffe40033",
|
||||
stone_with_tin = "^[colorize:#d0d0d040",
|
||||
stone_with_iron = "^[colorize:#b66d4940",
|
||||
stone_with_copper = "^[colorize:#b5875240",
|
||||
@ -28,9 +28,6 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
end
|
||||
|
||||
if stack:get_name() == "default:"..mineral.."_ingot" then
|
||||
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
@ -43,11 +40,23 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
||||
return 0
|
||||
end
|
||||
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
|
||||
return stack:get_count()
|
||||
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
|
||||
--
|
||||
@ -135,7 +144,8 @@ function spawners_ores.create(def)
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
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_take = allow_metadata_inventory_take,
|
||||
})
|
||||
@ -177,6 +187,17 @@ function spawners_ores.create(def)
|
||||
return drops
|
||||
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_take = allow_metadata_inventory_take,
|
||||
})
|
||||
@ -201,7 +222,7 @@ function spawners_ores.create(def)
|
||||
|
||||
on_construct = function(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
|
||||
local inv = meta:get_inventory()
|
||||
@ -211,14 +232,11 @@ function spawners_ores.create(def)
|
||||
meta:set_string("mineral", ore[3])
|
||||
meta:set_string("ore_name", ore_name)
|
||||
meta:set_string("status", "")
|
||||
meta:set_int("tick", 0)
|
||||
|
||||
-- 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,
|
||||
|
||||
on_blast = function(pos)
|
||||
@ -229,10 +247,8 @@ function spawners_ores.create(def)
|
||||
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,
|
||||
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_take = allow_metadata_inventory_take,
|
||||
})
|
||||
@ -241,8 +257,7 @@ function spawners_ores.create(def)
|
||||
minetest.register_lbm({
|
||||
name = "spawners_ores:start_nodetimer_"..ore_name,
|
||||
nodenames = {
|
||||
"spawners_ores:"..ore_name.."_spawner_active",
|
||||
"spawners_ores:"..ore_name.."_spawner_waiting"
|
||||
"spawners_ores:"..ore_name.."_spawner_active"
|
||||
},
|
||||
action = function(pos, node)
|
||||
spawners_ores.tick_short(pos)
|
||||
|