PDA

View Full Version : CT linking question



Varsuuk
February 20th, 2021, 20:42
Hey there, I want to get "live data" from PC CT entries. I could add the fields to the CT entry when the PC is added, but then the data is "frozen" in time.

I seen the use of "setLink" thing on fields like health and used it when I added similar "visible" fields to the CT.
I would have to look it up, but I think I recall Moon mentioning that getCreatureNode() from ActorManager was not a good idea (not putting words into his mouth - it's my (TERRIBLE - and why I ask things more than once sometimes) MEMORY of it, I think ;P

Because, in the ideal world, I'd find that the entry is a PC and therefore I know there is a method to grab a particular possibly changing field from the char sheet.

Barring that, some what to link a character sheet DB field to the CT DB entry but NOT have it represented as a visual element. Basically so the roll handlers can query target or source and get the CT entry to then get this value.

(of simpler if I remembered wrong - query CT for creature node and get it from that DB?

bmos
February 20th, 2021, 21:00
Use ActorManager.isPC(rActor) to see if it's a PC.
If it is, use ActorManager.getCreatureNode(rActor) to get the child node under charsheet.

Moon Wizard
February 20th, 2021, 21:32
One caveat. If you are using those functions on the player client, ActorManager.getCreatureNode may return nil, because that player client does not own the player record.

If you look at the examples in 3.5E/5E for ActorManager35E/ActorManager5E.getDefenseValue; you'll see that it still uses the older ActorManager.getTypeAndNode, which returns a node with the specific type of the node returned. (i.e. "pc", "ct", "npc") That function prioritizes owned PC nodes, then CT nodes, then the base creature record node. (based on availability)

Regards,
JPG

SilentRuin
February 20th, 2021, 22:56
One caveat. If you are using those functions on the player client, ActorManager.getCreatureNode may return nil, because that player client does not own the player record.

If you look at the examples in 3.5E/5E for ActorManager35E/ActorManager5E.getDefenseValue; you'll see that it still uses the older ActorManager.getTypeAndNode, which returns a node with the specific type of the node returned. (i.e. "pc", "ct", "npc") That function prioritizes owned PC nodes, then CT nodes, then the base creature record node. (based on availability)

Regards,
JPG

Wait a second - I changed all my getTypeAndNode calls because it was being deprecated - going away. Are you telling me that getCreatureNode does not do the same things that one did? And that I should have left them all as I had them as its never going away? Also this makes me wonder if there are not some hidden bugs I've not tested for yet in some obscure case that I do.

Varsuuk
February 20th, 2021, 23:00
It's my wife's birthday so I am done for the day working on this today (or until really late) but I will check that.

Thanks for the feedback BMOS (are you THE! BMOS? ;) ) - I had code like that - was wondering if I'd run into trouble due to some factor - which was probably what Moon mentioned in his reply (I dreaded remembering terms to search for my original question and his reply :) I appreciate the recap.)

Basically, the first use is to check/grab a possibly variety of modifiers to rolls. I will look at the 3.5/5e thing you suggested. You said "still uses the older" - is there any near-term expected problem if that happens to be the right solution for me?

If >I< am doing the rolling from the CT (as GM), I would have full access I presume from this.
I am not sure I will be including player rolling now that think of it, from the CT. They have character sheets (or, am I missing a reason as a player would need to roll from ther e- I've only played for last few years never DMed but I dont think I ever rolled from CT)

So, if the morecore "attack roller" is being triggered from the character sheet itself, it should be able to get the record. I think I was looking at a solution before truly defining the use case. The only time I expect it to be rolled from CT is for "monsters" and perhaps "npcs" - if I go route of npcs as character sheets later - but they would be owned by me in that case.

Thanks folks

[EDIT: Just saw Ruin’s' reply - like said, have to run off to get restaurant "takeout" (Turkish Mez, been a while!) to have our BDay dinner at hom - but will keep eye out for this so learn me stuff]

Varsuuk
February 21st, 2021, 18:39
I just read through this getTypeAndNode vs getCreature to see what they do (and resolveActor to boot) and am


NOTE: This is CoreRPG from earlier in year, in case has changed.


function getTypeAndNode(varActor)
local rActor = resolveActor(varActor);
if not rActor then return nil, nil; end

if rActor.sType == "pc" then
local nodeCreature = getCreatureNode(rActor);
if nodeCreature then
if nodeCreature.isOwner() then return "pc", nodeCreature; end
end
end

local nodeCT = getCTNode(rActor);
if nodeCT then return "ct", nodeCT; end

if rActor.sType ~= "pc" then
local nodeNPC = getCreatureNode(rActor);
if nodeNPC then return "npc", nodeNPC; end
end

return nil, nil;
end


Since there is a shortcut inside resolveActor, it doesn't seem that the oldeR? typeAndNode isn't the one to call. Again, I have surface only knowledge of this stuff - but it looks like tAN does a neat job of "return the PC record if you have access to it and it is a PC record, if it is a PC record and you don't have access - get the CT record for this guy and return it. If it is not in the CT - then return as an NPC record".
(Correct if imprecise or worse wrong wording)


getCreatureNode seems to be for when you want the full PC or NPC node only (and can return a node you do not own so you. much check for that if it is for non host client)
If you did't own the PC record, you'd have to basically do what tAN does anyway.


But there may be another reason it is the "old way"? Maybe there is another oe coming that they know and that is why it was referred to that way?

Varsuuk
February 21st, 2021, 18:47
This also means (ASKING here ;) ) that if you get a "source" rActor in a roll handler (think MoreCore) that it is safe to use getCreature() since you will get your PC record or NPC record (npc is where it gets weirder since I haven't gotten to testing as a player connected to a game to see what they can access on CT if given "ownership" of an NPC - otherwise for sure they wouldn't be able to click on npc attacks on the CT)

So if you just want to get info from the SOURCE - if I understand, it is fine to use getCreatureNode() because you won't get a node you don't own if YOU started the action - right?

Moon Wizard
February 21st, 2021, 19:54
You can use getCreatureNode() when you know that you are on a client that has access to that node; or you can write your own tiered fallback like getTypeAndNode() does.

I would use getTypeAndNode in roll handlers; because your players could be targeting another player, which means that the target creature node is not available (even though the path will be non-empty).

Regards,
JPG

Varsuuk
February 21st, 2021, 20:04
I understand Moon and will do that when I am trying to get "target" nodes. The handler method I am adjusting is one that is adding "mods" and so far is only querying the sourceActor for data for the mods.

So from your reply, do we infer that there is no reason to remove "getTypeAndNode" anywhere it is not "old" in the sense of deprecated, it is "old" only compared to "getCreature"?

As an aside ;) I connected a client on my laptop for the first time in a long time. Tried the rolls with just getCreature(), and it all worked. UNTIL I closed the client lol... seems I might have made a mistake in my "careful" mirroring of register/unregister - but oddly (to me only prob) it is only present in the Client console. I'll look at this later - but if anyone knows of something to look out - let me know. My gut tells me there is corresponding client and server code and that I put the unregister in both but it might be something else completely as it seems to be an endless loop:



Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: [string "scripts/manager_options.lua"]:159: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: [string "scripts/manager_options.lua"]:159: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: [string "scripts/manager_options.lua"]:159: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: [string "scripts/manager_options.lua"]:159: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: C stack overflow
Script Error: [string "scripts/manager_options.lua"]:159: C stack overflow
Runtime Notice: Returning to launcher


I WISH I was looking at C/C++ code :) THAT I feel confident on debugging heheh.

Moon Wizard
February 22nd, 2021, 08:34
That's an endless loop triggering an overflow in the Lua engine. Make sure you don't have any functions calling themselves (or make sure they won't go endless if you do).

Regards,
JPG