-
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
Dynamic field from nested object #12
Conversation
mod_nested_tooltips/hooks/ui/screens/tooltip/tooltip_events.nut
Outdated
Show resolved
Hide resolved
| 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 |
2bda3d0 to
51020e4
Compare
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+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/skills 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.
51020e4 to
c4e0af2
Compare
919d995 to
c0e7d6d
Compare
c4e0af2 to
256a8a4
Compare
As these require the objects to be instantiated, this will break hooks if this is done before AfterHooks. We require it to be done after FirstWorldInit because some skills require certain global things e.g. MapGen to exist for their `create` function to work.
256a8a4 to
728309e
Compare
- By default we return the first match for the filename in the order the IO.enumerateFiles enumerates files. - Subfolder path can still be specified for a specific match.
- Instead we try to find the item manually by iterating over all possible itemOwners until we match the itemId. - If not found then we return the default ItemObjectByFilename.
This ensures that skills related to items use the item's properties e.g. damage instead of showing how the skill behaves for the actor himself.
|
Closed in favor of #17 |
Obj/Fieldnotation 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/knifeinstead ofknife. Shorthand:[Knife|Item+weapons/knife]or[Obj/Name|Item+weapons/knife]scripts/skillsfolder so now we haveeffects/stunned_effectinstead ofstunned_effect. Shorthand:[Stunned|Skill+effects/stunned_effect]or[Obj/Name|Skill+effects/stunned_effect]SkillObjectsByFilenametable. Skill objects are instantiated on demand during a nested tooltip query.ItemObjectsByFilenameon demand when a nested tooltip is queried for them.