Update deprecated methods and move x_default to optional dependencies

This commit is contained in:
Juraj Vajda 2023-04-08 22:24:50 -04:00
parent 6676b6a3f8
commit f30395040c
7 changed files with 38 additions and 29 deletions

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
.DS_Store
docs/build
*.blend1
*.blend2
*.old
node_modules
*.log
logs
*.mtl

View File

@ -23,15 +23,15 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture,
} }
dummy_definition.on_activate = function(self) dummy_definition.on_activate = function(self)
self.object:setvelocity({x=0, y=0, z=0}) self.object:set_velocity({x=0, y=0, z=0})
self.object:setacceleration({x=0, y=0, z=0}) self.object:set_acceleration({x=0, y=0, z=0})
self.object:set_armor_groups({immortal=1}) self.object:set_armor_groups({immortal=1})
end end
-- remove dummy after dug up the spawner -- remove dummy after dug up the spawner
dummy_definition.on_step = function(self, dtime) dummy_definition.on_step = function(self, dtime)
self.timer = self.timer + dtime self.timer = self.timer + dtime
local n = minetest.get_node_or_nil(self.object:getpos()) local n = minetest.get_node_or_nil(self.object:get_pos())
if self.timer > 2 then if self.timer > 2 then
if n and n.name and n.name ~= "spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_active" then if n and n.name and n.name ~= "spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_active" then
self.object:remove() self.object:remove()

View File

@ -1,5 +1,5 @@
default default
x_default x_default?
xpanes? xpanes?
fire? fire?
mobs? mobs?

View File

