X
Xikini
Guest
The Forgotten Server, version 0.3.7_SVN (Crying Damson)
Trying to make a wall trap that gives an animation, and then attempts to 'follow the area' of the projectile.
Picture for reference.
I know it takes about 100/200 milliseconds to travel the width of the area, and I can fiddle with that later.
Current problem is I don't seem to be doing something correctly.
When I step on the tile I get 4 instances of this error,
Which makes sense, seeing as it has no idea where 'i' is.
I don't really care if the loop doesn't work, I just need it to 'work'.
Here's my current script.
How can I modify it to get the desired results?
Thanks,
Xikini
Trying to make a wall trap that gives an animation, and then attempts to 'follow the area' of the projectile.
Picture for reference.
I know it takes about 100/200 milliseconds to travel the width of the area, and I can fiddle with that later.
Current problem is I don't seem to be doing something correctly.
When I step on the tile I get 4 instances of this error,
Code:
[13:30:47.007] [Error - MoveEvents Interface]
[13:30:47.007] In a timer event called from:
[13:30:47.007] data/movements/scripts/trapthrowingstar.lua:onStepIn
[13:30:47.008] Description:
[13:30:47.008] attempt to index a nil value
[13:30:47.008] stack traceback:
[13:30:47.008] [C]: in function 'getTopCreature'
[13:30:47.009] data/movements/scripts/trapthrowingstar.lua:14: in function <data/movements/scripts/trapthrowingstar.lua:13>
I don't really care if the loop doesn't work, I just need it to 'work'.
Here's my current script.
Code:
local config = {
[1] = {x = 1411, y = 1421, z = 7}, -- top wall for animation
[2] = {x = 1411, y = 1426, z = 7}, -- bottom wall for animation
mindmg = -40,
maxdmg = -200
}
local hitArea = {
[1] = {x = 1411, y = 1422, z = 7}, -- hit area for damage between walls
[2] = {x = 1411, y = 1423, z = 7},
[3] = {x = 1411, y = 1424, z = 7},
[4] = {x = 1411, y = 1425, z = 7}
}
function hitTarget()
doTargetCombatHealth(0, getTopCreature(hitArea[i]), COMBAT_PHYSICALDAMAGE, config.mindmg, config.maxdmg, CONST_ME_NONE)
end
function onStepIn(cid, item, fromPos, item2, toPos)
doSendDistanceShoot(config[1], config[2], CONST_ANI_THROWINGSTAR)
for i = 1, #hitArea do
addEvent(hitTarget, i * 25)
end
return true
end
Thanks,
Xikini
Last edited by a moderator: