• 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!

Lua tfs 1.3 manarune from % to standard calculating value

Opatulek

New Member
Joined
Apr 25, 2021
Messages
22
Reaction score
2
Hello! If anyone can help me with change calculating value in this script I I will be grateful:

local runeTest = Spell(SPELL_RUNE) function runeTest.onCastSpell(creature, variant) local target = Tile(variant:getPosition()):getTopVisibleCreature(creature) if not target or not target:isPlayer() then creature:getPosition():sendMagicEffect(CONST_ME_POFF) return false end local maxMana = creature:getMaxMana() / 100 target:addMana(math.random(maxMana * 10, maxMana * 15)) target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) target:say("MR Aaahh!") return true end runeTest:name("ManaRune#1") runeTest:isAggressive(false) runeTest:runeId(2280) runeTest:blockWalls(true) runeTest:magicLevel(0) runeTest:level(1) runeTest:group("support") runeTest:vocation("sorcerer", "master sorcerer") runeTest:id(24) runeTest:cooldown(1 * 1000) runeTest:groupCooldown(1 * 1000) runeTest:isPremium(true)

to

function onGetFormulaValues(player, level, magicLevel) local min = (level / 5) + (magicLevel * 3.2) + 20 local max = (level / 5) + (magicLevel * 5.4) + 40 return min, max end
 
Hello! If anyone can help me with change calculating value in this script I I will be grateful:

local runeTest = Spell(SPELL_RUNE) function runeTest.onCastSpell(creature, variant) local target = Tile(variant:getPosition()):getTopVisibleCreature(creature) if not target or not target:isPlayer() then creature:getPosition():sendMagicEffect(CONST_ME_POFF) return false end local maxMana = creature:getMaxMana() / 100 target:addMana(math.random(maxMana * 10, maxMana * 15)) target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) target:say("MR Aaahh!") return true end runeTest:name("ManaRune#1") runeTest:isAggressive(false) runeTest:runeId(2280) runeTest:blockWalls(true) runeTest:magicLevel(0) runeTest:level(1) runeTest:group("support") runeTest:vocation("sorcerer", "master sorcerer") runeTest:id(24) runeTest:cooldown(1 * 1000) runeTest:groupCooldown(1 * 1000) runeTest:isPremium(true)

to

function onGetFormulaValues(player, level, magicLevel) local min = (level / 5) + (magicLevel * 3.2) + 20 local max = (level / 5) + (magicLevel * 5.4) + 40 return min, max end
Lua:
local runeTest = Spell(SPELL_RUNE)
function runeTest.onCastSpell(creature, variant)
local player = Player(cid)
local level = player:getLevel()
local magicLevel= player:getMagicLevel()
local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
if not target or not target:isPlayer() then
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local min = ((level / 5) + (magicLevel * 3.2) + 20)
local max = ((level / 5) + (magicLevel * 5.4) + 40)
target:addMana(math.random(min, max))
target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
target:say("MR Aaahh!")
return true
end
runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2280)
runeTest:blockWalls(true)
runeTest:magicLevel(0)
runeTest:level(1)
runeTest:group("support")
runeTest:vocation("sorcerer", "master sorcerer")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)
 
manarune.lua:callback
manarune.lua:4: attempt to index local 'player' (a nil value)
stack traceback:
[C]: in function '__index'
manarune.lua:4: in function manarune.lua:2>
 
manarune.lua:callback
manarune.lua:4: attempt to index local 'player' (a nil value)
stack traceback:
[C]: in function '__index'
manarune.lua:4: in function manarune.lua:2>

Lua:
local runeTest = Spell(SPELL_RUNE)

function runeTest.onCastSpell(cid, variant, target)

local player = Player(cid)
local level = player:getLevel()
local magicLevel= player:getMagicLevel()

    if not target then
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
  
    local min = ((level / 5) + (magicLevel * 3.2) + 20)
    local max = ((level / 5) + (magicLevel * 5.4) + 40)
    target:addMana(math.random(min, max))
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    target:say("MR Aaahh!")
    return true
end

runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2280)
runeTest:blockWalls(true)
runeTest:magicLevel(0)
runeTest:level(1)
runeTest:group("support")
runeTest:vocation("sorcerer", "master sorcerer")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)
runeTest:register()
 
Last edited:
Lua:
 [error] Lua script error: manarune.lua:callback
manarune.lua:16: attempt to index local 'target' (a boolean value)
stack traceback:
        [C]: in function '__index'
        manarune.lua:16: in function manarune.lua:3>
 
Lua:
 [error] Lua script error: manarune.lua:callback
manarune.lua:16: attempt to index local 'target' (a boolean value)
stack traceback:
        [C]: in function '__index'
        manarune.lua:16: in function manarune.lua:3>

Lua:
local runeTest = Spell(SPELL_RUNE)

