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, {
local remove = minetest.after(2, function()
self.object:remove()
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)
for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
......@@ -28,22 +28,22 @@ minetest.register_entity(fname, {
for dz=0,1 do
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 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 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()
return
end
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()
end
end
end
end
end
local apos = self.object:getpos()
local apos = self.object:get_pos()
local part = minetest.add_particlespawner(
6, --amount
0.3, --time
......
......@@ -22,9 +22,9 @@ dmobs.dragon.ride = function(self, clicker)
object_detach(self, clicker, {x=1, y=0, z=1})
if inv:room_for_item("main", "mobs:saddle") then
inv:add_item("main", "mobs:saddle")
inv:add_item("main", "mobs:saddle")
else
minetest.add_item(clicker.getpos(), "mobs:saddle")
minetest.add_item(clicker:get_pos(), "mobs:saddle")
end
elseif not self.driver then
......
......@@ -59,7 +59,7 @@ mobs:register_mob("dmobs:waterdragon", {
self.hydra = true -- flip switch so this part is done only once
-- get head position and define a few temp variables
local pos = self.object:getpos()
local pos = self.object:get_pos()
local obj, obj2, ent
-- add body and make it follow head
......
......@@ -2,11 +2,13 @@
--butterflies
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,
chance = 10,
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
})
......@@ -20,18 +22,18 @@ minetest.register_entity("dmobs:butterfly", {
num = math.random(1,4)
self.object:set_properties({textures = {"dmobs_butterfly"..num..".png",},})
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()
self.object:remove()
end)
end,
on_step = function(self)
local pos = self.object:getpos()
local vec = self.object:getvelocity()
local pos = self.object:get_pos()
local vec = self.object:get_velocity()
local num = math.random(-math.pi, math.pi)
self.object:setyaw(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:setacceleration({x=-math.sin(6*vec.y), y=math.cos(6*vec.x), z=-math.sin(6*vec.y)})
self.object:set_yaw(math.pi+num)
self.object:set_velocity({x=-math.sin(12*pos.y), y=math.cos(12*pos.x), z=-math.sin(12*pos.y)})
self.object:set_acceleration({x=-math.sin(6*vec.y), y=math.cos(6*vec.x), z=-math.sin(6*vec.y)})
end,
collisionbox = {0,0,0,0,0.1,0},
})
......@@ -44,8 +44,8 @@ mobs:register_mob("dmobs:nyan", {
},
do_custom = function(self)
local apos = self.object:getpos()
local vec = self.object:getvelocity()
local apos = self.object:get_pos()
local vec = self.object:get_velocity()
local part = minetest.add_particlespawner(
5, --amount
0.3, --time
......
......@@ -81,8 +81,8 @@ mobs:register_mob("dmobs:wasp_leader", {
},
do_custom = function(self)
if math.random(1, 500) >= 500 then
local pos = self.object:getpos()
minetest.env:add_entity(pos, "dmobs:wasp")
local pos = self.object:get_pos()
minetest.add_entity(pos, "dmobs:wasp")
end
end,
replace_rate = 700,
......
......@@ -7,10 +7,10 @@ minetest.register_node("dmobs:hive", {
tiles = {"dmobs_hive.png"},
groups = {crumbly=1, oddly_breakable_by_hand=1, falling_node=1, flammable=1},
on_destruct = function(pos, oldnode)
minetest.env:add_entity(pos, "dmobs:wasp")
minetest.env:add_entity(pos, "dmobs:wasp")
minetest.env:add_entity(pos, "dmobs:wasp")
minetest.env:add_entity(pos, "dmobs:wasp")
minetest.add_entity(pos, "dmobs:wasp")
minetest.add_entity(pos, "dmobs:wasp")
minetest.add_entity(pos, "dmobs:wasp")
minetest.add_entity(pos, "dmobs:wasp")
end,
})
......@@ -21,14 +21,14 @@ minetest.register_node("dmobs:golemstone", {
tiles = {"dmobs_golem_stone.png",},
groups = {cracky=1},
on_construct = function(pos, node, _)
local node1 = minetest.env: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 node3 = 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.get_node({x=pos.x, y=pos.y-2, 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
minetest.env:add_entity(pos, "dmobs:golem_friendly")
minetest.env: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.env:remove_node({x=pos.x, y=pos.y, z=pos.z})
minetest.add_entity(pos, "dmobs:golem_friendly")
minetest.remove_node({x=pos.x, y=pos.y-1, z=pos.z})
minetest.remove_node({x=pos.x, y=pos.y-2, z=pos.z})
minetest.remove_node({x=pos.x, y=pos.y, z=pos.z})
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