DICE PACKS BUNDLE
  1. #1

    Need help with auto-populated text

    So I am trying to update the text in a label, based off of the value of a number field. Any help would be appreciated.

    The code I have tied to the numberfield would be something like:

    Code:
    function onValueChanged()
    	local nMod = math.floor(getValue());
    
    	--...grab some label on my sheet...
    	local mylabel = getmylabelsomehow;
    	
    	--...change the value of the text on the label based on nMod from array in another file...
    	mylabel.setValue(ability_level_itos[nMod]);
    end
    My array is a simple number to string which is in some_common_data_file.

    Code:
    ability_level_itos = {
    	["1"] = "somevalue",
    	["2"] = "somevalue", 
    	["3"] = "somevalue",
    	["4"] = "somevalue",
    	["5"] = "somevalue",
    };

  2. #2
    What you can do is look at 3.5e or 5e to see how the ability scores changes the value of the modifier boxes as it would be the same principle of what you are approaching here. Using what you have above, I would do:
    Code:
    ability_level_itos = {
    	["1"] = "somevalue",
    	["2"] = "somevalue", 
    	["3"] = "somevalue",
    	["4"] = "somevalue",
    	["5"] = "somevalue",
    };
    
    function onValueChanged()
    	local nMod = math.floor(getValue());
    	
         --[[Choose one--]]
         --[[Setting by database--]]
         DB.setValue(dbnode, "mylabel", "string", ability_level_itos[tostring(nMod)]);
    
        --[[OR--]]
         --[[Setting by control--]]
         window.mylabel.setValue(ability_level_itos[tostring(nMod)]);
    end
    You can just simply place the lua table with the script outside of the function and call to it. This would make it local to this control. If you wanted it global, then you would need to set something up like data_common.lua that can be seen from the rulesets mentioned previously.
    Dominic Morta
    Ruleset Developer
    Smiteworks

    How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it

    How to provide an Unity Connection issue?-Connection Issues and What to Provide

    Unity Updater issue?-Updater Issues

    Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained

    Comcast or Cox ISP User?-Comcast XFinity and Cox Users

    Have a suggestion?-Feature Request

  3. #3
    Thanks for the reply. I'll test this out. I did reference 5e but was having some trouble back tracing the code. Will data_common.lua overwrite if I create a new one or just be additive to the existing like a form of inheritance? I'm still trying to figure out LUA syntax as most of my code has been written in versions of C or Java over the years.

    Update: using the array as local is working as intended. TY!
    Last edited by mixologee; August 11th, 2021 at 03:12.

  4. #4
    If you declare a new data_common.lua in the your extension code, it will overwrite the one in the ruleset code
    Dominic Morta
    Ruleset Developer
    Smiteworks

    How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it

    How to provide an Unity Connection issue?-Connection Issues and What to Provide

    Unity Updater issue?-Updater Issues

    Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained

    Comcast or Cox ISP User?-Comcast XFinity and Cox Users

    Have a suggestion?-Feature Request

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

Log in

Log in