• 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!

Solved Change direction of the monster.

matti450

Member
Joined
Apr 13, 2008
Messages
507
Reaction score
24
how do i change the direction of the monster in my room? i dont really like that the fact they are looking south ^^
 
They are set to always face south by default, and then once a player is on screen they will face towards their target.

To change this, requires source edits.
 
You could change the direction of monsters on startup.
I assume you want to change the direction of the monsters in your "spawn room".

Here's how to do it with TFS 1.x:
Code:
local monsters = {
    {position = {x = 100, y = 100, z = 7}, dir = SOUTH},
    {position = {x = 101, y = 100, z = 7}, dir = NORTH},
    {position = {x = 102, y = 100, z = 7}, dir = WEST},
    {position = {x = 103, y = 100, z = 7}, dir = EAST}
}

function onStartup()
    for _, mob in ipairs(monsters) do
        local tile = Tile(mob.position)
        if tile then
            local creature = tile:getTopCreature()
            if creature then
                creature:setDirection(mob.dir)
            end
        end
    end
    return true
end

I haven't used the older versions of TFS for a while, but you can try this for 0.3.x.
Code:
local monsters = {
    {position = {x = 100, y = 100, z = 7}, dir = SOUTH},
    {position = {x = 101, y = 100, z = 7}, dir = NORTH},
    {position = {x = 102, y = 100, z = 7}, dir = WEST},
    {position = {x = 103, y = 100, z = 7}, dir = EAST}
}

function onStartup()
    for _, mob in ipairs(monsters) do
        local monster = getTopCreature(mob.position)
        if monster.uid > 0 then
            doCreatureSetLookDirection(monster.uid, mob.dir)
        end
    end
    return true
end
 
Last edited:
You could change the direction of monsters on startup.
I assume you want to change the direction of the monsters in your "spawn room".

Here's how to do it with TFS 1.x:
Code:
local monsters = {
    {position = {x = 100, y = 100, z = 7}, dir = SOUTH},
    {position = {x = 101, y = 100, z = 7}, dir = NORTH},
    {position = {x = 102, y = 100, z = 7}, dir = WEST},
    {position = {x = 103, y = 100, z = 7}, dir = EAST}
}

function onStartup()
    for _, mob in ipairs(monsters) do
        local tile = Tile(mob.position)
        if tile then
            local creature = tile:getTopCreature()
            if creature then
                creature:setDirection(mob.dir)
            end
        end
    end
    return true
end

I haven't used the older versions of TFS for a while, but you can try this for 0.3.x.
Code:
local monsters = {
    {position = {x = 100, y = 100, z = 7}, dir = SOUTH},
    {position = {x = 101, y = 100, z = 7}, dir = NORTH},
    {position = {x = 102, y = 100, z = 7}, dir = WEST},
    {position = {x = 103, y = 100, z = 7}, dir = EAST}
}

function onStartup()
    for _, mob in ipairs(monsters) do
        local monster = getTopCreature(mob.position)
        if monster.uid > 0 then
            setCreatureLookDir(monster.uid, mob.dir)
        end
    end
    return true
end
i will try them thx alot, but one question where do i have to put like monster id or the name of the monster? or i do only need to put the pos of the area?
 
Yes, in globalevents/scripts/name.lua.

<globalevent type="startup" name="Name" script="name.lua"/>
i get errors ;)
Code:
[06/02/2015 17:35:01] [Error - GlobalEvent Interface]
[06/02/2015 17:35:01] data/globalevents/scripts/name.lua:onStartup
[06/02/2015 17:35:01] Description:
[06/02/2015 17:35:01] data/globalevents/scripts/name.lua:8: attempt to call global 'Tile' (a nil value)
[06/02/2015 17:35:01] stack traceback:
[06/02/2015 17:35:01]     data/globalevents/scripts/name.lua:8: in function <data/globalevents/scripts/name.lua:6>
 
Use the one for 0.3 (the second one).
tried both i get same error
Code:
[06/02/2015 17:43:39] [Error - GlobalEvent Interface]
[06/02/2015 17:43:39] data/globalevents/scripts/name.lua:onStartup
[06/02/2015 17:43:39] Description:
[06/02/2015 17:43:39] data/globalevents/scripts/name.lua:12: attempt to call global 'setCreatureLookDir' (a nil value)
[06/02/2015 17:43:39] stack traceback:
[06/02/2015 17:43:39]     data/globalevents/scripts/name.lua:12: in function <data/globalevents/scripts/name.lua:8>
 
Back
Top