• 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 Help with Script Please -.-"

KylerXX

Active Member
Joined
Jun 24, 2010
Messages
439
Reaction score
30
Im trying to do a script that if you cast, creates on target if lookdir is north then this create an item in north, but doesn't work and I dont know why... here is the code:`

PHP:
function onCastSpell(cid, var)

local directions = {
[0] = {getCreaturePosition(getCreatureTarget(cid)).y - 1, 1987},
[1] = {getCreaturePosition(getCreatureTarget(cid)).x + 1, 1987},
[2] = {getCreaturePosition(getCreatureTarget(cid)).y + 1, 1987},
[3] = {getCreaturePosition(getCreatureTarget(cid)).x - 1, 1987}
}


local dir = getPlayerLookDir(cid)
if directions[dir] == getPlayerLookDir(cid) then
doCreateItem(directions[dir][2], 1, directions[dir][1])
return true
end



end

Here is the error:

[19/07/2010 21:08:59] Lua Script Error: [Spell Interface]
[19/07/2010 21:08:59] data/spells/scripts/summon/mrmime.lua:eek:nCastSpell

[19/07/2010 21:08:59] luaGetCreaturePosition(). Creature not found

[19/07/2010 21:08:59] Lua Script Error: [Spell Interface]
[19/07/2010 21:08:59] data/spells/scripts/summon/mrmime.lua:eek:nCastSpell

[19/07/2010 21:08:59] data/spells/scripts/summon/mrmime.lua:6: attempt to index a boolean value
[19/07/2010 21:08:59] stack traceback:
[19/07/2010 21:08:59] data/spells/scripts/summon/mrmime.lua:6: in function <data/spells/scripts/summon/mrmime.lua:3>





Please help!! Im a begginner on LUA
 
Why not any one wants help me .. :S I posted in this section 4 times and no replies!
 
Last edited:
ftw i posted the solution in the other forum you requested it ;/ and it worked for me
Lua:
function onCastSpell(cid, var)
    local target = getCreatureTarget(cid)
 
    if not isCreature(target) then
        doPlayerSendDefaultCancel(cid, 46)    
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        return false
    end
 
    local pos, thing = getPosByDir(getThingPos(target), getCreatureLookDirection(target), 1), 2268
 
    if doTileQueryAdd(target, pos) ~= RETURNVALUE_NOERROR then
        doPlayerSendDefaultCancel(cid, 7)    
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        return false
    end
 
    doCreateItem(2268, 1, pos)        
    return true
end
tfs 0.3.6pl1
 
Back
Top