Hi, i have just started trying to learn a bit more about the basic scripting but i have run into a problem
Not made for TFS 1.x at the begining but have tryed to translate
The basic thing is that i want it to work one way if you are knight and one way if you are not
code:
Error:
Not made for TFS 1.x at the begining but have tryed to translate
The basic thing is that i want it to work one way if you are knight and one way if you are not
code:
Lua:
local runes = {
[2298] = {
voc = {1, 2, 3, 4, 5, 6, 7, 8},
min = 'level * 1 + maglv * 6',
max = 'level * 1 + maglv * 8'
}
}
function onUse(player, item, fromPosition, itemEx, toPosition)
local i = runes[item.itemid]
if isInArray(i.voc, player:getVocation()) then
if player == true then
if player:getVocation()(player) == 4 or player:getVocation()(player) == 8 then
level, maglv = getPlayerLevel(player), getPlayerMagLevel(player)
player:addMana(itemEx.uid, (math.random( 125, 175)))
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:say(itemEx.uid, "First Manarune", TALKTYPE_MONSTER_SAY)
else
level, maglv = getPlayerLevel(player), getPlayerMagLevel(player)
player:addMana(itemEx.uid, math.random(loadstring('return '..i.min)(), loadstring('return '..i.max)()))
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:say(itemEx.uid, "First Manarune", TALKTYPE_MONSTER_SAY)
end
else
doPlayerSendDefaultCancel(player, RETURNVALUE_CANONLYUSETHISRUNEONCREATURES)
end
else
doPlayerSendCancel(player, 'Your vocation cannot use this rune.')
end
return true
end
Error:
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/liquids/first_manarune.lua:onUse
data/actions/scripts/liquids/first_manarune.lua:10: attempt to index global 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/actions/scripts/liquids/first_manarune.lua:10: in function <data/actions/scripts/liquids/first_manarune.lua:8>