Thread: LUA Pattern matching issue...
-
October 19th, 2020, 21:18 #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);
Code:<p>Add links below.</p> <linklist> <link class="imagewindow" recordname="image.id-00002">Image: tsr</link> </linklist>
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>
---
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.
-
October 19th, 2020, 22:25 #2
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?
-
October 19th, 2020, 22:41 #3
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.
-
October 20th, 2020, 23:07 #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 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
[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)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