1
0
Fork 0

Remove formspec of monster spawner, default pigs

This commit is contained in:
Wuzzy 2017-05-25 05:45:45 +02:00
parent a9b54a0980
commit 83150f43ea
1 changed files with 7 additions and 31 deletions

View File

@ -42,11 +42,9 @@ end
--[[ Public function: Setup the spawner at pos. --[[ Public function: Setup the spawner at pos.
This function blindly assumes there's actually a spawner at pos. This function blindly assumes there's actually a spawner at pos.
If not, then the results are undefined. If not, then the results are undefined.
All the arguments are optional!
* Mob: ID of mob to spawn * Mob: ID of mob to spawn (default: mobs_mc:pig)
All the following arguments are optional!
* MinLight: Minimum light to spawn (default: 0) * MinLight: Minimum light to spawn (default: 0)
* MaxLight: Maximum light to spawn (default: 15) * MaxLight: Maximum light to spawn (default: 15)
* MaxMobsInArea: How many mobs are allowed in the area around the spawner (default: 4) * MaxMobsInArea: How many mobs are allowed in the area around the spawner (default: 4)
@ -56,6 +54,7 @@ All the following arguments are optional!
function mcl_monster_spawner.setup_spawner(pos, Mob, MinLight, MaxLight, MaxMobsInArea, PlayerDistance, YOffset) function mcl_monster_spawner.setup_spawner(pos, Mob, MinLight, MaxLight, MaxMobsInArea, PlayerDistance, YOffset)
-- Activate monster spawner and disable editing functionality -- Activate monster spawner and disable editing functionality
if Mob == nil then Mob = default_mob end
if MinLight == nil then MinLight = 0 end if MinLight == nil then MinLight = 0 end
if MaxLight == nil then MaxLight = 15 end if MaxLight == nil then MaxLight = 15 end
if MaxMobsInArea == nil then MaxMobsInArea = 4 end if MaxMobsInArea == nil then MaxMobsInArea = 4 end
@ -69,11 +68,6 @@ function mcl_monster_spawner.setup_spawner(pos, Mob, MinLight, MaxLight, MaxMobs
meta:set_int("PlayerDistance", PlayerDistance) meta:set_int("PlayerDistance", PlayerDistance)
meta:set_int("YOffset", YOffset) meta:set_int("YOffset", YOffset)
meta:set_int("active", 1)
meta:set_string("infotext", "")
meta:set_string("formspec", "")
meta:set_string("command", "")
-- Create doll -- Create doll
local doll = minetest.add_entity({x=pos.x, y=pos.y-0.3, z=pos.z}, "mcl_monster_spawner:doll") local doll = minetest.add_entity({x=pos.x, y=pos.y-0.3, z=pos.z}, "mcl_monster_spawner:doll")
set_doll_properties(doll, Mob) set_doll_properties(doll, Mob)
@ -89,11 +83,6 @@ local spawn_monsters = function(pos, elapsed)
-- get meta -- get meta
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local active = meta:get_int("active")
if active == 0 then
-- Spawner not active yet, do nothing
return
end
-- get settings -- get settings
local mob = meta:get_string("Mob") local mob = meta:get_string("Mob")
@ -206,27 +195,14 @@ minetest.register_node("mcl_monster_spawner:spawner", {
is_ground_content = false, is_ground_content = false,
drop = "", drop = "",
on_construct = function(pos) on_construct = mcl_monster_spawner.setup_spawner,
local meta = minetest.get_meta(pos)
-- text entry formspec
meta:set_string("formspec",
"field[text;" .. S("Mob MinLight MaxLight MaxMobsInArea PlayerDistance YOffset") .. ";${command}]")
meta:set_string("infotext", S("Monster spawner not active (Rightclick to enter settings)"))
meta:set_string("command", spawner_default)
meta:set_int("active", 0)
end,
on_destruct = function(pos) on_destruct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if meta:get_int("active") == 1 then
local obj = find_doll(pos) local obj = find_doll(pos)
if obj then if obj then
obj:remove() obj:remove()
end end
end
end, end,
on_timer = spawn_monsters, on_timer = spawn_monsters,