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

Healing Orb Error in movements

Ravauvial

Member
Joined
Mar 19, 2009
Messages
186
Reaction score
8
Location
Stanwood, Washington, USA
A good thread name: Healing Orb Error in movements
Distro name: Forgotten Server 8.4 (Crying Damson)
Script type: Healing Orb Lua
MoveEvent
Lua Function: doTeleportThing I think
Description of the script: Healing Orb is Item: 2180 when you walk through it it heals you.
What it should do: Heal you and it does but

Errors (in console) :

Lua Script Error: [MoveEvents Interface]
data/movements/scripts/healingorb.lua: onStepIn
attempt to index a nil value
stack traceback:
[C]: in function 'doTeleportThing'
data/movements/scripts/healingorb.lua:7: in function

<data/movements/scripts/healingorb.lua:1>


My code:

Code:
function onStepIn(cid, item, pos)
    if item.itemid == 2180 and item.uid == 5002 then
           if getPlayerStorageValue(cid, 64553) ~= 1 then 
              doCreatureAddHealth(cid, 500)
              doCreatureAddMana(cid, 1500)
              doSendMagicEffect(getCreaturePosition(cid), 12)
              doTeleportThing(cid, fromPosition, TRUE) 
              setPlayerStorageValue(cid,64553,1)
           end
    end
end
 
Code:
doTeleportThing(cid, fromPosition, TRUE)

Here's used fromPosition variable, but you haven't defined it.


Use this header:
Code:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)

Insteand of:
Code:
function onStepIn(cid, item, pos)
 
Ok now I get this Error:
ERROR:
[13/11/2009 17:21:09] Lua Script Error: [MoveEvents Interface]
[13/11/2009 17:21:09] data/movements/scripts/healingorb.lua:onStepIn

[13/11/2009 17:21:09] attempt to index a nil value
[13/11/2009 17:21:09] stack traceback:
[13/11/2009 17:21:09] [C]: in function 'doTeleportThing'
[13/11/2009 17:21:09] data/movements/scripts/healingorb.lua:7: in function <data/movements/scripts/healingorb.lua:1>
/END

Code now looks like:

Code:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) 
    if item.itemid == 2180 and item.uid == 5002 then
           if getPlayerStorageValue(cid, 64553) ~= 1 then 
              doCreatureAddHealth(cid, 500)
              doCreatureAddMana(cid, 1500)
              doSendMagicEffect(getCreaturePosition(cid), 12)
              doTeleportThing(cid, fromPosition, TRUE) 
              setPlayerStorageValue(cid,64553,1)
           end
    end
end
 
Can't you just do this?
LUA:
local newPos = {x = 1000, y = 1000, z = 7}
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) 
    if item.itemid == 2180 and item.uid == 5002 then
           if getPlayerStorageValue(cid, 64553) ~= 1 then 
              doCreatureAddHealth(cid, 500)
              doCreatureAddMana(cid, 1500)
              doSendMagicEffect(getCreaturePosition(cid), 12)
              doTeleportThing(cid, newPos)
              setPlayerStorageValue(cid,64553,1)
           end
    end
end
 
Back
Top