1
0
Fork 0

Replace deprecated functions

This commit is contained in:
Wuzzy 2019-03-06 04:38:57 +01:00
parent b31a717410
commit 2f74aea6f5
29 changed files with 159 additions and 159 deletions

View File

@ -20,7 +20,7 @@ minetest.register_entity("drippingwater:drop_water", {
initial_sprite_basepos = {x=0, y=0}, initial_sprite_basepos = {x=0, y=0},
on_activate = function(self, staticdata) on_activate = function(self, staticdata)
self.object:setsprite({x=0,y=0}, 1, 1, true) self.object:set_sprite({x=0,y=0}, 1, 1, true)
end, end,
on_step = function(self, dtime) on_step = function(self, dtime)
@ -28,11 +28,11 @@ minetest.register_entity("drippingwater:drop_water", {
local ownpos = self.object:get_pos() local ownpos = self.object:get_pos()
if k==1 then if k==1 then
self.object:setacceleration({x=0, y=-5, z=0}) self.object:set_acceleration({x=0, y=-5, z=0})
end end
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
self.object:setacceleration({x=0, y=-5, z=0}) self.object:set_acceleration({x=0, y=-5, z=0})
end end
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
@ -58,7 +58,7 @@ minetest.register_entity("drippingwater:drop_lava", {
initial_sprite_basepos = {x=0, y=0}, initial_sprite_basepos = {x=0, y=0},
on_activate = function(self, staticdata) on_activate = function(self, staticdata)
self.object:setsprite({x=0,y=0}, 1, 0, true) self.object:set_sprite({x=0,y=0}, 1, 0, true)
end, end,
on_step = function(self, dtime) on_step = function(self, dtime)
@ -66,11 +66,11 @@ minetest.register_entity("drippingwater:drop_lava", {
local ownpos = self.object:get_pos() local ownpos = self.object:get_pos()
if k==1 then if k==1 then
self.object:setacceleration({x=0, y=-5, z=0}) self.object:set_acceleration({x=0, y=-5, z=0})
end end
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
self.object:setacceleration({x=0, y=-5, z=0}) self.object:set_acceleration({x=0, y=-5, z=0})
end end

View File

@ -69,7 +69,7 @@ function boat.on_rightclick(self, clicker)
mcl_player.player_set_animation(clicker, "stand" , 30) mcl_player.player_set_animation(clicker, "stand" , 30)
local pos = clicker:get_pos() local pos = clicker:get_pos()
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z} pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
clicker:setpos(pos) clicker:set_pos(pos)
elseif not self._driver then elseif not self._driver then
local attach = clicker:get_attach() local attach = clicker:get_attach()
if attach and attach:get_luaentity() then if attach and attach:get_luaentity() then
@ -91,7 +91,7 @@ function boat.on_rightclick(self, clicker)
mcl_player.player_set_animation(player, "sit" , 30) mcl_player.player_set_animation(player, "sit" , 30)
end end
end, name) end, name)
clicker:set_look_horizontal(self.object:getyaw()) clicker:set_look_horizontal(self.object:get_yaw())
end end
end end
@ -143,10 +143,10 @@ function boat.on_punch(self, puncher)
end end
function boat.on_step(self, dtime) function boat.on_step(self, dtime)
self._v = get_v(self.object:getvelocity()) * get_sign(self._v) self._v = get_v(self.object:get_velocity()) * get_sign(self._v)
if self._driver then if self._driver then
local ctrl = self._driver:get_player_control() local ctrl = self._driver:get_player_control()
local yaw = self.object:getyaw() local yaw = self.object:get_yaw()
if ctrl.up then if ctrl.up then
-- Forwards -- Forwards
self._v = self._v + 0.1 self._v = self._v + 0.1
@ -174,15 +174,15 @@ function boat.on_step(self, dtime)
end end
if ctrl.left then if ctrl.left then
if self._v < 0 then if self._v < 0 then
self.object:setyaw(yaw - (1 + dtime) * 0.03) self.object:set_yaw(yaw - (1 + dtime) * 0.03)
else else
self.object:setyaw(yaw + (1 + dtime) * 0.03) self.object:set_yaw(yaw + (1 + dtime) * 0.03)
end end
elseif ctrl.right then elseif ctrl.right then
if self._v < 0 then if self._v < 0 then
self.object:setyaw(yaw + (1 + dtime) * 0.03) self.object:set_yaw(yaw + (1 + dtime) * 0.03)
else else
self.object:setyaw(yaw - (1 + dtime) * 0.03) self.object:set_yaw(yaw - (1 + dtime) * 0.03)
end end
end end
else else
@ -192,15 +192,15 @@ function boat.on_step(self, dtime)
self._animation = 0 self._animation = 0
end end
end end
local velo = self.object:getvelocity() local velo = self.object:get_velocity()
if self._v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then if self._v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
self.object:setpos(self.object:get_pos()) self.object:set_pos(self.object:get_pos())
return return
end end
local s = get_sign(self._v) local s = get_sign(self._v)
self._v = self._v - 0.02 * s self._v = self._v - 0.02 * s
if s ~= get_sign(self._v) then if s ~= get_sign(self._v) then
self.object:setvelocity({x = 0, y = 0, z = 0}) self.object:set_velocity({x = 0, y = 0, z = 0})
self._v = 0 self._v = 0
return return
end end
@ -220,13 +220,13 @@ function boat.on_step(self, dtime)
else else
new_acce = {x = 0, y = -9.8, z = 0} new_acce = {x = 0, y = -9.8, z = 0}
end end
new_velo = get_velocity(self._v, self.object:getyaw(), new_velo = get_velocity(self._v, self.object:get_yaw(),
self.object:getvelocity().y) self.object:get_velocity().y)
self.object:setpos(self.object:get_pos()) self.object:set_pos(self.object:get_pos())
else else
p.y = p.y + 1 p.y = p.y + 1
if is_water(p) then if is_water(p) then
local y = self.object:getvelocity().y local y = self.object:get_velocity().y
if y >= 5 then if y >= 5 then
y = 5 y = 5
elseif y < 0 then elseif y < 0 then
@ -234,24 +234,24 @@ function boat.on_step(self, dtime)
else else
new_acce = {x = 0, y = 5, z = 0} new_acce = {x = 0, y = 5, z = 0}
end end
new_velo = get_velocity(self._v, self.object:getyaw(), y) new_velo = get_velocity(self._v, self.object:get_yaw(), y)
self.object:setpos(self.object:get_pos()) self.object:set_pos(self.object:get_pos())
else else
new_acce = {x = 0, y = 0, z = 0} new_acce = {x = 0, y = 0, z = 0}
if math.abs(self.object:getvelocity().y) < 1 then if math.abs(self.object:get_velocity().y) < 1 then
local pos = self.object:get_pos() local pos = self.object:get_pos()
pos.y = math.floor(pos.y) + boat_y_offset pos.y = math.floor(pos.y) + boat_y_offset
self.object:setpos(pos) self.object:set_pos(pos)
new_velo = get_velocity(self._v, self.object:getyaw(), 0) new_velo = get_velocity(self._v, self.object:get_yaw(), 0)
else else
new_velo = get_velocity(self._v, self.object:getyaw(), new_velo = get_velocity(self._v, self.object:get_yaw(),
self.object:getvelocity().y) self.object:get_velocity().y)
self.object:setpos(self.object:get_pos()) self.object:set_pos(self.object:get_pos())
end end
end end
end end
self.object:setvelocity(new_velo) self.object:set_velocity(new_velo)
self.object:setacceleration(new_acce) self.object:set_acceleration(new_acce)
end end
-- Register one entity for all boat types -- Register one entity for all boat types

View File

@ -141,9 +141,9 @@ minetest.register_entity(":__builtin:falling_node", {
on_step = function(self, dtime) on_step = function(self, dtime)
-- Set gravity -- Set gravity
local acceleration = self.object:getacceleration() local acceleration = self.object:get_acceleration()
if not vector.equals(acceleration, {x = 0, y = -10, z = 0}) then if not vector.equals(acceleration, {x = 0, y = -10, z = 0}) then
self.object:setacceleration({x = 0, y = -10, z = 0}) self.object:set_acceleration({x = 0, y = -10, z = 0})
end end
-- Turn to actual node when colliding with ground, or continue to move -- Turn to actual node when colliding with ground, or continue to move
local pos = self.object:get_pos() local pos = self.object:get_pos()
@ -222,7 +222,7 @@ minetest.register_entity(":__builtin:falling_node", {
minetest.check_for_falling(np) minetest.check_for_falling(np)
return return
end end
local vel = self.object:getvelocity() local vel = self.object:get_velocity()
-- Fix position if entity does not move -- Fix position if entity does not move
if vector.equals(vel, {x = 0, y = 0, z = 0}) then if vector.equals(vel, {x = 0, y = 0, z = 0}) then
local npos = vector.round(self.object:get_pos()) local npos = vector.round(self.object:get_pos())

View File

@ -98,14 +98,14 @@ minetest.register_globalstep(function(dtime)
local opos = object:get_pos() local opos = object:get_pos()
local vec = vector.subtract(checkpos, opos) local vec = vector.subtract(checkpos, opos)
vec = vector.add(opos, vector.divide(vec, 2)) vec = vector.add(opos, vector.divide(vec, 2))
object:moveto(vec) object:move_to(vec)
--fix eternally falling items --fix eternally falling items
minetest.after(0, function(object) minetest.after(0, function(object)
local lua = object:get_luaentity() local lua = object:get_luaentity()
if lua then if lua then
object:setacceleration({x=0, y=0, z=0}) object:set_acceleration({x=0, y=0, z=0})
end end
end, object) end, object)
@ -264,7 +264,7 @@ function minetest.handle_node_drops(pos, drops, digger)
if math.random(1,2) == 1 then if math.random(1,2) == 1 then
z = -z z = -z
end end
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z}) obj:set_velocity({x=1/x, y=obj:get_velocity().y, z=1/z})
end end
end end
end end
@ -285,7 +285,7 @@ function minetest.item_drop(itemstack, dropper, pos)
v.x = v.x*4 v.x = v.x*4
v.y = v.y*4 + 2 v.y = v.y*4 + 2
v.z = v.z*4 v.z = v.z*4
obj:setvelocity(v) obj:set_velocity(v)
-- Force collection delay -- Force collection delay
obj:get_luaentity()._insta_collect = false obj:get_luaentity()._insta_collect = false
return itemstack return itemstack
@ -373,7 +373,7 @@ core.register_entity(":__builtin:item", {
if not self or not self.object or not self.object:get_luaentity() then if not self or not self.object or not self.object:get_luaentity() then
return return
end end
local vel = self.object:getvelocity() local vel = self.object:get_velocity()
if vel and vel.x == 0 and vel.z == 0 then if vel and vel.x == 0 and vel.z == 0 then
local x = math.random(1, 5) local x = math.random(1, 5)
if math.random(1,2) == 1 then if math.random(1,2) == 1 then
@ -384,7 +384,7 @@ core.register_entity(":__builtin:item", {
z = -z z = -z
end end
local y = math.random(2,4) local y = math.random(2,4)
self.object:setvelocity({x=1/x, y=y, z=1/z}) self.object:set_velocity({x=1/x, y=y, z=1/z})
end end
end, self) end, self)
end end
@ -444,8 +444,8 @@ core.register_entity(":__builtin:item", {
self._forcetimer = 0 self._forcetimer = 0
self.object:set_armor_groups({immortal = 1}) self.object:set_armor_groups({immortal = 1})
self.object:setvelocity({x = 0, y = 2, z = 0}) self.object:set_velocity({x = 0, y = 2, z = 0})
self.object:setacceleration({x = 0, y = -get_gravity(), z = 0}) self.object:set_acceleration({x = 0, y = -get_gravity(), z = 0})
self:set_item(self.itemstring) self:set_item(self.itemstring)
end, end,
@ -589,8 +589,8 @@ core.register_entity(":__builtin:item", {
-- Set new item moving speed accordingly -- Set new item moving speed accordingly
local newv = vector.multiply(shootdir, 3) local newv = vector.multiply(shootdir, 3)
self.object:setacceleration({x = 0, y = 0, z = 0}) self.object:set_acceleration({x = 0, y = 0, z = 0})
self.object:setvelocity(newv) self.object:set_velocity(newv)
disable_physics(self.object, self, false, false) disable_physics(self.object, self, false, false)
@ -643,8 +643,8 @@ core.register_entity(":__builtin:item", {
local f = 1.39 local f = 1.39
-- Set new item moving speed into the direciton of the liquid -- Set new item moving speed into the direciton of the liquid
local newv = vector.multiply(vec, f) local newv = vector.multiply(vec, f)
self.object:setacceleration({x = 0, y = 0, z = 0}) self.object:set_acceleration({x = 0, y = 0, z = 0})
self.object:setvelocity({x = newv.x, y = -0.22, z = newv.z}) self.object:set_velocity({x = newv.x, y = -0.22, z = newv.z})
self.physical_state = true self.physical_state = true
self._flowing = true self._flowing = true
@ -662,7 +662,7 @@ core.register_entity(":__builtin:item", {
-- If node is not registered or node is walkably solid and resting on nodebox -- If node is not registered or node is walkably solid and resting on nodebox
local nn = minetest.get_node({x=p.x, y=p.y-0.5, z=p.z}).name local nn = minetest.get_node({x=p.x, y=p.y-0.5, z=p.z}).name
local v = self.object:getvelocity() local v = self.object:get_velocity()
if not core.registered_nodes[nn] or core.registered_nodes[nn].walkable and v.y == 0 then if not core.registered_nodes[nn] or core.registered_nodes[nn].walkable and v.y == 0 then
if self.physical_state then if self.physical_state then

View File

@ -61,7 +61,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
if puncher:get_player_control().sneak then if puncher:get_player_control().sneak then
if self._driver then if self._driver then
if self._old_pos then if self._old_pos then
self.object:setpos(self._old_pos) self.object:set_pos(self._old_pos)
end end
mcl_player.player_attached[self._driver] = nil mcl_player.player_attached[self._driver] = nil
local player = minetest.get_player_by_name(self._driver) local player = minetest.get_player_by_name(self._driver)
@ -98,7 +98,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
return return
end end
local vel = self.object:getvelocity() local vel = self.object:get_velocity()
if puncher:get_player_name() == self._driver then if puncher:get_player_name() == self._driver then
if math.abs(vel.x + vel.z) > 7 then if math.abs(vel.x + vel.z) > 7 then
return return
@ -121,7 +121,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
end end
function cart:on_step(dtime) function cart:on_step(dtime)
local vel = self.object:getvelocity() local vel = self.object:get_velocity()
local update = {} local update = {}
if self._last_float_check == nil then if self._last_float_check == nil then
self._last_float_check = 0 self._last_float_check = 0
@ -139,7 +139,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
-- Detach driver -- Detach driver
if self._driver then if self._driver then
if self._old_pos then if self._old_pos then
self.object:setpos(self._old_pos) self.object:set_pos(self._old_pos)
end end
mcl_player.player_attached[self._driver] = nil mcl_player.player_attached[self._driver] = nil
local player = minetest.get_player_by_name(self._driver) local player = minetest.get_player_by_name(self._driver)
@ -164,7 +164,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
if self._punched then if self._punched then
vel = vector.add(vel, self._velocity) vel = vector.add(vel, self._velocity)
self.object:setvelocity(vel) self.object:set_velocity(vel)
self._old_dir.y = 0 self._old_dir.y = 0
elseif vector.equals(vel, {x=0, y=0, z=0}) then elseif vector.equals(vel, {x=0, y=0, z=0}) then
return return
@ -217,8 +217,8 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
(self._old_vel.x * vel.x < 0 or self._old_vel.z * vel.z < 0) then (self._old_vel.x * vel.x < 0 or self._old_vel.z * vel.z < 0) then
self._old_vel = {x = 0, y = 0, z = 0} self._old_vel = {x = 0, y = 0, z = 0}
self._old_pos = pos self._old_pos = pos
self.object:setvelocity(vector.new()) self.object:set_velocity(vector.new())
self.object:setacceleration(vector.new()) self.object:set_acceleration(vector.new())
return return
end end
self._old_vel = vector.new(vel) self._old_vel = vector.new(vel)
@ -292,7 +292,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
new_acc = vector.multiply(dir, acc) new_acc = vector.multiply(dir, acc)
end end
self.object:setacceleration(new_acc) self.object:set_acceleration(new_acc)
self._old_pos = vector.new(pos) self._old_pos = vector.new(pos)
self._old_dir = vector.new(dir) self._old_dir = vector.new(dir)
self._old_switch = last_switch self._old_switch = last_switch
@ -321,7 +321,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
elseif dir.z < 0 then elseif dir.z < 0 then
yaw = 1 yaw = 1
end end
self.object:setyaw(yaw * math.pi) self.object:set_yaw(yaw * math.pi)
end end
if self._punched then if self._punched then
@ -341,9 +341,9 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
end end
self.object:set_animation(anim, 1, 0) self.object:set_animation(anim, 1, 0)
self.object:setvelocity(vel) self.object:set_velocity(vel)
if update.pos then if update.pos then
self.object:setpos(pos) self.object:set_pos(pos)
end end
update = nil update = nil
end end
@ -387,7 +387,7 @@ mcl_minecarts.place_minecart = function(itemstack, pointed_thing)
le._railtype = railtype le._railtype = railtype
end end
local cart_dir = mcl_minecarts:get_rail_direction(railpos, {x=1, y=0, z=0}, nil, nil, railtype) local cart_dir = mcl_minecarts:get_rail_direction(railpos, {x=1, y=0, z=0}, nil, nil, railtype)
cart:setyaw(minetest.dir_to_yaw(cart_dir)) cart:set_yaw(minetest.dir_to_yaw(cart_dir))
if not minetest.settings:get_bool("creative_mode") then if not minetest.settings:get_bool("creative_mode") then
itemstack:take_item() itemstack:take_item()

View File

@ -137,15 +137,15 @@ local set_velocity = function(self, v)
-- do not move if mob has been ordered to stay -- do not move if mob has been ordered to stay
if self.order == "stand" then if self.order == "stand" then
self.object:setvelocity({x = 0, y = 0, z = 0}) self.object:set_velocity({x = 0, y = 0, z = 0})
return return
end end
local yaw = (self.object:get_yaw() or 0) + self.rotate local yaw = (self.object:get_yaw() or 0) + self.rotate
self.object:setvelocity({ self.object:set_velocity({
x = sin(yaw) * -v, x = sin(yaw) * -v,
y = self.object:getvelocity().y, y = self.object:get_velocity().y,
z = cos(yaw) * v z = cos(yaw) * v
}) })
end end
@ -154,7 +154,7 @@ end
-- calculate mob velocity -- calculate mob velocity
local get_velocity = function(self) local get_velocity = function(self)
local v = self.object:getvelocity() local v = self.object:get_velocity()
return (v.x * v.x + v.z * v.z) ^ 0.5 return (v.x * v.x + v.z * v.z) ^ 0.5
end end
@ -403,7 +403,7 @@ local item_drop = function(self, cooked)
if obj and obj:get_luaentity() then if obj and obj:get_luaentity() then
obj:setvelocity({ obj:set_velocity({
x = random(-10, 10) / 9, x = random(-10, 10) / 9,
y = 6, y = 6,
z = random(-10, 10) / 9, z = random(-10, 10) / 9,
@ -642,7 +642,7 @@ local do_env_damage = function(self)
-- don't fall when on ignore, just stand still -- don't fall when on ignore, just stand still
if self.standing_in == "ignore" then if self.standing_in == "ignore" then
self.object:setvelocity({x = 0, y = 0, z = 0}) self.object:set_velocity({x = 0, y = 0, z = 0})
end end
local nodef = minetest.registered_nodes[self.standing_in] local nodef = minetest.registered_nodes[self.standing_in]
@ -738,7 +738,7 @@ local do_jump = function(self)
-- something stopping us while moving? -- something stopping us while moving?
if self.state ~= "stand" if self.state ~= "stand"
and get_velocity(self) > 0.5 and get_velocity(self) > 0.5
and self.object:getvelocity().y ~= 0 then and self.object:get_velocity().y ~= 0 then
return false return false
end end
@ -776,13 +776,13 @@ local do_jump = function(self)
if not nod.name:find("fence") if not nod.name:find("fence")
and not nod.name:find("gate") then and not nod.name:find("gate") then
local v = self.object:getvelocity() local v = self.object:get_velocity()
v.y = self.jump_height v.y = self.jump_height
set_animation(self, "jump") -- only when defined set_animation(self, "jump") -- only when defined
self.object:setvelocity(v) self.object:set_velocity(v)
-- when in air move forward -- when in air move forward
minetest.after(0.3, function(self, v) minetest.after(0.3, function(self, v)
@ -912,7 +912,7 @@ local breed = function(self)
self.on_grown(self) self.on_grown(self)
else else
-- jump when fully grown so as not to fall into ground -- jump when fully grown so as not to fall into ground
self.object:setvelocity({ self.object:set_velocity({
x = 0, x = 0,
y = self.jump_height, y = self.jump_height,
z = 0 z = 0
@ -1041,7 +1041,7 @@ local replace = function(self, pos)
or not self.replace_rate or not self.replace_rate
or not self.replace_what or not self.replace_what
or self.child == true or self.child == true
or self.object:getvelocity().y ~= 0 or self.object:get_velocity().y ~= 0
or random(1, self.replace_rate) > 1 then or random(1, self.replace_rate) > 1 then
return return
end end
@ -1267,7 +1267,7 @@ local smart_mobs = function(self, s, p, dist, dtime)
end end
s.y = s.y - sheight s.y = s.y - sheight
self.object:setpos({x = s.x, y = s.y + 2, z = s.z}) self.object:set_pos({x = s.x, y = s.y + 2, z = s.z})
else -- dig 2 blocks to make door toward player direction else -- dig 2 blocks to make door toward player direction
@ -1670,7 +1670,7 @@ local follow_flop = function(self)
if not flight_check(self, s) then if not flight_check(self, s) then
self.state = "flop" self.state = "flop"
self.object:setvelocity({x = 0, y = -5, z = 0}) self.object:set_velocity({x = 0, y = -5, z = 0})
set_animation(self, "stand") set_animation(self, "stand")
@ -1944,7 +1944,7 @@ local do_states = function(self, dtime)
self.timer = 0 self.timer = 0
self.blinktimer = 0 self.blinktimer = 0
self.blinkstatus = false self.blinkstatus = false
self.object:settexturemod("") self.object:set_texture_mod("")
end end
-- walk right up to player unless the timer is active -- walk right up to player unless the timer is active
@ -1970,9 +1970,9 @@ local do_states = function(self, dtime)
self.blinktimer = 0 self.blinktimer = 0
if self.blinkstatus then if self.blinkstatus then
self.object:settexturemod("") self.object:set_texture_mod("")
else else
self.object:settexturemod("^[brighten") self.object:set_texture_mod("^[brighten")
end end
self.blinkstatus = not self.blinkstatus self.blinkstatus = not self.blinkstatus
@ -2026,13 +2026,13 @@ local do_states = function(self, dtime)
local me_y = floor(p1.y) local me_y = floor(p1.y)
local p2 = p local p2 = p
local p_y = floor(p2.y + 1) local p_y = floor(p2.y + 1)
local v = self.object:getvelocity() local v = self.object:get_velocity()
if flight_check(self, s) then if flight_check(self, s) then
if me_y < p_y then if me_y < p_y then
self.object:setvelocity({ self.object:set_velocity({
x = v.x, x = v.x,
y = 1 * self.walk_velocity, y = 1 * self.walk_velocity,
z = v.z z = v.z
@ -2040,7 +2040,7 @@ local do_states = function(self, dtime)
elseif me_y > p_y then elseif me_y > p_y then
self.object:setvelocity({ self.object:set_velocity({
x = v.x, x = v.x,
y = -1 * self.walk_velocity, y = -1 * self.walk_velocity,
z = v.z z = v.z
@ -2049,7 +2049,7 @@ local do_states = function(self, dtime)
else else
if me_y < p_y then if me_y < p_y then
self.object:setvelocity({ self.object:set_velocity({
x = v.x, x = v.x,
y = 0.01, y = 0.01,
z = v.z z = v.z
@ -2057,7 +2057,7 @@ local do_states = function(self, dtime)
elseif me_y > p_y then elseif me_y > p_y then
self.object:setvelocity({ self.object:set_velocity({
x = v.x, x = v.x,
y = -0.01, y = -0.01,
z = v.z z = v.z
@ -2241,7 +2241,7 @@ local do_states = function(self, dtime)
vec.y = vec.y * (v / amount) vec.y = vec.y * (v / amount)
vec.z = vec.z * (v / amount) vec.z = vec.z * (v / amount)
obj:setvelocity(vec) obj:set_velocity(vec)
end end
end end
end end
@ -2257,12 +2257,12 @@ local falling = function(self, pos)
end end
-- floating in water (or falling) -- floating in water (or falling)
local v = self.object:getvelocity() local v = self.object:get_velocity()
if v.y > 0 then if v.y > 0 then
-- apply gravity when moving up -- apply gravity when moving up
self.object:setacceleration({ self.object:set_acceleration({
x = 0, x = 0,
y = -10, y = -10,
z = 0 z = 0
@ -2271,14 +2271,14 @@ local falling = function(self, pos)
elseif v.y <= 0 and v.y > self.fall_speed then elseif v.y <= 0 and v.y > self.fall_speed then
-- fall downwards at set speed -- fall downwards at set speed
self.object:setacceleration({ self.object:set_acceleration({
x = 0, x = 0,
y = self.fall_speed, y = self.fall_speed,
z = 0 z = 0
}) })
else else
-- stop accelerating once max fall speed hit -- stop accelerating once max fall speed hit
self.object:setacceleration({x = 0, y = 0, z = 0}) self.object:set_acceleration({x = 0, y = 0, z = 0})
end end
-- in water then float up -- in water then float up
@ -2286,7 +2286,7 @@ local falling = function(self, pos)
if self.floats == 1 then if self.floats == 1 then
self.object:setacceleration({ self.object:set_acceleration({
x = 0, x = 0,
y = -self.fall_speed / (max(1, v.y) ^ 2), y = -self.fall_speed / (max(1, v.y) ^ 2),
z = 0 z = 0
@ -2296,7 +2296,7 @@ local falling = function(self, pos)
-- fall damage onto solid ground -- fall damage onto solid ground
if self.fall_damage == 1 if self.fall_damage == 1
and self.object:getvelocity().y == 0 then and self.object:get_velocity().y == 0 then
local d = (self.old_y or 0) - self.object:get_pos().y local d = (self.old_y or 0) - self.object:get_pos().y
@ -2475,7 +2475,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
if self.knock_back if self.knock_back
and tflp >= punch_interval then and tflp >= punch_interval then
local v = self.object:getvelocity() local v = self.object:get_velocity()
local r = 1.4 - min(punch_interval, 1.4) local r = 1.4 - min(punch_interval, 1.4)
local kb = r * 2.0 local kb = r * 2.0
local up = 2 local up = 2
@ -2496,7 +2496,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
kb = kb * 1.5 kb = kb * 1.5
end end
self.object:setvelocity({ self.object:set_velocity({
x = dir.x * kb, x = dir.x * kb,
y = up, y = up,
z = dir.z * kb z = dir.z * kb

View File

@ -190,7 +190,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
end end
local acce_y = 0 local acce_y = 0
local velo = entity.object:getvelocity() local velo = entity.object:get_velocity()
entity.v = get_v(velo) * get_sign(entity.v) entity.v = get_v(velo) * get_sign(entity.v)
@ -215,7 +215,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
end end
-- fix mob rotation -- fix mob rotation
entity.object:setyaw(entity.driver:get_look_horizontal() - entity.rotate) entity.object:set_yaw(entity.driver:get_look_horizontal() - entity.rotate)
if can_fly then if can_fly then
@ -275,7 +275,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
if s ~= get_sign(entity.v) then if s ~= get_sign(entity.v) then
entity.object:setvelocity({x = 0, y = 0, z = 0}) entity.object:set_velocity({x = 0, y = 0, z = 0})
entity.v = 0 entity.v = 0
return return
end end
@ -348,7 +348,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
if math.abs(velo.y) < 1 then if math.abs(velo.y) < 1 then
local pos = entity.object:get_pos() local pos = entity.object:get_pos()
pos.y = math.floor(pos.y) + 0.5 pos.y = math.floor(pos.y) + 0.5
entity.object:setpos(pos) entity.object:set_pos(pos)
velo.y = 0 velo.y = 0
end end
end end
@ -360,8 +360,8 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
new_velo = get_velocity(v, entity.object:get_yaw() - rot_view, velo.y) new_velo = get_velocity(v, entity.object:get_yaw() - rot_view, velo.y)
new_acce.y = new_acce.y + acce_y new_acce.y = new_acce.y + acce_y
entity.object:setvelocity(new_velo) entity.object:set_velocity(new_velo)
entity.object:setacceleration(new_acce) entity.object:set_acceleration(new_acce)
-- CRASH! -- CRASH!
if enable_crash then if enable_crash then
@ -387,7 +387,7 @@ end
function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim) function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
local ctrl = entity.driver:get_player_control() local ctrl = entity.driver:get_player_control()
local velo = entity.object:getvelocity() local velo = entity.object:get_velocity()
local dir = entity.driver:get_look_dir() local dir = entity.driver:get_look_dir()
local yaw = entity.driver:get_look_horizontal() + 1.57 -- offset fix between old and new commands local yaw = entity.driver:get_look_horizontal() + 1.57 -- offset fix between old and new commands
local rot_steer, rot_view = math.pi / 2, 0 local rot_steer, rot_view = math.pi / 2, 0
@ -397,24 +397,24 @@ function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
end end
if ctrl.up then if ctrl.up then
entity.object:setvelocity({ entity.object:set_velocity({
x = dir.x * speed, x = dir.x * speed,
y = dir.y * speed + 2, y = dir.y * speed + 2,
z = dir.z * speed z = dir.z * speed
}) })
elseif ctrl.down then elseif ctrl.down then
entity.object:setvelocity({ entity.object:set_velocity({
x = -dir.x * speed, x = -dir.x * speed,
y = dir.y * speed + 2, y = dir.y * speed + 2,
z = -dir.z * speed z = -dir.z * speed
}) })
elseif not ctrl.down or ctrl.up or ctrl.jump then elseif not ctrl.down or ctrl.up or ctrl.jump then
entity.object:setvelocity({x = 0, y = -2, z = 0}) entity.object:set_velocity({x = 0, y = -2, z = 0})
end end
entity.object:setyaw(yaw + math.pi + math.pi / 2 - entity.rotate) entity.object:set_yaw(yaw + math.pi + math.pi / 2 - entity.rotate)
-- firing arrows -- firing arrows
if ctrl.LMB and ctrl.sneak and shoots then if ctrl.LMB and ctrl.sneak and shoots then
@ -431,8 +431,8 @@ function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
ent.owner_id = tostring(entity.object) -- so arrows dont hurt entity you are riding ent.owner_id = tostring(entity.object) -- so arrows dont hurt entity you are riding
local vec = {x = dir.x * 6, y = dir.y * 6, z = dir.z * 6} local vec = {x = dir.x * 6, y = dir.y * 6, z = dir.z * 6}
local yaw = entity.driver:get_look_horizontal() local yaw = entity.driver:get_look_horizontal()
obj:setyaw(yaw + math.pi / 2) obj:set_yaw(yaw + math.pi / 2)
obj:setvelocity(vec) obj:set_velocity(vec)
else else
obj:remove() obj:remove()
end end

View File

@ -116,9 +116,9 @@ local throwing_shoot_arrow = function(itemstack, player)
local playerpos = player:get_pos() local playerpos = player:get_pos()
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow[2]) --mc local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow[2]) --mc
local dir = player:get_look_dir() local dir = player:get_look_dir()
obj:setvelocity({x=dir.x*22, y=dir.y*22, z=dir.z*22}) obj:set_velocity({x=dir.x*22, y=dir.y*22, z=dir.z*22})
obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3}) obj:set_acceleration({x=dir.x*-3, y=-10, z=dir.z*-3})
obj:setyaw(player:get_look_yaw()+math.pi) obj:set_yaw(player:get_look_yaw()+math.pi)
minetest.sound_play("throwing_sound", {pos=playerpos}) minetest.sound_play("throwing_sound", {pos=playerpos})
if obj:get_luaentity().player == "" then if obj:get_luaentity().player == "" then
obj:get_luaentity().player = player obj:get_luaentity().player = player
@ -267,13 +267,13 @@ if c("egg") then
ent.velocity = egg_VELOCITY -- needed for api internal timing ent.velocity = egg_VELOCITY -- needed for api internal timing
ent.switch = 1 -- needed so that egg doesn't despawn straight away ent.switch = 1 -- needed so that egg doesn't despawn straight away
obj:setvelocity({ obj:set_velocity({
x = dir.x * egg_VELOCITY, x = dir.x * egg_VELOCITY,
y = dir.y * egg_VELOCITY, y = dir.y * egg_VELOCITY,
z = dir.z * egg_VELOCITY z = dir.z * egg_VELOCITY
}) })
obj:setacceleration({ obj:set_acceleration({
x = dir.x * -3, x = dir.x * -3,
y = -egg_GRAVITY, y = -egg_GRAVITY,
z = dir.z * -3 z = dir.z * -3
@ -351,13 +351,13 @@ if c("snowball") then
ent.velocity = snowball_VELOCITY -- needed for api internal timing ent.velocity = snowball_VELOCITY -- needed for api internal timing
ent.switch = 1 -- needed so that egg doesn't despawn straight away ent.switch = 1 -- needed so that egg doesn't despawn straight away
obj:setvelocity({ obj:set_velocity({
x = dir.x * snowball_VELOCITY, x = dir.x * snowball_VELOCITY,
y = dir.y * snowball_VELOCITY, y = dir.y * snowball_VELOCITY,
z = dir.z * snowball_VELOCITY z = dir.z * snowball_VELOCITY
}) })
obj:setacceleration({ obj:set_acceleration({
x = dir.x * -3, x = dir.x * -3,
y = -snowball_GRAVITY, y = -snowball_GRAVITY,
z = dir.z * -3 z = dir.z * -3

View File

@ -53,7 +53,7 @@ mobs_mc.make_owner_teleport_function = function(dist, teleport_check_interval)
if minetest.registered_nodes[minetest.get_node(telepos).name].walkable == false and if minetest.registered_nodes[minetest.get_node(telepos).name].walkable == false and
minetest.registered_nodes[minetest.get_node(telepos_below).name].walkable == true then minetest.registered_nodes[minetest.get_node(telepos_below).name].walkable == true then
-- Correct position found! Let's teleport. -- Correct position found! Let's teleport.
self.object:setpos(telepos) self.object:set_pos(telepos)
return return
end end
end end

View File

@ -101,7 +101,7 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
if node.name == "air" then if node.name == "air" then
minetest.set_node(pos_above, {name=mobs_mc.items.fire}) minetest.set_node(pos_above, {name=mobs_mc.items.fire})
else else
local v = self.object:getvelocity() local v = self.object:get_velocity()
v = vector.normalize(v) v = vector.normalize(v)
local crashpos = vector.subtract(pos, v) local crashpos = vector.subtract(pos, v)
local crashnode = minetest.get_node(crashpos) local crashnode = minetest.get_node(crashpos)

View File

@ -100,10 +100,10 @@ mooshroom_def.on_rightclick = function(self, clicker)
minetest.add_item({x=pos.x, y=pos.y+1.4, z=pos.z}, mobs_mc.items.mushroom_red .. " 5") minetest.add_item({x=pos.x, y=pos.y+1.4, z=pos.z}, mobs_mc.items.mushroom_red .. " 5")
end end
local oldyaw = self.object:getyaw() local oldyaw = self.object:get_yaw()
self.object:remove() self.object:remove()
local cow = minetest.add_entity(pos, "mobs_mc:cow") local cow = minetest.add_entity(pos, "mobs_mc:cow")
cow:setyaw(oldyaw) cow:set_yaw(oldyaw)
if not minetest.settings:get_bool("creative_mode") then if not minetest.settings:get_bool("creative_mode") then
item:add_wear(mobs_mc.misc.shears_wear) item:add_wear(mobs_mc.misc.shears_wear)

View File

@ -314,7 +314,7 @@ mobs:register_mob("mobs_mc:enderman", {
end end
end end
if telepos then if telepos then
self.object:setpos(telepos) self.object:set_pos(telepos)
end end
end end
end, end,

View File

@ -595,7 +595,7 @@ local function return_item(itemstack, dropper, pos, inv_p)
v.x = v.x*4 v.x = v.x*4
v.y = v.y*4 + 2 v.y = v.y*4 + 2
v.z = v.z*4 v.z = v.z*4
obj:setvelocity(v) obj:set_velocity(v)
obj:get_luaentity()._insta_collect = false obj:get_luaentity()._insta_collect = false
end end
end end

View File

@ -163,7 +163,7 @@ lightning.strike = function(pos)
posadd = {x=math.cos(angle),y=0,z=math.sin(angle)} posadd = {x=math.cos(angle),y=0,z=math.sin(angle)}
posadd = vector.normalize(posadd) posadd = vector.normalize(posadd)
local mob = minetest.add_entity(vector.add(pos2, posadd), "mobs_mc:skeleton") local mob = minetest.add_entity(vector.add(pos2, posadd), "mobs_mc:skeleton")
mob:setyaw(angle-math.pi/2) mob:set_yaw(angle-math.pi/2)
angle = angle + (math.pi*2) / 3 angle = angle + (math.pi*2) / 3
end end

View File

@ -20,7 +20,7 @@ local function return_item(itemstack, dropper, pos, inv)
v.x = v.x*4 v.x = v.x*4
v.y = v.y*4 + 2 v.y = v.y*4 + 2
v.z = v.z*4 v.z = v.z*4
obj:setvelocity(v) obj:set_velocity(v)
obj:get_luaentity()._insta_collect = false obj:get_luaentity()._insta_collect = false
end end
end end

View File

@ -310,7 +310,7 @@ function mesecon.mvps_move_objects(pos, dir, nodestack)
local nn = minetest.get_node(np) local nn = minetest.get_node(np)
if not ((not minetest.registered_nodes[nn.name]) if not ((not minetest.registered_nodes[nn.name])
or minetest.registered_nodes[nn.name].walkable) then or minetest.registered_nodes[nn.name].walkable) then
obj:setpos(np) obj:set_pos(np)
end end
end end
end end

View File

@ -41,7 +41,7 @@ mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damag
end end
obj:set_velocity({x=dir.x*power, y=dir.y*power, z=dir.z*power}) obj:set_velocity({x=dir.x*power, y=dir.y*power, z=dir.z*power})
obj:set_acceleration({x=0, y=-GRAVITY, z=0}) obj:set_acceleration({x=0, y=-GRAVITY, z=0})
obj:setyaw(yaw-math.pi/2) obj:set_yaw(yaw-math.pi/2)
local le = obj:get_luaentity() local le = obj:get_luaentity()
le._shooter = shooter le._shooter = shooter
le._damage = damage le._damage = damage

View File

@ -35,10 +35,10 @@ minetest.register_entity("mcl_end:ender_eye", {
else else
-- 80% to drop as an item -- 80% to drop as an item
local pos = self.object:get_pos() local pos = self.object:get_pos()
local v = self.object:getvelocity() local v = self.object:get_velocity()
self.object:remove() self.object:remove()
local item = minetest.add_item(pos, "mcl_end:ender_eye") local item = minetest.add_item(pos, "mcl_end:ender_eye")
item:setvelocity(v) item:set_velocity(v)
return return
end end
elseif self._age >= 2 then elseif self._age >= 2 then
@ -46,8 +46,8 @@ minetest.register_entity("mcl_end:ender_eye", {
self._phase = 1 self._phase = 1
-- Stop the eye and wait for another second. -- Stop the eye and wait for another second.
-- The vertical speed changes are just eye candy. -- The vertical speed changes are just eye candy.
self.object:setacceleration({x=0, y=-3, z=0}) self.object:set_acceleration({x=0, y=-3, z=0})
self.object:setvelocity({x=0, y=self.object:getvelocity().y*0.2, z=0}) self.object:set_velocity({x=0, y=self.object:get_velocity().y*0.2, z=0})
end end
else else
-- Fly normally and generate particles -- Fly normally and generate particles
@ -126,7 +126,7 @@ minetest.register_craftitem("mcl_end:ender_eye", {
local velocity = 4 local velocity = 4
-- Stronghold is close: Fly directly to stronghold and take Y into account. -- Stronghold is close: Fly directly to stronghold and take Y into account.
dir = vector.normalize(vector.direction(origin, closest_stronghold.pos)) dir = vector.normalize(vector.direction(origin, closest_stronghold.pos))
obj:setvelocity({x=dir.x*velocity, y=dir.y*velocity, z=dir.z*velocity}) obj:set_velocity({x=dir.x*velocity, y=dir.y*velocity, z=dir.z*velocity})
else else
local velocity = 12 local velocity = 12
-- Don't care about Y if stronghold is still far away. -- Don't care about Y if stronghold is still far away.
@ -134,8 +134,8 @@ minetest.register_craftitem("mcl_end:ender_eye", {
local o = {x=origin.x, y=0, z=origin.z} local o = {x=origin.x, y=0, z=origin.z}
local s = {x=closest_stronghold.pos.x, y=0, z=closest_stronghold.pos.z} local s = {x=closest_stronghold.pos.x, y=0, z=closest_stronghold.pos.z}
dir = vector.normalize(vector.direction(o, s)) dir = vector.normalize(vector.direction(o, s))
obj:setacceleration({x=dir.x*-3, y=4, z=dir.z*-3}) obj:set_acceleration({x=dir.x*-3, y=4, z=dir.z*-3})
obj:setvelocity({x=dir.x*velocity, y=3, z=dir.z*velocity}) obj:set_velocity({x=dir.x*velocity, y=3, z=dir.z*velocity})
end end
@ -150,4 +150,4 @@ minetest.register_craft({
type = "shapeless", type = "shapeless",
output = "mcl_end:ender_eye", output = "mcl_end:ender_eye",
recipe = {"mcl_mobitems:blaze_powder", "mcl_throwing:ender_pearl"}, recipe = {"mcl_mobitems:blaze_powder", "mcl_throwing:ender_pearl"},
}) })

View File

@ -46,7 +46,7 @@ minetest.register_craftitem("mcl_fire:fire_charge", {
local ent = fireball:get_luaentity() local ent = fireball:get_luaentity()
ent._shot_from_dispenser = true ent._shot_from_dispenser = true
local v = ent.velocity or 1 local v = ent.velocity or 1
fireball:setvelocity(vector.multiply(dropdir, v)) fireball:set_velocity(vector.multiply(dropdir, v))
ent.switch = 1 ent.switch = 1
stack:take_item() stack:take_item()
end, end,

View File

@ -77,7 +77,7 @@ local update_item_entity = function(pos, node)
lua:_update_texture() lua:_update_texture()
if node.name == "mcl_itemframes:item_frame" then if node.name == "mcl_itemframes:item_frame" then
local yaw = math.pi*2 - node.param2 * math.pi/2 local yaw = math.pi*2 - node.param2 * math.pi/2
e:setyaw(yaw) e:set_yaw(yaw)
end end
end end
end end

View File

@ -338,8 +338,8 @@ doll_def.on_activate = function(self, staticdata, dtime_s)
mob = default_mob mob = default_mob
end end
set_doll_properties(self.object, mob) set_doll_properties(self.object, mob)
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

@ -197,7 +197,7 @@ local function find_nether_target_y(target_x, target_z)
local air = 4 local air = 4
for y = start_y, math.max(mcl_vars.mg_lava_nether_max + 1), -1 do for y = start_y, math.max(mcl_vars.mg_lava_nether_max + 1), -1 do
local nval_cave = nobj_cave:get3d({x = target_x, y = y, z = target_z}) local nval_cave = nobj_cave:get_3d({x = target_x, y = y, z = target_z})
if nval_cave > TCAVE then -- Cavern if nval_cave > TCAVE then -- Cavern
air = air + 1 air = air + 1

View File

@ -223,7 +223,7 @@ local update_sign = function(pos, fields, sender)
text_entity:get_luaentity()._signnodename = nn text_entity:get_luaentity()._signnodename = nn
text_entity:set_properties({textures={generate_texture(create_lines(text), nn)}}) text_entity:set_properties({textures={generate_texture(create_lines(text), nn)}})
text_entity:setyaw(sign_info.yaw) text_entity:set_yaw(sign_info.yaw)
end end
local show_formspec = function(player, pos) local show_formspec = function(player, pos)
@ -359,7 +359,7 @@ minetest.register_node("mcl_signs:wall_sign", {
x = place_pos.x + sign_info.delta.x, x = place_pos.x + sign_info.delta.x,
y = place_pos.y + sign_info.delta.y, y = place_pos.y + sign_info.delta.y,
z = place_pos.z + sign_info.delta.z}, "mcl_signs:text") z = place_pos.z + sign_info.delta.z}, "mcl_signs:text")
text_entity:setyaw(sign_info.yaw) text_entity:set_yaw(sign_info.yaw)
text_entity:get_luaentity()._signnodename = nodeitem:get_name() text_entity:get_luaentity()._signnodename = nodeitem:get_name()
minetest.sound_play({name="default_place_node_hard", gain=1.0}, {pos = place_pos}) minetest.sound_play({name="default_place_node_hard", gain=1.0}, {pos = place_pos})

View File

@ -28,8 +28,8 @@ mcl_throwing.throw = function(throw_item, pos, dir, velocity)
local itemstring = ItemStack(throw_item):get_name() local itemstring = ItemStack(throw_item):get_name()
local obj = minetest.add_entity(pos, entity_mapping[itemstring]) local obj = minetest.add_entity(pos, entity_mapping[itemstring])
obj:setvelocity({x=dir.x*velocity, y=dir.y*velocity, z=dir.z*velocity}) obj:set_velocity({x=dir.x*velocity, y=dir.y*velocity, z=dir.z*velocity})
obj:setacceleration({x=dir.x*-3, y=-GRAVITY, z=dir.z*-3}) obj:set_acceleration({x=dir.x*-3, y=-GRAVITY, z=dir.z*-3})
return obj return obj
end end
@ -208,7 +208,7 @@ local pearl_on_step = function(self, dtime)
-- First determine good teleport position -- First determine good teleport position
local dir = {x=0, y=0, z=0} local dir = {x=0, y=0, z=0}
local v = self.object:getvelocity() local v = self.object:get_velocity()
if walkable then if walkable then
local vc = table.copy(v) -- vector for calculating local vc = table.copy(v) -- vector for calculating
-- Node is walkable, we have to find a place somewhere outside of that node -- Node is walkable, we have to find a place somewhere outside of that node
@ -261,7 +261,7 @@ local pearl_on_step = function(self, dtime)
local oldpos = player:get_pos() local oldpos = player:get_pos()
-- Teleport and hurt player -- Teleport and hurt player
player:setpos(telepos) player:set_pos(telepos)
player:set_hp(player:get_hp() - 5) player:set_hp(player:get_hp() - 5)
-- 5% chance to spawn endermite at the player's origin -- 5% chance to spawn endermite at the player's origin

View File

@ -10,7 +10,7 @@ end
local function activate_if_tnt(nname, np, tnt_np, tntr) local function activate_if_tnt(nname, np, tnt_np, tntr)
if nname == "mcl_tnt:tnt" then if nname == "mcl_tnt:tnt" then
local e = spawn_tnt(np, nname) local e = spawn_tnt(np, nname)
e:setvelocity({x=(np.x - tnt_np.x)*5+(tntr / 4), y=(np.y - tnt_np.y)*5+(tntr / 3), z=(np.z - tnt_np.z)*5+(tntr / 4)}) e:set_velocity({x=(np.x - tnt_np.x)*5+(tntr / 4), y=(np.y - tnt_np.y)*5+(tntr / 3), z=(np.z - tnt_np.z)*5+(tntr / 4)})
end end
end end
@ -18,13 +18,13 @@ local function do_tnt_physics(tnt_np,tntr)
local objs = minetest.get_objects_inside_radius(tnt_np, tntr) local objs = minetest.get_objects_inside_radius(tnt_np, tntr)
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
local ent = obj:get_luaentity() local ent = obj:get_luaentity()
local v = obj:getvelocity() local v = obj:get_velocity()
local p = obj:get_pos() local p = obj:get_pos()
if ent and ent.name == "mcl_tnt:tnt" then if ent and ent.name == "mcl_tnt:tnt" then
obj:setvelocity({x=(p.x - tnt_np.x) + (tntr / 2) + v.x, y=(p.y - tnt_np.y) + tntr + v.y, z=(p.z - tnt_np.z) + (tntr / 2) + v.z}) obj:set_velocity({x=(p.x - tnt_np.x) + (tntr / 2) + v.x, y=(p.y - tnt_np.y) + tntr + v.y, z=(p.z - tnt_np.z) + (tntr / 2) + v.z})
else else
if v ~= nil then if v ~= nil then
obj:setvelocity({x=(p.x - tnt_np.x) + (tntr / 4) + v.x, y=(p.y - tnt_np.y) + (tntr / 2) + v.y, z=(p.z - tnt_np.z) + (tntr / 4) + v.z}) obj:set_velocity({x=(p.x - tnt_np.x) + (tntr / 4) + v.x, y=(p.y - tnt_np.y) + (tntr / 2) + v.y, z=(p.z - tnt_np.z) + (tntr / 4) + v.z})
else else
local dist = math.max(1, vector.distance(tnt_np, p)) local dist = math.max(1, vector.distance(tnt_np, p))
local damage = (4 / dist) * tntr local damage = (4 / dist) * tntr
@ -100,9 +100,9 @@ function TNT:on_activate(staticdata)
local phi = math.random(0, 65535) / 65535 * 2*math.pi local phi = math.random(0, 65535) / 65535 * 2*math.pi
local hdir_x = math.cos(phi) * 0.02 local hdir_x = math.cos(phi) * 0.02
local hdir_z = math.sin(phi) * 0.02 local hdir_z = math.sin(phi) * 0.02
self.object:setvelocity({x=hdir_x, y=2, z=hdir_z}) self.object:set_velocity({x=hdir_x, y=2, z=hdir_z})
self.object:setacceleration({x=0, y=-10, z=0}) self.object:set_acceleration({x=0, y=-10, z=0})
self.object:settexturemod("^mcl_tnt_blink.png") self.object:set_texture_mod("^mcl_tnt_blink.png")
end end
local function add_effects(pos, radius, drops) local function add_effects(pos, radius, drops)
@ -170,9 +170,9 @@ function TNT:on_step(dtime)
if self.blinktimer > 0.25 then if self.blinktimer > 0.25 then
self.blinktimer = self.blinktimer - 0.25 self.blinktimer = self.blinktimer - 0.25
if self.blinkstatus then if self.blinkstatus then
self.object:settexturemod("") self.object:set_texture_mod("")
else else
self.object:settexturemod("^mcl_tnt_blink.png") self.object:set_texture_mod("^mcl_tnt_blink.png")
end end
self.blinkstatus = not self.blinkstatus self.blinkstatus = not self.blinkstatus
end end

View File

@ -433,7 +433,7 @@ if ARMOR_DROP == true or ARMOR_DESTROY == true then
armor.drop_armor = function(pos, stack) armor.drop_armor = function(pos, stack)
local obj = minetest.add_item(pos, stack) local obj = minetest.add_item(pos, stack)
if obj then if obj then
obj:setvelocity({x=math.random(-1, 1), y=5, z=math.random(-1, 1)}) obj:set_velocity({x=math.random(-1, 1), y=5, z=math.random(-1, 1)})
end end
end end
minetest.register_on_dieplayer(function(player) minetest.register_on_dieplayer(function(player)

View File

@ -63,7 +63,7 @@ local function update_entity(pos)
yaw = math.pi / 2 yaw = math.pi / 2
end end
end end
object:setyaw(yaw) object:set_yaw(yaw)
object:set_properties({textures={texture}}) object:set_properties({textures={texture}})
end end
end end

View File

@ -1022,7 +1022,7 @@ local function generate_clay(minp, maxp, seed, voxelmanip_data, voxelmanip_area,
local surfacenode = voxelmanip_data[surface_pos] local surfacenode = voxelmanip_data[surface_pos]
local genrnd = math.random(1, 20) local genrnd = math.random(1, 20)
if genrnd == 1 and perlin_clay:get3d({x=cx,y=y,z=cz}) > 0 and waternode == c_water and if genrnd == 1 and perlin_clay:get_3d({x=cx,y=y,z=cz}) > 0 and waternode == c_water and
(surfacenode == c_dirt or minetest.get_item_group(minetest.get_name_from_content_id(surfacenode), "sand") == 1) then (surfacenode == c_dirt or minetest.get_item_group(minetest.get_name_from_content_id(surfacenode), "sand") == 1) then
local diamondsize = math.random(1, 3) local diamondsize = math.random(1, 3)
for x1 = -diamondsize, diamondsize do for x1 = -diamondsize, diamondsize do
@ -1062,7 +1062,7 @@ local function generate_structures(minp, maxp, seed, biomemap)
local x1 = minp.x + math.floor((divx+1)*divlen) local x1 = minp.x + math.floor((divx+1)*divlen)
local z1 = minp.z + math.floor((divz+1)*divlen) local z1 = minp.z + math.floor((divz+1)*divlen)
-- Determine amount from perlin noise -- Determine amount from perlin noise
local amount = math.floor(perlin_structures:get2d({x=x0, y=z0}) * 9) local amount = math.floor(perlin_structures:get_2d({x=x0, y=z0}) * 9)
-- Find random positions based on this random -- Find random positions based on this random
local pr = PseudoRandom(seed+1) local pr = PseudoRandom(seed+1)
for i=0, amount do for i=0, amount do
@ -1445,12 +1445,12 @@ local function generate_tree_decorations(minp, maxp, seed, data, param2_data, ar
local pos = vector.add(pos, dirs[d]) local pos = vector.add(pos, dirs[d])
local p_pos = area:index(pos.x, pos.y, pos.z) local p_pos = area:index(pos.x, pos.y, pos.z)
local vine_threshold = math.max(0.33333, perlin_vines_density:get2d(pos)) local vine_threshold = math.max(0.33333, perlin_vines_density:get_2d(pos))
if dense_vegetation then if dense_vegetation then
vine_threshold = vine_threshold * (2/3) vine_threshold = vine_threshold * (2/3)
end end
if perlin_vines:get2d(pos) > -1.0 and perlin_vines_fine:get3d(pos) > vine_threshold and data[p_pos] == c_air then if perlin_vines:get_2d(pos) > -1.0 and perlin_vines_fine:get_3d(pos) > vine_threshold and data[p_pos] == c_air then
local rdir = {} local rdir = {}
rdir.x = -dirs[d].x rdir.x = -dirs[d].x
@ -1462,13 +1462,13 @@ local function generate_tree_decorations(minp, maxp, seed, data, param2_data, ar
local grow_upwards = false local grow_upwards = false
-- Only possible on the wood, not on the leaves -- Only possible on the wood, not on the leaves
if i == 1 then if i == 1 then
grow_upwards = perlin_vines_upwards:get3d(pos) > 0.8 grow_upwards = perlin_vines_upwards:get_3d(pos) > 0.8
end end
if grow_upwards then if grow_upwards then
-- Grow vines up 1-4 nodes, even through jungleleaves. -- Grow vines up 1-4 nodes, even through jungleleaves.
-- This may give climbing access all the way to the top of the tree :-) -- This may give climbing access all the way to the top of the tree :-)
-- But this will be fairly rare. -- But this will be fairly rare.
local length = math.ceil(math.abs(perlin_vines_length:get3d(pos)) * 4) local length = math.ceil(math.abs(perlin_vines_length:get_3d(pos)) * 4)
for l=0, length-1 do for l=0, length-1 do
local t_pos = area:index(treepos.x, treepos.y, treepos.z) local t_pos = area:index(treepos.x, treepos.y, treepos.z)
@ -1486,7 +1486,7 @@ local function generate_tree_decorations(minp, maxp, seed, data, param2_data, ar
end end
else else
-- Grow vines down, length between 1 and maxvinelength -- Grow vines down, length between 1 and maxvinelength
local length = math.ceil(math.abs(perlin_vines_length:get3d(pos)) * maxvinelength) local length = math.ceil(math.abs(perlin_vines_length:get_3d(pos)) * maxvinelength)
for l=0, length-1 do for l=0, length-1 do
if data[p_pos] == c_air then if data[p_pos] == c_air then
data[p_pos] = c_vine data[p_pos] = c_vine

View File

@ -736,13 +736,13 @@ local function create_corridor_section(waypoint, axis, sign, up_or_down, up_or_d
-- Mob spawner (at center) -- Mob spawner (at center)
if place_mob_spawners and tsm_railcorridors.nodes.spawner and not no_spawner and if place_mob_spawners and tsm_railcorridors.nodes.spawner and not no_spawner and
webperlin_major:get3d(p) > 0.3 and webperlin_minor:get3d(p) > 0.5 then webperlin_major:get_3d(p) > 0.3 and webperlin_minor:get_3d(p) > 0.5 then
-- Place spawner (if activated in gameconfig), -- Place spawner (if activated in gameconfig),
-- enclose in cobwebs and setup the spawner node. -- enclose in cobwebs and setup the spawner node.
local spawner_placed = SetNodeIfCanBuild(p, {name=tsm_railcorridors.nodes.spawner}) local spawner_placed = SetNodeIfCanBuild(p, {name=tsm_railcorridors.nodes.spawner})
if spawner_placed then if spawner_placed then
local size = 1 local size = 1
if webperlin_major:get3d(p) > 0.5 then if webperlin_major:get_3d(p) > 0.5 then
size = 2 size = 2
end end
if place_cobwebs then if place_cobwebs then
@ -765,7 +765,7 @@ local function create_corridor_section(waypoint, axis, sign, up_or_down, up_or_d
if pr:next(1,5) == 1 then if pr:next(1,5) == 1 then
local h = pr:next(0, 2) -- 3 possible cobweb heights local h = pr:next(0, 2) -- 3 possible cobweb heights
local cpos = {x=basepos.x+vek.x, y=basepos.y+h, z=basepos.z+vek.z} local cpos = {x=basepos.x+vek.x, y=basepos.y+h, z=basepos.z+vek.z}
if webperlin_major:get3d(cpos) > 0.05 and webperlin_minor:get3d(cpos) > 0.1 then if webperlin_major:get_3d(cpos) > 0.05 and webperlin_minor:get_3d(cpos) > 0.1 then
if h == 0 then if h == 0 then
-- No check neccessary at height offset 0 since the cobweb is on the floor -- No check neccessary at height offset 0 since the cobweb is on the floor
return TryPlaceCobweb(cpos) return TryPlaceCobweb(cpos)