function runeTest.onCastSpell(cid, target)

    if not target then
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
    
    local targetPlayer = Player(target)
    local player = Player(cid)
    local level = player:getLevel()
    local magicLevel= player:getMagicLevel()
 
    local min = ((level / 5) + (magicLevel * 3.2) + 20)
    local max = ((level / 5) + (magicLevel * 5.4) + 40)
    local addmana = math.random(min,max)
    targetPlayer:addMana(addmana)
    targetPlayer:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    targetPlayer:say('Ahhh', TALKTYPE_ORANGE_1)
    return true
end

runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2280)
runeTest:blockWalls(true)
runeTest:magicLevel(0)
runeTest:level(1)
runeTest:group("support")
runeTest:vocation("sorcerer", "master sorcerer")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)
runeTest:register()
Post automatically merged:

im dumb honestly
 
Last edited:
Lua:
 Lua script error: manarune.lua:callback
manarune.lua:18: attempt to index local 'targetPlayer' (a nil value)
stack traceback:
        [C]: in function '__index'
        manarune.lua:18: in function manarune.lua:3>


meh, still have error.
 
Lua:
 Lua script error: manarune.lua:callback
manarune.lua:18: attempt to index local 'targetPlayer' (a nil value)
stack traceback:
        [C]: in function '__index'
        manarune.lua:18: in function manarune.lua:3>


meh, still have error.

i will check that soon if no one fixed it befor
sorry :D
 
Lua:
local runeTest = Spell(SPELL_RUNE)

function runeTest.onCastSpell(player, variant)
    local targetPlayer = Creature(variant.number)
    if not targetPlayer or not targetPlayer:isPlayer() then
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
    local level = player:getLevel()
    local magicLevel= player:getMagicLevel()
 
    local min = ((level / 5) + (magicLevel * 3.2) + 20)
    local max = ((level / 5) + (magicLevel * 5.4) + 40)
    local addmana = math.random(min,max)
    targetPlayer:addMana(addmana)
    targetPlayer:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    targetPlayer:say('Ahhh', TALKTYPE_ORANGE_1)
    return true
end

runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2280)
runeTest:blockWalls(true)
runeTest:magicLevel(0)
runeTest:level(1)
runeTest:group("support")
runeTest:vocation("sorcerer", "master sorcerer")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)
runeTest:register()
 
Here it is and I took the trouble to try it first ;)

data/scripts/runeTest.lua
Lua:
local runeTest = Spell(SPELL_RUNE)

function runeTest.onCastSpell(creature, variant)
    local target = Player(variant:getNumber())
    if not target then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    local level, magLvl = creature:getLevel(), creature:getMagicLevel()
    target:addMana(math.random((level / 5) + (magLvl * 3.2) + 20, (level / 5) + (magLvl * 5.4) + 40))
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    target:say("MR Aaahh!")
    return true
end

runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2280)
runeTest:blockWalls(true)
runeTest:needTarget(true)
runeTest:magicLevel(0)
runeTest:level(1)
runeTest:group("support")
runeTest:vocation("sorcerer", "master sorcerer")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)
runeTest:register()
 
Last edited:
Here it is and I took the trouble to try it first ;)

data/scripts/runeTest.lua
Lua:
local runeTest = Spell(SPELL_RUNE)

function runeTest.onCastSpell(creature, variant)
    local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
    if not target or not target:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    local level, magLvl = creature:getLevel(), creature:getMagicLevel()
    target:addMana(math.random((level / 5) + (magLvl * 3.2) + 20, (level / 5) + (magLvl * 5.4) + 40))
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    target:say("MR Aaahh!")
    return true
end

runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2280)
runeTest:blockWalls(true)
runeTest:magicLevel(0)
runeTest:level(1)
runeTest:group("support")
runeTest:vocation("sorcerer", "master sorcerer")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)
runeTest:register()
thanks! it is working <3
 
I don't mean to be rude but I recommend using
Lua:
Creature(variant.number)
because if you use the rune on the target list it will not work using variant:getPosition()

add
Lua:
runeTest:needTarget(true)
if you use my script as well
 
I don't mean to be rude but I recommend using
Lua:
Creature(variant.number)
because if you use the rune on the target list it will not work using variant:getPosition()

add
Lua:
runeTest:needTarget(true)
if you use my script as well
I don't know which version you are testing your scripts, but:
GIF 11-05-2021 05-23-15 p. m..gif
working :D
 
I don't know which version you are testing your scripts, but:
View attachment 58580
working :D
It works, yeah, but it will always take the top creature, even if you use it on yourself, if someone (be it monster or player) moves into your position they will be considered the top creature, so in stairs you will be using the mana rune in another person if you are not the last to enter the sqm
 
It works, yeah, but it will always take the top creature, even if you use it on yourself, if someone (be it monster or player) moves into your position they will be considered the top creature, so in stairs you will be using the mana rune in another person if you are not the last to enter the sqm
With this explanation now everything makes sense, you're right gentleman! I already updated the code so that no one else can get confused
 
Back
Top