mirror of
https://github.com/minetest/minetest_game.git
synced 2024-12-22 23:10:17 +01:00
Replace deprecated function calls
This commit is contained in:
parent
0df2753a68
commit
255031fc91
@ -69,7 +69,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if p then
|
if p then
|
||||||
player:setpos(p)
|
player:set_pos(p)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- physics, eye_offset, etc
|
-- physics, eye_offset, etc
|
||||||
@ -94,7 +94,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
|||||||
local dir = minetest.facedir_to_dir(param2)
|
local dir = minetest.facedir_to_dir(param2)
|
||||||
local p = {x = bed_pos.x + dir.x / 2, y = bed_pos.y, z = bed_pos.z + dir.z / 2}
|
local p = {x = bed_pos.x + dir.x / 2, y = bed_pos.y, z = bed_pos.z + dir.z / 2}
|
||||||
player:set_physics_override(0, 0, 0)
|
player:set_physics_override(0, 0, 0)
|
||||||
player:setpos(p)
|
player:set_pos(p)
|
||||||
default.player_attached[name] = true
|
default.player_attached[name] = true
|
||||||
hud_flags.wielditem = false
|
hud_flags.wielditem = false
|
||||||
default.player_set_animation(player, "lay" , 0)
|
default.player_set_animation(player, "lay" , 0)
|
||||||
@ -139,7 +139,7 @@ end
|
|||||||
|
|
||||||
function beds.on_rightclick(pos, player)
|
function beds.on_rightclick(pos, player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local ppos = player:getpos()
|
local ppos = player:get_pos()
|
||||||
local tod = minetest.get_timeofday()
|
local tod = minetest.get_timeofday()
|
||||||
|
|
||||||
if tod > 0.2 and tod < 0.805 then
|
if tod > 0.2 and tod < 0.805 then
|
||||||
@ -194,7 +194,7 @@ if enable_respawn then
|
|||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local pos = beds.spawn[name]
|
local pos = beds.spawn[name]
|
||||||
if pos then
|
if pos then
|
||||||
player:setpos(pos)
|
player:set_pos(pos)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -53,7 +53,7 @@ end
|
|||||||
function beds.set_spawns()
|
function beds.set_spawns()
|
||||||
for name,_ in pairs(beds.player) do
|
for name,_ in pairs(beds.player) do
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
local p = player:getpos()
|
local p = player:get_pos()
|
||||||
-- but don't change spawn location if borrowing a bed
|
-- but don't change spawn location if borrowing a bed
|
||||||
if not minetest.is_protected(p, name) then
|
if not minetest.is_protected(p, name) then
|
||||||
beds.spawn[name] = p
|
beds.spawn[name] = p
|
||||||
|
@ -58,10 +58,10 @@ function boat.on_rightclick(self, clicker)
|
|||||||
clicker:set_detach()
|
clicker:set_detach()
|
||||||
player_api.player_attached[name] = false
|
player_api.player_attached[name] = false
|
||||||
player_api.set_animation(clicker, "stand" , 30)
|
player_api.set_animation(clicker, "stand" , 30)
|
||||||
local pos = clicker:getpos()
|
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}
|
||||||
minetest.after(0.1, function()
|
minetest.after(0.1, function()
|
||||||
clicker:setpos(pos)
|
clicker:set_pos(pos)
|
||||||
end)
|
end)
|
||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
local attach = clicker:get_attach()
|
local attach = clicker:get_attach()
|
||||||
@ -79,7 +79,7 @@ function boat.on_rightclick(self, clicker)
|
|||||||
minetest.after(0.2, function()
|
minetest.after(0.2, function()
|
||||||
player_api.set_animation(clicker, "sit" , 30)
|
player_api.set_animation(clicker, "sit" , 30)
|
||||||
end)
|
end)
|
||||||
clicker:set_look_horizontal(self.object:getyaw())
|
clicker:set_look_horizontal(self.object:get_yaw())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ function boat.on_punch(self, puncher)
|
|||||||
local leftover = inv:add_item("main", "boats:boat")
|
local leftover = inv:add_item("main", "boats:boat")
|
||||||
-- if no room in inventory add a replacement boat to the world
|
-- if no room in inventory add a replacement boat to the world
|
||||||
if not leftover:is_empty() then
|
if not leftover:is_empty() then
|
||||||
minetest.add_item(self.object:getpos(), leftover)
|
minetest.add_item(self.object:get_pos(), leftover)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- delay remove to ensure player is detached
|
-- delay remove to ensure player is detached
|
||||||
@ -128,10 +128,10 @@ 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
|
||||||
self.v = self.v + 0.1
|
self.v = self.v + 0.1
|
||||||
elseif ctrl.down then
|
elseif ctrl.down then
|
||||||
@ -139,27 +139,27 @@ 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
|
||||||
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:getpos())
|
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
|
||||||
@ -167,7 +167,7 @@ function boat.on_step(self, dtime)
|
|||||||
self.v = 5 * get_sign(self.v)
|
self.v = 5 * get_sign(self.v)
|
||||||
end
|
end
|
||||||
|
|
||||||
local p = self.object:getpos()
|
local p = self.object:get_pos()
|
||||||
p.y = p.y - 0.5
|
p.y = p.y - 0.5
|
||||||
local new_velo
|
local new_velo
|
||||||
local new_acce = {x = 0, y = 0, z = 0}
|
local new_acce = {x = 0, y = 0, z = 0}
|
||||||
@ -179,13 +179,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:getpos())
|
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
|
||||||
@ -193,24 +193,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:getpos())
|
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:getpos()
|
local pos = self.object:get_pos()
|
||||||
pos.y = math.floor(pos.y) + 0.5
|
pos.y = math.floor(pos.y) + 0.5
|
||||||
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:getpos())
|
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
|
||||||
|
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ minetest.register_craftitem("boats:boat", {
|
|||||||
boat = minetest.add_entity(pointed_thing.under, "boats:boat")
|
boat = minetest.add_entity(pointed_thing.under, "boats:boat")
|
||||||
if boat then
|
if boat then
|
||||||
if placer then
|
if placer then
|
||||||
boat:setyaw(placer:get_look_horizontal())
|
boat:set_yaw(placer:get_look_horizontal())
|
||||||
end
|
end
|
||||||
local player_name = placer and placer:get_player_name() or ""
|
local player_name = placer and placer:get_player_name() or ""
|
||||||
if not (creative and creative.is_enabled_for and
|
if not (creative and creative.is_enabled_for and
|
||||||
|
@ -159,7 +159,7 @@ end
|
|||||||
local drop = function(pos, itemstack)
|
local drop = function(pos, itemstack)
|
||||||
local obj = minetest.add_item(pos, itemstack:take_item(itemstack:get_count()))
|
local obj = minetest.add_item(pos, itemstack:take_item(itemstack:get_count()))
|
||||||
if obj then
|
if obj then
|
||||||
obj:setvelocity({
|
obj:set_velocity({
|
||||||
x = math.random(-10, 10) / 9,
|
x = math.random(-10, 10) / 9,
|
||||||
y = 5,
|
y = 5,
|
||||||
z = math.random(-10, 10) / 9,
|
z = math.random(-10, 10) / 9,
|
||||||
|
@ -148,7 +148,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
|||||||
if inv:room_for_item("main", {name=liquiddef.itemname}) then
|
if inv:room_for_item("main", {name=liquiddef.itemname}) then
|
||||||
inv:add_item("main", liquiddef.itemname)
|
inv:add_item("main", liquiddef.itemname)
|
||||||
else
|
else
|
||||||
local pos = user:getpos()
|
local pos = user:get_pos()
|
||||||
pos.y = math.floor(pos.y + 0.5)
|
pos.y = math.floor(pos.y + 0.5)
|
||||||
minetest.add_item(pos, liquiddef.itemname)
|
minetest.add_item(pos, liquiddef.itemname)
|
||||||
end
|
end
|
||||||
|
@ -121,7 +121,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
if inv:room_for_item("main", new_stack) then
|
if inv:room_for_item("main", new_stack) then
|
||||||
inv:add_item("main", new_stack)
|
inv:add_item("main", new_stack)
|
||||||
else
|
else
|
||||||
minetest.add_item(player:getpos(), new_stack)
|
minetest.add_item(player:get_pos(), new_stack)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
stack:get_meta():from_table({ fields = data })
|
stack:get_meta():from_table({ fields = data })
|
||||||
@ -247,7 +247,7 @@ minetest.register_craftitem("default:skeleton_key", {
|
|||||||
itemstack = new_stack
|
itemstack = new_stack
|
||||||
else
|
else
|
||||||
if inv:add_item("main", new_stack):get_count() > 0 then
|
if inv:add_item("main", new_stack):get_count() > 0 then
|
||||||
minetest.add_item(user:getpos(), new_stack)
|
minetest.add_item(user:get_pos(), new_stack)
|
||||||
end -- else: added to inventory successfully
|
end -- else: added to inventory successfully
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ local item = {
|
|||||||
burn_up = function(self)
|
burn_up = function(self)
|
||||||
-- disappear in a smoke puff
|
-- disappear in a smoke puff
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
local p = self.object:getpos()
|
local p = self.object:get_pos()
|
||||||
minetest.sound_play("default_item_smoke", {
|
minetest.sound_play("default_item_smoke", {
|
||||||
pos = p,
|
pos = p,
|
||||||
max_hear_distance = 8,
|
max_hear_distance = 8,
|
||||||
@ -48,7 +48,7 @@ local item = {
|
|||||||
if self.ignite_timer > 10 then
|
if self.ignite_timer > 10 then
|
||||||
self.ignite_timer = 0
|
self.ignite_timer = 0
|
||||||
|
|
||||||
local node = minetest.get_node_or_nil(self.object:getpos())
|
local node = minetest.get_node_or_nil(self.object:get_pos())
|
||||||
if not node then
|
if not node then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
minetest.set_gen_notify({dungeon = true, temple = true})
|
minetest.set_gen_notify({dungeon = true, temple = true})
|
||||||
|
|
||||||
local function noise3d_integer(noise, pos)
|
local function noise3d_integer(noise, pos)
|
||||||
return math.abs(math.floor(noise:get3d(pos) * 0x7fffffff))
|
return math.abs(math.floor(noise:get_3d(pos) * 0x7fffffff))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function random_sample(rand, list, count)
|
local function random_sample(rand, list, count)
|
||||||
|
@ -169,7 +169,7 @@ if flame_sound then
|
|||||||
function fire.update_player_sound(player)
|
function fire.update_player_sound(player)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
-- Search for flame nodes in radius around player
|
-- Search for flame nodes in radius around player
|
||||||
local ppos = player:getpos()
|
local ppos = player:get_pos()
|
||||||
local areamin = vector.subtract(ppos, radius)
|
local areamin = vector.subtract(ppos, radius)
|
||||||
local areamax = vector.add(ppos, radius)
|
local areamax = vector.add(ppos, radius)
|
||||||
local fpos, num = minetest.find_nodes_in_area(
|
local fpos, num = minetest.find_nodes_in_area(
|
||||||
|
@ -89,7 +89,7 @@ minetest.register_chatcommand("sethome", {
|
|||||||
func = function(name)
|
func = function(name)
|
||||||
name = name or "" -- fallback to blank name if nil
|
name = name or "" -- fallback to blank name if nil
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
if player and sethome.set(name, player:getpos()) then
|
if player and sethome.set(name, player:get_pos()) then
|
||||||
return true, "Home set!"
|
return true, "Home set!"
|
||||||
end
|
end
|
||||||
return false, "Player not found!"
|
return false, "Player not found!"
|
||||||
|
@ -23,7 +23,7 @@ local function rotate_and_place(itemstack, placer, pointed_thing)
|
|||||||
local param2 = 0
|
local param2 = 0
|
||||||
|
|
||||||
if placer then
|
if placer then
|
||||||
local placer_pos = placer:getpos()
|
local placer_pos = placer:get_pos()
|
||||||
if placer_pos then
|
if placer_pos then
|
||||||
param2 = minetest.dir_to_facedir(vector.subtract(p1, placer_pos))
|
param2 = minetest.dir_to_facedir(vector.subtract(p1, placer_pos))
|
||||||
end
|
end
|
||||||
|
@ -58,8 +58,8 @@ local function eject_drops(drops, pos, radius)
|
|||||||
local obj = minetest.add_item(drop_pos, dropitem)
|
local obj = minetest.add_item(drop_pos, dropitem)
|
||||||
if obj then
|
if obj then
|
||||||
obj:get_luaentity().collect = true
|
obj:get_luaentity().collect = true
|
||||||
obj:setacceleration({x = 0, y = -10, z = 0})
|
obj:set_acceleration({x = 0, y = -10, z = 0})
|
||||||
obj:setvelocity({x = math.random(-3, 3),
|
obj:set_velocity({x = math.random(-3, 3),
|
||||||
y = math.random(0, 10),
|
y = math.random(0, 10),
|
||||||
z = math.random(-3, 3)})
|
z = math.random(-3, 3)})
|
||||||
end
|
end
|
||||||
@ -152,7 +152,7 @@ end
|
|||||||
local function entity_physics(pos, radius, drops)
|
local function entity_physics(pos, radius, drops)
|
||||||
local objs = minetest.get_objects_inside_radius(pos, radius)
|
local objs = minetest.get_objects_inside_radius(pos, radius)
|
||||||
for _, obj in pairs(objs) do
|
for _, obj in pairs(objs) do
|
||||||
local obj_pos = obj:getpos()
|
local obj_pos = obj:get_pos()
|
||||||
local dist = math.max(1, vector.distance(pos, obj_pos))
|
local dist = math.max(1, vector.distance(pos, obj_pos))
|
||||||
|
|
||||||
local damage = (4 / dist) * radius
|
local damage = (4 / dist) * radius
|
||||||
@ -164,7 +164,7 @@ local function entity_physics(pos, radius, drops)
|
|||||||
local moveoff = vector.multiply(dir, dist + 1.0)
|
local moveoff = vector.multiply(dir, dist + 1.0)
|
||||||
local newpos = vector.add(pos, moveoff)
|
local newpos = vector.add(pos, moveoff)
|
||||||
newpos = vector.add(newpos, {x = 0, y = 0.2, z = 0})
|
newpos = vector.add(newpos, {x = 0, y = 0.2, z = 0})
|
||||||
obj:setpos(newpos)
|
obj:set_pos(newpos)
|
||||||
|
|
||||||
obj:set_hp(obj:get_hp() - damage)
|
obj:set_hp(obj:get_hp() - damage)
|
||||||
else
|
else
|
||||||
@ -179,8 +179,8 @@ local function entity_physics(pos, radius, drops)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if do_knockback then
|
if do_knockback then
|
||||||
local obj_vel = obj:getvelocity()
|
local obj_vel = obj:get_velocity()
|
||||||
obj:setvelocity(calc_velocity(pos, obj_pos,
|
obj:set_velocity(calc_velocity(pos, obj_pos,
|
||||||
obj_vel, radius * 10))
|
obj_vel, radius * 10))
|
||||||
end
|
end
|
||||||
if do_damage then
|
if do_damage then
|
||||||
|
Loading…
Reference in New Issue
Block a user