Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
function BOAT_ENTITY:on_rightclick(clicker)
if clicker then
clicker:set_attachment(self.object, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
end
end
Entire Code:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
BOAT_ENTITY={
physical = false,
timer=0,
textures = {"gunmod_bullet1_back.png"},
lastpos={},
collisionbox = {-17,-17,-17,17,17,17},
}
-- Arrow_entity.on_step()--> called when arrow is moving
BOAT_ENTITY.on_step = function(self, dtime)
self.timer=self.timer+dtime
local pos = self.object:getpos()
for _,obj in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
if obj:is_player() then
local obj_p = obj:getpos()
local calc = {x=pos.x - obj_p.x,y=0,z=pos.z - obj_p.z}
self.object:setvelocity({x=calc.x,y=calc.y,z=calc.z})
self.object:setacceleration({x=calc.x * -1,y=0,z=calc.z * -1})
--print(calc.x)
end
if not obj:is_player() then
local vel = self.object:getvelocity()
--print(vel.x)
if vel.x < 0.2 and vel.x > -0.2 and vel.y < 0.2 and vel.y > -0.2 then
self.object:setvelocity({x=vel.x / 2,y=vel.y / 2,z=vel.z / 2})
self.object:setacceleration({x=0,y=0,z=0})
end
end
end
end
function BOAT_ENTITY:on_rightclick(clicker)
if clicker:get_player_name() then
clicker:get_player_name():set_attachment(self.object, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
end
end
minetest.register_entity("boat_test:boat", BOAT_ENTITY)