DICE PACKS BUNDLE
Page 2 of 2 First 12

Thread: Cycler

  1. #11
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    262
    OK, now what I would like to do is to have a button_stringcycler whose value is saved on the DB. There must always be a value on a field of the DB. I declared it wirhout the sourceles tag.
    Code:
    <button_stringcycler name="mycycler">
        <anchored width="60">
            <left parent="mylabel" anchor="right" offset="10"/>
            <top parent="mylabel" />
        </anchored>
    </button_stringcycler>
    In the LUA code, I initialized the values and labels in the same way:
    Code:
    myValues="one|two|three|four|five"
    Now I can initialize mycycler passing labels, values, empty value and default value.
    Code:
    mycycler.initialize(myValues, myValues);
    or
    mycycler.initialize(myValues, myValues, nil);
    or
    mycycler.initialize(myValues, myValues, "");
    or
    mycycler.initialize(myValues, myValues, nil, "one");
    or
    mycycler.initialize(myValues, myValues, "", "one");
    or
    mycycler.initialize(myValues, myValues, "one");
    The is no way to:
    1. have the value initialized with the db value ("one") - I've already tried to use
      Code:
      mycycler.setStringValue("one")
    2. hide the empty value


    A can remove "one" from the intial values/labels, but I still have no good result.
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

  2. #12
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    262
    I get an initial good result using
    Code:
    mycycler.initialize(myValues, myValues, "one", "one");
    But if I close and reopen the window, mycycler is empty.
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

  3. #13
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    262
    Ok, here is my solution. In this way I always have a field (and a value) on DB and I've no empty string shown.

    Template
    Code:
    <template name="mybutton_stringcycler">
       <button_stringcycler>
          <script file="common/scripts/mybutton_stringcycler.lua" />
          <sourceless/>
       </button_stringcycler>
    </template>
    mybutton_stringcycler.lua
    Code:
    local _nodeRecord;
    
    function onInit()
        _nodeRecord = window.getDatabaseNode();
    
        if super and super.onInit() then
            super.onInit();
        end
    end
    
    function onValueChanged()
        DB.setValue(_nodeRecord, self.getName(), "string", self.getValue());
    end
    window class
    Code:
    <mybutton_stringcycler name="mycycler">
        <anchored width="60">
            <left parent="mylabel" anchor="right" offset="10"/>
            <top parent="mylabel" />
        </anchored>
    </mybutton_stringcycler>
    window code
    Code:
    local _nodeRecord;       
    
    function onInit()
        _nodeRecord = window.getDatabaseNode();
    
        myValues="two|three|four|five";
    
        mycycler.initialize(myValues, myValues, "one");
        mycycler.setStringValue(DB.getValue(_nodeRecord, "mycycler", "one");
    end
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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 Product Walkthrough Playlist

Log in

Log in