RPedit - Macro Importer/Exporter and Editor [4/19/13]

These are tools and utilities that make it easier to run games. This includes Lib: macro tokens dropped into MapTool to manage the game, a conversion file for CharacterTool to allow use in MapTool, or just about anything else you can think of -- except graphics with macros and anything specific to a particular campaign framework. Those are already covered by the Tilesets subforum and the Links and External Resources forum.

Moderators: dorpond, trevor, Azhrei, giliath, Gamerdude, jay, Mr.Ice

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by aliasmask »

No evaluations taking place. It's all in the assignment of the variable. From what I can tell, the parser goes, hey there's a json.. then says, there shouldn't be anything after CR and deletes it. Then says, wait, this isn't a json.. I'll just pass back what I have. That could be why only the first line is returned.

Lee
Dragon
Posts: 958
Joined: Wed Oct 19, 2011 2:07 am

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by Lee »

Ok, no evaluations then. Hmm, I'll look at the part of the code between b87 and 89. I'm not sure if it has something to do with MT per se; there might be a library upgrade in between versions that caused this. Out of curiousity, how does it look in b88? Also, I'd like to say that maybe we shouldn't put too much effort in ironing this bug out and, instead, do a workaround in mtscript instead. It may be a moot point some months down the line, I'm just saying.

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by aliasmask »

Yikes, that would be a pain if it was the java library. Whatever you feel is best. I didn't do enough testing on b88 to determine if there was an issue because it was so broken to start off.

Lee
Dragon
Posts: 958
Joined: Wed Oct 19, 2011 2:07 am

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by Lee »

aliasmask wrote:Yikes, that would be a pain if it was the java library. Whatever you feel is best. I didn't do enough testing on b88 to determine if there was an issue because it was so broken to start off.
I'm on the road ATM and I don't have my MT-related stuff, so I can't check right now, but, with regard to a libary change, I was referring to the json library (jsonlib I think) used by MT. Historically, upgrading to the latest. or at least newer, version of a 3rd party library broke some of the older MT functionalities e.g. UPnP. I should know this personally because I tried out the latest Apache Commons Lang and IO on MT, and I ended up bleeding for about a week :lol:

I hesitate to say anything as of the moment, but the changes I spoke of on PM look promising. I wish I had huge data sets to work with though.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by wolph42 »

How do you want the data sets? You can download them directly through my sig. In my framework. There is a lib on there with 1000 items containing 25 keys each which again contain 10 characters on average. There are also nested json objects. All are on lib:compendium.

EDIT: added the lib and its properties. (the fact that the .rptok is almost 1Mb and zipped and contains text only, gives you a hint of its datasize)
the biggest property should be allWeapons. It contains roughly 170k characters... which reminds me: I know of an even bigger set: the VBL stored for the dungeon builder 2. Ill attach that one too.
Nerps.DB.VBL.WithWallsAndCorners.Data.Long contains 350k characters

HTH
Attachments
VBL properties.txt
(686 Bytes) Downloaded 90 times
libVBL_DungeonTiles.rptok
(354.72 KiB) Downloaded 94 times
compendium properties.txt
(1.12 KiB) Downloaded 99 times
libCompendium.rptok
(787.17 KiB) Downloaded 95 times

Lee
Dragon
Posts: 958
Joined: Wed Oct 19, 2011 2:07 am

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by Lee »

Awesome, wolph, and thanks. If you have anything that is sure to break MT, I'd like to also try it out.

With all the work you and Jamz put in, I owe it to you both to be upfront with regard to the VBL work. Currently, I can't use it as I haven't incorporated Jamz' work into mine. It's not that I don't want to, but I've long since gone off on a different branch experimenting with vision that the VBL functions are sure to break. It's either I will have to write them anew to reflect the underlying/planned changes, or Jamz will have to wait to get the source in order to refactor his code and keep the user facing functions working like they do now. But, there's also the chance that I'll hit a brick wall and revert to what MT currently employs (i.e. Jamz won't have to do a rewrite) but, till then, I can't say anything more unless I see this through.

Thanks again :)

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by wolph42 »

