mirror of
https://github.com/mt-mods/pipeworks.git
synced 2024-11-08 08:23:59 +01:00
Replace deprecated Lua function calls
This commit is contained in:
parent
1a396c707c
commit
92a55c3985
@ -13,7 +13,7 @@ function pipeworks.tube_inject_item(pos, start_pos, velocity, item, owner)
|
||||
local obj = luaentity.add_entity(pos, "pipeworks:tubed_item")
|
||||
obj:set_item(stack:to_string())
|
||||
obj.start_pos = vector.new(start_pos)
|
||||
obj:setvelocity(velocity)
|
||||
obj:set_velocity(velocity)
|
||||
obj.owner = owner
|
||||
--obj:set_color("red") -- todo: this is test-only code
|
||||
return obj
|
||||
@ -207,7 +207,7 @@ minetest.register_entity("pipeworks:tubed_item", {
|
||||
textures = {stack:get_name()}
|
||||
})
|
||||
local def = stack:get_definition()
|
||||
self.object:setyaw((def and def.type == "node") and 0 or math.pi * 0.25)
|
||||
self.object:set_yaw((def and def.type == "node") and 0 or math.pi * 0.25)
|
||||
end,
|
||||
|
||||
get_staticdata = luaentity.get_staticdata,
|
||||
@ -220,7 +220,7 @@ minetest.register_entity("pipeworks:tubed_item", {
|
||||
return
|
||||
end
|
||||
local item = minetest.deserialize(staticdata)
|
||||
pipeworks.tube_inject_item(self.object:getpos(), item.start_pos, item.velocity, item.itemstring)
|
||||
pipeworks.tube_inject_item(self.object:get_pos(), item.start_pos, item.velocity, item.itemstring)
|
||||
self.object:remove()
|
||||
end,
|
||||
})
|
||||
@ -293,15 +293,15 @@ luaentity.register_entity("pipeworks:tubed_item", {
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
local pos = self:getpos()
|
||||
local pos = self:get_pos()
|
||||
if self.start_pos == nil then
|
||||
self.start_pos = vector.round(pos)
|
||||
self:setpos(pos)
|
||||
self:set_pos(pos)
|
||||
end
|
||||
|
||||
local stack = ItemStack(self.itemstring)
|
||||
|
||||
local velocity = self:getvelocity()
|
||||
local velocity = self:get_velocity()
|
||||
|
||||
local moved = false
|
||||
local speed = math.abs(velocity.x + velocity.y + velocity.z)
|
||||
@ -331,8 +331,8 @@ luaentity.register_entity("pipeworks:tubed_item", {
|
||||
return
|
||||
end
|
||||
velocity = vector.multiply(velocity, -1)
|
||||
self:setpos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1)))
|
||||
self:setvelocity(velocity)
|
||||
self:set_pos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1)))
|
||||
self:set_velocity(velocity)
|
||||
self:set_item(leftover:to_string())
|
||||
return
|
||||
end
|
||||
@ -350,13 +350,13 @@ luaentity.register_entity("pipeworks:tubed_item", {
|
||||
-- compatible with Minetest 0.4.13.
|
||||
-- Using item_drop here makes Minetest 0.4.13 crash.
|
||||
local dropped_item = minetest.add_item(self.start_pos, stack)
|
||||
dropped_item:setvelocity(vector.multiply(velocity, 5))
|
||||
dropped_item:set_velocity(vector.multiply(velocity, 5))
|
||||
self:remove()
|
||||
return
|
||||
else
|
||||
velocity = vector.multiply(velocity, -1)
|
||||
self:setpos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1)))
|
||||
self:setvelocity(velocity)
|
||||
self:set_pos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1)))
|
||||
self:set_velocity(velocity)
|
||||
end
|
||||
elseif is_multimode(multimode) then
|
||||
-- create new stacks according to returned data.
|
||||
@ -371,8 +371,8 @@ luaentity.register_entity("pipeworks:tubed_item", {
|
||||
|
||||
if new_velocity and not vector.equals(velocity, new_velocity) then
|
||||
local nvelr = math.abs(new_velocity.x + new_velocity.y + new_velocity.z)
|
||||
self:setpos(vector.add(self.start_pos, vector.multiply(new_velocity, (moved_by - 1) / nvelr)))
|
||||
self:setvelocity(new_velocity)
|
||||
self:set_pos(vector.add(self.start_pos, vector.multiply(new_velocity, (moved_by - 1) / nvelr)))
|
||||
self:set_velocity(new_velocity)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -388,11 +388,11 @@ if minetest.get_modpath("mesecons_mvps") then
|
||||
end
|
||||
for id, entity in pairs(luaentity.entities) do
|
||||
if entity.name == "pipeworks:tubed_item" then
|
||||
local pos = entity:getpos()
|
||||
local pos = entity:get_pos()
|
||||
local rpos = vector.round(pos)
|
||||
local dir = moved[minetest.hash_node_position(rpos)]
|
||||
if dir then
|
||||
entity:setpos(vector.add(pos, dir))
|
||||
entity:set_pos(vector.add(pos, dir))
|
||||
entity.start_pos = vector.add(entity.start_pos, dir)
|
||||
end
|
||||
end
|
||||
|
@ -36,7 +36,7 @@ if not minetest.get_modpath("auto_tree_tap") and
|
||||
end,
|
||||
after_place_node = function (pos, placer)
|
||||
pipeworks.scan_for_tube_objects(pos, placer)
|
||||
local placer_pos = placer:getpos()
|
||||
local placer_pos = placer:get_pos()
|
||||
|
||||
--correct for the player's height
|
||||
if placer:is_player() then placer_pos.y = placer_pos.y + 1.5 end
|
||||
|
@ -74,7 +74,7 @@ local move_entities_globalstep_part1 = function(dtime)
|
||||
local active_block_range = tonumber(minetest.settings:get("active_block_range")) or 2
|
||||
local new_active_blocks = {}
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
local blockpos = get_blockpos(player:getpos())
|
||||
local blockpos = get_blockpos(player:get_pos())
|
||||
local minp = vector.subtract(blockpos, active_block_range)
|
||||
local maxp = vector.add(blockpos, active_block_range)
|
||||
|
||||
@ -114,9 +114,9 @@ local entitydef_default = {
|
||||
if not def.entity then
|
||||
return
|
||||
end
|
||||
def.entity:setpos(vector.add(self._pos, def.offset))
|
||||
def.entity:setvelocity(self._velocity)
|
||||
def.entity:setacceleration(self._acceleration)
|
||||
def.entity:set_pos(vector.add(self._pos, def.offset))
|
||||
def.entity:set_velocity(self._velocity)
|
||||
def.entity:set_acceleration(self._acceleration)
|
||||
end,
|
||||
_attach_all = function(self)
|
||||
local master = self._attached_entities_master
|
||||
@ -196,13 +196,13 @@ local entitydef_default = {
|
||||
self._pos = vector.new(pos)
|
||||
--for _, entity in pairs(self._attached_entities) do
|
||||
-- if entity.entity then
|
||||
-- entity.entity:setpos(vector.add(self._pos, entity.offset))
|
||||
-- entity.entity:set_pos(vector.add(self._pos, entity.offset))
|
||||
-- end
|
||||
--end
|
||||
local master = self._attached_entities_master
|
||||
if master then
|
||||
local master_def = self._attached_entities[master]
|
||||
master_def.entity:setpos(vector.add(self._pos, master_def.offset))
|
||||
master_def.entity:set_pos(vector.add(self._pos, master_def.offset))
|
||||
end
|
||||
end,
|
||||
getvelocity = function(self)
|
||||
@ -212,7 +212,7 @@ local entitydef_default = {
|
||||
self._velocity = vector.new(velocity)
|
||||
local master = self._attached_entities_master
|
||||
if master then
|
||||
self._attached_entities[master].entity:setvelocity(self._velocity)
|
||||
self._attached_entities[master].entity:set_velocity(self._velocity)
|
||||
end
|
||||
end,
|
||||
getacceleration = function(self)
|
||||
@ -222,7 +222,7 @@ local entitydef_default = {
|
||||
self._acceleration = vector.new(acceleration)
|
||||
local master = self._attached_entities_master
|
||||
if master then
|
||||
self._attached_entities[master].entity:setacceleration(self._acceleration)
|
||||
self._attached_entities[master].entity:set_acceleration(self._acceleration)
|
||||
end
|
||||
end,
|
||||
remove = function(self)
|
||||
@ -314,7 +314,7 @@ function luaentity.get_objects_inside_radius(pos, radius)
|
||||
local objects = {}
|
||||
local index = 1
|
||||
for id, entity in pairs(luaentity.entities) do
|
||||
if vector.distance(pos, entity:getpos()) <= radius then
|
||||
if vector.distance(pos, entity:get_pos()) <= radius then
|
||||
objects[index] = entity
|
||||
index = index + 1
|
||||
end
|
||||
@ -329,11 +329,11 @@ local move_entities_globalstep_part2 = function(dtime)
|
||||
local master = entity._attached_entities_master
|
||||
local master_def = master and entity._attached_entities[master]
|
||||
local master_entity = master_def and master_def.entity
|
||||
local master_entity_pos = master_entity and master_entity:getpos()
|
||||
local master_entity_pos = master_entity and master_entity:get_pos()
|
||||
if master_entity_pos then
|
||||
entity._pos = vector.subtract(master_entity_pos, master_def.offset)
|
||||
entity._velocity = master_entity:getvelocity()
|
||||
entity._acceleration = master_entity:getacceleration()
|
||||
entity._velocity = master_entity:get_velocity()
|
||||
entity._acceleration = master_entity:get_acceleration()
|
||||
else
|
||||
entity._pos = vector.add(vector.add(
|
||||
entity._pos,
|
||||
|
@ -87,7 +87,7 @@ local function vacuum(pos, radius)
|
||||
for _, object in pairs(minetest.get_objects_inside_radius(pos, math.sqrt(3) * radius)) do
|
||||
local lua_entity = object:get_luaentity()
|
||||
if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then
|
||||
local obj_pos = object:getpos()
|
||||
local obj_pos = object:get_pos()
|
||||
local minpos = vector.subtract(pos, radius)
|
||||
local maxpos = vector.add(pos, radius)
|
||||
if obj_pos.x >= minpos.x and obj_pos.x <= maxpos.x
|
||||
|
@ -258,7 +258,7 @@ local function register_wielder(data)
|
||||
end,
|
||||
after_place_node = function (pos, placer)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
local placer_pos = placer:getpos()
|
||||
local placer_pos = placer:get_pos()
|
||||
if placer_pos and placer:is_player() then placer_pos = vector.add(placer_pos, assumed_eye_pos) end
|
||||
if placer_pos then
|
||||
local dir = vector.subtract(pos, placer_pos)
|
||||
@ -495,7 +495,9 @@ if pipeworks.enable_dispenser then
|
||||
sneak = true,
|
||||
act = function(virtplayer, pointed_thing)
|
||||
local wieldstack = virtplayer:get_wielded_item()
|
||||
virtplayer:set_wielded_item((minetest.registered_items[wieldstack:get_name()] or {on_drop=minetest.item_drop}).on_drop(wieldstack, virtplayer, virtplayer:getpos()) or wieldstack)
|
||||
virtplayer:set_wielded_item((minetest.registered_items[wieldstack:get_name()] or
|
||||
{on_drop=minetest.item_drop}).on_drop(wieldstack, virtplayer, virtplayer:get_pos()) or
|
||||
wieldstack)
|
||||
end,
|
||||
eject_drops = false,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user