DICE PACKS BUNDLE
  1. #1

    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 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.

  2. #2
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,674
    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?

  3. #3
    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 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
    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 20th, 2020 at 23:14.
    ---
    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.

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