• 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 getThingFromPos - a joke.

sestorme

Member
Joined
Dec 9, 2011
Messages
272
Reaction score
6
Location
Birmingham, UK
Code:
local combat = createCombatObject()

function onTargetTile(cid, pos)
local target = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=254})
local dur = 0.25 + ((0.25 * getPlayerStorageValue(cid, 1002)) * getCreatureStorage(target.uid, 2000))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "".. dur .."")
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end

Simply:

[27/01/2013 18:06:17] [Error - Spell Interface]
[27/01/2013 18:06:17] In a callback: data/spells/scripts/attack/stone shower.lua:eek:nTargetTile
[27/01/2013 18:06:17] (Unknown script file)
[27/01/2013 18:06:17] Description:
[27/01/2013 18:06:17] (luaGetCreatureStorage) Creature not found

[27/01/2013 18:06:17] [Error - Spell Interface]
[27/01/2013 18:06:17] In a callback: data/spells/scripts/attack/stone shower.lua:eek:nTargetTile
[27/01/2013 18:06:17] (Unknown script file)
[27/01/2013 18:06:17] Description:
[27/01/2013 18:06:17] data/spells/scripts/attack/stone shower.lua:21: attempt to perform arithmetic on a boolean value
[27/01/2013 18:06:17] stack traceback:
[27/01/2013 18:06:17] data/spells/scripts/attack/stone shower.lua:21: in function <data/spells/scripts/attack/stone shower.lua:18>
[27/01/2013 18:06:17] [C]: in function 'doCombat'
[27/01/2013 18:06:17] data/spells/scripts/attack/stone shower.lua:28: in function <data/spells/scripts/attack/stone shower.lua:27>

It's a rune that requires target, so apparently it is there, but for some reason script can't return it. What's wrong?
 
made by is why have "" ...dur... "" <- i remember only are " not ""
try
Lua:
local combat = createCombatObject()

function onTargetTile(cid, pos)
local target = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=254})
local dur = 0.25 + ((0.25 * getPlayerStorageValue(cid, 1002)) * getCreatureStorage(target.uid, 2000))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, " .. dur .. ")

end

setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end
 
Lua:
local combat = createCombatObject()
 
function onTargetTile(cid, pos)
local target = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=254})
local dur = 0.25 + ((0.25 * getPlayerStorageValue(cid, 1002)) * getCreatureStorage(target.uid, 2000))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, dur)
 
end
 
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
 
function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end
 
This is exactly what you should prevent in scripting.
You cannot expect a creature to be existing at a certain position and create the script just like it is a given fact that it is there.

When you get the thing from stackpos 254 there might be nothing, so make sure to check whether target.uid > 0 and isCreature(target.uid) first before you proceed.
 
If it is a stone shower rune it has an area and onTargetTile will be executed for every tile..
 
Back
Top Bottom