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

[TFS 1.3] Item Abilities via Lua V2

Hello i tried to implement this to latest tfs pull. I had no errors during compilation or during server startup.
For testing i was using action script posted somewhere here on otland. The problem is when i use this action script it shows 0 error in log, the magic effect will appear but the target item remains the same no bonuses.

<action itemid="8300" script="custom/upgrade.lua" />
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local position = player:getPosition()
    target:setAbility(ITEM_ABILITY_ABSORBPHYSICAL, 10)
    target:setAbility(ITEM_ABILITY_SKILL_SWORD, 5)
    position:sendMagicEffect(CONST_ME_MAGIC_RED)
    return true
end
EDIT:
The sword fighting is added (so its working) i just cant see the description of item with bonuses
 
Somebody can help?

[2021-12-06 13:29:06.016] [error] Lua script error: data/global.lua
[2021-12-06 13:29:06.016] [error] data/lib/compat/compat.lua:1388: table index is nil
stack traceback:
[C]: in function '__newindex'
data/lib/compat/compat.lua:1388: in main chunk
[C]: in function 'dofile'
data/lib/lib.lua:5: in main chunk
[C]: in function 'dofile'
data/global.lua:2: in main chunk
[2021-12-06 13:29:06.017] [info] Loading data/global.lua
[2021-12-06 13:29:06.018] [error] Cannot load: data/global.lua
 

Attachments

  • Zrzut ekranu (821).png
    Zrzut ekranu (821).png
    14.3 KB · Views: 10 · VirusTotal
Last edited:
Somebody can help?

[2021-12-06 13:29:06.016] [error] Lua script error: data/global.lua
[2021-12-06 13:29:06.016] [error] data/lib/compat/compat.lua:1388: table index is nil
stack traceback:
[C]: in function '__newindex'
data/lib/compat/compat.lua:1388: in main chunk
[C]: in function 'dofile'
data/lib/lib.lua:5: in main chunk
[C]: in function 'dofile'
data/global.lua:2: in main chunk
[2021-12-06 13:29:06.017] [info] Loading data/global.lua
[2021-12-06 13:29:06.018] [error] Cannot load: data/global.lua
post your compat.lua
 
Limit 25000 characters :s
Edit: problem with that solved, but i have next problem, i can't see items when i double click on it, and when using crystal for adding bonus i have new problem:
Lua:
[2021-13-06 18:00:25.422] [error] Lua script error: data/events/scripts/player.lua:Player@onLook
[2021-13-06 18:00:25.423] [error] ...tservbr-global\data\scripts\ItemAbilities\extensions.lua:33: attempt to call method 'getAbilities' (a nil value)
stack traceback:
        [C]: in function 'getAbilities'
        ...tservbr-global\data\scripts\ItemAbilities\extensions.lua:33: in function 'getAbilities'
        data/lib/core/item.lua:294: in function 'getDescription'
        data/events/scripts/player.lua:138: in function <data/events/scripts/player.lua:121>
[2021-13-06 18:00:25.872] [error] Lua script error: data/events/scripts/player.lua:Player@onLook
[2021-13-06 18:00:25.873] [error] ...tservbr-global\data\scripts\ItemAbilities\extensions.lua:33: attempt to call method 'getAbilities' (a nil value)
stack traceback:
        [C]: in function 'getAbilities'
        ...tservbr-global\data\scripts\ItemAbilities\extensions.lua:33: in function 'getAbilities'
        data/lib/core/item.lua:294: in function 'getDescription'
        data/events/scripts/player.lua:138: in function <data/events/scripts/player.lua:121>
[2021-13-06 18:10:25.542] [error] Lua script error: data/events/scripts/player.lua:Player@onLook
[2021-13-06 18:10:25.542] [error] ...tservbr-global\data\scripts\ItemAbilities\extensions.lua:33: attempt to call method 'getAbilities' (a nil value)
stack traceback:
        [C]: in function 'getAbilities'
        ...tservbr-global\data\scripts\ItemAbilities\extensions.lua:33: in function 'getAbilities'
        data/lib/core/item.lua:294: in function 'getDescription'
        data/events/scripts/player.lua:138: in function <data/events/scripts/player.lua:121>
[2021-13-06 18:10:25.940] [error] Lua script error: data/events/scripts/player.lua:Player@onLook
[2021-13-06 18:10:25.940] [error] ...tservbr-global\data\scripts\ItemAbilities\extensions.lua:33: attempt to call method 'getAbilities' (a nil value)
stack traceback:
        [C]: in function 'getAbilities'
        ...tservbr-global\data\scripts\ItemAbilities\extensions.lua:33: in function 'getAbilities'
        data/lib/core/item.lua:294: in function 'getDescription'
        data/events/scripts/player.lua:138: in function <data/events/scripts/player.lua:121>

and this:

Lua:
[2021-13-06 18:21:21.835] [warning] [Events::load] - Unknown player method: onInventoryUpdate
 

Attachments

Last edited:
Hello @Infernum and OTLanders,