did some debuggin on the 'label' issue and it turns out that it chokes on varsFromStrProp() doing this line:
0=fontColor=black;autoExecute=true;fontSize=11pt;sortBy=1;color=aqua;playerEditable=false;applyToSelected=false;group=debug;tooltip=;minWidth=94;index=3;maxWith=;includeLabel=false;compare=["group","sortPrefix","command","includeLabel","autoExecute","applyToSelected"];command=[H: id = arg(0)] [H: assert(getName(id) != getMacroLocation(),"Unless you like infinite loops, I don't recommend debugging the debugger",0)] [H: indexes = getProperty("rpe.allIndexes",id)] [H: eol = decode("%0A")] [H: debugStr.start = strformat('[H: am.test.debug(getMacroName(),macro.args)]%{eol}')] [H: debugStr.end = strformat('%{eol}[H: am.test.debug(macro.return)]')] [H: ' '] [H: debugStr.regex = "(^|\n)\[H: am[.]test[.]debug[(].*[)]\](\n|$)"] [H, foreach(index,indexes), code: { [H: setMacroCommand(index,debugStr.start+trim(replace(getMacroCommand(index,id),debugStr.regex,""))+debugStr.end,id)] }];label=addDebug
there are 16 variables, but it only does 15, so the last variable 'label' is never turned into a variable. macro in question is reformatMacroOutput. As I sorely need rpedit to work, i'll try to find a workaround for now.

edit: the first attempt immediatly resulted in an interesting error:

Code: Select all

2013-09-04 10:07:21,827 [client.MapToolLineParser:1301] DEBUG -   tmp	= macro
2013-09-04 10:07:21,829 [client.MapToolLineParser:1301] DEBUG -   tmp1	= json.toStrProp(tmp)
2013-09-04 10:07:21,830 [client.MapToolLineParser:1301] DEBUG -   tmp2	= varsFromStrProp(tmp1)
2013-09-04 10:07:21,832 [client.MapToolLineParser:1301] DEBUG -   tmp3	= getStrProp(tmp2, "label")
2013-09-04 10:07:21,833 [client.MapToolLineParser:1316] DEBUG - net.rptools.parser.function.ParameterException: "getStrProp()" requires exactly 1 parameters.
although the code was wrong, I found the error striking as getStrProp requires 2 parameters. After correcting the code, getStrProp returned nothing (which I partially expected).

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by aliasmask »

My last edit should have removed command from the variable before doing the varsFromStrProp just for that reason. I think I posted that up in the thread.

http://forums.rptools.net/viewtopic.php?f=1&t=21980

It still doesn't fix the MT bug with json misinterpreting the command line for a json, then nuking the string. You can make the adjustment manually from the link above. Oh, I just thought of a work around for that. I'll post something in the morning when I wake up. Going to bed now though. Basically, instead of putting the line in to a string which is mistaken for a bad json, I'll put it in to a json array of one. That should fix it. I'll have to change references to command to json.get as well.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by wolph42 »

aliasmask wrote:My last edit should have removed command from the variable before doing the varsFromStrProp just for that reason. I think I posted that up in the thread.

http://forums.rptools.net/viewtopic.php?f=1&t=21980

It still doesn't fix the MT bug with json misinterpreting the command line for a json, then nuking the string. You can make the adjustment manually from the link above. Oh, I just thought of a work around for that. I'll post something in the morning when I wake up. Going to bed now though. Basically, instead of putting the line in to a string which is mistaken for a bad json, I'll put it in to a json array of one. That should fix it. I'll have to change references to command to json.get as well.
here's a workaround, fairly simple solution, just add an extra json grab in the label = replace(....) line:

Code: Select all

@@reformatMacroOutput
@PROPS@ fontColor=white ; autoExecute=true ; fontSize=11pt ; sortBy=21 ; color=red ; playerEditable=false ; applyToSelected=false ; group=RPedit ; tooltip=Make it pretty ; minWidth=147 ; 
[h:'<!-- ---------------------------------------- reformatMacroOutput ------------------------------------------ -->']

[H: macro    = arg(0)]
[H: id        = arg(1)]
[H: eol        = decode("%0A")]
[H: defaultProps = am.test.glp("rpe.defaultProps")]
[H: macro    = json.merge(defaultProps,macro)]
[H: macro    = replace(macro,";","&#"+59)]
[H: varsFromStrProp(json.toStrProp(macro))]

