Fantasy Grounds Fridays Pre
  1. #1
    celestian's Avatar
    Join Date
    Jan 2017
    Location
    DFW, Texas
    Posts
    2,997

    LUA Pattern matching issue...

    Can anyone see why this:

    Code:
    local nStart, nEnd = string.find(sNoteText,'<linklist>[^<]+<link class="imagewindow" recordname="[^\"]+">[^<]+</link>[^<]+</linklist>',1);
    Doesn't match:
    Code:
    					<p>Add links below.</p>
    					<linklist>
    						<link class="imagewindow" recordname="image.id-00002">Image: tsr</link>
    					</linklist>
    The same code works in FGC so im not sure why it breaks in FGU unless there is some hidden chars in there but even if that the method im using to set barriers should still accommodate that.

    For reference here is a similar entry from FGC:
    Code:
    					<p>Links here:</p>
    					<linklist>
    						<link class="imagewindow" recordname="image.id-00003">wizard-token</link>
    					</linklist>
    (this is one of those places where we REALLY REALLY need actual regular expressions)
    ---
    Fantasy Grounds AD&D Content Bundle (All The AD&D Content)
    Coding the Official AD&D Ruleset
    Documentation for AD&D 2E ruleset.
    My Twitch Channel for AD&D and FG related streams (See schedule for live days)
    My YouTube for FG related Tutorials and AD&D Actual Plays
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)

  2. #2
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    22,454
    Blog Entries
    1
    Can you try matching on:

    local nStart, nEnd = string.find(sNoteText,'<link class="imagewindow" recordname="[^\"]+">[^<]+</link>',1);

    and see if its the linebreak that is causing the issue?

    MoreCore - Generic Ruleset
    --- Projects ---
    Extensions | Tutorials | MoreCore | MoreCore Themes | Call of Cthulhu | Maelstrom | FG Con

  3. #3
    celestian's Avatar
    Join Date
    Jan 2017
    Location
    DFW, Texas
    Posts
    2,997
    Quote Originally Posted by damned View Post
    Can you try matching on:

    local nStart, nEnd = string.find(sNoteText,'<link class="imagewindow" recordname="[^\"]+">[^<]+</link>',1);

    and see if its the linebreak that is causing the issue?
    Unfortunately the way the code works is I need the entire <linklist>...</linklist> piece... that said [^<]+ should process any character (including \r or \n) up until the first < which is <link ...

    This would be so much easier if one could use "'<linklist>(.*)?<link class="imagewindow" recordname="(.*)"</link>(.*)?</linklist>'"


    That said I can test it and if it is then perhaps the return value from a formattedtext is different in FGU versus FGC.
    ---
    Fantasy Grounds AD&D Content Bundle (All The AD&D Content)
    Coding the Official AD&D Ruleset
    Documentation for AD&D 2E ruleset.
    My Twitch Channel for AD&D and FG related streams (See schedule for live days)
    My YouTube for FG related Tutorials and AD&D Actual Plays
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)

  4. #4
    celestian's Avatar
    Join Date
    Jan 2017
    Location
    DFW, Texas
    Posts
    2,997
    This looks to be a "bug" or... new way to handle text fields in FGU? If I change the match string to:

    Code:
    local nStart, nEnd = string.find(sNoteText,'<linklist><link class="imagewindow" recordname="[^\"]+">[^<]+</link></linklist>',1);
    It matches.... which means the local sNoteText = DB.getValue(nodeStory,"text",""); Removes \n\r now?

    IT also seems like getImageSize is no longer valid?

    Code:
        local w = Interface.openWindow("imagewindow",nodeImage);
        if w then 
          local ctrl = w.createControl("image_refblock", "image");
    Debug.console("manager_author_adnd.lua","createBlockImage","window (w)",w);   
    Debug.console("manager_author_adnd.lua","createBlockImage","ctrl",ctrl);      
          nXOriginal, nYOriginal = ctrl.getImageSize();
          nX, nY = getAdjustedImageSize(win,ctrl);
          w.close();
        end
    The above code fails when the values "w" and "ctrl" seem valid.

    [10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'sImageNode' | s'image.id-00002'
    [10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'sImageCaption' | s'Image tsr'
    [10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'nodeImage' | databasenode = { image.id-00002 }
    [10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'window (w)' | windowinstance = { class = imagewindow, node = image.id-00002, x,y,w,h = 658,44,778,765 }
    [10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'ctrl' | genericcontrol = { name = s'image', x,y,w,h = 0,0,0,0 }
    [10/20/2020 5:09:50 PM] [<color="red">ERROR</color>] Script execution error: [string "scripts/manager_author_adnd.lua"]:398: attempt to call field 'getImageSize' (a nil value)
    Same output in FGC (with the newline pattern) except getImageSize() works.
    Last edited by celestian; October 21st, 2020 at 00:14.
    ---
    Fantasy Grounds AD&D Content Bundle (All The AD&D Content)
    Coding the Official AD&D Ruleset
    Documentation for AD&D 2E ruleset.
    My Twitch Channel for AD&D and FG related streams (See schedule for live days)
    My YouTube for FG related Tutorials and AD&D Actual Plays
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Starfinder Playlist

Log in

Log in