PDA

View Full Version : getCTNode



Kelrugem
July 4th, 2019, 19:48
Hello :)

I have some problem getting the CT node of a player controlled character. Normally I use


ActorManager.getCTNode

and that works perfectly (for adding strings as effect for example). But when the character is controlled by a player this does not work anymore. I realized by debugging that the host has the informations about all the ct entries like their nodes as long as they are not controlled by someone. When I open the console on the player side then I can see that the player has the information about his node instead of the host (i.e. the console debug lists the player controlled CT node only on the player side). But the problem is that the code seemingly only looks at the host informations :)

How can I get the node informations of player controlled characters? :)

I hope I have described it well enough :)

Best wishes and thanks in advance,

Kelrugem

Trenloe
July 4th, 2019, 19:57
I can't see how a player controlling a PC would stop the GM instance getting access to their Combat Tracker node - the GM always has access to all DB nodes. The only thing I can think of is if the LUA code is handling it differently.

Please provide an example of the code you're running and what happens when a PC is controlled and when it's not controlled?

Kelrugem
July 4th, 2019, 20:33
okay, I try to rebuild the bit of code here :) Thanks :) Basically I do the following:



local rEffectSpell = {};
rEffectSpell.sName = "test";
rEffectSpell.nDuration = 1;
rEffectSpell.nInit = 0;
rEffectSpell.nGMOnly = 1;
rEffectSpell.sApply = "";
EffectManager.addEffect("", "", ActorManager.getCTNode(rActor), rEffectSpell, false);

rEffectSpell is some variable defining the effect-string "test" and rActor is the character called in some function (here in some save roll function but that should be not important (I guess?)). That bit of code adds the string rEffectSpell as an effect to rActor. When rActor is not controlled by anyone then "test" is added as an effect to the rActor. But when rActor is controlled by a player then nothing happens, also no errors but the effect is also not added then :)

EDIT: It might be that I misunderstand the function addEffect. I just review that now, maybe the arguments are wrong there :)

EDIT2: Hm, okay, I do not find anyting wrong in my use of addEffect. But doesn't mean anything :D

Trenloe
July 4th, 2019, 21:01
If you put some debug just before the EffectManager.addEffect function call, what does rActor show at that point?

Where does this code run - on the client, or on the GM side (via OOB messaging)?

Kelrugem
July 4th, 2019, 22:00
If you put some debug just before the EffectManager.addEffect function call, what does rActor show at that point?

Where does this code run - on the client, or on the GM side (via OOB messaging)?

When the character is not controlled by anyone I get:


Runtime Notice: { s'sType' = s'pc', s'sCreatureNode' = s'charsheet.id-00001', s'sCTNode' = s'combattracker.list.id-00001', s'sName' = s'Test' }

But when it is controlled by someone then I do not get anything. But when I open the console on the player side then I get this information in that other console.

Due to this and due to your second question I now read a bit more about OOB messaging and the part of that in the code. It can run on both, client and host depending on the situation, so Comm.deliverOOBMessage(msgOOB, ""); is only being used when it is not a character controlled by a player. Otherwise the function calls Comm.deliverOOBMessage(msgOOB, sOwner); (when an enemy attacks a controlled character) or the function which is triggered by that OOB message is directly called without using deliverOOBMessage (when the owner casts on his owned character). Seemingly this changes the behaviour on controlled characters. When I replace everything with Comm.deliverOOBMessage(msgOOB, ""); then it works as wanted but I am afraid doing that because that is not my part of the code and especially I do not know what else is changed (there must be a reason for this different treatment; one change I can see, is that the portrait at the roll result is then always the GM portrait and not the one of the controlled character).

I am not that experienced with OOB messaging :) Is there a simple way to resolve that? The information of rActor is still there, but "somewhere else". So the original code still seems to work of course but not my part then :) Is there a way to call the information on the player side? (the sOwner in the deliver message above)

Trenloe
July 4th, 2019, 22:54
I'm not at my computer now, so can only give a very quick response. OOBMessaging is usually used when the player instance of FG needs some code running and it doesn't have the right access to be able to do that - most commonly the player instance doesn't own a record on the database that needs modifying, so the task of modifying the database is passed off to the GM via OOB Messaging.

