-
October 13th, 2017, 18:17 #1
User.isHost() giving odd return...
This is related to User.* https://www.fantasygrounds.com/refdoc/User.xcp
I'm trying to clean up some output that will only show to player when it's not DMonly and if not, show them.
Problem is User.isHost() is returning TRUE when the client it initiating the action.
Code:Runtime Notice: s'manager_effect_adnd.lua' | s'sendRawMessage' | s'nDMOnly' | #1 Runtime Notice: s'manager_effect_adnd.lua' | s'sendRawMessage' | s'sUser' | s'DM' Runtime Notice: s'manager_effect_adnd.lua' | s'sendRawMessage' | s'msg' | { s'font' = s'msgfont', s'icon' = s'roll_effect', s'text' = s'Advanced Effect ['BSTR: 18; BPSTR: 100'] removed [from Paladin] [by Magical, Gauntlets of Ogre Power]' } Runtime Notice: s'manager_effect_adnd.lua' | s'sendRawMessage' | s'User.isHost()' | bTRUE Database Notice: Campaign saved.
The code that generated the debug output for above is just a send message function but here it is.
Code:function sendRawMessage(nDMOnly,sUser, msg) Debug.console("manager_effect_adnd.lua","sendRawMessage","nDMOnly",nDMOnly); Debug.console("manager_effect_adnd.lua","sendRawMessage","sUser",sUser); Debug.console("manager_effect_adnd.lua","sendRawMessage","msg",msg); Debug.console("manager_effect_adnd.lua","sendRawMessage","User.isHost()",User.isHost()); if nDMOnly == 1 and User.isHost() then msg.secret = true; Comm.addChatMessage(msg); elseif nDMOnly ~= 1 then if sUser ~= "" then Comm.addChatMessage(msg); --Comm.deliverChatMessage(msg, sUser); else Comm.deliverChatMessage(msg); end end end
---
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.
-
October 13th, 2017, 19:24 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
The item transfers happen on the GM machine, because each user only has access to modify their own character, not the other character involved in the trade.
Regards,
JPG
-
October 13th, 2017, 19:37 #3
There is no transfer, the person is just marking the item equipped which is then scanned for effects on it and then applied, the "effects" details are what I'm outputting.
Wondering if it might just be best to only output that to DM only completely and what the player sees in the combat tracker is sufficient.---
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.
-
October 13th, 2017, 19:51 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
Similarly, when effects are applied to a creature, it is done on the GM machine, since the GM owns that combat tracker node and is only one who can edit.
I haven’t seen any case where User.isHost returns incorrectly. It’s a very simple function internally.
So, I’m trying to brainstorm why it might return true. My guess is that the code is actually running on the host for some reason.
Another function for debugging that might be useful is printstack(), in conjunction with Debug.console.
Regards,
JPG
-
October 13th, 2017, 20:26 #5
Oh, good one, I like that thanks!
Here is what it shows.
Code:Script Notice: stack traceback: [string "scripts/manager_effect_adnd.lua"]:193: in function 'sendRawMessage' [string "scripts/manager_effect_adnd.lua"]:173: in function 'sendEffectRemovedMessage' [string "scripts/manager_effect_adnd.lua"]:66: in function 'updateItemEffect' [string "scripts/manager_effect_adnd.lua"]:41: in function 'updateItemEffects' [string "campaign/scripts/char_invlist.lua"]:185: in function 'updateItemEffects' [string "campaign/scripts/char_invlist.lua"]:118: in function <[string "campaign/scripts/char_invlist.lua"]:95>
---
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.
-
October 13th, 2017, 21:13 #6
So, I did some experimentation to try and figure this out a bit.
First I added debug output for onInit() in char_invlist.lua for both 5E and my ruleset.
Started up server. Did nothing with it, immediately started client up and connected. As player selected a character and opened and toggled an equipped item and the weight carried changed when it was not carried. If the item had an AC it would adjust character AC during this phase if toggled on/off. During this phase NO logging was showing.
If I toggled it with the host side it would suddenly start showing debug output and from then on both sides would show it.
I checked the 5E ruleset for this and saw the same behavior.
The fact that weight carried changes indicates it's actually running the functions. I am confused as to the debug output and why it doesn't work all the time.. until a Host actually does it.
At each point of the above traceback I added a debug output to show the User.isHost() and that was why I was surprised nothing was showing. Once the host did something to cause it to begin logging ... from then on it was always "TRUE" no matter who toggled anything.---
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.
-
October 13th, 2017, 21:40 #7
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
As I mentioned, there's nothing specifically in the client that would do that. The User.isHost check is simply a "if (mode == HOST) return true; return false;" in the client. If the mode == HOST was wrong, a bunch of stuff would be messed up because it's used extensively.
So, that leads me to believe that there is something specific to the Lua code that only triggers after host scripts run. Since scripts don't run until they are loaded (at campaign load for global scripts, or when window opened for window/control scripts), my guess is that the scripts are windows/control scripts that aren't registered until the script is loaded on the host.
Is there a way to get me a simple example using an extension that shows this issue?
JPG
-
October 14th, 2017, 06:20 #8
Okay, so... uh... I was not watching console on the client connection (duh, now I get it). I made some bad assumptions on that one. So when watching the client /console my debug of User.isHost() is correct.
Everyday I learn more than a few things about how FG works
What it seems I must do as host/DM is load each PC up and select the inventory tab for the players to be able to toggle on/off the items so that they apply/remove effects. If I do not do that they get the messages that it happens but the effects are not actually changed.
I'll have to see if I can figure out a way to trigger a load of the PC when the client loads it if that's even possible. Time for more digging...
Apologies for the wrong direction!Last edited by celestian; October 14th, 2017 at 06:57.
---
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.
-
October 14th, 2017, 07:12 #9
So while looking into figuring out how to trigger a load I found this dude asking a similar question. I was digging for "onIdentityActivation" when I found this.
Moon Wizard said:
October 26th, 2007 20:41
Just figured it out. Apparently, database nodes are only shared with clients if the user is a "holder" registered with the database node. Once I registered each client as they login, then they are able to correctly see the options nodes I set up.
Cheers,
JPG---
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.
-
October 14th, 2017, 12:48 #10
Archangel
- Join Date
- Apr 2008
- Location
- Virginia Beach
- Posts
- 3,096
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks