FG Spreadshirt Swag
Page 1 of 3 123 Last
  1. #1
    Valarian's Avatar
    Join Date
    Mar 2007
    Location
    Worcestershire, UK
    Posts
    2,567

    StringField setUnderline()

    I'm trying to use the setUnderline(boolean) method to underline the skill names for The One Ring. This is working fine for the common skills, where I'm using a StringCOntrol with static text. However, it doesn't seem to work with a StringField to underline the value - which I'm using for weapon skills. Is the setUnderline method meant to work with StringField objects, or does it just work with static text?

    Examples:
    Code:
    function onValueChanged()
       window.awelabel.setUnderline(getState())
    end
    Above is the call to the setUnderline of the static stringcontrol from the checkbox.

    Code:
    function onInit()
       setUnderline(window.awefavour.getState())
    end
    This is the reciprocal code for the skill label stringcontrol to set the underline when the tab is opened.

    The weapon list item code is similar, but in an item windowclass for the weapon list. The name is also a stringfield rather than a stringcontrol.
    Code:
    function onValueChanged()
      window.name.setUnderline(getState())
      print("in OnValueChanged")
    end
    Again, I'm trying to set the underline on if the indicator is set. It's definitely going in to the code as I'm getting the debug comments.

    Code:
    function onInit()
        setUnderline(window.weaponfavour.getState())
        print("in OnInit")
    end
    And the reciprocal code in the name stringfield
    Using Ultimate license - that means anyone can play.
    Valarian's Fantasy Grounds Rulesets

  2. #2
    The function should be identical for both stringcontrol and stringfield, based on the code. Stringfield is actually derived from stringcontrol.

    You might want to set some print statements for the getState() result to see if the return value is not what you expect.

    Also, you might want to check out the Debug extension on the Downloads page. Once you turn on for a ruleset, it allows you to use Debug.chat and Debug.console to pass a list of variables to the chat window or console log, respectively.

    Regards,
    JPG

  3. #3
    Valarian's Avatar
    Join Date
    Mar 2007
    Location
    Worcestershire, UK
    Posts
    2,567
    Thanks Moon Wizard, I'll give this a go tonight
    Using Ultimate license - that means anyone can play.
    Valarian's Fantasy Grounds Rulesets

  4. #4
    Valarian's Avatar
    Join Date
    Mar 2007
    Location
    Worcestershire, UK
    Posts
    2,567
    Looks like the cross-referencing isn't working.
    The onInit in the name stringfield doesn't recognise the one weaponfavour checkbox value set. All three weapons I have in the list are coming back as false.
    The onValueChanged looks right in terms of the getState in the weaponfavour checkbox, but it's not setting the underline for the name stringfield.

    Code:
    Script Notice: in OnInit: 
    Script Notice: false
    Script Notice: in OnInit: 
    Script Notice: false
    Script Notice: in OnInit: 
    Script Notice: false
    Script Notice: in OnValueChanged:
    Script Notice: false
    Script Notice: in OnValueChanged:
    Script Notice: true
    Script Notice: in OnValueChanged:
    Script Notice: false
    Script Notice: in OnValueChanged:
    Script Notice: true
    Now trying the debug extension to see if that sheds any light.
    Last edited by Valarian; October 3rd, 2011 at 18:45.
    Using Ultimate license - that means anyone can play.
    Valarian's Fantasy Grounds Rulesets

  5. #5
    Valarian's Avatar
    Join Date
    Mar 2007
    Location
    Worcestershire, UK
    Posts
    2,567
    It's not making any more sense, even with Debug.

    I've added these lines to the code:
    Code:
    Debug.console(window)
    Debug.console(window.name)
    Debug.console(window.weaponfavour)
    Which produces this:
    Code:
    Runtime Notice: Reloading ruleset
    Script Notice: in OnInit: 
    Script Notice: false
    Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00001, x,y,w,h = 0,0,0,0 }
    Script Notice: STRINGCONTROL = { value = Bow, x,y,w,h = 0,0,0,0 }
    Script Notice: WINDOWCONTROL = { nil }
    Script Notice: in OnInit: 
    Script Notice: false
    Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00002, x,y,w,h = 0,0,0,0 }
    Script Notice: STRINGCONTROL = { value = Short Sword, x,y,w,h = 0,0,0,0 }
    Script Notice: WINDOWCONTROL = { nil }
    Script Notice: in OnInit: 
    Script Notice: false
    Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00003, x,y,w,h = 0,0,0,0 }
    Script Notice: STRINGCONTROL = { value = Dagger, x,y,w,h = 0,0,0,0 }
    Script Notice: WINDOWCONTROL = { nil }
    Script Notice: in OnValueChanged:
    Script Notice: false
    Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00001, x,y,w,h = 406,295,467,35 }
    Script Notice: STRINGCONTROL = { value = Bow, x,y,w,h = 0,10,110,15 }
    Script Notice: WINDOWCONTROL = { nil }
    Script Notice: in OnValueChanged:
    Script Notice: true
    Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00001, x,y,w,h = 406,295,467,35 }
    Script Notice: STRINGCONTROL = { value = Bow, x,y,w,h = 0,10,110,15 }
    Script Notice: WINDOWCONTROL = { nil }
    It looks as though the checkbox is not being recognised. The value exists in the db.xml and the tick is working on screen.

    EDIT: Looks like the nil value is a red-herring. Tried comparing to the common skills (which work) and I get nil for the checkbox there too.
    Last edited by Valarian; October 3rd, 2011 at 19:43.
    Using Ultimate license - that means anyone can play.
    Valarian's Fantasy Grounds Rulesets

  6. #6
    Ikael's Avatar
    Join Date
    Jan 2008
    Location
    Finland/Joensuu
    Posts
    2,384
    Is the problem that your stringfield's onInit() function is not recognizing checkbox's value and rather always returns false? If this is the case, I recall facing similar issue and the problem was that checkbox is custom made, with own onInit function that actually initializes and binds it to datasource. Stringfield and stringcontrol seemed to behave differently when invoking onInit, like they would be called in different stages and that messed up the whole thing. Could you try out invoking checkboxes onInit at stringfield's onInit function?
    "Alright, you primitive screwheads, listen up: THIS... is my BOOMSTICK!" -- Ash Williams, Army of Darkness

    Post your SavageWorlds ruleset feature requests and issue reports here!

  7. #7
    Valarian's Avatar
    Join Date
    Mar 2007
    Location
    Worcestershire, UK
    Posts
    2,567
    I've now got it working with the correct Debug output. Possibly to do with initialisation order. Still no underlines though.

    Now have, in the checkbox script area:
    Code:
        function onValueChanged()
          window.name.setUnderline(getState())
          print("in OnValueChanged:")
          Debug.console(window)
          Debug.console(window.name)
          Debug.console(getState())
        end
    
        function onInit()
          super.onInit()
          window.name.setUnderline(getState())
          print("in OnInit: ")
          Debug.console(window)
          Debug.console(window.name)
          Debug.console(getState())
        end
    This produces:
    Code:
    Script Notice: in OnInit: 
    Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00001, x,y,w,h = 0,0,0,0 }
    Script Notice: STRINGCONTROL = { value = Bow, x,y,w,h = 0,0,0,0 }
    Script Notice: bTRUE
    Script Notice: in OnInit: 
    Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00002, x,y,w,h = 0,0,0,0 }
    Script Notice: STRINGCONTROL = { value = Short Sword, x,y,w,h = 0,0,0,0 }
    Script Notice: bFALSE
    Script Notice: in OnInit: 
    Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00003, x,y,w,h = 0,0,0,0 }
    Script Notice: STRINGCONTROL = { value = Dagger, x,y,w,h = 0,0,0,0 }
    Script Notice: bFALSE
    Script Notice: in OnValueChanged:
    Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00001, x,y,w,h = 406,295,467,35 }
    Script Notice: STRINGCONTROL = { value = Bow, x,y,w,h = 0,10,110,15 }
    Script Notice: bFALSE
    Script Notice: in OnValueChanged:
    Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00001, x,y,w,h = 406,295,467,35 }
    Script Notice: STRINGCONTROL = { value = Bow, x,y,w,h = 0,10,110,15 }
    Script Notice: bTRUE
    So, now all looks good in terms of output, but no underlines. Losing hair tonight. Something to do with the x,y,w,h coordinates I think, but what I have no idea. Might leave it for tonight.
    Last edited by Valarian; October 3rd, 2011 at 20:21.
    Using Ultimate license - that means anyone can play.
    Valarian's Fantasy Grounds Rulesets

  8. #8
    Valarian's Avatar
    Join Date
    Mar 2007
    Location
    Worcestershire, UK
    Posts
    2,567

    Unhappy

    Still haven't got the underline to work properly, even though the Debug output looks correct.

    I've tried putting a setUnderline script in the stringfield, to call the same method in the superclass. This doesn't seem to get called at all.
    Code:
      function setUnderline(state)
        super.setUnderline(state)
        print("in setUnderline")
        Debug.console(state)
      end
    I've also tried placing an onInit function within the name stringfield. This should set the underline on for everything, no checking of conditions. The rest of the script code was disabled so that just this would run.
    Code:
      function onInit()
        print("in OnInit for name")
        setUnderline(true)
      end
    I'm coming to the conclusion that the setUnderline won't work at all for stringfield.
    Using Ultimate license - that means anyone can play.
    Valarian's Fantasy Grounds Rulesets

  9. #9
    On the skills page in the 3.5E and 4E ruleset character sheets, the rulesets use a textline frame to denote underlining. Then the frame is set or cleared depending on whether the skill name is editable. (i.e. custom)

    Check out charsheet/scripts/charsheet_skilllistitem.lua in the 3.5E ruleset.

    I'll add a note to my to do list to check out setUnderline.

    Thanks,
    JPG

  10. #10
    Valarian's Avatar
    Join Date
    Mar 2007
    Location
    Worcestershire, UK
    Posts
    2,567
    Thanks, it's looking at the moment as if setUnderline is working only for static text stringcontrols. The setFrame won't work for me as there's no way to turn it off again.

    The only way I can think of at the moment is a secondary invisible stringcontrol which has a frame and takes its value from the stringfield. Then display the stringcontrol instead of the stringfield if the favoured checkbox is ticked.
    Using Ultimate license - that means anyone can play.
    Valarian's Fantasy Grounds Rulesets

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