• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Movements.xml stepIn trap, nil value, creature not found.

  • Thread starter Thread starter Xikini
  • Start date Start date
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.
iQJVEtI.png

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>
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'. :p

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
How can I modify it to get the desired results?
Thanks,

Xikini
 
Last edited by a moderator:
We need to know the server version. It appears as if you don't have that function in your server. I don't know though. If you are using 1.x maybe it is missing from your compat.lua or need to use the metatmethod. But it could also be that it's not returning a creature there, so you could add an extra check. if getTopCreature(hitArea) then
 
Unsure if I'm doing this correctly.. but
Code:
0
268438612
0
0

[13:50:43.695] [Error - MoveEvents Interface]
[13:50:43.696] In a timer event called from:
[13:50:43.697] data/movements/scripts/trapthrowingstar.lua:onStepIn
[13:50:43.697] Description:
[13:50:43.698] (luaDoTargetCombatHealth) Creature not found

[13:50:43.698] [Error - MoveEvents Interface]
[13:50:43.699] In a timer event called from:
[13:50:43.699] data/movements/scripts/trapthrowingstar.lua:onStepIn
[13:50:43.700] Description:
[13:50:43.700] (luaDoTargetCombatHealth) Creature not found

[13:50:43.721] [Error - MoveEvents Interface]
[13:50:43.722] In a timer event called from:
[13:50:43.723] data/movements/scripts/trapthrowingstar.lua:onStepIn
[13:50:43.723] Description:
[13:50:43.723] (luaDoTargetCombatHealth) Creature not found

[13:50:43.747] [Error - MoveEvents Interface]
[13:50:43.748] In a timer event called from:
[13:50:43.749] data/movements/scripts/trapthrowingstar.lua:onStepIn
[13:50:43.749] Description:
[13:50:43.750] (luaDoTargetCombatHealth) Creature not found
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).uid, 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
     print(getTopCreature(hitArea[i]).uid)
     if getTopCreature(hitArea).uid then
       addEvent(hitTarget, i * 25)
     end
   end
   return true
end
 
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 onStepIn(cid, item, fromPos, item2, toPos)
  function hitTarget(uid)
     doTargetCombatHealth(0, uid, COMBAT_PHYSICALDAMAGE, config.mindmg, config.maxdmg, CONST_ME_NONE)
  end
  doSendDistanceShoot(config[1], config[2], CONST_ANI_THROWINGSTAR)
   for i = 1, #hitArea do
     if isPlayer(getTopCreature(hitArea).uid) then
       addEvent(hitTarget, getTopCreature(hitArea[i]).uid, i * 25)
     end
   end
   return true
end
test, i want to test it but just cant :/
 
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 onStepIn(cid, item, fromPos, item2, toPos)
  function hitTarget(uid)
     doTargetCombatHealth(0, uid, COMBAT_PHYSICALDAMAGE, config.mindmg, config.maxdmg, CONST_ME_NONE)
  end
  doSendDistanceShoot(config[1], config[2], CONST_ANI_THROWINGSTAR)
   for i = 1, #hitArea do
     if isPlayer(getTopCreature(hitArea).uid) then
       addEvent(hitTarget, getTopCreature(hitArea[i]).uid, i * 25)
     end
   end
   return true
end
test, i want to test it but just cant :/
It gives no error's when loaded or stepped into, however no damage is received.
 
oh my bad
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 onStepIn(cid, item, fromPos, item2, toPos)
  function hitTarget(uid)
     doTargetCombatHealth(0, uid, COMBAT_PHYSICALDAMAGE, config.mindmg, config.maxdmg, CONST_ME_NONE)
  end
  doSendDistanceShoot(config[1], config[2], CONST_ANI_THROWINGSTAR)
   for i = 1, #hitArea do
     if isPlayer(getTopCreature(hitArea[i]).uid) then
       addEvent(hitTarget, getTopCreature(hitArea[i]).uid, i * 25)
     end
   end
   return true
