0
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},
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,
on_step = function(self, dtime)
@ -28,11 +28,11 @@ minetest.register_entity("drippingwater:drop_water", {
local ownpos = self.object:get_pos()
if k==1 then
self.object:setacceleration({x=0, y=-5, z=0})
self.object:set_acceleration({x=0, y=-5, z=0})
end
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
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},
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,
on_step = function(self, dtime)
@ -66,11 +66,11 @@ minetest.register_entity("drippingwater:drop_lava", {
local ownpos = self.object:get_pos()
if k==1 then
self.object:setacceleration({x=0, y=-5, z=0})
self.object:set_acceleration({x=0, y=-5, z=0})
end
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

View File

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

View File

@ -141,9 +141,9 @@ minetest.register_entity(":__builtin:falling_node", {
on_step = function(self, dtime)
-- 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
self.object:setacceleration({x = 0, y = -10, z = 0})
self.object:set_acceleration({x = 0, y = -10, z = 0})
end
-- Turn to actual node when colliding with ground, or continue to move
local pos = self.object:get_pos()
@ -222,7 +222,7 @@ minetest.register_entity(":__builtin:falling_node", {
minetest.check_for_falling(np)
return
end
local vel = self.object:getvelocity()
local vel = self.object:get_velocity()
-- Fix position if entity does not move
if vector.equals(vel, {x = 0, y = 0, z = 0}) then
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 vec = vector.subtract(checkpos, opos)
vec = vector.add(opos, vector.divide(vec, 2))
object:moveto(vec)
object:move_to(vec)
--fix eternally falling items
minetest.after(0, function(object)
local lua = object:get_luaentity()
if lua then
object:setacceleration({x=0, y=0, z=0})
object:set_acceleration({x=0, y=0, z=0})
end
end, object)
@ -264,7 +264,7 @@ function minetest.handle_node_drops(pos, drops, digger)
if math.random(1,2) == 1 then
z = -z
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
@ -285,7 +285,7 @@ function minetest.item_drop(itemstack, dropper, pos)
v.x = v.x*4
v.y = v.y*4 + 2
v.z = v.z*4
obj:setvelocity(v)
obj:set_velocity(v)
-- Force collection delay
obj:get_luaentity()._insta_collect = false
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
return
end
local vel = self.object:getvelocity()
local vel = self.object:get_velocity()
if vel and vel.x == 0 and vel.z == 0 then
local x = math.random(1, 5)
if math.random(1,2) == 1 then
@ -384,7 +384,7 @@ core.register_entity(":__builtin:item", {
z = -z
end
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, self)
end
@ -444,8 +444,8 @@ core.register_entity(":__builtin:item", {
self._forcetimer = 0
self.object:set_armor_groups({immortal = 1})
self.object:setvelocity({x = 0, y = 2, z = 0})
self.object:setacceleration({x = 0, y = -get_gravity(), z = 0})
self.object:set_velocity({x = 0, y = 2, z = 0})
self.object:set_acceleration({x = 0, y = -get_gravity(), z = 0})
self:set_item(self.itemstring)
end,
@ -589,8 +589,8 @@ core.register_entity(":__builtin:item", {
-- Set new item moving speed accordingly
local newv = vector.multiply(shootdir, 3)
self.object:setacceleration({x = 0, y = 0, z = 0})
self.object:setvelocity(newv)
self.object:set_acceleration({x = 0, y = 0, z = 0})
self.object:set_velocity(newv)
disable_physics(self.object, self, false, false)
@ -643,8 +643,8 @@ core.register_entity(":__builtin:item", {
local f = 1.39
-- Set new item moving speed into the direciton of the liquid
local newv = vector.multiply(vec, f)
self.object:setacceleration({x = 0, y = 0, z = 0})
self.object:setvelocity({x = newv.x, y = -0.22, z = newv.z})
self.object:set_acceleration({x = 0, y = 0, z = 0})
self.object:set_velocity({x = newv.x, y = -0.22, z = newv.z})
self.physical_state = 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
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 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 self._driver then
if self._old_pos then
self.object:setpos(self._old_pos)
self.object:set_pos(self._old_pos)
end
mcl_player.player_attached[self._driver] = nil
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
end
local vel = self.object:getvelocity()
local vel = self.object:get_velocity()
if puncher:get_player_name() == self._driver then
if math.abs(vel.x + vel.z) > 7 then
return
@ -121,7 +121,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
end
function cart:on_step(dtime)
local vel = self.object:getvelocity()
local vel = self.object:get_velocity()
local update = {}
if self._last_float_check == nil then
self._last_float_check = 0
@ -139,7 +139,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
-- Detach driver
if self._driver then
if self._old_pos then
self.object:setpos(self._old_pos)
self.object:set_pos(self._old_pos)
end
mcl_player.player_attached[self._driver] = nil
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
vel = vector.add(vel, self._velocity)
self.object:setvelocity(vel)
self.object:set_velocity(vel)
self._old_dir.y = 0
elseif vector.equals(vel, {x=0, y=0, z=0}) then
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 = 0, y = 0, z = 0}
self._old_pos = pos
self.object:setvelocity(vector.new())
self.object:setacceleration(vector.new())
self.object:set_velocity(vector.new())
self.object:set_acceleration(vector.new())
return
end
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)
end
self.object:setacceleration(new_acc)
self.object:set_acceleration(new_acc)
self._old_pos = vector.new(pos)
self._old_dir = vector.new(dir)
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
yaw = 1
end
self.object:setyaw(yaw * math.pi)
self.object:set_yaw(yaw * math.pi)
end
if self._punched then
@ -341,9 +341,9 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick)
end
self.object:set_animation(anim, 1, 0)
self.object:setvelocity(vel)
self.object:set_velocity(vel)
if update.pos then
self.object:setpos(pos)
self.object:set_pos(pos)
end
update = nil
end
@ -387,7 +387,7 @@ mcl_minecarts.place_minecart = function(itemstack, pointed_thing)
le._railtype = railtype
end
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
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
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
end
local yaw = (self.object:get_yaw() or 0) + self.rotate
self.object:setvelocity({
self.object:set_velocity({
x = sin(yaw) * -v,
y = self.object:getvelocity().y,
y = self.object:get_velocity().y,
z = cos(yaw) * v
})
end
@ -154,7 +154,7 @@ end
-- calculate mob velocity
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
end
@ -403,7 +403,7 @@ local item_drop = function(self, cooked)
if obj and obj:get_luaentity() then
obj:setvelocity({
obj:set_velocity({
x = random(-10, 10) / 9,
y = 6,
z = random(-10, 10) / 9,
@ -642,7 +642,7 @@ local do_env_damage = function(self)
-- don't fall when on ignore, just stand still
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
local nodef = minetest.registered_nodes[self.standing_in]
@ -738,7 +738,7 @@ local do_jump = function(self)
-- something stopping us while moving?
if self.state ~= "stand"
and get_velocity(self) > 0.5
and self.object:getvelocity().y ~= 0 then
and self.object:get_velocity().y ~= 0 then
return false
end
@ -776,13 +776,13 @@ local do_jump = function(self)
if not nod.name:find("fence")
and not nod.name:find("gate") then
local v = self.object:getvelocity()
local v = self.object:get_velocity()
v.y = self.jump_height
set_animation(self, "jump") -- only when defined
self.object:setvelocity(v)
self.object:set_velocity(v)
-- when in air move forward
minetest.after(0.3, function(self, v)
@ -912,7 +912,7 @@ local breed = function(self)
self.on_grown(self)
else
-- jump when fully grown so as not to fall into ground
self.object:setvelocity({
self.object:set_velocity({
x = 0,
y = self.jump_height,
z = 0
@ -1041,7 +1041,7 @@ local replace = function(self, pos)
or not self.replace_rate
or not self.replace_what
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
return
end
@ -1267,7 +1267,7 @@ local smart_mobs = function(self, s, p, dist, dtime)
end
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
@ -1670,7 +1670,7 @@ local follow_flop = function(self)
if not flight_check(self, s) then
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")
@ -1944,7 +1944,7 @@ local do_states = function(self, dtime)
self.timer = 0
self.blinktimer = 0
self.blinkstatus = false
self.object:settexturemod("")
self.object:set_texture_mod("")
end
-- walk right up to player unless the timer is active
@ -1970,9 +1970,9 @@ local do_states = function(self, dtime)
self.blinktimer = 0
if self.blinkstatus then
self.object:settexturemod("")
self.object:set_texture_mod("")
else
self.object:settexturemod("^[brighten")
self.object:set_texture_mod("^[brighten")
end
self.blinkstatus = not self.blinkstatus
@ -2026,13 +2026,13 @@ local do_states = function(self, dtime)
local me_y = floor(p1.y)
local p2 = p
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 me_y < p_y then
self.object:setvelocity({
self.object:set_velocity({
x = v.x,
y = 1 * self.walk_velocity,
z = v.z
@ -2040,7 +2040,7 @@ local do_states = function(self, dtime)
elseif me_y > p_y then
self.object:setvelocity({
self.object:set_velocity({
x = v.x,
y = -1 * self.walk_velocity,
z = v.z
@ -2049,7 +2049,7 @@ local do_states = function(self, dtime)
else
if me_y < p_y then
self.object:setvelocity({
self.object:set_velocity({
x = v.x,
y = 0.01,
z = v.z
@ -2057,7 +2057,7 @@ local do_states = function(self, dtime)
elseif me_y > p_y then
self.object:setvelocity({
self.object:set_velocity({
x = v.x,
y = -0.01,
z = v.z
@ -2241,7 +2241,7 @@ local do_states = function(self, dtime)
vec.y = vec.y * (v / amount)
vec.z = vec.z * (v / amount)
obj:setvelocity(vec)
obj:set_velocity(vec)
end
end
end
@ -2257,12 +2257,12 @@ local falling = function(self, pos)
end
-- floating in water (or falling)
local v = self.object:getvelocity()
local v = self.object:get_velocity()
if v.y > 0 then
-- apply gravity when moving up
self.object:setacceleration({
self.object:set_acceleration({
x = 0,
y = -10,
z = 0
@ -2271,14 +2271,14 @@ local falling = function(self, pos)
elseif v.y <= 0 and v.y > self.fall_speed then
-- fall downwards at set speed
self.object:setacceleration({
self.object:set_acceleration({
x = 0,
y = self.fall_speed,
z = 0
})
else
-- 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
-- in water then float up
@ -2286,7 +2286,7 @@ local falling = function(self, pos)
if self.floats == 1 then
self.object:setacceleration({
self.object:set_acceleration({
x = 0,
y = -self.fall_speed / (max(1, v.y) ^ 2),
z = 0
@ -2296,7 +2296,7 @@ local falling = function(self, pos)
-- fall damage onto solid ground
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
@ -2475,7 +2475,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
if self.knock_back
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 kb = r * 2.0
local up = 2
@ -2496,7 +2496,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
kb = kb * 1.5
end
self.object:setvelocity({
self.object:set_velocity({
x = dir.x * kb,
y = up,
z = dir.z * kb

View File

@ -190,7 +190,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
end
local acce_y = 0
local velo = entity.object:getvelocity()
local velo = entity.object:get_velocity()
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
-- 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
@ -275,7 +275,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
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
return
end
@ -348,7 +348,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
if math.abs(velo.y) < 1 then
local pos = entity.object:get_pos()
pos.y = math.floor(pos.y) + 0.5
entity.object:setpos(pos)
entity.object:set_pos(pos)
velo.y = 0
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_acce.y = new_acce.y + acce_y
entity.object:setvelocity(new_velo)
entity.object:setacceleration(new_acce)
entity.object:set_velocity(new_velo)
entity.object:set_acceleration(new_acce)
-- CRASH!
if enable_crash then
@ -387,7 +387,7 @@ end
function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
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 yaw = entity.driver:get_look_horizontal() + 1.57 -- offset fix between old and new commands
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
if ctrl.up then
entity.object:setvelocity({
entity.object:set_velocity({
x = dir.x * speed,
y = dir.y * speed + 2,
z = dir.z * speed
})
elseif ctrl.down then
entity.object:setvelocity({
entity.object:set_velocity({
x = -dir.x * speed,
y = dir.y * speed + 2,
z = -dir.z * speed
})
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
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
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
local vec = {x = dir.x * 6, y = dir.y * 6, z = dir.z * 6}
local yaw = entity.driver:get_look_horizontal()
obj:setyaw(yaw + math.pi / 2)
obj:setvelocity(vec)
obj:set_yaw(yaw + math.pi / 2)
obj:set_velocity(vec)
else
obj:remove()
end

View File

@ -116,9 +116,9 @@ local throwing_shoot_arrow = function(itemstack, player)
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 dir = player:get_look_dir()
obj:setvelocity({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:setyaw(player:get_look_yaw()+math.pi)
obj:set_velocity({x=dir.x*22, y=dir.y*22, z=dir.z*22})
obj:set_acceleration({x=dir.x*-3, y=-10, z=dir.z*-3})
obj:set_yaw(player:get_look_yaw()+math.pi)
minetest.sound_play("throwing_sound", {pos=playerpos})
if obj:get_luaentity().player == "" then
obj:get_luaentity().player = player
@ -267,13 +267,13 @@ if c("egg") then
ent.velocity = egg_VELOCITY -- needed for api internal timing
ent.switch = 1 -- needed so that egg doesn't despawn straight away
obj:setvelocity({
obj:set_velocity({
x = dir.x * egg_VELOCITY,
y = dir.y * egg_VELOCITY,
z = dir.z * egg_VELOCITY
})
obj:setacceleration({
obj:set_acceleration({
x = dir.x * -3,
y = -egg_GRAVITY,
z = dir.z * -3
@ -351,13 +351,13 @@ if c("snowball") then
ent.velocity = snowball_VELOCITY -- needed for api internal timing
ent.switch = 1 -- needed so that egg doesn't despawn straight away
obj:setvelocity({
obj:set_velocity({
x = dir.x * snowball_VELOCITY,
y = dir.y * snowball_VELOCITY,
z = dir.z * snowball_VELOCITY
})
obj:setacceleration({
obj:set_acceleration({
x = dir.x * -3,
y = -snowball_GRAVITY,
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
minetest.registered_nodes[minetest.get_node(telepos_below).name].walkable == true then
-- Correct position found! Let's teleport.
self.object:setpos(telepos)
self.object:set_pos(telepos)
return
end
end

View File

@ -101,7 +101,7 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
if node.name == "air" then
minetest.set_node(pos_above, {name=mobs_mc.items.fire})
else
local v = self.object:getvelocity()
local v = self.object:get_velocity()
v = vector.normalize(v)
local crashpos = vector.subtract(pos, v)
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")
end
local oldyaw = self.object:getyaw()
local oldyaw = self.object:get_yaw()
self.object:remove()
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
item:add_wear(mobs_mc.misc.shears_wear)

View File

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

View File

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

View File

@ -163,7 +163,7 @@ lightning.strike = function(pos)
posadd = {x=math.cos(angle),y=0,z=math.sin(angle)}
posadd = vector.normalize(posadd)
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
end

View File

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

View File

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

View File

@ -41,7 +41,7 @@ mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damag
end
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:setyaw(yaw-math.pi/2)
obj:set_yaw(yaw-math.pi/2)
local le = obj:get_luaentity()
le._shooter = shooter
le._damage = damage

View File

@ -35,10 +35,10 @@ minetest.register_entity("mcl_end:ender_eye", {
else
-- 80% to drop as an item
local pos = self.object:get_pos()
local v = self.object:getvelocity()
local v = self.object:get_velocity()
self.object:remove()
local item = minetest.add_item(pos, "mcl_end:ender_eye")
item:setvelocity(v)
item:set_velocity(v)
return
end
elseif self._age >= 2 then
@ -46,8 +46,8 @@ minetest.register_entity("mcl_end:ender_eye", {
self._phase = 1
-- Stop the eye and wait for another second.
-- The vertical speed changes are just eye candy.
self.object:setacceleration({x=0, y=-3, z=0})
self.object:setvelocity({x=0, y=self.object:getvelocity().y*0.2, z=0})
self.object:set_acceleration({x=0, y=-3, z=0})
self.object:set_velocity({x=0, y=self.object:get_velocity().y*0.2, z=0})
end
else
-- Fly normally and generate particles
@ -126,7 +126,7 @@ minetest.register_craftitem("mcl_end:ender_eye", {
local velocity = 4
-- Stronghold is close: Fly directly to stronghold and take Y into account.
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
local velocity = 12
-- 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 s = {x=closest_stronghold.pos.x, y=0, z=closest_stronghold.pos.z}
dir = vector.normalize(vector.direction(o, s))
obj:setacceleration({x=dir.x*-3, y=4, z=dir.z*-3})
obj:setvelocity({x=dir.x*velocity, y=3, z=dir.z*velocity})
obj:set_acceleration({x=dir.x*-3, y=4, z=dir.z*-3})
obj:set_velocity({x=dir.x*velocity, y=3, z=dir.z*velocity})
end
@ -150,4 +150,4 @@ minetest.register_craft({
type = "shapeless",
output = "mcl_end:ender_eye",
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()
ent._shot_from_dispenser = true
local v = ent.velocity or 1
fireball:setvelocity(vector.multiply(dropdir, v))
fireball:set_velocity(vector.multiply(dropdir, v))
ent.switch = 1
stack:take_item()
end,

View File

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

View File

@ -338,8 +338,8 @@ doll_def.on_activate = function(self, staticdata, dtime_s)
mob = default_mob
end
set_doll_properties(self.object, mob)
self.object:setvelocity({x=0, y=0, z=0})
self.object:setacceleration({x=0, y=0, z=0})
self.object:set_velocity({x=0, y=0, z=0})
self.object:set_acceleration({x=0, y=0, z=0})
self.object:set_armor_groups({immortal=1})
end

View File

@ -197,7 +197,7 @@ local function find_nether_target_y(target_x, target_z)
local air = 4
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
air = air + 1

View File

@ -223,7 +223,7 @@ local update_sign = function(pos, fields, sender)
text_entity:get_luaentity()._signnodename = 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
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,
y = place_pos.y + sign_info.delta.y,
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()
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 obj = minetest.add_entity(pos, entity_mapping[itemstring])
obj:setvelocity({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_velocity({x=dir.x*velocity, y=dir.y*velocity, z=dir.z*velocity})
obj:set_acceleration({x=dir.x*-3, y=-GRAVITY, z=dir.z*-3})
return obj
end
@ -208,7 +208,7 @@ local pearl_on_step = function(self, dtime)
-- First determine good teleport position
local dir = {x=0, y=0, z=0}
local v = self.object:getvelocity()
local v = self.object:get_velocity()
if walkable then
local vc = table.copy(v) -- vector for calculating
-- 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()
-- Teleport and hurt player
player:setpos(telepos)
player:set_pos(telepos)
player:set_hp(player:get_hp() - 5)
-- 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)
if nname == "mcl_tnt:tnt" then
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
@ -18,13 +18,13 @@ local function do_tnt_physics(tnt_np,tntr)
local objs = minetest.get_objects_inside_radius(tnt_np, tntr)
for k, obj in pairs(objs) do
local ent = obj:get_luaentity()
local v = obj:getvelocity()
local v = obj:get_velocity()
local p = obj:get_pos()
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
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
local dist = math.max(1, vector.distance(tnt_np, p))
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 hdir_x = math.cos(phi) * 0.02
local hdir_z = math.sin(phi) * 0.02
self.object:setvelocity({x=hdir_x, y=2, z=hdir_z})
self.object:setacceleration({x=0, y=-10, z=0})
self.object:settexturemod("^mcl_tnt_blink.png")
self.object:set_velocity({x=hdir_x, y=2, z=hdir_z})
self.object:set_acceleration({x=0, y=-10, z=0})
self.object:set_texture_mod("^mcl_tnt_blink.png")
end
local function add_effects(pos, radius, drops)
@ -170,9 +170,9 @@ function TNT:on_step(dtime)
if self.blinktimer > 0.25 then
self.blinktimer = self.blinktimer - 0.25
if self.blinkstatus then
self.object:settexturemod("")
self.object:set_texture_mod("")
else
self.object:settexturemod("^mcl_tnt_blink.png")
self.object:set_texture_mod("^mcl_tnt_blink.png")
end
self.blinkstatus = not self.blinkstatus
end

View File

@ -433,7 +433,7 @@ if ARMOR_DROP == true or ARMOR_DESTROY == true then
armor.drop_armor = function(pos, stack)
local obj = minetest.add_item(pos, stack)
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
minetest.register_on_dieplayer(function(player)

View File

@ -63,7 +63,7 @@ local function update_entity(pos)
yaw = math.pi / 2
end
end
object:setyaw(yaw)
object:set_yaw(yaw)
object:set_properties({textures={texture}})
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 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
local diamondsize = math.random(1, 3)
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 z1 = minp.z + math.floor((divz+1)*divlen)
-- 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
local pr = PseudoRandom(seed+1)
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 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
vine_threshold = vine_threshold * (2/3)
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 = {}
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
-- Only possible on the wood, not on the leaves
if i == 1 then
grow_upwards = perlin_vines_upwards:get3d(pos) > 0.8
grow_upwards = perlin_vines_upwards:get_3d(pos) > 0.8
end
if grow_upwards then
-- Grow vines up 1-4 nodes, even through jungleleaves.
-- This may give climbing access all the way to the top of the tree :-)
-- 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
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
else
-- 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
if data[p_pos] == c_air then
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)
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),
-- enclose in cobwebs and setup the spawner node.
local spawner_placed = SetNodeIfCanBuild(p, {name=tsm_railcorridors.nodes.spawner})
if spawner_placed then
local size = 1
if webperlin_major:get3d(p) > 0.5 then
if webperlin_major:get_3d(p) > 0.5 then
size = 2
end
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
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}
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
-- No check neccessary at height offset 0 since the cobweb is on the floor
return TryPlaceCobweb(cpos)