DICE PACKS BUNDLE
Page 3 of 3 First 123
  1. #21
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,709
    Blog Entries
    1
    Hi Trenloe - what things am I looking at for extending this to include NPCs?
    Am i duplicating the function addPC(nodePC) and modifying or am i sticking with that function and doing some if/then?

    Im getting this error:
    Script Error: [string "scripts/manager_combat2.lua"]:38: attempt to call field 'getNodeName' (a nil value)

    From this statement (38 in red):

    -- Set up the CT specific information
    DB.setValue(nodeEntry, "link", "windowreference", "npc", nodeNPC.getNodeName());
    DB.setValue(nodeEntry, "friendfoe", "string", "friend");
    nCharInit = DB.getValue(nodeNPC, "char.init", "number", "");
    Debug.console("nCharInit");
    DB.setValue(nodeEntry, "initresult", "number", nCharInit);


    looking at db.xml I see a problem... there is no recordname in the NPCs in the combattracker section
    <id-00012>
    <public />
    <active type="number">0</active>
    <effects>
    <public />
    </effects>
    <initresult type="number">0</initresult>
    <link type="windowreference">
    <class>npc</class>
    <recordname></recordname>
    </link>
    <reach type="number">1</reach>
    <space type="number">1</space>
    <token type="token"></token>
    <tokenscale type="number">1</tokenscale>
    <tokenvis type="number">0</tokenvis>
    </id-00012>


    when i look at the characters:
    <id-00007>
    <public />
    <active type="number">0</active>
    <effects>
    <public />
    </effects>
    <friendfoe type="string">friend</friendfoe>
    <initresult type="number">43</initresult>
    <link type="windowreference">
    <class>charsheet</class>
    <recordname>charsheet.id-00002</recordname>
    </link>
    <name type="string">Eavan Wainright</name>
    <reach type="number">1</reach>
    <space type="number">1</space>
    <token type="token">Tokens/man062.png@Pulp Photo Tokens - Public Domain Images</token>
    <tokenscale type="number">1</tokenscale>
    <tokenvis type="number">0</tokenvis>
    </id-00007>


    Whats happening? Whats not happening is probably more accurate? Somewhere before I query that data its not getting set.

  2. #22
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,470
    Look at the reason for the error. This is what you need to do - don't jump ahead and try to look at the database after the event.

    The error is attempt to call field 'getNodeName' (a nil value) This means that there is nothing/nil/zip/nada in relation to the getNodeName function call. This function is getting called with nodeNPC.getNodeName() which is correct syntax, so the only think that could be nil at this point is nodeNPC. That is the reason for your error - nodeNPC doesn't exist or isn't a databasenode.

    Anyway, I'd not recommend doing what you're trying to do. Instead you should be copying the addNPC code from manager_combat.lua into manager_combat2.lua (as I eluded to earlier). But, when you look at this code, it gets a little more complicated - addNPC doesn't do much, the main code is in addNPCHelper. So:
    1. copy both of these functions (addNPC *and* addNPCHelper) to your manager_combat2.lua file
    2. remove the 3 lines beginning with if fCustomAddNPC then in addNPC in your manager_combat2.lua file
    3. add CombatManager.setCustomAddNPC(addNPC); to onInit in manager_combat2.lua to register the custom addNPC function.
    4. add CT_LIST = "combattracker.list"; at the top of the manager_combat2.lua (before onInit).

    Then, do any of your custom code in the addNPCHelper function in manager_combat2.lua.
    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. #23
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,709
    Blog Entries
    1
    I was torn between the two methods and I did try them both initially. I went back to the one above as the current addNPC from the manager_combat.lua was so much more complex - has lots more options...

    anyways Ive grabbed the addNPC and addNPCHelper into my manager_combat2.lua
    i stripped a bunch of code to do with renaming/numbering (for 2 reasons - i dont have those options and they were erroring and failing...) and some code on size and reach which was failing as I removed those options from the NPC character sheet so they will always be NIL...
    the stripped down code is allowing NPCs to add to CT again
    Ive checked both the existing code and the stripped code and I cant find any reference to INIT in there... so my NPCs are adding but without any INIT.

    So Ive added the following code -

    nNPCInit = DB.getValue(nodeNPC, "char.init", "number", "");
    Debug.console("nNPCInit");
    DB.setValue(nodeEntry, "initresult", "number", nNPCInit);

    and it seems to be working.

    Other than tracking on battlemaps - do you see any issue on removing the random numbering of NPC entries? (eg: Mercenary 2, Mercenary 13, Mercenary 6).

  4. #24
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,470
    Quote Originally Posted by damned View Post
    Other than tracking on battlemaps - do you see any issue on removing the random numbering of NPC entries? (eg: Mercenary 2, Mercenary 13, Mercenary 6).
    I'd recommend including this now if you can - it's only enabling the options in the campaign options entry and leaving the code in addNPCHelper. I can pretty much guarantee very soon you'll want to have the NPC names unique - even if just to avoid confusion of identifying which token belongs to which entry on the combat tracker, but also if you introduce targeting, effects, etc., etc.. I don't think there is any specific functionality it will break, but having each NPC uniquely identified will avoid a lot of confusion in your game.
    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!

  5. #25
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,709
    Blog Entries
    1
    Runtime Notice: s'sEntryName = Eavan Wainright'
    Script Error: [string "scripts/manager_combat2.lua"]:151: attempt to call global 'stripCreatureNumber' (a nil value)

    I think I know why I get the error... if I put the whole code - bar the reach and size - back in I get the above. The problem seems to be that the DB.getValue is NOT grabbing the NPC - it is grabbing the name of the FIRST EXISTING entry in the Combat Tracker... if there isnt one in there it adds the NPC successfully - if there is an existing PC or NPC it returns the name of the first one and errors and does not proceed... line 151 in red.

    for _,v in pairs(DB.getChildren(CT_LIST)) do
    local sEntryName = DB.getValue(v, "name", "");
    Debug.console("sEntryName = " .. sEntryName);
    local sTemp, sNumber = stripCreatureNumber(sEntryName);
    if sTemp == sNameLocal then
    nodeLastMatch = v;

    local nNumber = tonumber(sNumber) or 0;
    if nNumber > 0 then
    nNameHigh = math.max(nNameHigh, nNumber);
    table.insert(aMatchesWithNumber, v);
    else
    table.insert(aMatchesToNumber, v);
    end
    end

  6. #26
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,470
    Use: CombatManager.stripCreatureNumber(sEntryName); instead of stripCreatureNumber(sEntryName);

    The stripCreatureNumber function is in the manager_combat.lua file. Leave it there, it's fine where it is. You just need to reference the package name CombatManager. in front of any function you're using from manager_combat.lua if you're not making the call from within the same file.
    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!

  7. #27
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,709
    Blog Entries
    1
    Great - that was the answer to the nextissue too! When I turned on Random numbering in the Options it also failed until adding that to the randomName function. i better see what else is doing that...

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
  •  
STAR TREK 2d20

Log in

Log in