Example #1
0
// get_look_pitch(self)
int ObjectRef::l_get_look_pitch(lua_State *L)
{
    ObjectRef *ref = checkobject(L, 1);
    Player *player = getplayer(ref);
    if(player == NULL) return 0;
    // Do it
    lua_pushnumber(L, player->getRadPitch());
    return 1;
}
Example #2
0
// get_look_dir(self)
int ObjectRef::l_get_look_dir(lua_State *L)
{
    ObjectRef *ref = checkobject(L, 1);
    Player *player = getplayer(ref);
    if(player == NULL) return 0;
    // Do it
    float pitch = player->getRadPitch();
    float yaw = player->getRadYaw();
    v3f v(cos(pitch)*cos(yaw), sin(pitch), cos(pitch)*sin(yaw));
    push_v3f(L, v);
    return 1;
}