end
 
add print(uid) inside hittarget func and show me console
Tried both
Code:
print(uid)
print(getTopCreature(hitArea[i]).uid)
Both provide no error's.
Code:
[14:41:57.786] > Loading AlchemySystem.xml... done.
[14:41:57.793] > Loading buypremium_command.xml... done.
[14:41:57.800] > Loading capped player speed.xml... done.
[14:41:57.807] > Loading change-gold.xml... done.
[14:41:57.813] > Loading changender_command.xml... done.
[14:41:57.815] > Loading custommonsters.xml... done.
[14:41:57.816] > Loading customspells.xml... done.
[14:41:57.829] > Loading Enchanted loot drops.xml... done.
[14:41:57.835] > Loading firstitems.xml... done.
[14:41:57.842] > Loading highscorebook.xml... done.
[14:41:57.861] > Loading Inquisition.xml... done.
[14:41:57.873] > Loading yourname.xml... done.
[14:41:57.873] > 12 mods were loaded.
[14:42:27.876] > Saving server...
[14:42:27.908] > SAVE: Complete in 0.031 seconds using binary house storage.
[14:42:36.794] > Loading AlchemySystem.xml... done.
[14:42:36.801] > Loading buypremium_command.xml... done.
[14:42:36.807] > Loading capped player speed.xml... done.
[14:42:36.815] > Loading change-gold.xml... done.
[14:42:36.821] > Loading changender_command.xml... done.
[14:42:36.824] > Loading custommonsters.xml... done.
[14:42:36.825] > Loading customspells.xml... done.
[14:42:36.838] > Loading Enchanted loot drops.xml... done.
[14:42:36.844] > Loading firstitems.xml... done.
[14:42:36.851] > Loading highscorebook.xml... done.
[14:42:36.871] > Loading Inquisition.xml... done.
[14:42:36.884] > Loading yourname.xml... done.
[14:42:36.885] > 12 mods were loaded.
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 onStepIn(cid, item, fromPos, item2, toPos)
  function hitTarget(uid)
  print(uid)
  doTargetCombatHealth(0, uid, COMBAT_PHYSICALDAMAGE, config.mindmg, config.maxdmg, CONST_ME_NONE)
  end
  doSendDistanceShoot(config[1], config[2], CONST_ANI_THROWINGSTAR)
  for i = 1, #hitArea do
  if isPlayer(getTopCreature(hitArea[i]).uid) then
  addEvent(hitTarget, getTopCreature(hitArea[i]).uid, i * 25)
  end
  end
  return true
end

I'm trying with both a gm, a standard character, and a summon.
 
test the last one
Tried both the original + revision, both same results.
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 onStepIn(cid, item, fromPos, item2, toPos)
  function hitTarget(uid)
  doTargetCombatHealth(0, uid, COMBAT_PHYSICALDAMAGE, config.mindmg, config.maxdmg, CONST_ME_NONE)
  end
  doSendDistanceShoot(config[1], config[2], CONST_ANI_THROWINGSTAR)
  for i = 1, #hitArea do
  if isPlayer(getTopCreature(hitArea[i]).uid) then
  addEvent(hitTarget, getTopCreature(hitArea[i]).uid, i * 25)
  end
  end
  return true
end
 
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 onStepIn(cid, item, fromPos, item2, toPos)
  function hitTarget(uid)
    print(uid)
    doTargetCombatHealth(0, uid, COMBAT_PHYSICALDAMAGE, config.mindmg, config.maxdmg, CONST_ME_NONE)
  end
  doSendDistanceShoot(config[1], config[2], CONST_ANI_THROWINGSTAR)
   for i = 1, #hitArea do
     if isPlayer(getTopCreature(hitArea[i]).uid) then
       addEvent(hitTarget, getTopCreature(hitArea[i]).uid, i * 25)
     end
   end
   return true