@ -146,7 +146,7 @@ local balrog_def = {
local player_hp = object:get_hp() local player_hp = object:get_hp()
-- is in MMO Arena & health check -- is in MMO Arena & health check
if x_default:isInMMOArena(player_pos) and player_hp > 0 then if minetest.global_exists('x_default') and x_default:isInMMOArena(player_pos) and player_hp > 0 then
-- play sound -- play sound
minetest.sound_play("spawners_mobs_teleport", { minetest.sound_play("spawners_mobs_teleport", {
object = object, object = object,

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 KiB

View File

@ -24,8 +24,8 @@ function spawners_mobs.create(mob_table, idx)
static_save = false, static_save = false,
on_activate = function(self, staticdata, dtime_s) on_activate = function(self, staticdata, dtime_s)
self.object:setvelocity({x = 0, y = 0, z = 0}) self.object:set_velocity({x = 0, y = 0, z = 0})
self.object:setacceleration({x = 0, y = 0, z = 0}) self.object:set_acceleration({x = 0, y = 0, z = 0})
self.object:set_armor_groups({immortal = 1}) self.object:set_armor_groups({immortal = 1})
end end
}) })

View File

@ -1,6 +1,6 @@
-- --
-- Colorize HEX -- Colorize HEX
-- --
local colorize = { local colorize = {
stone_with_gold = "^[colorize:#ffe40033", stone_with_gold = "^[colorize:#ffe40033",
@ -9,9 +9,9 @@ local colorize = {
stone_with_copper = "^[colorize:#b5875240", stone_with_copper = "^[colorize:#b5875240",
} }
-- --
-- Handle formspec and inventory management -- Handle formspec and inventory management
-- --
local function allow_metadata_inventory_put(pos, listname, index, stack, player) local function allow_metadata_inventory_put(pos, listname, index, stack, player)
@ -57,9 +57,9 @@ local function on_metadata_inventory_take(pos)
minetest.get_node_timer(pos):start(1.0) minetest.get_node_timer(pos):start(1.0)
end end
-- --
-- Spawners Ores creation function -- Spawners Ores creation function
-- --
function spawners_ores.create(def) function spawners_ores.create(def)
@ -89,15 +89,15 @@ function spawners_ores.create(def)
local ore = string.split(ore_name, "_") local ore = string.split(ore_name, "_")
dummy_ore_definition.on_activate = function(self) dummy_ore_definition.on_activate = function(self)
self.object:setvelocity({x=0, y=0, z=0}) self.object:set_velocity({x=0, y=0, z=0})
self.object:setacceleration({x=0, y=0, z=0}) self.object:set_acceleration({x=0, y=0, z=0})
self.object:set_armor_groups({immortal=1}) self.object:set_armor_groups({immortal=1})
end end
-- remove dummy after dug up the spawner -- remove dummy after dug up the spawner
dummy_ore_definition.on_step = function(self, dtime) dummy_ore_definition.on_step = function(self, dtime)
self.timer = self.timer + dtime self.timer = self.timer + dtime
local n = minetest.get_node_or_nil(self.object:getpos()) local n = minetest.get_node_or_nil(self.object:get_pos())
if self.timer > 2 then if self.timer > 2 then
if n and n.name and n.name ~= "spawners_ores:"..ore_name.."_spawner_active" and n.name ~= "spawners_ores:"..ore_name.."_spawner_waiting" and n.name ~= "spawners_ores:"..ore_name.."_spawner" then if n and n.name and n.name ~= "spawners_ores:"..ore_name.."_spawner_active" and n.name ~= "spawners_ores:"..ore_name.."_spawner_waiting" and n.name ~= "spawners_ores:"..ore_name.."_spawner" then
self.object:remove() self.object:remove()
@ -132,11 +132,11 @@ function spawners_ores.create(def)
is_ground_content = true, is_ground_content = true,
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_ores:"..ore_name.."_spawner", drop = "spawners_ores:"..ore_name.."_spawner",
can_dig = spawners_ores.can_dig, can_dig = spawners_ores.can_dig,
on_timer = spawners_ores.on_timer, on_timer = spawners_ores.on_timer,
on_blast = function(pos) on_blast = function(pos)
local drops = {} local drops = {}
default.get_inventory_drops(pos, "fuel", drops) default.get_inventory_drops(pos, "fuel", drops)
@ -174,9 +174,9 @@ function spawners_ores.create(def)
is_ground_content = true, is_ground_content = true,
groups = {cracky=1,level=2,not_in_creative_inventory=1}, groups = {cracky=1,level=2,not_in_creative_inventory=1},
drop = "spawners_ores:"..ore_name.."_spawner_waiting", drop = "spawners_ores:"..ore_name.."_spawner_waiting",
can_dig = spawners_ores.can_dig, can_dig = spawners_ores.can_dig,
on_timer = spawners_ores.on_timer, on_timer = spawners_ores.on_timer,
on_blast = function(pos) on_blast = function(pos)
@ -186,7 +186,7 @@ function spawners_ores.create(def)
minetest.remove_node(pos) minetest.remove_node(pos)
return drops return drops
end, end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
if fields.restart then if fields.restart then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -215,9 +215,9 @@ function spawners_ores.create(def)
is_ground_content = true, is_ground_content = true,
groups = {cracky = 1, level = 2}, groups = {cracky = 1, level = 2},
stack_max = 1, stack_max = 1,
can_dig = spawners_ores.can_dig, can_dig = spawners_ores.can_dig,
on_timer = spawners_ores.on_timer, on_timer = spawners_ores.on_timer,
on_construct = function(pos) on_construct = function(pos)
@ -252,7 +252,7 @@ function spawners_ores.create(def)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name()) meta:set_string("owner", placer:get_player_name())
end, end,
on_metadata_inventory_put = on_metadata_inventory_put, on_metadata_inventory_put = on_metadata_inventory_put,
on_metadata_inventory_take = on_metadata_inventory_take, on_metadata_inventory_take = on_metadata_inventory_take,
allow_metadata_inventory_put = allow_metadata_inventory_put, allow_metadata_inventory_put = allow_metadata_inventory_put,
@ -271,9 +271,9 @@ function spawners_ores.create(def)
}) })
end end
-- --
-- Ore Spawners Definitions -- Ore Spawners Definitions
-- --
-- default:stone_with_gold -- default:stone_with_gold
spawners_ores.create({ spawners_ores.create({
@ -303,9 +303,9 @@ spawners_ores.create({
offset = 0 offset = 0
}) })
-- --
-- Recipes -- Recipes
-- --
minetest.register_craft({ minetest.register_craft({
output = "spawners_ores:stone_with_gold_spawner", output = "spawners_ores:stone_with_gold_spawner",