Commit e60fac47 authored by SmallJoker's avatar SmallJoker

Modernize code: Replace deprecated function calls

parent 3cc3d4dc
This diff is collapsed.
...@@ -10,7 +10,7 @@ minetest.register_entity(fname, { ...@@ -10,7 +10,7 @@ minetest.register_entity(fname, {
local remove = minetest.after(2, function() local remove = minetest.after(2, function()
self.object:remove() self.object:remove()
end) end)
local pos = self.object:getpos() local pos = self.object:get_pos()
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then if obj:get_luaentity() ~= nil then
...@@ -28,22 +28,22 @@ minetest.register_entity(fname, { ...@@ -28,22 +28,22 @@ minetest.register_entity(fname, {
for dz=0,1 do for dz=0,1 do
local p = {x=pos.x+dx, y=pos.y, z=pos.z+dz} local p = {x=pos.x+dx, y=pos.y, z=pos.z+dz}
local t = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz} local t = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
local n = minetest.env:get_node(p).name local n = minetest.get_node(p).name
if n ~= fname and n ~="default:dirt_with_grass" and n ~="default:dirt_with_dry_grass" and n ~="default:stone" then if n ~= fname and n ~="default:dirt_with_grass" and n ~="default:dirt_with_dry_grass" and n ~="default:stone" then
if minetest.registered_nodes[n].groups.flammable --[[or math.random(1, 100) <= 1]] then if minetest.registered_nodes[n].groups.flammable --[[or math.random(1, 100) <= 1]] then
minetest.env:set_node(t, {name=replace_node}) minetest.set_node(t, {name=replace_node})
self.object:remove() self.object:remove()
return return
end end
if ice and n == "default:water_source" then if ice and n == "default:water_source" then
minetest.env:set_node(t, {name="default:ice"}) minetest.set_node(t, {name="default:ice"})
self.object:remove() self.object:remove()
end end
end end
end end
end end
end end
local apos = self.object:getpos() local apos = self.object:get_pos()
local part = minetest.add_particlespawner( local part = minetest.add_particlespawner(
6, --amount 6, --amount
0.3, --time 0.3, --time
......
...@@ -24,7 +24,7 @@ dmobs.dragon.ride = function(self, clicker) ...@@ -24,7 +24,7 @@ dmobs.dragon.ride = function(self, clicker)
if inv:room_for_item("main", "mobs:saddle") then if inv:room_for_item("main", "mobs:saddle") then
inv:add_item("main", "mobs:saddle") inv:add_item("main", "mobs:saddle")
else else
minetest.add_item(clicker.getpos(), "mobs:saddle") minetest.add_item(clicker:get_pos(), "mobs:saddle")
end end
elseif not self.driver then elseif not self.driver then
......
...@@ -59,7 +59,7 @@ mobs:register_mob("dmobs:waterdragon", { ...@@ -59,7 +59,7 @@ mobs:register_mob("dmobs:waterdragon", {
self.hydra = true -- flip switch so this part is done only once self.hydra = true -- flip switch so this part is done only once
-- get head position and define a few temp variables -- get head position and define a few temp variables
local pos = self.object:getpos() local pos = self.object:get_pos()
local obj, obj2, ent local obj, obj2, ent
-- add body and make it follow head -- add body and make it follow head
......
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
--butterflies --butterflies
minetest.register_abm({ minetest.register_abm({
nodenames = {"flowers:flower_rose", "flowers:flower_tulip", "flowers:flower_dandelion_yellow", "flowers:flower_viola", "flowers:flower_dandelion_white", "flowers:flower_geranium"}, nodenames = {"flowers:flower_rose", "flowers:flower_tulip",
"flowers:flower_dandelion_yellow", "flowers:flower_viola",
"flowers:flower_dandelion_white", "flowers:flower_geranium"},
interval = 10.0, interval = 10.0,
chance = 10, chance = 10,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:add_entity({x=pos.x,y=pos.y+0.3,z=pos.z}, "dmobs:butterfly") minetest.add_entity({x=pos.x,y=pos.y+0.3,z=pos.z}, "dmobs:butterfly")
end end
}) })
...@@ -20,18 +22,18 @@ minetest.register_entity("dmobs:butterfly", { ...@@ -20,18 +22,18 @@ minetest.register_entity("dmobs:butterfly", {
num = math.random(1,4) num = math.random(1,4)
self.object:set_properties({textures = {"dmobs_butterfly"..num..".png",},}) self.object:set_properties({textures = {"dmobs_butterfly"..num..".png",},})
self.object:set_animation({x=1, y=10}, 20, 0) self.object:set_animation({x=1, y=10}, 20, 0)
self.object:setyaw(math.pi+num) self.object:set_yaw(math.pi+num)
minetest.after(10, function() minetest.after(10, function()
self.object:remove() self.object:remove()
end) end)
end, end,
on_step = function(self) on_step = function(self)
local pos = self.object:getpos() local pos = self.object:get_pos()
local vec = self.object:getvelocity() local vec = self.object:get_velocity()
local num = math.random(-math.pi, math.pi) local num = math.random(-math.pi, math.pi)
self.object:setyaw(math.pi+num) self.object:set_yaw(math.pi+num)
self.object:setvelocity({x=-math.sin(12*pos.y), y=math.cos(12*pos.x), z=-math.sin(12*pos.y)}) self.object:set_velocity({x=-math.sin(12*pos.y), y=math.cos(12*pos.x), z=-math.sin(12*pos.y)})
self.object:setacceleration({x=-math.sin(6*vec.y), y=math.cos(6*vec.x), z=-math.sin(6*vec.y)}) self.object:set_acceleration({x=-math.sin(6*vec.y), y=math.cos(6*vec.x), z=-math.sin(6*vec.y)})
end, end,
collisionbox = {0,0,0,0,0.1,0}, collisionbox = {0,0,0,0,0.1,0},
}) })
...@@ -44,8 +44,8 @@ mobs:register_mob("dmobs:nyan", { ...@@ -44,8 +44,8 @@ mobs:register_mob("dmobs:nyan", {
}, },
do_custom = function(self) do_custom = function(self)
local apos = self.object:getpos() local apos = self.object:get_pos()
local vec = self.object:getvelocity() local vec = self.object:get_velocity()
local part = minetest.add_particlespawner( local part = minetest.add_particlespawner(
5, --amount 5, --amount
0.3, --time 0.3, --time
......
...@@ -81,8 +81,8 @@ mobs:register_mob("dmobs:wasp_leader", { ...@@ -81,8 +81,8 @@ mobs:register_mob("dmobs:wasp_leader", {
}, },
do_custom = function(self) do_custom = function(self)
if math.random(1, 500) >= 500 then if math.random(1, 500) >= 500 then
local pos = self.object:getpos() local pos = self.object:get_pos()
minetest.env:add_entity(pos, "dmobs:wasp") minetest.add_entity(pos, "dmobs:wasp")
end end
end, end,
replace_rate = 700, replace_rate = 700,
......
...@@ -7,10 +7,10 @@ minetest.register_node("dmobs:hive", { ...@@ -7,10 +7,10 @@ minetest.register_node("dmobs:hive", {
tiles = {"dmobs_hive.png"}, tiles = {"dmobs_hive.png"},
groups = {crumbly=1, oddly_breakable_by_hand=1, falling_node=1, flammable=1}, groups = {crumbly=1, oddly_breakable_by_hand=1, falling_node=1, flammable=1},
on_destruct = function(pos, oldnode) on_destruct = function(pos, oldnode)
minetest.env:add_entity(pos, "dmobs:wasp") minetest.add_entity(pos, "dmobs:wasp")
minetest.env:add_entity(pos, "dmobs:wasp") minetest.add_entity(pos, "dmobs:wasp")
minetest.env:add_entity(pos, "dmobs:wasp") minetest.add_entity(pos, "dmobs:wasp")
minetest.env:add_entity(pos, "dmobs:wasp") minetest.add_entity(pos, "dmobs:wasp")
end, end,
}) })
...@@ -21,14 +21,14 @@ minetest.register_node("dmobs:golemstone", { ...@@ -21,14 +21,14 @@ minetest.register_node("dmobs:golemstone", {
tiles = {"dmobs_golem_stone.png",}, tiles = {"dmobs_golem_stone.png",},
groups = {cracky=1}, groups = {cracky=1},
on_construct = function(pos, node, _) on_construct = function(pos, node, _)
local node1 = minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name local node1 = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
local node2 = minetest.env:get_node({x=pos.x, y=pos.y-2, z=pos.z}).name local node2 = minetest.get_node({x=pos.x, y=pos.y-2, z=pos.z}).name
local node3 = minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}).name local node3 = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name
if node1 == "default:stone" and node2 == "default:stone" and node3 == "air" then if node1 == "default:stone" and node2 == "default:stone" and node3 == "air" then
minetest.env:add_entity(pos, "dmobs:golem_friendly") minetest.add_entity(pos, "dmobs:golem_friendly")
minetest.env:remove_node({x=pos.x, y=pos.y-1, z=pos.z}) minetest.remove_node({x=pos.x, y=pos.y-1, z=pos.z})
minetest.env:remove_node({x=pos.x, y=pos.y-2, z=pos.z}) minetest.remove_node({x=pos.x, y=pos.y-2, z=pos.z})
minetest.env:remove_node({x=pos.x, y=pos.y, z=pos.z}) minetest.remove_node({x=pos.x, y=pos.y, z=pos.z})
end end
end, end,
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment