5E Character Create Playlist
  1. #1

    Array of controls?

    Want to setup a set of graphical items in an array, so I'll need to figure out how many I have, and arrange them in the static space provided for them, most likely bind the set into a single generic control instance or the like, the set will change occassionally, and be derived from two database values, max/min, and I'll likely use the combobox check boxes as placeholder images. The numbers will not be directly editable by the user, but are derived from other values that they can set.

    All of this is relatively simple coding, but I'm unsrue how to instance a new control directly from a lua script, and assign it a location to me.

    I'm also wondering if the lua list is the best way to do this, as it can reference n-1 element in a list of n length, except where n=1, to determine it's relative partner for location of the element.

    I'm having trouble figuring out how to instantiated a new control from lua, and how to expose it's properties or manipulate it's properties. For example the generic control has nothing in it's lua information that would allow me to set it's anchor properties or offsets that I can find, but I'm guessing these elements are expose in the basic setup, I'm just not seeing it.

    It looks like everything inherits from widget, am I correct? So would my generic control be referenced by "window.controlname.setPosition(anchor, x, y)"?

    Hoping I'm on the right track here.
    Ultimate License Holder

  2. #2
    It's hard do tell what you are doing, so I'll respond with some general answers:

    • Widgets are definitely not the way to go; they are designed for simple label/graphic decorations on controls.
    • Every control is a widget container object (i.e. it can have one or more widgets). Every windowinstance is a control container object (i.e. it can hold one or more controls). Every windowinstance is a specific instantiation of a windowclass definition.
    • You will want to use numberfield if you want a control to reflect an internal database value.
    • You can create window controls by calling the createControl function which is valid within a given windowinstance.
    • The "characterlist" and "shortcuts" window classes and associated templates/child windowclasses are similar to what you are asking, but this is fairly complex coding.
    • My recommendation is that you go with a fixed set of controls. A lot of the challenges you are facing with the FG coding is because you are already trying to generalize everything without figuring out how to do things directly first.


    Regards,
    JPG

  3. #3
    Yes, I was planning to have a hidden number field, like the one I've used for ordering in the other work I've been posting here.

    Hmmm sounds like createControl is exactly what I want, then I can just set the anchor tags properties how I like based on where I am in an iteration, that should be possible.

    So say I had a character sheet window open, in a subwindow like "main", and I had a window with a frame setup called "combat_details", I could do something like window.combat_details.createControl, and setup a control, perhaps based on a template I've already constructed for the control I want to instance?

    It's not a bad suggestion, and I'll probably try to do that, though in the end I want to make efficient, brief code where possible, and reuse all the code I can. So ideally I want to pick up as much as I can for doing things as many ways as I can. I've been setting up other various fixed controls to get a handle on various other items.
    Ultimate License Holder

  4. #4
    Since you have a finite set of controls that you want visible at all times on a sheet, you are better off not using a list or dynamically creating controls. That's why all the ability score controls on every ruleset you've seen don't use that model. Just a suggestion to make your life easier in the long run.

    Regards,
    JPG

  5. #5
    Quote Originally Posted by GrimmSpector View Post
    Hmmm sounds like createControl is exactly what I want, then I can just set the anchor tags properties how I like based on where I am in an iteration, that should be possible.
    What you're missing is the (mental) understanding that a control created via creteControl is a windowcontrol. If you check the Ruleset Reference Guide on the Wiki you'll discover that there are three functions that windowcontrols have (among others): setAnchor, setAnchorHeight and setAnchorWidth. I suggest you check them out - they're what you need.

    Quote Originally Posted by GrimmSpector View Post
    So say I had a character sheet window open, in a subwindow like "main", and I had a window with a frame setup called "combat_details", I could do something like window.combat_details.createControl, and setup a control, perhaps based on a template I've already constructed for the control I want to instance?
    No, MUST be on a template, as per the description of the createControl function.

    Quote Originally Posted by GrimmSpector View Post
    It's not a bad suggestion, and I'll probably try to do that, though in the end I want to make efficient, brief code where possible, and reuse all the code I can. So ideally I want to pick up as much as I can for doing things as many ways as I can. I've been setting up other various fixed controls to get a handle on various other items.
    One of the things I tend to do is write and get working the specific, then generalise the specific solution - it normally always takes less time in the long-run, and I learn how the general works - Newton & Einstein did the same thing: Newton's 1st Law is only a specific case of the 2nd (I think it was Newton - it may have been Einstein)
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  6. #6
    Cool thanks, so I can create a window control as a template, that hold a bitmapwidget, and I can setup the code to make those bitmaps empty, or whatever I need on the fly as data changes. Probably use invisible fields, since they seem to update their data when the database updates right away. I think I can see a good way to structure and lay this out. Thanks again!

    Edit: Were you referring to special and general relativity? If you're speaking of Netwon's First and Second Laws, he didn't originate them, he just refined and described them more fully, with much better math, and codified their meanings. I'm a physics major.
    Last edited by GrimmSpector; February 27th, 2016 at 07:24.
    Ultimate License Holder

  7. #7
    Just to clarify:

    When you create a windowcontrol, you can specify the name of any built-in control type, or of any named template asset.

    Every windowcontrol is a widgetcontainer, and supports the addTextWidget and addBitmapWidget functions.

    Regards,
    JPG

  8. #8
    Quote Originally Posted by Moon Wizard View Post
    Just to clarify:

    When you create a windowcontrol, you can specify the name of any built-in control type, or of any named template asset.

    Every windowcontrol is a widgetcontainer, and supports the addTextWidget and addBitmapWidget functions.

    Regards,
    JPG
    Yup, I caught that Moon Wizard, thank you.
    Ultimate License Holder

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
  •  
DICE PACKS BUNDLE

Log in

Log in