Return early from on_step (#33)

This commit is contained in:
Jude Melton-Houghton 2022-05-15 10:58:35 -04:00 committed by GitHub
parent 3b31b6f9c0
commit 1349ff8dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -311,8 +311,6 @@ luaentity.register_entity("pipeworks:tubed_item", {
self:set_pos(pos)
end
local stack = ItemStack(self.itemstring)
local velocity = self:get_velocity()
local moved = false
@ -329,9 +327,15 @@ luaentity.register_entity("pipeworks:tubed_item", {
moved = true
end
if not moved then
return
end
local stack = ItemStack(self.itemstring)
pipeworks.load_position(self.start_pos)
local node = minetest.get_node(self.start_pos)
if moved and minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then
if minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then
local leftover
if minetest.registered_nodes[node.name].tube and minetest.registered_nodes[node.name].tube.insert_object then
leftover = minetest.registered_nodes[node.name].tube.insert_object(self.start_pos, node, stack, vel, self.owner)
@ -349,7 +353,6 @@ luaentity.register_entity("pipeworks:tubed_item", {
return
end
if moved then
local found_next, new_velocity, multimode = go_next(self.start_pos, velocity, stack, self.owner) -- todo: color
local rev_vel = vector.multiply(velocity, -1)
local rev_dir = vector.direction(self.start_pos,vector.add(self.start_pos,rev_vel))
@ -389,7 +392,6 @@ luaentity.register_entity("pipeworks:tubed_item", {
self:set_velocity(new_velocity)
end
end
end
})
if minetest.get_modpath("mesecons_mvps") then