STAR TREK 2d20
  1. #1
    rpotor's Avatar
    Join Date
    Sep 2015
    Location
    Szekesfehervar, Hungary
    Posts
    21

    Referencing stringcontrol value

    I know there will be a totally simple way to do this and I'll feel dumb, but anyways:

    In a windowclass I have a stringcontrol definition like so:
    Code:
    <stringcontrol name="theology">
    	<anchored to="knowledgesframe" position="insidetopleft" offset="10,240" />
    	<center />
    	<font>sheettextsmall</font>
    	<static>Theology</static>
    </stringcontrol>
    Within the same windowclass I have a number defined like so:

    Code:
    <basicnumber name="theologyscore">
    	<anchored to="knowledgesframe" position="insidetopright" offset="50,240" width="28" height="16" />
    	<script>
    	function onDoubleClick(x,y)
    	local abscorevalue = getValue();
    	local abname = window.theology.getValue();
    	end
    	</script>
    </basicnumber>
    And this works as is, without problem, but bear with me, we're slowly getting to my question. :-)

    So, with the control named theologyscore I can also do this if I want to:
    Code:
    local controlname = "theologyscore";
    local abscorevalue = window.getDatabaseNode().getChild(controlname).getValue();
    This works because the theologyscore control is in the database. However what I would like to accomplish is that on this line in the code:

    local abname = window.theology.getValue();

    I would like to reference the stringcontrol named theology with a variable, like I can do it with the theologyscore control in the getChild function in my above example. The problem of course is, that a stringcontrol is not in the database, so I can't do a getDatabaseNode().getChild call on it. So what I would like to do is something like:

    Code:
    local controlname = "theology"
    local abname = window.GetControlValueByName(controlname)
    Of course I know a GetControlValueByName function does not exist in Fantasy Grounds, well at least as far as I know :-), so it's just to demonstrate what I would like to accomplish.

    Is there any way to do something like this?

  2. #2

  3. #3
    rpotor's Avatar
    Join Date
    Sep 2015
    Location
    Szekesfehervar, Hungary
    Posts
    21
    Well yeah, I mean instead of stringcontrol I can use stringfield, which is bound to a database node, I just wanted to avoid unneccessarily bloating the db.

    The question in general is basically how I can access any xml tag from a lua script? I believe what I would like to accomplish is described here at the section titled Accessing XML parameters from script, but I think I'd need a working example code to be able to wrap my mind around that description.

  4. #4
    rpotor's Avatar
    Join Date
    Sep 2015
    Location
    Szekesfehervar, Hungary
    Posts
    21
    Oh, well. As usual, I figure out the solution after I ask for help... :-) So, to answer my own question and maybe enlighten future developers who find this topic years from now:

    To access for example a stringcontrol node, that is not in the database, do this (referring to my example codes above):
    Instead of
    Code:
    local abname = window.theology.getValue();
    you can do
    Code:
    local controlname = "theology"
    local abname = window[controlname].getValue()
    This enlightenment came to me on page 11 of the Anatomy of a Ruleset pdf, where it says The globally-visible variables provide shortcuts for other routines to access the character's basic traits (using characteristics.DEX or characteristics["DEX"] notation).

    So, TLDR move along, no question, figured it out, thanks damned anyway for trying to help. :-)

  5. #5
    Tubel's Avatar
    Join Date
    Mar 2012
    Location
    Canberra, Australia
    Posts
    34
    Although I am far from 100% sure, I believe I have seen the tag <target> used within some controls to do something similar

  6. #6

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    I believe target only works in cases where target is defined in the control xml. It is not an api feature per se.

  7. #7
    Tubel's Avatar
    Join Date
    Mar 2012
    Location
    Canberra, Australia
    Posts
    34
    Quote Originally Posted by Bidmaron View Post
    I believe target only works in cases where target is defined in the control xml. It is not an api feature per se.
    and now I'm 100% sure i didn't know :-)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in