Adding a script to a buff

Need help with scripting. I made an armor with a backpack that i Injected a buff to. I want the buff to increase the backpack size of the hearthling wearing it. So far I have this:

backpack_buff.json

{ "type": "buff", "axis": "buff", "display_name": "i18n(random_additions:data.buffs.backpack.backpack_buff.display_name)", "description": "i18n(random_additions:data.buffs.backpack.backpack_buff.description)", "icon": "file(backpack_buff.png)", "modifiers": { "speed": { "add": 25 } }, "script": "file(backpack_buff.lua)", "backpack_size_increase": "12" }

backpack_buff.lua

[code]local backpack_buff = class()

function backpack_buff:increase_backpack_size(args)
local sc = self._sv._entity:get_component(‘stonehearth:storage’)
sc:change_max_capacity(args.backpack_size_increase)
end

return backpack_buff[/code]

I know something is wrong somewhere, but I have no clue where. Any help will be appreciated.

I believe the issue lies when you are calling

local sc = self._sv._entity:get_component('stonehearth:storage')

and this is due to the fact that in the trapper.lua (which is a subclass of base_job.lua) self._sv._entity is initialized as the entity that the trapper.lua is referring to.

In your class you have not initialised self._sv._entity as anything, thus the command is not being applied.

This is what I think is the issue here, not 100%. I haven’t delved into modifying entities like this, so I can’t really be of much more help than that :stuck_out_tongue: .