#why won't modifier give me

1 messages · Page 1 of 1 (latest)

outer badger
#

i'm trying to write my own item, but for some reason the lua file for the item is not tied up, the path works exactly because after clicking the right mouse button on the path, vscode opens the necessary file for me, please help me for an hour I've been racking my brain

LinkLuaModifier( "modifier_item_bkb", "items/item_bkb.lua", LUA_MODIFIER_MOTION_NONE )
--Abilities
if item_bkb == nil then
    item_bkb = class({})
end
function item_bkb:GetIntrinsicModifierName()
    return "modifier_item_bkb"
end
---------------------------------------------------------------------
--Modifiers
if modifier_item_bkb == nil then
    modifier_item_bkb = class({})
end
function modifier_item_bkb:IsHidden() return false end
function modifier_item_bkb:OnCreated(params)
    print('test')
    if IsServer() then
    end
end
function modifier_item_bkb:OnRefresh(params)
    if IsServer() then
    end
end
function modifier_item_bkb:OnDestroy()
    if IsServer() then
    end
end
function modifier_item_bkb:DeclareFunctions()
    return {
        MODIFIER_PROPERTY_STATS_STRENGTH_BONUS
    }
end

function modifier_item_bkb:GetModifierBonusStats_Strength()
    return 1000
end

#

I tried to connect the script from another item, but the modifier does not work from it either, although it works correctly on the original item

keen jacinth
#

Before we get into the code, a small tip: you should try to give your modifier names names that are definitely unique. modifier_item_bkb has a chance to actually be the same name as the official Valve BKB modifier name.

A good way to handle this would be to add some kind of "prefix" - for example, dota imba always added imba_... to the name, e.g. modifier_imba_item_bkb.

#

The code looks straightforward. Do you see any kind of error message in console?

outer badger
#

no one error

#

there would be errors, I would know what to do, but here the file simply does not work

keen jacinth
#

If you put prints before and after the LinkLuaModifier, do you see them both? Same for before/after modifier_item_bkb?

outer badger
#

changed modifier name to unique didn't help

keen jacinth
#

Also, I'm seeing that your KV says the item name is item_bkb_custom but your item class name is item_bkb in lua

#

Which is probably wrong

outer badger
#
print('before')
LinkLuaModifier( "modifier_item_bkb_aa", "items/item_bkb_aa.lua", LUA_MODIFIER_MOTION_NONE )
print('after')
--Abilities
if item_bkb_aa == nil then
    item_bkb_aa = class({})
end
function item_bkb_aa:GetIntrinsicModifierName()
    print('addedmodifier')
    return "modifier_item_bkb"
end
---------------------------------------------------------------------
--Modifiers
if modifier_item_bkb_aa == nil then
    modifier_item_bkb_aa = class({})
end
function modifier_item_bkb_aa:IsHidden() return false end
function modifier_item_bkb_aa:OnCreated(params)
    print('test')
    if IsServer() then
    end
end
function modifier_item_bkb_aa:OnRefresh(params)
    if IsServer() then
    end
end
function modifier_item_bkb_aa:OnDestroy()
    if IsServer() then
    end
end
function modifier_item_bkb_aa:DeclareFunctions()
    return {
        MODIFIER_PROPERTY_STATS_STRENGTH_BONUS
    }
end

function modifier_item_bkb_aa:GetModifierBonusStats_Strength()
    return 1000
end
keen jacinth
#

Try that

#

change:

if item_bkb_aa == nil then
    item_bkb_aa = class({})
end
function item_bkb_aa:GetIntrinsicModifierName()
    print('addedmodifier')
    return "modifier_item_bkb"
end

to:

if item_bkb_custom == nil then
    item_bkb_custom = class({})
end
function item_bkb_aa:GetIntrinsicModifierName()
    print('addedmodifier')
    return "modifier_item_bkb"
end
outer badger
#

i replaced it in kv

keen jacinth
#

OK, good. Restart?

outer badger
#

it worked

#

what is wrong with the item being called exactly the same as the script and not using dotA keywords?

feral flicker
keen jacinth
#

Yep. In other words, the name of the item is also the class name in lua - they must be identical.
The name of the item doesn't have to be the same name of the file, though. For example, the name could be item_bkb_aa and the ScriptFile could be item_kbk - this is fine, as long as the file is named item_kbk.lua and in lua you do item_bkb_aa = class({}).