DICE PACKS BUNDLE
  1. #1

    setValue not actually setting Data issue.

    Ok. I finally admit it. I'm a little stumped. Can someone look over the following code and let me know why the setValue() call in it isn't actually setting any data to the node?

    Code:
    function setdiepool( prcQscore, statName)
        print("prcQscore: " .. prcQscore);
        print("statName: " ..statName);
        local highDieCountsource = window.getDatabaseNode().createChild("qualities." .. statName .. ".diepool.high.count");
        local highDieTypesource = window.getDatabaseNode().createChild("qualities." .. statName .. ".diepool.high.type");
        local lowDieCountsource = window.getDatabaseNode().createChild("qualities." .. statName .. ".diepool.low.count");
        local lowDieTypesource = window.getDatabaseNode().createChild("qualities." .. statName .. ".diepool.low.type");
        print("highDieCountsource NodeName outside if scope: " .. highDieCountsource.getNodeName());
        print("highDieTypesource NodeName outside if scope: " .. highDieTypesource.getNodeName());
    
        if prcQscore>0 then
            while not diepoolref[prcQscore] do
                prcQscore = prcQscore - 1;
            end
            print("Post While prcQscore: " .. prcQscore);
            if diepoolref[prcQscore] then
                if diepoolref[prcQscore]["highpool"] then
                    print("Highpool Processing");
                    if diepoolref[prcQscore]["highpool"]["count"] then
                        print("Diepool High Count: " .. diepoolref[prcQscore]["highpool"]["count"]);
                        print("Diepool High Typet: " .. diepoolref[prcQscore]["highpool"]["die"]);
                        print("highDieCountsource NodeName inside if scope: " .. highDieCountsource.getNodeName());
                        print("highDieTypesource NodeName inside if scope: " .. highDieTypesource.getNodeName());
                        highDieCountsource.setValue(diepoolref[prcQscore]["highpool"]["count"]);
                        highDieTypesource.setValue(diepoolref[prcQscore]["highpool"]["die"]);
                        print("highDieCountsource value inside if scope: " .. highDieCountsource.getValue());
                        print("highDieTypesource value inside if scope: " .. highDieTypesource.getValue());
                    else
                        print("-");
                        highDieCountsource.setValue("-");
                        highDieCountsource.setValue("-");
                    end
                end
                print("prcQscore: " .. prcQscore);
                if diepoolref[prcQscore]["lowpool"] then
                    print("Lowpool Processing");
                    if diepoolref[prcQscore]["lowpool"]["count"] then
                        print("Diepool Low Count: " .. diepoolref[prcQscore]["lowpool"]["count"]);
                        print("Diepool Low Typet: " .. diepoolref[prcQscore]["lowpool"]["die"]);
                        print("lowDieCountsource NodeName inside if scope: " .. lowDieCountsource.getNodeName());
                        print("lowDieTypesource NodeName inside if scope: " .. lowDieTypesource.getNodeName());
                        lowDieCountsource.setValue(diepoolref[prcQscore]["lowpool"]["count"]);
                        lowDieTypesource.setValue(diepoolref[prcQscore]["lowpool"]["die"])
                        print("lowDieCountsource value inside if scope: " .. lowDieCountsource.getValue());
                        print("lowDieTypesource value inside if scope: " .. lowDieTypesource.getValue());
                    else
                        print("-");
                        lowDieCountsource.setValue("-");
                        lowDieCountsource.setValue("-");
                    end
                end
            end
        end
    end
    The diepoolref table is defined later in the file and has been confirmed that its pulling all the data correctly.

  2. #2
    Anyone have any thoughts or suggestions?

  3. #3
    This is maddening. There is absolutely no reason this shouldn't be working that I can find. If anyone can offer some thoughts, I would most appreciate it.

  4. #4
    Zeus's Avatar
    Join Date
    Mar 2009
    Location
    Olympus
    Posts
    2,658
    Blog Entries
    2
    Drahkar - I think it would be useful to see the whole file rather than just this function. Any chance you could post it up?

    Is the code getting into the conditional blocks i.e. what output are you seeing on the console (print commands)?

    Also is this code from within the script block for a windowclass or window control or is it from a LUA file?
    FG Project Development
    Next Project(s)*: Starfinder v1.2 Starship Combat

    Current Project:
    Starfinder v1.1 - Character Starships
    Completed Projects: Starfinder Ruleset v1.0, Starfinder Core Rulebook, Alien Archive, Paizo Pathfinder Official Theme, D&D 5E data updates
    * All fluid by nature and therefore subject to change.

  5. #5
    Quote Originally Posted by DrZeuss
    Drahkar - I think it would be useful to see the whole file rather than just this function. Any chance you could post it up?


    I can do that. Just a note, I left off the reference tables. But those are just normal nested array tables. I can add them if you'd like, but I'm holding off if I can just because they contain book data and I'm not comfortable posting it until the ruleset has been approved by the publishers.

    Code:
    local speciessource = nil;
    local spectype = nil;
    local qstat = nil;
    
    function onInit()
        speciessource = window.getDatabaseNode().getChild("details.species");
        spectype = string.gsub(speciessource.getValue(), "(%(*)(%s*)(%)*)(%-*)", "");
        qstat = stat[1];
        print("Stat Variable Contents: " .. stat[1]);
        setdiepool(getValue(), stat[1]);
        speciessource.onUpdate = update;
        if getValue() == 0 then
            setValue(speciesqualityscore[spectype][qstat]);
        end
    end
    
    function update()
        speciessource = window.getDatabaseNode().getChild("details.species");
        spectype = string.gsub(speciessource.getValue(), "(%(*)(%s*)(%)*)(%-*)", "");
        qstat = stat[1];
        setValue(speciesqualityscore[spectype][qstat]);
    end
    
    function setdiepool( prcQscore, statName)
        print("prcQscore: " .. prcQscore);
        print("statName: " ..statName);
        local highDieCountsource = window.getDatabaseNode().createChild("qualities." .. statName .. ".diepool.high.count");
        local highDieTypesource = window.getDatabaseNode().createChild("qualities." .. statName .. ".diepool.high.type");
        local lowDieCountsource = window.getDatabaseNode().createChild("qualities." .. statName .. ".diepool.low.count");
        local lowDieTypesource = window.getDatabaseNode().createChild("qualities." .. statName .. ".diepool.low.type");
        print("highDieCountsource NodeName outside if scope: " .. highDieCountsource.getNodeName());
        print("highDieTypesource NodeName outside if scope: " .. highDieTypesource.getNodeName());
    
        if prcQscore>0 then
            while not diepoolref[prcQscore] do
                prcQscore = prcQscore - 1;
            end
            print("Post While prcQscore: " .. prcQscore);
            if diepoolref[prcQscore] then
                if diepoolref[prcQscore]["highpool"] then
                    print("Highpool Processing");
                    if diepoolref[prcQscore]["highpool"]["count"] then
                        print("Diepool High Count: " .. diepoolref[prcQscore]["highpool"]["count"]);
                        print("Diepool High Typet: " .. diepoolref[prcQscore]["highpool"]["die"]);
                        print("highDieCountsource NodeName inside if scope: " .. highDieCountsource.getNodeName());
                        print("highDieTypesource NodeName inside if scope: " .. highDieTypesource.getNodeName());
                        highDieCountsource.setValue(diepoolref[prcQscore]["highpool"]["count"]);
                        highDieTypesource.setValue(diepoolref[prcQscore]["highpool"]["die"]);
                        print("highDieCountsource value inside if scope: " .. highDieCountsource.getValue());
                        print("highDieTypesource value inside if scope: " .. highDieTypesource.getValue());
                    else
                        print("-");
                        highDieCountsource.setValue("-");
                        highDieCountsource.setValue("-");
                    end
                end
                print("prcQscore: " .. prcQscore);
                if diepoolref[prcQscore]["lowpool"] then
                    print("Lowpool Processing");
                    if diepoolref[prcQscore]["lowpool"]["count"] then
                        print("Diepool Low Count: " .. diepoolref[prcQscore]["lowpool"]["count"]);
                        print("Diepool Low Typet: " .. diepoolref[prcQscore]["lowpool"]["die"]);
                        print("lowDieCountsource NodeName inside if scope: " .. lowDieCountsource.getNodeName());
                        print("lowDieTypesource NodeName inside if scope: " .. lowDieTypesource.getNodeName());
                        lowDieCountsource.setValue(diepoolref[prcQscore]["lowpool"]["count"]);
                        lowDieTypesource.setValue(diepoolref[prcQscore]["lowpool"]["die"])
                        print("lowDieCountsource value inside if scope: " .. lowDieCountsource.getValue());
                        print("lowDieTypesource value inside if scope: " .. lowDieTypesource.getValue());
                    else
                        print("-");
                        lowDieCountsource.setValue("-");
                        lowDieCountsource.setValue("-");
                    end
                end
            end
        end
    end


    Quote Originally Posted by DrZeuss
    Is the code getting into the conditional blocks i.e. what output are you seeing on the console (print commands)?


    From what I can see, everything is outputting from the prints correctly right up until it errors for a nil value because the '
    print("highDieCountsource value inside if scope: " .. highDieCountsource.getValue());' is getting a blank datanode.

    Quote Originally Posted by DrZeuss
    Also is this code from within the script block for a windowclass or window control or is it from a LUA file?
    This is in a Lua file which is pointed to from a numberfield control.

  6. #6
    Zeus's Avatar
    Join Date
    Mar 2009
    Location
    Olympus
    Posts
    2,658
    Blog Entries
    2
    What happens if you try assigning the value from the nested array tables to an intermediate variable and then use the variable with setValue().

    e.g.

    Code:
    local strval = diepoolref[prcQscore]["highpool"]["count"];
    highDieCountsource.setValue(strval);
    
    print(strval);
    print(highDieCountsource.getValue());
    FG Project Development
    Next Project(s)*: Starfinder v1.2 Starship Combat

    Current Project:
    Starfinder v1.1 - Character Starships
    Completed Projects: Starfinder Ruleset v1.0, Starfinder Core Rulebook, Alien Archive, Paizo Pathfinder Official Theme, D&D 5E data updates
    * All fluid by nature and therefore subject to change.

  7. #7
    Tested and unfortunately the same result. It's a curiously weird problem.

  8. #8
    Zeus's Avatar
    Join Date
    Mar 2009
    Location
    Olympus
    Posts
    2,658
    Blog Entries
    2
    So from my example when you print the variable you get a value but when you print the getValue() from the control you get nil?

    EDIT: Also, What type is highDieCountsource and the other nodes your setting, have you tried forcing the node type during the createChild() calls? You maybe trying to assign a string to a number etc.

    EDIT 2: I'm on IRC if that makes it easier.
    Last edited by Zeus; September 3rd, 2010 at 12:09.
    FG Project Development
    Next Project(s)*: Starfinder v1.2 Starship Combat

    Current Project:
    Starfinder v1.1 - Character Starships
    Completed Projects: Starfinder Ruleset v1.0, Starfinder Core Rulebook, Alien Archive, Paizo Pathfinder Official Theme, D&D 5E data updates
    * All fluid by nature and therefore subject to change.

  9. #9

  10. #10
    And that hurdle is solved. With DrZeuss' help we were able to narrow it down to improperly set Node Types.

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