PDA

View Full Version : Difference in some CT Client/host Fields - onInit()/update() [MoreCore]



Varsuuk
January 2nd, 2021, 01:13
I have so far 99% of the time worked on the "host" as I work on my MoreCore ruleset extension.

I came across an odd thing when investigating a bug where when I add a character to the CT it does not check my "asc/descending" flag until it is flipped (it uses right one but both controls are visible so the Asc, last control, is the visible one) - the issue was obvious, I added handlers but I did not add a check on initializing.

So when I loaded up the ct_host.xml and ct_client.xml, I noticed my scripts had update() and onInit(), respectively, defined in the <script> tag. I thought I typed while writing it but it seems I got this from the same files of the same name in MoreCore.

Is there a reason they vary this way? I noticed in the same file, for some controls onInit() is defined, others update().

I have yet to do anything in client mode and the options they check are meaningless until/when I look up what MCC2/MCC2C/MCC3 etc MEAN... - perhaps onInit() is used when the option should never change again (but... it CAN right? What does that mean then?) and update() for ones where you want to react to?


I may be able to answer this myself once I get to work on the ClientUI - but figured I'd ask in case anyone saw this and knew the answer on why it is supposed to be that way.

Varsuuk
January 2nd, 2021, 04:22
I verified this with my ruleset working on just using "update" for both so that when I flipped between Ascending and Descending AC it updated the AC on my client's CT/

Then I tried it with MoreCore and flipped the "show health" field to GM+Player and it stayed visible in Host CT but not Client CT. Until I exited and restarted client and then the field was there.

So at first, I thought it was the update() vs onInit() - but it is more than that. I suspect there is no callback when a change occurs or when there is, it does not refresh the CT. In my extension, when Option for AC direction is clicked both are registered to listen for the change and update themselves.

So when I make a change - existing CT entries in client do not change. They remain showing the Health (unless I exit the client and come back in then it's removed). I suspect neither register since same happens for HOST if set health to "None" it stays on HOST until we remove and re-add the CT entry.

Of other note is if you change the option with an entry already there, both host and client see it as was under prior setting. If you ADD another entry, THAT entry comes in under the new settings and the Health is removed or added.

I'll take a look at this later but I am done for the evening after fixing my own CT issue.

However, it may be that it's INTENDED to work the way it is (I can see, if wanted a mix?) then it makes sense why it's how it is. Before I investigated, I'd prefer to know people WANTED it "hot swappable" like I needed for my AC thing.

Varsuuk
January 2nd, 2021, 04:49
Emily Litella... nevermind.

After speaking to someone and hearing it aloud.

There is no need for it actually :). The better question is WHY would I need to swap these after you decided what you wanted?
If it started up wrong, you will notice it right away and restart the Host to fix it.

damned
January 2nd, 2021, 04:49
The column settings and some others only change when you load the sheet.
At the time I wrote that learning how to apply the changes on the run was too much for my poor little head.
If you have time, and you want to update that code please send the change files thru and Ill incorporate it.

Varsuuk
January 2nd, 2021, 05:19
Glad to do that it really isn’t that much. That said, my follow up after review made me realize I was overengineering it in the options I looked at in MoreCore.

But there may be cases/times wheee that code will be useful even if you agree that it isn’t needed for the options I first brought up.

I was doing testing of to hit against both ACA/dsc AC and it was certainly more convenient for me to hit an option to switch live vs restart each time I verified the other way. But that’s more of a coding reason vs a “use” reason and I should have seen that. No one is going to swap between Asc/dsc more than one time and a restart is trivial for it.


But - will send you an example using MoreCore CT when done with my thaco work.