end
 
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 onStepIn(cid, item, fromPos, item2, toPos)
  function hitTarget(uid)
    print(uid)
    doTargetCombatHealth(0, uid, COMBAT_PHYSICALDAMAGE, config.mindmg, config.maxdmg, CONST_ME_NONE)
  end
  doSendDistanceShoot(config[1], config[2], CONST_ANI_THROWINGSTAR)
   for i = 1, #hitArea do
     if isPlayer(getTopCreature(hitArea[i]).uid) then
       addEvent(hitTarget, getTopCreature(hitArea[i]).uid, i * 25)
     end
   end
   return true
end
No error.
Just loaded mods, star flies.
No print.

If anyone is interested pm me, I don't mind doing teamviewer.
 
Last edited by a moderator:
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 = {
   {x = 1411, y = 1422, z = 7}, -- hit area for damage between walls
   {x = 1411, y = 1423, z = 7},
   {x = 1411, y = 1424, z = 7},
   {x = 1411, y = 1425, z = 7}
}
function onStepIn(cid, item, fromPos, item2, toPos)
  function hitTarget(uid)
    print(uid)
    doTargetCombatHealth(0, uid, COMBAT_PHYSICALDAMAGE, config.mindmg, config.maxdmg, CONST_ME_NONE)
  end
  doSendDistanceShoot(config[1], config[2], CONST_ANI_THROWINGSTAR)
   for _, pos in ipairs(hitArea) do
     if isPlayer(getTopCreature(pos).uid) then
       addEvent(hitTarget, getTopCreature(pos).uid, i * 25)
     end
   end
   return true
end
test
 
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 = {
   {x = 1411, y = 1422, z = 7}, -- hit area for damage between walls
   {x = 1411, y = 1423, z = 7},
   {x = 1411, y = 1424, z = 7},
   {x = 1411, y = 1425, z = 7}
}
function onStepIn(cid, item, fromPos, item2, toPos)
  function hitTarget(uid)
    print(uid)
    doTargetCombatHealth(0, uid, COMBAT_PHYSICALDAMAGE, config.mindmg, config.maxdmg, CONST_ME_NONE)
  end
  doSendDistanceShoot(config[1], config[2], CONST_ANI_THROWINGSTAR)
   for _, pos in ipairs(hitArea) do
     if isPlayer(getTopCreature(pos).uid) then
       addEvent(hitTarget, getTopCreature(pos).uid, i * 25)
     end
   end
   return true
end
test
Code:
[15:7:27.067] [Error - MoveEvents Interface]
[15:7:27.068] data/movements/scripts/trapthrowingstar.lua:onStepIn
[15:7:27.068] Description:
[15:7:27.069] data/movements/scripts/trapthrowingstar.lua:19: bad argument #1 to 'ipairs' (table expected, got number)
[15:7:27.069] stack traceback:
[15:7:27.069]  [C]: in function 'ipairs'
[15:7:27.069]  data/movements/scripts/trapthrowingstar.lua:19: in function <data/movements/scripts/trapthrowingstar.lua:13>
 
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 = {
   {x = 1411, y = 1422, z = 7}, -- hit area for damage between walls
   {x = 1411, y = 1423, z = 7},
   {x = 1411, y = 1424, z = 7},
   {x = 1411, y = 1425, z = 7}
}
function onStepIn(cid, item, fromPos, item2, toPos)
  function hitTarget(uid)
    print(uid)
    doTargetCombatHealth(0, uid, COMBAT_PHYSICALDAMAGE, config.mindmg, config.maxdmg, CONST_ME_NONE)
  end
  doSendDistanceShoot(config[1], config[2], CONST_ANI_THROWINGSTAR)
   for _, pos in pairs(hitArea) do
     if isPlayer(getTopCreature(pos).uid) then
       addEvent(hitTarget, getTopCreature(pos).uid, i * 25)
     end
   end
   return true
end
 
Back
Top