I'm using TFS 1.3:
Lua Script Error: [Action Interface]
data/actions/scripts/tools/minerar.luanUse
LuaScriptInterface::luaAddEvent(). Argument #3 is unsafe
stack traceback:
[C]: in function 'addEvent'
data/actions/scripts/tools/minerar.lua:18: in function 'vinteVezes'
data/actions/scripts/tools/minerar.lua:34: in function <data/actions/scripts/tools/minerar.lua:28>
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/actions/scripts/tools/minerar.lua:9: attempt to index local 'player' (a number value)
stack traceback:
[C]: in function '__index'
data/actions/scripts/tools/minerar.lua:9: in function <data/actions/scripts/tools/minerar.lua:8>
Lua:
local stone_id = 19959
function vinteMinutos(toPosition) -- Recreate the stone after 20 minutes.
Game.createItem(stone_id, 1, toPosition)
return true
end
function vinteVezes(player, toPosition) -- Repeat this function every second. Repeat this twenty times.
if player:getStorageValue(mining) <= 20 then
toPosition:sendMagicEffect(CONST_ME_BLOCKHIT) -- Effect while mining.
player:setStorageValue(mining, player:getStorageValue(mining) + 1)
if player:getStorageValue(mining) == 20 then
player:setStorageValue(started, 0)
end
player:addItem(2225, 1, true) -- Piece of Iron
player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Sucesso!") -- Success message!
addEvent(vinteVezes, 1*1000, player, toPosition) -- Perform this function after 1 second.
else
-- Remove stone.
player:setStorageValue(mining, 0)
addEvent(vinteMinutos, 20*60*1000, toPosition) -- Perform this function after 20 minutes.
end
return true
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local miningSkill = player:getStorageValue(SKILL_MINERADOR)
local random = math.random(1, 100000)
if random <= (miningSkill*500) then
player:setStorageValue(ESTIMA, getPlayerStorageValue(player, ESTIMA) + 1) -- Adds a reputation point.
vinteVezes(player, toPosition)
else
toPosition:sendMagicEffect(CONST_ME_POFF) -- Effect while mining.
player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Falha!") -- Failure message.
addEvent(vinteMinutos, 20*60*1000, toPosition) -- Perform this function after 20 minutes.
end
return true
end
-- To do:
-- It makes it impossible for the character to move for twenty seconds.
-- It makes it impossible for the character to use spells for twenty seconds.
-- Impossible for the character to attack for twenty seconds.
-- It prevents the character from leaving the game for twenty seconds.