1
0
Fork 0

Refactor mob spawner metadata

objects
Wuzzy 2017-05-25 01:45:16 +02:00
parent 4283edd84d
commit 9b4d174c43
1 changed files with 15 additions and 9 deletions

View File

@ -103,10 +103,17 @@ minetest.register_node("mobs:spawner", {
and yof and yof > -10 and yof < 10 then and yof and yof > -10 and yof < 10 then
-- Activate monster spawner and disable editing functionality -- Activate monster spawner and disable editing functionality
meta:set_string("command", fields.text) meta:set_string("Mob", mob)
meta:set_int("MinLight", mlig)
meta:set_int("MaxLight", xlig)
meta:set_int("MaxMobsInArea", num)
meta:set_int("PlayerDistance", pla)
meta:set_int("YOffset", yof)
meta:set_int("active", 1) meta:set_int("active", 1)
meta:set_string("infotext", "") meta:set_string("infotext", "")
meta:set_string("formspec", "") meta:set_string("formspec", "")
meta:set_string("command", "")
-- Create or update doll -- Create or update doll
local doll = find_doll(pos) local doll = find_doll(pos)
@ -196,15 +203,14 @@ minetest.register_abm({
-- Spawner not active yet, do nothing -- Spawner not active yet, do nothing
return return
end end
local comm = meta:get_string("command"):split(" ")
-- get settings from command -- get settings
local mob = comm[1] local mob = meta:get_string("Mob")
local mlig = tonumber(comm[2]) local mlig = meta:get_int("MinLight")
local xlig = tonumber(comm[3]) local xlig = meta:get_int("MaxLight")
local num = tonumber(comm[4]) local num = meta:get_int("MaxMobsInArea")
local pla = tonumber(comm[5]) or 0 local pla = meta:get_int("PlayerDistance")
local yof = tonumber(comm[6]) or 0 local yof = meta:get_int("YOffset")
-- if amount is 0 then do nothing -- if amount is 0 then do nothing
if num == 0 then if num == 0 then