[H: am.test.local.loadOptions()]
[H: command = replace(json.get(macro,"command"),"\\n{3,}",eol+eol)]
[H: command = replace(command,"&#"+59,";")]
[H: tooltip = replace(tooltip,"&#"+59,";")]
[H: label = replace(json.get(macro, "label"),"&#"+59,";")]

[H: props = strPropFromVars("fontColor,autoExecute,fontSize,sortBy,color,playerEditable,applyToSelected,group,tooltip,minWidth","UNSUFFIXED")]
[H, if(notepadFormat): macroheader = strformat("@@ @%s",label);macroheader = strformat("@@%s",label)]
[H: propStr = strformat("@PROPS@ %s",props)]
[H: oldSize = "0.75em,0.80em,0.85em,0.90em,0.95em,1.00em,1.05em,1.10em,1.15em,1.20em,1.25em"]
[H: oldSizeReplace = "8pt,8pt,8pt,9pt,10pt,11pt,12pt,14pt,18pt,20pt,24pt"]
[H: sizeList = "8pt,9pt,10pt,11pt,12pt,14pt,16pt,18pt,20pt,24pt"]
[H, if(listFind(oldSize,fontSize)+1): fontSize = listGet(oldSizeReplace,listFind(oldSize,fontSize))]
[H, if(!listFind(sizeList,fontSize)+1): fontSize = "11pt"]
[H: moutput = macroheader+eol+propStr+eol+trim(command)]
[H: macro.return = moutput] 

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by wolph42 »

found an issue again.

Tested in b90. I have a macro called 'remove %20' (which changes %20 in a token name into " "). The button macro chokes both on the macro name '%20' and the tooltip which contains '%20'

the choke takes place in
tool.editButtons.form
in

Code: Select all

      [H: output.2 = json.append(output.2,line1,line2)]

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by aliasmask »

I'll take a look later, but an error there doesn't make sense unless it's java related or if something is undefined. Now if it was related to strformat, I can understand the problem.

strformat has a bug when using % in certain circumstances. I only have b89. Is this a problem there as well?


User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by aliasmask »

The fix should be relatively easy. The strformat has the string and I think 2 parameters. Removing the parameters and setting them with their own value before and changing the %s to %{var} should fix it. The other option would be to replace % with %%, but I'm not as comfortable with that fix. I only discovered the strformat bug after writing RPEdit.

Lee
Dragon
Posts: 958
Joined: Wed Oct 19, 2011 2:07 am

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by Lee »

@AM Hi. I've been tracking an obscure bug which lies within RPEdit's code. under selectMacroIndexes, there's a simple line:

Code: Select all

[H: nameValue = eval("group_"+counter)]
which triggers the prompt for value popup we all know and love. I was wondering why it never caused any problems since this macro seemed like an integral part of pulling up the macro commands. The line on its own triggers the prompt.

I went as far back as b87 and it produces the same results, which is...weird, since a lot of people use the tool seemingly without problems.

If there is any information you can supply, I'd appreciate it. The problem with this is, the Wiki: eval() macro is different from other macro functions as it is actually a direct call to the parser's evaluate method. Since the parser's source is shot atm, it will be tricky to fix.

Thanks.

Edit: Looking at it more, I see it is because the resultant string of e.g. "group_1" is evaluated as a valueless variable, which then triggers the prompt. But the question remains, why hasn't this cause and problems when it goes as far back as (at least) b87?

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: RPedit - Macro Importer/Exporter and Editor [4/19/13]

Post by aliasmask »

I think you may be referring to an error that occurs when you manually change a macro on a token without reloading the indexes. Because I work on lib tokens that are fairly large and because I only update macros through the save button I thought doing an index update would take too long after each function, so I only do it with certain functions.

I'd have to go through the code for each time getGroups is called and see if it's a good place to put refreshGroups. Now if you think the error is caused by something else, then I'll need more details. BTW, it's very bad to do updates when the indexes are mixed up. You'll be updating a macro with the wrong code. Generally speaking, this can all be avoided if you don't change the macros manually. You can also close and open the RPEdit window to refresh or go to the Buttons menu and click Refresh.

Post Reply

Return to “Drop-In Macro Resources”