fire_shock666
New Member
hey there,
i found a script here on otland,
but i have an error in it and i dont know the error.
so if some1 want to take a look at it?
i use cryingdamson 0.3.6 (8.60) V8.2
and this is the error
and this is the script:
i hope you guys can help me out, thanks anyway
i found a script here on otland,
but i have an error in it and i dont know the error.
so if some1 want to take a look at it?
i use cryingdamson 0.3.6 (8.60) V8.2
and this is the error
HTML:
[14/06/2015 15:54:28] [Error - CreatureScript Interface]
[14/06/2015 15:54:28] In a timer event called from:
[14/06/2015 15:54:28] mods/scripts/treasure_goblin/treasure_goblin.lua:onStatsChange
[14/06/2015 15:54:28] Description:
[14/06/2015 15:54:28] (luaGetThingPosition) Thing not found
[14/06/2015 15:54:28] [Error - CreatureScript Interface]
[14/06/2015 15:54:28] In a timer event called from:
[14/06/2015 15:54:29] mods/scripts/treasure_goblin/treasure_goblin.lua:onStatsChange
[14/06/2015 15:54:29] Description:
[14/06/2015 15:54:29] mods/scripts/treasure_goblin/treasure_goblin.lua:90: attempt to index local 'pos' (a boolean value)
[14/06/2015 15:54:29] stack traceback:
[14/06/2015 15:54:29] mods/scripts/treasure_goblin/treasure_goblin.lua:90: in function <mods/scripts/treasure_goblin/treasure_goblin.lua:82>
and this is the script:
HTML:
local offset = {
[NORTH] = { 0, -1 },
[EAST] = { 1, 0 },
[SOUTH] = { 0, 1 },
[WEST] = { -1, 0 },
[SOUTHWEST] = { -1, 1 },
[SOUTHEAST] = { 1, 1 },
[NORTHWEST] = { -1, -1 },
[NORTHEAST] = { 1, -1 }
}
-- for how long the goblin will run away before opening the portal
local TIMEOUT_SECONDS = 40
-- how long is the delay between opening the portal and going through it
local TIMEOUT_ESCAPE_ROUTINE = 6
local TELEPORT_ITEMID = 1387
-- how many coins the goblin has in the beggining
-- he drops a small amount from this reserve each time he's hit
local GOLD_RESERVE = 100
-- what type of coins he has
local GOLD_ITEMID = 2152 -- platinum coin
local bank = nil
local tppos = { x = 1, y = 1, z = 1}
local lastpos = { x = 1, y = 1, z = 1}
function onStatsChange(creature, cid, type, combat, value)
if type ~= STATSCHANGE_HEALTHLOSS then
return true
end
if not bank then
-- that's the first hit so start the timer
bank = GOLD_RESERVE
getawayRoutine(creature, 0)
CURRENT_STATE = STATE_RUNNING
end
-- now it's time to drop some gold
if bank > 0 then
local drop = math.random(1, math.ceil(bank / 15))
bank = bank - drop
doCreateItem(GOLD_ITEMID, drop, getCreaturePosition(creature))
end
return true
end
function getawayRoutine(creature, timer)
if timer >= TIMEOUT_SECONDS then
escapeRoutine(creature, 0)
else
addEvent(getawayRoutine, 1000, creature, timer + 1)
-- drop some minor amounts of gold while running away
local pos = getCreaturePosition(creature)
if pos.x ~= lastpos.x or pos.y ~= lastpos.y then
doCreateItem(2148, math.random(1, 9), pos)
lastpos = pos
end
end
end
function getTeleportPosition(creature)
local pos = getCreaturePosition(creature)
local dir = getCreatureLookDirection(creature)
pos.x = pos.x + offset[dir][1]
pos.y = pos.y + offset[dir][2]
return pos
end
function escapeRoutine(creature, timer)
if not isCreature(creature) then
return
elseif timer >= TIMEOUT_ESCAPE_ROUTINE then
finishEscapeRoutine(creature)
else
if timer == 0 then
tppos = getTeleportPosition(creature)
tppos.stackpos = 253
doCreateItem(TELEPORT_ITEMID, 1, tppos)
-- doCreatureSetNoMove(creature, true) doesn't seem to work on monsters - tested on TFS 0.3.7-preview
-- so let's slow him down a bit...
doChangeSpeed(creature, -getCreatureBaseSpeed(creature))
end
addEvent(escapeRoutine, 1000, creature, timer + 1)
end
end
function finishEscapeRoutine(creature)
doSendMagicEffect(getCreaturePosition(creature), CONST_ME_TELEPORT)
doRemoveCreature(creature)
doRemoveItem(getTileItemById(tppos, TELEPORT_ITEMID).uid)
end
i hope you guys can help me out, thanks anyway