• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ [TFS 1.5] Monster with skulls

Ridjin

New Member
Joined
Dec 17, 2014
Messages
21
Reaction score
3
in TFS 1.3 or lower, monsters were still in xml, which made it easy to add skulls to specific monsters.

Now, TFS 1.5 uses lua type monsters, with different syntax.
Do you know how I add skulls to specific monsters in tfs 1.5?
 
in register_monster_type, have this sentence
Lua:
registerMonsterType.skull = function(mtype, mask)
    if mask.skull then
        mtype:skull(mask.skull)
    end
end

i creat a monster with skull = 1

1689081219636.png

but, the error maintain

1689081265444.png
 
oh, its otservbr, I thought it was tfs 1.5, then I have no idea

next time you ask for help, make sure to tell everyone that you are using otservbr and not TFS 1.5 (no, they are not the same thing)
 
Last edited by a moderator:
It says method which makes a reference to userdata

src\lua\functions\creatures\monster\monster_type_functions.cpp
C++:
int MonsterTypeFunctions::luaMonsterTypeSkull(lua_State* L)
{
    // get: monsterType:skull() set: monsterType:skull(str/constant)
    MonsterType* monsterType = getUserdata<MonsterType>(L, 1);
    if (monsterType) {
        if (lua_gettop(L) == 1) {
            lua_pushnumber(L, monsterType->info.skull);
        } else {
            if (isNumber(L, 2)) {
                monsterType->info.skull = getNumber<Skulls_t>(L, 2);
            } else {
                monsterType->info.skull = getSkullType(getString(L, 2));
            }
            pushBoolean(L, true);
        }
    } else {
        lua_pushnil(L);
    }
    return 1;
}

src\lua\functions\creatures\monster\monster_type_functions.hpp
C++:
registerMethod(L, "MonsterType", "skull", MonsterTypeFunctions::luaMonsterTypeSkull);
static int luaMonsterTypeSkull(lua_State * L);
 
It says method which makes a reference to userdata

src\lua\functions\creatures\monster\monster_type_functions.cpp
C++:
int MonsterTypeFunctions::luaMonsterTypeSkull(lua_State* L)
{
    // get: monsterType:skull() set: monsterType:skull(str/constant)
    MonsterType* monsterType = getUserdata<MonsterType>(L, 1);
    if (monsterType) {
        if (lua_gettop(L) == 1) {
            lua_pushnumber(L, monsterType->info.skull);
        } else {
            if (isNumber(L, 2)) {
                monsterType->info.skull = getNumber<Skulls_t>(L, 2);
            } else {
                monsterType->info.skull = getSkullType(getString(L, 2));
            }
            pushBoolean(L, true);
        }
    } else {
        lua_pushnil(L);
    }
    return 1;
}

src\lua\functions\creatures\monster\monster_type_functions.hpp
C++:
registerMethod(L, "MonsterType", "skull", MonsterTypeFunctions::luaMonsterTypeSkull);
static int luaMonsterTypeSkull(lua_State * L);
Where do I use this?
 
Back
Top