Allow passing in custom params to Item.create() that get set before on_init_params #206
Labels
enhancement
New feature or request
modding
Concerns new modding features beyond the scope of porting vanilla's codebase.
Say I want to change which character gets displayed on a card or figure, using an event hook. Normally I would want to run this code inside
on_item_generate
or something:But this doesn't work, because what actually happens is inside the code in
LootDrops
for generating cards/figures, the parameter gets set after the item has been fully built and then anIDrawable
gets registered based on its value. The drawable has no knowledge of updates toitem.params.chara_id
.The main problem is the fact that we have no good way of modifying
params
while the object is being built while also allowing callbacks that depend onparams
to be run with the custom values we want. To solve this, we could separate random generation ofparams
and initialization of the item based onparams
into two separate callbacks. That way you could have an event handler that gets run before theIDrawable
gets initialized in the example, but after theparams
have been given default values.Taking advantage of this, the example issue would be solved by doing what we already do with
IActivity
objects (and ought to do with feats also, see #110) by passing in aparams
table toItem.create()
and similar.The text was updated successfully, but these errors were encountered: