5E Product Walkthrough Playlist
  1. #1

    Character Name and Skill Value in extension

    I am trying to learn how to program extensions for fantasy grounds and this is totally new to me. I have created projects in php and visual basic before but never touched lua. The best way to learn for me is to look at old code and examples, so I have gone through a lot of Damned's videos and they are so helpful and I have also zipped up extensions and looked at the structure there to understand it better. But I ran into some problems in a hobby project of mine.

    This is for 5e and the normal (not the unity) version of fantasy grounds.

    So I have added a skill called taunt to all characters. This worked and everytime I create a character this comes up. I also added this skill to the dropdown list on the Party Sheet so that I can test all characters at once with a simple click at the bottom of the main-frame of the Party Sheet. So far so good.

    My plan is to let the characters set a taunt skill in the misc-column from 0 to 6 on the skill page on the character sheet. A tank would set perhaps 6 and a caster 0. This is just a little help for me in some cases when I want to see which character that will be attacked. Of course I don't look blindly at this, but it is just a little help for me. Or should I say, just a test project. So I roll in those kind of situations and looked which one that rolled highest with the taunt-value added and I decide which character the mob attacks.

    What I want to do is to add text to the chat when a character have changed the misc value.

    I got this to work when I added the function for this in an already existing onValueChanged() in record_char_skills.xml. When you click on the edit skills button at the bottom of that frame. I first wanted to try so that I got the code correct. And I got it right there. The correct value from the skill taunt was shown in the chat with the character name when I clicked the edit button. When I saw that it worked there I removed it and wanted add this to an onValueChanged when someone actually changed the misc-value.

    I got this to work by adding the same code that worked before in a misc-tag. But instead of the charactername I got the skill name now and the skillvalue resulted in a nil-result. So I assume the code for calling the correct DB (local nodeWin = window.getDatabaseNode(); )is not correct, it seems to go to the skill-db instead or something just because I am inside the tags. I am just guessing.

    So my question, how do I get the correct character name from the character sheet I am on and why is not the getValue working anymore to get the correct value of the skill when it worked before I tried to do it inside the misc-tag?

    Here is the code that worked in one section of the character sheet but not inside the "misc"-tag.

    <script>
    function onValueChanged()


    local msg = {font = "msgfont"};
    local nodeWin = window.getDatabaseNode();
    local rActor = ActorManager.getActor("pc", window.getDatabaseNode());
    local curTaunt = DB.getValue(nodeWin, "skilllist.id-00016.misc");

    msg.text = rActor.sName .. " is changing the Taunt Value " .. " to ".. curTaunt;
    Comm.deliverChatMessage(msg);
    end
    </script>

    Thanks in advance for any directions or help. And thanks a lot for your videos Damned, they are really helpful.

  2. #2
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,649
    Blog Entries
    1
    What you should do first is add a debug after local nodeWin - something like:
    Debug.console("nodeWin: ", window.getDatabaseNode()

    and make sure that this is giving the result that you expect...

    Then do one for curTaunt
    and one for rActor.sName

  3. #3
    I did and it shows what I assessed happened when I ran the code. Since the function runs when I click enter after I have added a number to the misc-column on the skill-page it's like it forgot the character name and only focuses on the skill. When it worked it said "Angar changed his taunt-value to 6". Now it says Taunt changed...".

    This is what I get.

    Runtime Notice: s'nodeWin: ' | databasenode = { charsheet.id-00001.skilllist.id-00016 }
    Runtime Notice: s'rActor: ' | { s'sType' = s'pc', s'sCreatureNode' = s'charsheet.id-00001.skilllist.id-00016', s'sCTNode' = s'', s'sName' = s'Taunt' }

    So it's like I am one step too far in the database catalog to get the charactername. I am in charsheet.skillist when I should be in charsheet I guess. It most likely something simple but if you could push me in the right direction then I would be happy.

    With this console-help I understand how to get the correct value for the skill. I just changed to local curTaunt = DB.getValue(nodeWin, "misc");. But I have no clue how to get the charactername.
    Last edited by lindhsky; August 7th, 2020 at 14:56.

  4. #4

  5. #5
    the getParent fixed the problem! Thanks once again. I noticed one thing with this problem. I should have listened to you in your videos more about using console. That really pushed me in the right direction and made me understand.

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
  •  
FG Spreadshirt Swag

Log in

Log in