-
Notifications
You must be signed in to change notification settings - Fork 1
Dynamic field from nested object #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: better-item-handling-for-nested-tooltips
Are you sure you want to change the base?
Dynamic field from nested object #12
Conversation
Such as Name for skills and items.
- This allows files with the same filename to exist. - For perks this is the scripts/skills/perks/ folder so they remain unchanged. Shorthand: [Anticipation|Perk+perk_anticipation] or [Obj/Name|Perk+perks/perk_anticipation] - For items it is the scripts/items/ folder so now we have weapons/knife instead of knife. Shorthand: [Knife|Item+weapons/knife] or [Obj/Name|Item+weapons/knife] - For skills it is the scripts/items folder so now we have effects/stunned_effect instead of stunned_effect. Shorthand: [Stunned|Skill+effects/stunned_effect] or [Obj/Name|Skill+effects/stunned_effect] - Delete SkillObjectsByFilename table. Skill objects are instantiated on demand during a nested tooltip query. - No longer instantiate all items at the start of the game. Instead they are instantiated and added to ItemObjectsByFilename on demand when a nested tooltip is queried for them.
else | ||
{ | ||
item = ::MSU.NestedTooltips.ItemObjectsByFilename[_data.Filename]; | ||
if (_data.filename in ::MSU.NestedTooltips.ItemObjectsByFilename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would factor this out into some getItemByFilename()
handler.
if (ret == null) | ||
{ | ||
skill = ::MSU.NestedTooltips.SkillObjectsByFilename[_data.Filename]; | ||
skill = ::new(scriptPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we do that caching to items but not skills, why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem necessary and just hogs memory. For items it is necessary because we need to have the item available for the nested tooltips of skills which want to refer to that item e.g. reload_bolt which needs an item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, doesn't make sense. Why don't you create an item on demand like everything else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do that in this new system, we create it on demand. But when we create it, we also add it to this table with a strong reference so it always exists. We need it to persist outside this scope as well because the skill's tooltip will need to refer to that item. If we just create it on demand and return it, the object will be garbage collected and we won't have access to it anymore. See how our hook in tooltip_events.nut
where we need to access an item if necessary, so the item needs to exist.
We don't need to do this for skills i.e. they don't need to exist outside that scope as they are never accessed outside it.
Why we need all this dummy player, fake item and stuff? Why don't use the real thing? |
This is a long topic but I'll try to summarize it:
Without this DummyPlayer most of the framework will not work because skills will be hanging without a container and items will be hanging without being equipped. This is just a brief summary of it, going into much detail of it will be probably too long here. |
I understand that you need a player, but a skill usually already has one, why not use that? |
For example if I want to give the nested tooltip of |
Obj/Field
notation in shorthand.scripts/skills/perks/
folder so they remain unchanged. Shorthand:[Anticipation|Perk+perk_anticipation]
or[Obj/Name|Perk+perk_anticipation]
scripts/items/
folder so now we haveweapons/knife
instead ofknife
. Shorthand:[Knife|Item+weapons/knife]
or[Obj/Name|Item+weapons/knife]
scripts/skills
folder so now we haveeffects/stunned_effect
instead ofstunned_effect
. Shorthand:[Stunned|Skill+effects/stunned_effect]
or[Obj/Name|Skill+effects/stunned_effect]
SkillObjectsByFilename
table. Skill objects are instantiated on demand during a nested tooltip query.ItemObjectsByFilename
on demand when a nested tooltip is queried for them.