PDA

View Full Version : Just trying to learn



Octavious
April 22nd, 2019, 00:39
Hi ,
I am trying to learn a little on the rulesets.. going thru it all I have lots of questions and maybe someone can point me to some documentation to help..

here is snippit of code I have a question about.

<buttoncontrol name="button_global_effects">
<anchored to="header_toggles" position="insidetopleft" offset="50,8" width="20" height="20" />
<state icon="button_effect" />
<state icon="button_effect_down" />
<script>
function onValueChanged()
window.list.toggleEffects();
end
</script>
</buttoncontrol>

This xml snippit is defining a button control I assume , and the script code has the function onValueChanged which is called when a field value is changed for the button. Im assuming it toggles the down and up icon for the button .


My question is .. about window.list.toggleEffects(); my experience is in C++ so to me "window" would be a defined Class with "list" a defined member of "window" which" toggleEffects()" would be a function member of "list".

so.. where would I find documentation of these members (if that is actually what they are?) so I could begin my learning process. I see this a lot in the rules coding but have no idea where to find the info I need and ill be danged if I can find it being defined anywhere .

any help here would be greatly appreciated..

thanks in advance ..

damned
April 22nd, 2019, 00:48
Start by search the wholeruleset + corerpg (using find in files) for buttoncontrol
and then search that file you are in now for toggleEffects

The doco lists the inbuilt functions/routines
How you implement/use them and build on them is not doco'd - use the existing rulesets as guides

Forgive me if Ive mangled/mis-used terminology - Im no programmer!

Octavious
April 22nd, 2019, 01:06
Start by search the wholeruleset + corerpg (using find in files) for buttoncontrol
and then search that file you are in now for toggleEffects

The doco lists the inbuilt functions/routines
How you implement/use them and build on them is not doco'd - use the existing rulesets as guides

Forgive me if Ive mangled/mis-used terminology - Im no programmer!

Hi Damned thanks for your reply .. is this the documentation you are talking about ? https://www.fantasygrounds.com/refdoc/
..and is that the only source of information

I actually did a search of "window.list" of all the files in corerpg but came up with nothing to do with any definitions of those members. I also found that there are function members of "window" and function members of "list" so I am assuming all that is derived from some sort of library if its not defined anywhere in the corerpg. Things like that is what I am trying to determine if there is any docs or SDK on all that ?

Thanks for any help .

Varsuuk
April 22nd, 2019, 04:21
I'm running to take care of something but one thing I can suggest you do first is check out the page where they give you an overview of "scripting"
https://www.fantasygrounds.com/modguide/scripting.xcp
And the whole FG API page: https://www.fantasygrounds.com/refdoc/DB.xcp

As damned said, next is trace objects and how they are created from a ruleset to the base CoreRPG in some cases.

These are not really "classes" in the same sense you and I use with C++.
You should definitely skim read the Lua reference book to get a feel for it - but be aware to skip all the stuff that discusses using meta-tables (basically class prototypes) to create instances. The first link I gave explains why.
If you can find a short Lua fast tutorial that should be good enough for a dev to start with with the ref book for lookups.

Note that sometimes things are referred to (like windowclasses "instances") by the value in their [name="foo"] field. It got me a few times trying to find a template by that name instead. Yeah, forget everything about templates in C++, it isn't the same thing. It's probably an XML thing, but I never did C++ UI work and my configs were usually message based or in early days ini. So I don't know if template is an xml standard thing.

And yeah, damned is a source of damned good advice and helpful to the extreme.



Hi ,
I am trying to learn a little on the rulesets.. going thru it all I have lots of questions and maybe someone can point me to some documentation to help..

here is snippit of code I have a question about.

<buttoncontrol name="button_global_effects">
<anchored to="header_toggles" position="insidetopleft" offset="50,8" width="20" height="20" />
<state icon="button_effect" />
<state icon="button_effect_down" />
<script>
function onValueChanged()
window.list.toggleEffects();
end
</script>
</buttoncontrol>

This xml snippit is defining a button control I assume , and the script code has the function onValueChanged which is called when a field value is changed for the button. Im assuming it toggles the down and up icon for the button .


My question is .. about window.list.toggleEffects(); my experience is in C++ so to me "window" would be a defined Class with "list" a defined member of "window" which" toggleEffects()" would be a function member of "list".

so.. where would I find documentation of these members (if that is actually what they are?) so I could begin my learning process. I see this a lot in the rules coding but have no idea where to find the info I need and ill be danged if I can find it being defined anywhere .

any help here would be greatly appreciated..

thanks in advance ..

dulux-oz
April 22nd, 2019, 04:44
So, the key word "window" is is used to represnt the window object (duh!) just as you suspect. The "list" is the name of a child object of the window, and Moon's(?) coding style is to name all windowlists as "list" (you learn that from playing around with the code as much as I do :) ).

So, you're looking for a windowlist object named "list" defined as a child of the window (windowclass object).

Once you've found the correct "list" - and the full definition for windowlist objects are often in a corresponding "template" file - there will be a script with the "toggleEffects()" function - which is what you're after. This script could be embedded in the "list" windowlist definition, or it could be is a separate lua file referenced from the "list" object.

That should get you where you need to go - if you have any other question ask away :)

Octavious
April 22nd, 2019, 07:07
Varsuuk and Dulux-Oz .. thank you so much for the reply and help that will get me going in the right direction.. I really appreciate the help ..

thanx again !