PDA

View Full Version : Target DC on the Desktop?



Oberoten
April 30th, 2018, 23:35
I have been looking at creating control like the modifier-box on the desktop. One which in turn would contain a DC and be accessible for automated rolls of various kinds.

I have tried by copying the modifierstack code but it fails at


function registerControl(ctrl)
control = ctrl;
end



Can I do just a simple numbercontrol and register it somehow so I can reach it the same way I'd pull numbers from the Modifier? (And if so, how? )


- Obe

Trenloe
May 1st, 2018, 00:10
See some info on panels here: https://www.fantasygrounds.com/wiki/index.php/Developer_Guide_-_Rulesets_-_Interface#Panels

Attached is an example of a desktop panel where you can enter a number in the desktop panel.

The code currently stores the number entered in the database and syncs across all clients - you could change that to just store the number locally on each FG instance.

You'd then have to create a global script package (like ModifierStack) so that you can register the desktop panel control in the package and then get access to that package during your actions. The package can use the registered control to access the desktop panel and get the DC number stored in the control. This is really all you'll be using the global script package for - to give access to the control from your action script, so that it action script can access the DC stored in the control.

Look at how the <windowclass name="modifierstack"> section in CoreRPG registers the control in the ModifierStack global script package. And how the register and unregister happens in modifierstack.lua - note that control is actually a local variable declared at the stop of the script file - it is here that the reference to the desktop panel control will be stored when it is registered. This allows future function calls into this package to get access to the desktop panel control.

You could then write a function (perhaps getDCValue) in your global script package that uses control.examplenumber.getValue() to get the value stored in the examplenumber number control in the desktop panel registered in control

Sounds complex? But, it's actually not that bad. The code in the end will be only a few lines. Sorry I don't have exactly what you need - but it's pretty close...

Trenloe
May 1st, 2018, 00:32
Here's a better example - it does all what I mentioned in the previous post.

There is example code in the onDoubleClick event of the number control showing how to call the global package to get the number.

Enter a DC in the control, then double-click it to see the value written to the chat window.

Oberoten
May 1st, 2018, 05:46
23303

Thank you for a very nice example file to go over. It always helps to have the functions more isolated. I was close with what I was persuing and trying from the modifierstack, and probably failed mostly by the fact that I was delving into the wrong (and for my use of this irrelevant) parts of the code.

Compared, this was understandable and quite a bit easier to wrap my mind (and my own code) around. :) Once again Trenloe, you are a rock & you rock.

- Obe

Trenloe
May 1st, 2018, 14:23
No worries. It looks good on the desktop!