Even I, need help!

User avatar
jordan4ibanez
Member
 
Posts: 1865
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

Even I, need help!

by jordan4ibanez » Tue Nov 27, 2012 03:48

I am trying to create boats for minetest, and i am wondering why set_attachment keeps giving me a nil value for this:
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)
If you can think it, you can make it.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Tue Nov 27, 2012 14:58

The params of your on_rightclick callback are wrong. Heres the correct syntax: https://github.com/celeron55/minetest/blob/master/doc/lua_api.txt#L1259
BTW: nice avatar image ;-)
Last edited by PilzAdam on Tue Nov 27, 2012 14:58, edited 1 time in total.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 14 guests

cron