hook conventions

Regarding hooks, is the convention that all pre... hooks are executed on the machine that initiated the action? Ie, if a user updated an actor, it would call preUpdateActor only on their machine, and then updateActor on everyone elses?
C
Calego845d ago
This is an interesting topic with a deceptively simple answer: "All Hooks are only run client side" It just so happens that the Document lifecycle hooks happen in response to a Server message telling the client to update its understanding of a document. So for modules making their own hooks, the recommendation is to make the API consumer of the Hook implement its own socket if the hook is supposed to trigger something on other clients.
W
Wasp845d ago
Yeah, that's effectively what I'm doing
C
Calego845d ago
<#901108458944876584>
W
Wasp845d ago
Deleted channel indeed 😄
C
Calego845d ago
^ thread on the mothership oh dang
W
Wasp845d ago
pre hooks are called on the initiating machine, in this case, when a user drops an item onto a pile, preDropItem is called on their machine
C
Calego845d ago
it's "Local vs Socket Hooks" in the #dev-support channel archived threads if you're interested, basically just atro saying what I said 😛
W
Wasp845d ago
then dropItem is called on all users via a socket as each connected users should be able to observe said event Cool 😄 But is what I'm doing seem sane?
C
Calego845d ago
what does the dropping of the item actually do? creates an embeddded document on the scene right?
W
Wasp845d ago
Depends - if dropped on an existing pile, it transfer the item from actor to actor, otherwise it creates a new pile token before transferring I'm trying to stay in the bounds of Foundry's existing document models as to make it as easy to maintain and as extensible as possible
C
Calego845d ago
is this powered by unlinked tokens? I'll be honest those still scare me and I haven't looked into much for how they work
W
Wasp845d ago
I mean, there's still a "default" actor that all tokens refer back to
C
Calego845d ago
What you're saying seems sane though, I'm not sure what sorts of things another module might want to do with these hooks, that's somethign that helps me think about how a hook structure should work
W
Wasp845d ago
but the tokens aren't linked to that specific actor in the sense that they share the same inventory It's just a basic character actor, nothing fancy. If later down the line people want to create system specific sheets that enable it to look different, that's a whole different thing But I want to make it as system agnostic as possible while staying in the bounds of Foundry's patterns Thanks for the insight
C
Calego845d ago
I dig it! Ahh, is this meant to be system agnostic? if so, and this is off topic, remember that systems define their own actor types/data models so 'character' might not exist in a given system (nor might 'inventory')
W
Wasp845d ago
Yeah, it's just using whatever actor model is defined as default and using the default item document ownership as defined by the actor base class As ya can see, you're even able to define your own transferable attributes from piles: https://discordapp.com/channels/732325252788387980/734095524822777976/927333289977585724 So that currencies may be able to be picked up
C
Calego845d ago
i'm preachin to the choir, this is looking awesome @wasp vote
LTL
Leo The League Lion845d ago
@calego gave vote LeaguePoints™ to @wasp (#6 • 319)
M
Mana845d ago
I don't believe any of the drop hooks fire on all clients. They're all only on the initiating client's side. The rest of the users get whatever that results in (usually actor.update() hook chain) Otherwise you'd get drop hook firing and then all clients as result of it calling update actor on and try to add the same item on all clients, which is quite wrong.
W
Wasp845d ago
Oh, I'm not talking about the generic drop hook I'm talking about item pile's hooks, which ride off of the client drop hook
Want results from more Discord servers?
Add your server
More Posts
expand arraysIs there a way to `expandObject` except for an Array?edit-owned-item-effectI've made an abomination. This hacks its way past the limitations surrounding editing effects on ownItem Pile feedbackSimple is king!effects to chat@badideasbureau is the `temporary` flag you look for in Effects to Chat a convention from somewhere 5e AEsI've been messing pretty heavily with some Active Effect assumptions and mechanisms in 5e. This is mhero creator ui feedbackI'm trying to refactor the abilities' tab on the hero creation room to accomodate Race ASIs, but I deffect mechanic searchingI need someone to check me on a null hypothesis I'm making. > There are no abilities in 5e RAW whicDialog shennaneginsTIL the button callbacks for `Dialog.prompt` and `Dialog.confirm` can be asynchronous. ```js const Advancement Hooks@kandashi @ccjmk and anyone else who is currently working on modules that would interact with the AdAPI doc topicsGive me some ideas for what areas of the foundry core API would benefit from a wiki documentation paDiscord Permission IssueOh, I think you also need a Typescript roleDevelopment-APIA new section of the Wiki was created today: `development/api` This section is dedicated to documentitem to actors scriptI have this macro for updating actors in a compendium with spells from a compendium of spells (i.e. Primary and Embedded UpdatesTIL how to update embedded documents at the same time as parent documents. ``` game.actors.getName(compendium errors upgrading to v9hmm im not entirely sure how this will work though.. because I did just a quick smell test to my modBlind Chat MessagesAnyone have good examples of creating a chat message that should only be visible to a connected GM, compendium shennaneginsTIL about `CompendiumContent.getDocuments` taking nedb queries. ``` game.packs.get('dnd5e.heroes').gwith just a parent class and the class name, is there a way to instantiate a new class?JamesB and @veterini have a question for y'all in #coc7-dev https://discord.com/channels/7323252527More Hooks 5ehttps://github.com/ElfFriend-DnD/foundryvtt-more-hooks-5e I'm going to try to use this library to hacreateEmbeddedDocuments issueI'm going to throw my code in a thread so I don't clutter this channel up with a wall of text