5E Product Walkthrough Playlist
  1. #1

    add handler for xp awarding

    I am trying to figure out how to make an addHandler to watch the exp field of the party, and trigger a message when they receive xp..

    I do not know the best way to trigger it... I'm also not sure if the node I'm having it watch is the correct node... This script is completely off the top of my head... but it is something I am trying to figure out how to approach

    I'm not sure if it would be easier to watch the charsheet exp field or the partysheet exp field...

    What I am trying to do is when xp is awarded, I am trying to generate a chat message saying how much xp / xp needed each character in the party has...

    Code:
    onInit()
        DB.addHandler("charsheet.*.exp", "onUpdate", sendMsg);
    end
    
    function sendMsg(expNode)
        local expWindow = expNode.getParent();
        local nodeChar = expWindow.getParent();
        local exp = expNode.getValue();
        local expNeeded = DB.getValue(DB.findNode(expWindow),"expneeded","");
        local charName = DB.getValue(nodeChar, "name", 0);
    
        local msg {};
        msg.text = charName.." has "..exp.."/"..expNeeded.." XP";
        Comm.deliverChatMessage(msg);
    
    end
    any suggestions? corrections?

    V/r,
    Diablobob
    Last edited by Diablobob; July 26th, 2019 at 01:54.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,413
    If you want to display a message every time the XP changes it might be best to do it at the character sheet level - then any source of XP (including the player changing it themselves) will product a message.

    When you're looking to add DB handlers, create some example data in the campaign, save the campaign data (either type /save in the chat or exit the campaign) and then look at the DB structure in the campaign db.xml file.

    In this case, the character XP is stored in charsheet.*.exp and the exp needed is stored in charsheet.*.expneeded
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    The party already gets chat notice when experience is awarded.

    The EXP field is charsheet.*.exp
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  4. #4
    Yes... I want to send an exp left message... so a little something extra...

  5. #5
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    Expand the current message to include the XP awarded AND the XP required?

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
  •  
DICE PACKS BUNDLE

Log in

Log in