I don't know if that helps you work out what's going on? If not, I may have a little spare time to look at it tomorrow...

Kelrugem
July 4th, 2019, 23:24
I'm not at my computer now, so can only give a very quick response. OOBMessaging is usually used when the player instance of FG needs some code running and it doesn't have the right access to be able to do that - most commonly the player instance doesn't own a record on the database that needs modifying, so the task of modifying the database is passed off to the GM via OOB Messaging.

I don't know if that helps you work out what's going on? If not, I may have a little spare time to look at it tomorrow...

thanks a lot for your answer :) I try to solve this :D Thanks for your time :) and you do not need to look at it when you do not have so much time, I try to solve it somehow :) (and when I will have found a solution, I will write this here :) )

Kelrugem
July 5th, 2019, 16:52
Okay, I understand now what is happening. The client can seemingly not use the addEffect function (and removeEffect, too). The chat message of addEffect is possible but not the effect itself for some reason, therefore there is some notifyApply function for effects using the OOB message to carry over this procedure to the host.

Thanks again, Trenloe :) I really needed the information about OOB message and client-host interaction :) Now I have to see how to solve this because just using notifyApply is too slow (in sense of that the effect is applied too late because that effect is directly used in my code). Interesting, didn't know (and can not see yet, why) that the client can not produce effects directly :)

Trenloe
July 5th, 2019, 17:17
Glad you're making progress! :)


Interesting, didn't know (and can not see yet, why) that the client can not produce effects directly :)
It'll be because only the GM owns data in the combat tracker and so only the GM can make changes to data in the combat tracker. There's the odd exception (PC wounds, for example, as these aren't actually stored in the CT, they're linked to the data in the PC sheet - which a player can change). So only the GM can add effects as these are stored in the CT records.

Kelrugem
July 5th, 2019, 17:43
Glad you're making progress! :)


It'll be because only the GM owns data in the combat tracker and so only the GM can make changes to data in the combat tracker. There's the odd exception (PC wounds, for example, as these aren't actually stored in the CT, they're linked to the data in the PC sheet - which a player can change). So only the GM can add effects as these are stored in the CT records.

aaah, okay, that makes sense :) Thanks again :) Learned a lot :D

Kelrugem
July 6th, 2019, 01:49
Thanks again Trenloe :) I have now solved it; I added some OOB messaging as an intermediate step to delay the standard code in such a way that it "waits for the effect to be added by the host and then everything goes back to the client" :)

Trenloe
July 8th, 2019, 05:28
Glad you got it working.

I hope the delay thing works in all situations, especially under load. Doing stuff like that can be unreliable.

Kelrugem
July 8th, 2019, 18:27
yes, I hope that, too; so far it works, it is more like an intermediate step through which the code has to go through and the previous path is not done anymore. But yes, when the OOB message somehow breaks then the whole code would stop there, but there was already some OOB message in the standard code, I basically extended that part a bit :) (hopefully good; but I still think about a completely different solution, but hard to describe without going into the details of my code)

Trenloe
July 8th, 2019, 18:38
If you need to trigger some code once another set of code has finished (especially OOB code) then you could us a database flag or check a field that might be changing, and then run some database onUpdate code against that field. https://www.fantasygrounds.com/refdoc/databasenode.xcp#onUpdate

Kelrugem
July 8th, 2019, 18:52
If you need to trigger some code once another set of code has finished (especially OOB code) then you could us a database flag or check a field that might be changing, and then run some database onUpdate code against that field. https://www.fantasygrounds.com/refdoc/databasenode.xcp#onUpdate

aaah, that sounds interesting. Thanks again a lot, I look into that and try to implement that instead if possible :)

Kelrugem
August 3rd, 2019, 21:19
If you need to trigger some code once another set of code has finished (especially OOB code) then you could us a database flag or check a field that might be changing, and then run some database onUpdate code against that field. https://www.fantasygrounds.com/refdoc/databasenode.xcp#onUpdate

Now, thanks again a lot Trenloe :) My code for the save and immunity effects against specific traits/tags/whatever now works much better. I was able to get rid of the OOB messages and the performance increased now a lot :) But I did it a bit differently, I developed a new IF operator doing what I want :) (also with a better performance than IF)

PS: Sorry for the revival of that thread; I am too enthusiastic at the moment :D