Starfinder Playlist
Page 1 of 2 12 Last
  1. #1

    Host side AND Player side running code issue

    I've noticed a bug in my AdvancedEffects extension and it's got me baffled and probably due to something I'm not aware of in how FG handles things.

    When a game is running and the player opens up a character sheet and "equips" a weapon with effects it applies them normally. Remove item, effects are removed.

    Stop, close FG. Restart.

    When a game is running and the DM opens up the same character sheet and "equips" a weapon with effects it applies them normally. Remove item, effects are removed.

    Stop, close FG. Restart.

    When a game is running and the DM opens up the character sheet and the player ALSO opens the character sheet and then the player equips an item with effects the effects are applied twice.

    I added debug code to see what is up and what is happening is that the code is being executed on the Host AND player side if they both have the character sheet opened.

    Anyone have an idea why it does this and how best to build in logic to counter act it?
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  2. #2
    Sounds like you have a message being sent to all clients (that have registered for it via opening the character sheet). I assume that it is not to equip button that is applying the effect, but rather something further up the chain that is listening for an event from the equip button. Thus both the Host client and Player client hear the event and apply the effect.
    I never claimed to be sane. Besides, it's more fun this way.

  3. #3
    Quote Originally Posted by Nickademus View Post
    Sounds like you have a message being sent to all clients (that have registered for it via opening the character sheet). I assume that it is not to equip button that is applying the effect, but rather something further up the chain that is listening for an event from the equip button. Thus both the Host client and Player client hear the event and apply the effect.
    Hum, there are certainly handlers. I'll try printstack() and see if that helps me track it down. Thanks for the suggestion!
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  4. #4

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Does printstack() really work? Never even tried it. Thought it was part of the unimplemented LUA portions.

  5. #5
    Quote Originally Posted by Bidmaron View Post
    Does printstack() really work? Never even tried it. Thought it was part of the unimplemented LUA portions.
    Yeap, works for me at least. Here is an example. notifyEffectAdd is nearest function and the further down you go are the paths that got to notifyEffectAdd.

    Code:
    Script Notice: 
    stack traceback:
    	[string "scripts/manager_effect_adnd.lua"]:39: in function 'notifyEffectAdd'
    	[string "scripts/manager_effect_adnd.lua"]:190: in function 'updateItemEffect'
    	[string "scripts/manager_effect_adnd.lua"]:127: in function 'updateItemEffects'
    	[string "campaign/scripts/char_invlist_adnd.lua"]:183: in function 'updateItemEffects'
    	[string "campaign/scripts/char_invlist_adnd.lua"]:121: in function <[string "campaign/scripts/char_invlist_adnd.lua"]:98>
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  6. #6
    Quote Originally Posted by celestian View Post
    Hum, there are certainly handlers. I'll try printstack() and see if that helps me track it down. Thanks for the suggestion!
    Sure enough, it's the DB.addHandler(DB.getPath(node, "*.carried"), "onUpdate", onCarriedChanged); getting run for both sides (onCarriedChanged).

    I'm not sure how tho because I check for existence of the effects via source (the item's path) before I add it. I'll go over that and see why it's not working here.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  7. #7
    What I ended up having to do is check in the handlerApplyEffect() function and re-verify the effect source was not in any effects on that node. Unless there is some other way to ensure addHandler only is run once even if it's open on more than one user's copy of FG that'll have to work.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  8. #8
    You’d have to move your effect application to a global script handler registration that only runs on the host, instead of running on the character sheet. Since only he host can apply effects and the combat tracker , this seems like it would be a good way to go anyway.

    Regards,
    JPG

  9. #9
    Quote Originally Posted by Moon Wizard View Post
    You’d have to move your effect application to a global script handler registration that only runs on the host, instead of running on the character sheet. Since only he host can apply effects and the combat tracker , this seems like it would be a good way to go anyway.

    Regards,
    JPG
    I was actually converting it to a OOB style when I noticed this. Originally I had all kinds of stuff dealing with permissions, checking who "owned" a pc/etc to give them ownership/etc. But since then I figured out OOB and came back to drop all that mess. The problem was that with both people having the sheet opened it triggered the OOB notify twice when the "carried" variable was updated. I did add in a check in the "apply" section which catches if it's sent twice but if there is a way to only have the trigger sent once when there are multiple folks opening the sheets I'd be happy to experiment with it to figure it out.

    What is the "global script handler"?
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  10. #10
    You make a global script, like "ActionsManager" or "ActionAttack". Then, put the handler registration code into the onInit for the global script, but only is User.isHost() == true; Your handler would be looking at any database nodes matching "charsheet.*.inventorylist.*.carried". Then, you only have one trigger for when the carried state changes on a PC item. The host will get every notification, since the host is the database master.

    Cheers,
    JPG

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in