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

Lua Creature Position - Bug?

HeberPcL

[PowerOT.com.br]
Joined
Aug 21, 2007
Messages
1,292
Reaction score
51
Location
Brazil
GitHub
heberpcl
Hey,

I did the following script and found a strange error and for this reason I am sharing it may be a bug.

Code:
Code:
    toPosition = player:getPosition()
    local skeleton = doSummonCreature("Skeleton", toPosition)
    local skeletonCheckPositionNow = skelelton:getPosition() -- return error
    local skeletonCheckPositionNoww = getCreaturePosition(skeleton) -- work fine
 
Hey,

I did the following script and found a strange error and for this reason I am sharing it may be a bug.

Code:
Code:
    toPosition = player:getPosition()
    local skeleton = doSummonCreature("Skeleton", toPosition)
    local skeletonCheckPositionNow = skelelton:getPosition() -- return error
    local skeletonCheckPositionNoww = getCreaturePosition(skeleton) -- work fine
local skeletonCheckPositionNow = skelelton:getPosition() -- return error
Maybe that's the error?
 
As Evual stated. doSummonCreature return a id, so you need todo:
Code:
    local creatureId = doSummonCreature("Skeleton", toPosition)
    if creatureId ~= false then
        local monster = Monster(creatureId)
        monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    else
        toPosition:sendMagicEffect(CONST_ME_POFF)
    end

or, do this which i recommend:
Code:
    local monster = Game.createMonster("Skeleton", toPosition)
    if monster ~= nil then
        monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    else
        toPosition:sendMagicEffect(CONST_ME_POFF)
    end
 
Code:
function onSay(player, words, param)
    local toPosition = player:getPosition()
    local creatureID_1 = Game.createMonster("Orc",         toPosition)
    local creatureID_2 = Game.createMonster("Skeleton", toPosition)
  
    if ( creatureID_1 ~= nil and creatureID_2 ~= nil )then
        creatureID_1:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        creatureID_2:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        -- Set Target
        creatureID_1:addTarget(creatureID_2)
        creatureID_2:addTarget(creatureID_1)
      
    else
        toPosition:sendMagicEffect(CONST_ME_POFF)
    end
 
    return true
end

Using this code the monsters are to target each other, but it does not cause damage.
 
Hey,

I did the following script and found a strange error and for this reason I am sharing it may be a bug.

Code:
Code:
    toPosition = player:getPosition()
    local skeleton = doSummonCreature("Skeleton", toPosition)
    local skeletonCheckPositionNow = skelelton:getPosition() -- return error
    local skeletonCheckPositionNoww = getCreaturePosition(skeleton) -- work fine
toPosition = player:getPosition()
local skeleton = doSummonCreature("Skeleton", toPosition)
local skeletonCheckPositionNow = skelelton:getPosition() -- return error
local skeletonCheckPositionNoww = getCreaturePosition(skeleton) -- work fine

Please try to compare green text with red text. It's why you saw error.

#edit
Sorry i'm tired, didn't saw moj mistrz post. Delete please.
 
Last edited:

If you remove you are part solves?

Code:
else if (attacker->getMonster()) {
                const Creature* targetMaster = target->getMaster();

                if (!targetMaster || !targetMaster->getPlayer()) {
                    const Creature* attackerMaster = attacker->getMaster();

                    if (!attackerMaster || !attackerMaster->getPlayer()) {
                        return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE;
                    }
                }
            }

Thx
 
Back
Top