bug fixing and cleanup
This commit is contained in:
parent
8108835d2d
commit
66c05c46fd
17
API.lua
17
API.lua
@ -34,7 +34,6 @@ for k, mob_mod in ipairs(ENABLED_MODS) do
|
|||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print("[MOD] Spawners: MOD "..mob_mod.." not found and will not be loaded.")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -101,31 +100,29 @@ function spawners.start_spawning_ores(pos, ore_name, sound_custom, spawners_pos)
|
|||||||
|
|
||||||
local how_many = math.random(1,2)
|
local how_many = math.random(1,2)
|
||||||
-- how_many = how_many+1
|
-- how_many = how_many+1
|
||||||
print("how_many: "..how_many)
|
|
||||||
|
|
||||||
for i=1, how_many do
|
for i=1, how_many do
|
||||||
print("i: "..i)
|
|
||||||
|
|
||||||
if i > 1 then
|
if i > 1 then
|
||||||
player_near, pos = spawners.check_around_radius_ores(pos, "default:stone")
|
player_near, pos = spawners.check_around_radius_ores(pos, "default:stone")
|
||||||
|
|
||||||
|
if not pos then return end
|
||||||
|
|
||||||
minetest.sound_play(sound_name, {
|
minetest.sound_play(sound_name, {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
max_hear_distance = 32,
|
max_hear_distance = 32,
|
||||||
gain = 15,
|
gain = 20,
|
||||||
})
|
})
|
||||||
|
|
||||||
print("#2 spawing "..ore_name.." at "..minetest.pos_to_string(pos))
|
|
||||||
minetest.set_node(pos, {name=ore_name})
|
minetest.set_node(pos, {name=ore_name})
|
||||||
spawners.add_effects(pos, 1)
|
spawners.add_effects(pos, 1)
|
||||||
else
|
else
|
||||||
minetest.sound_play(sound_name, {
|
minetest.sound_play(sound_name, {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
max_hear_distance = 32,
|
max_hear_distance = 32,
|
||||||
gain = 15,
|
gain = 20,
|
||||||
})
|
})
|
||||||
|
|
||||||
print("#1 spawing "..ore_name.." at "..minetest.pos_to_string(pos))
|
|
||||||
minetest.set_node(pos, {name=ore_name})
|
minetest.set_node(pos, {name=ore_name})
|
||||||
spawners.add_effects(pos, 1)
|
spawners.add_effects(pos, 1)
|
||||||
end
|
end
|
||||||
@ -152,16 +149,12 @@ function spawners.check_around_radius_ores(pos, check_node)
|
|||||||
local player_near = spawners.check_around_radius(pos);
|
local player_near = spawners.check_around_radius(pos);
|
||||||
local found_node = false
|
local found_node = false
|
||||||
local node_ore_pos = nil
|
local node_ore_pos = nil
|
||||||
print("check_node: "..check_node)
|
|
||||||
if check_node then
|
if check_node then
|
||||||
|
|
||||||
node_ore_pos = minetest.find_node_near(pos, 2, {check_node})
|
node_ore_pos = minetest.find_node_near(pos, 2, {check_node})
|
||||||
|
|
||||||
if node_ore_pos then
|
if node_ore_pos then
|
||||||
found_node = node_ore_pos
|
found_node = node_ore_pos
|
||||||
print("found stone: "..minetest.pos_to_string(found_node));
|
|
||||||
else
|
|
||||||
found_node = false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -262,7 +255,7 @@ function spawners.check_node_status_ores(pos, ore_name, check_node)
|
|||||||
|
|
||||||
local player_near, found_node = spawners.check_around_radius_ores(pos, check_node)
|
local player_near, found_node = spawners.check_around_radius_ores(pos, check_node)
|
||||||
|
|
||||||
if player_near then
|
if player_near and found_node then
|
||||||
return true, found_node
|
return true, found_node
|
||||||
else
|
else
|
||||||
return true, false
|
return true, false
|
||||||
|
@ -28,12 +28,8 @@ function spawners.get_formspec(pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local fuellist = inv:get_list("fuel")
|
|
||||||
|
|
||||||
-- Update formspec, infotext and node
|
-- Update formspec, infotext and node
|
||||||
local formspec = ore_formspec
|
meta:set_string("formspec", ore_formspec)
|
||||||
|
|
||||||
meta:set_string("formspec", formspec)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function can_dig(pos, player)
|
local function can_dig(pos, player)
|
||||||
@ -43,7 +39,6 @@ local function can_dig(pos, player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||||
print("allow_metadata_inventory_put")
|
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
minetest.record_protection_violation(pos, player:get_player_name())
|
minetest.record_protection_violation(pos, player:get_player_name())
|
||||||
return
|
return
|
||||||
@ -67,7 +62,6 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||||
print("allow_metadata_inventory_take")
|
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
minetest.record_protection_violation(pos, player:get_player_name())
|
minetest.record_protection_violation(pos, player:get_player_name())
|
||||||
return 0
|
return 0
|
||||||
@ -76,7 +70,6 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function on_receive_fields(pos, formname, fields, sender)
|
local function on_receive_fields(pos, formname, fields, sender)
|
||||||
print("on_receive_fields")
|
|
||||||
local ore_node = minetest.get_node_or_nil(pos)
|
local ore_node = minetest.get_node_or_nil(pos)
|
||||||
|
|
||||||
if minetest.is_protected(pos, sender:get_player_name()) then
|
if minetest.is_protected(pos, sender:get_player_name()) then
|
||||||
@ -121,7 +114,7 @@ local function on_receive_fields(pos, formname, fields, sender)
|
|||||||
elseif waiting then
|
elseif waiting then
|
||||||
minetest.swap_node(pos, {name="spawners:stone_with_"..ingot[3].."_spawner_waiting"})
|
minetest.swap_node(pos, {name="spawners:stone_with_"..ingot[3].."_spawner_waiting"})
|
||||||
|
|
||||||
meta:set_string("infotext", "There is no stone around - waiting. "..ingot[3].." ore spawner fuel: "..inv:get_stack("fuel", 1):get_count())
|
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
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -259,7 +252,6 @@ function spawners.create_ore(ore_name, mod_prefix, size, offset, texture, sound_
|
|||||||
|
|
||||||
local waiting, found_node = spawners.check_node_status_ores(pos, ore_name, "default:stone")
|
local waiting, found_node = spawners.check_node_status_ores(pos, ore_name, "default:stone")
|
||||||
|
|
||||||
print("ore_name: "..ore_name)
|
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -270,34 +262,31 @@ function spawners.create_ore(ore_name, mod_prefix, size, offset, texture, sound_
|
|||||||
minetest.swap_node(pos, {name="spawners:"..ore_name.."_spawner_active"})
|
minetest.swap_node(pos, {name="spawners:"..ore_name.."_spawner_active"})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- take fuel
|
||||||
|
local stack = inv:get_stack("fuel", 1)
|
||||||
|
stack:take_item()
|
||||||
|
|
||||||
|
|
||||||
if inv:is_empty("fuel") then
|
inv:set_stack("fuel", 1, stack)
|
||||||
minetest.swap_node(pos, {name="spawners:"..ore_name.."_spawner"})
|
|
||||||
meta:set_string("infotext", ore[3].." ore spawner is empty.")
|
|
||||||
|
|
||||||
return
|
meta:set_string("infotext", ore[3].." ore spawner fuel: "..inv:get_stack("fuel", 1):get_count())
|
||||||
else
|
|
||||||
-- take fuel
|
|
||||||
local stack = inv:get_stack("fuel", 1)
|
|
||||||
stack:take_item()
|
|
||||||
|
|
||||||
print("stack: "..stack:get_count())
|
|
||||||
|
|
||||||
inv:set_stack("fuel", 1, stack)
|
|
||||||
|
|
||||||
meta:set_string("infotext", ore[3].." ore spawner fuel: "..inv:get_stack("fuel", 1):get_count())
|
|
||||||
end
|
|
||||||
|
|
||||||
-- enough place to spawn more ores
|
-- enough place to spawn more ores
|
||||||
spawners.start_spawning_ores(found_node, "default:"..ore_name, sound_custom)
|
spawners.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:"..ore_name.."_spawner"})
|
||||||
|
meta:set_string("infotext", ore[3].." ore spawner is empty.")
|
||||||
|
|
||||||
|
end
|
||||||
else
|
else
|
||||||
-- waiting status
|
-- waiting status
|
||||||
if node.name ~= "spawners:"..ore_name.."_spawner_waiting" then
|
if node.name ~= "spawners:"..ore_name.."_spawner_waiting" then
|
||||||
minetest.swap_node(pos, {name="spawners:"..ore_name.."_spawner_waiting"})
|
minetest.swap_node(pos, {name="spawners:"..ore_name.."_spawner_waiting"})
|
||||||
|
|
||||||
meta:set_string("infotext", "There is no stone around - waiting. "..ore[3].." ore spawner fuel: "..inv:get_stack("fuel", 1):get_count())
|
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
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user