Thanks for this amazing contribution!
I am using it for my server, and I encountered a strange thing:

Situation 1: HP regen only
When I set ITEM_ABILITY_HEALTHGAIN and ITEM_ABILITY_HEALTHTICKS and I equip the item, it don't work.

Situation 2: MP regen only

ITEM_ABILITY_MANAGAIN and ITEM_ABILITY_MANATICKS and I equip the item, it WORKS.

Situation 2: MP and HP regen
However, when I set all ITEM_ABILITY_HEALTHGAIN and ITEM_ABILITY_HEALTHTICKS and also ITEM_ABILITY_MANAGAIN and ITEM_ABILITY_MANATICKS, then it WORK for both mana and hp.

I am setting always the following values (for all the situations that I mentioned above):
ITEM_ABILITY_HEALTHGAIN = 2
ITEM_ABILITY_HEALTHTICKS = 10000 --10sec
ITEM_ABILITY_MANAGAIN = 2
ITEM_ABILITY_MANATICKS = 10000 --10sec

I hope anyone can help,
Cheers,
Zyzz
 
For some reason on nekiro's 772 downgrade i cant see following attributes on items :
Checked everything inside code no errors. Stats are loading fine i just dont see following abilities when i click on Item


Lua:
ITEM_ABILITY_MANALEECHAMOUNT,
ITEM_ABILITY_LIFELEECHAMOUNT,
ITEM_ABILITY_STAT_MAXHITPOINTS,
ITEM_ABILITY_STAT_MAXMANAPOINTS,
ITEM_ABILITY_MANAGAIN,
ITEM_ABILITY_HEALTHGAIN

Does someone knows how to show them properly in description ?
 
For some reason on nekiro's 772 downgrade i cant see following attributes on items :
Checked everything inside code no errors. Stats are loading fine i just dont see following abilities when i click on Item


Lua:
ITEM_ABILITY_MANALEECHAMOUNT,
ITEM_ABILITY_LIFELEECHAMOUNT,
ITEM_ABILITY_STAT_MAXHITPOINTS,
ITEM_ABILITY_STAT_MAXMANAPOINTS,
ITEM_ABILITY_MANAGAIN,
ITEM_ABILITY_HEALTHGAIN

Does someone knows how to show them properly in description ?
Fixed i had a typo in extensions.lua. so it would iterate only first index which is crit under special attributes
 
Does anyone else has this weird behavior that if take the item off the slot i still have all the conditions. If i equip another item it will reset and show correct values.
TFS 1.5 nekiro downgrade. How to fix unequip/drop item to remove its conditions from player ?
 
Does anyone else has this weird behavior that if take the item off the slot i still have all the conditions. If i equip another item it will reset and show correct values.
TFS 1.5 nekiro downgrade. How to fix unequip/drop item to remove its conditions from player ?
I have 1.5|8.00 also have this bug
 
Does anyone else has this weird behavior that if take the item off the slot i still have all the conditions. If i equip another item it will reset and show correct values.
TFS 1.5 nekiro downgrade. How to fix unequip/drop item to remove its conditions from player ?
Alright managed to fix it. The bug was caused in file extensions.lua:
Go to the function function Player.getAbilities(self, keymap):
There you will find a local variable abilities = { }, which if no item is equiped on inventory it will return a empty table,
and thus it will NOT return abilities set to 0.
What i've done is re-define this local variable to:

Lua:
local abilities = Item.getRawAbilitiesInit()

And also, introduce this funtion somewhere in the same lua script (for example after function Item.getRawAbilities(self)):
Code:
function Item.getRawAbilitiesInit()
    local abilities = {}
    for line in io.lines('data/scripts/ItemAbilities/1_enums.lua') do
        local key = line:match(" = '([%a_]*)'")
        abilities[key] = 0
    end
    return abilities
end

It may not be the fanciest workaround but now abilities is set to 0 instead of empty table.
Cheers!
PD edited function
 
Last edited:
Alright managed to fix it. The bug was caused in file extensions.lua:
Go to the function function Player.getAbilities(self, keymap):
There you will find a local variable abilities = { }, which if no item is equiped on inventory it will return a empty table,
and thus it will NOT return abilities set to 0.
What i've done is re-define this local variable to:

Lua:
local abilities = Item.getRawAbilitiesInit()

And also, introduce this funtion somewhere in the same lua script (for example after function Item.getRawAbilities(self)):
Code:
function Item.getRawAbilitiesInit()
    local abilities = {}
    for line in io.lines('data/scripts/ItemAbilities/1_enums.lua') do
        local key = line:match(" = '([%a_]*)'")
        abilities[key] = 0
    end
    return abilities
end

It may not be the fanciest workaround but now abilities is set to 0 instead of empty table.
Cheers!
PD edited function
Thanks man appreciate it ;)
 
Hi,
I've found one problem (and in couple next days a solution) related to maxhitpointspercent / maxmanapointspercent. Max mana/hp percent was stacking way too fast with every subsequent equipped item. More details if someone is interested: thread related.

Thanks for huge contribution with all these scripts!
 
Back
Top