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

Post Reply
User avatar
aliasmask
RPTools Team
Posts: 9101
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

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

Post by aliasmask »

RPedit - Macro Importer/Exporter and Editor

Download Latest Release (7-19-21)

Code: Select all

5-7-20 aliasmask: Update many of the varsFromStrProp references to the newer json.toVars() 
Requires MT version 1.5.5 or later.

5-18-20 aliasmask: MT bug with applyToSelected. Applied "temp" fix to reformatMacroOutput. 
This shouldn't break after the MT fix is applied.

7-19-21 (AM): Updated to filter CR in tooltips (new feature) and to handle 
html entities with ; in macro name.



The rest of this stuff is old, but still relevant.

Special thanks to CoveredInFish for the original inspiration of MacroIO.

I'm still updating the manual, but I hope most things are intuitive. It was fun using the editor to update the editor while running. Just can't touch the save or load stuff. I'm not really happy with the color scheme of the button editor, but it's less offensive than it was. I'll probably update that as well in the future. I'm going to start work on v1.2 adding debugger tools, reformatting the tools menu and removing tweaks tab and putting functionality in to the tools area. Once I get the debugger in there, I'll start working on my other projects, namely spell lib 2.0.[/b]

__________________________________________________________________________________________
__________________________________________________________________________________________

Getting Started

  • Download the latest release or pre-release version.
  • Add RPedit to your maptools map, version 1.3.b87 or later.
  • Drag Edit Token to your campaign frame. Make sure to uncheck Allow Players to Edit in options on new macro. Verify Apply to Selected Tokens is still checked.
  • First time, run onCampaignLoad to define functions and initialize data.
  • Select a token to modify and click Edit Token.
  • Click Config and set to your preferences. (see manual for options)
  • Paste text in to text area with the proper format and save macros.
  • Click Load and select macros to export to text area.
  • Use Tools for related macro manipulation.
  • Be sure to read the manual, feature history and FAQs.

__________________________________________________________________________________________

RPedit Manual
  • ||| Config Options - Modes |||
    • Image
    • Turn on Edit Mode: When selected, then the Text Area does not clear after saving.
      • Reload after Save: When selected, the Text Area will reload any new formats generated when saved. Depending on your other options selected, comments could be put in the statement, the property string will show and the order of macros could be resorted.
    • Enable Last Save History: When selected, a list of the macros saved are remembered.
      • Load Last Save on Startup: When selected, when the RPedit frame is opened the last saved macros are pre-loaded in to the text area.
    • Show TAB Groups for Multi Macro Select: When selected, you'll have the option to select macros by groups or individually.
      • Default Macro Select on Load: When selected, the Macro Select option is pre-selected for load options.
    • Default Text Area Setting on Load: When loading saved macros, you have an option to ignore, save or reload the text in the Text Area. Choosing an option here pre-selects that option for you.
    .
  • ||| Config Options - Tweaks |||
    • Image
    • Notepad++ collapsible format: When selected, loaded macro will be outputted in collapsible format. Notepad++ SCREEN SHOT
      Image
    • Re-sort buttons by color on Save: When selected, saving will change the sort order of colored buttons that have no sort order. This will group like-colored buttons together, then alphabetical. When editing buttons and this is selected, the same will be applied.
    • Change line comments to statements: When selected, saving macros will update comment lines to comments within a statement. This will prevent it from going to the chat panel.
    .
  • ||| Config Options - Local |||
    • Image
    • Set Form Width: This sets the width of the Text Area.
    • Set Form Height: This sets the height of the Text Area.
    • Open Dialog instead of Frame: When selected, a Dialog will open instead of a frame.
    .
  • ||| Edit Buttons |||
    • Edit Buttons SCREEN SHOT
      Image


      Notes:
    • Each group has a submit button that will only submit for that group. The Update All button is at the bottom of form.
    • You can quickly change multiple macro button and attributes at one time.
    • You can either enter a color code (#000000) for a button color or font or select from the dropdown list below custom field.
    • Buttons can be re-sorted by button color if you have re-sort enabled. Once an order is set, it is not changed with with the re-sort. You can set it to 0 and it will again be re-sorted based on button color.
    • Order does not effect how the macros are display in Edit Buttons form. They are listed alphabetically.
    • You can change macro button group with the dropdown list button.
    • You can add a group, temporarily if you update before a macros is assigned to it, by clicking "+ Group". Just enter a unique group name with no HTML or special characters.
    • Tooltip currently converts double quotes to single quotes.
    • Instead of having to go to Tools button, you can update the Edit Buttons screen with Refresh.
    • Macro Buttons are representative to how they appear in the Select Frame. If you click a macro button in the Edit Buttons window, you can bring it up in the Editor, Delete or Rename it.
    • Size is converted to pt style font and only pt fonts in the list are recognized. Unknown fonts will be set at 11pt.
    • If you do a lot of editing on the token and you leave the Edit Buttons window open, be sure to hit the Refresh button.
    .
__________________________________________________________________________________________

Logo
__________________________________________________________________________________________
/// Original v1.0 Download File \\\
RPedit v1.0 MT1.3.b75.rptok
Last edited by aliasmask on Fri Apr 19, 2013 5:06 am, edited 40 times in total.

User avatar
aliasmask
RPTools Team
Posts: 9101
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: RPedit - Macro Importer/Exporter and Editor

Post by aliasmask »

ImageRPedit Version History

Color Key[list][*]Green - completed but not released[*]Red - currently being worked on[*]Blue - Purposed feature not yet addressed[/list]
Purposed Features (likely order of progression)
  • Add debugger with built in timers
  • Exclude Props from export (hybrid, only show props that differ from default)
  • Comment Remover - saves comments to token, but not to macro. Export still shows comments.
  • Special comments - Tip shown below macro header, Props comment
  • Scan code for macro functions and add prefixes.
  • Auto create onCampaignLoad from template to make all macros UDF functions.
  • Add a token status tab with various info (num groups and their macro count). This may transform the way I display edit mode as well, ie shown as a symbol on a button. Not sure at this point.
  • Create an undo last save option. Only available if option for backups is on. This will rewrite existing macro back to old and delete newly created macros.
  • Delete and Save Copy As tools to be added.
  • Adding debugger - This will update each macro with code to track progress and give report at end of macro processing.
    • Adds code to start and end of macro when enabled, removes when disabled.
    • Will require MT 1.3.b76 for timer info.
    • Select macros to exclude from debugging. onCampaignLoad is always listed.
    • Walk through mode. Will pause at each macro with report then continue.


v1.2pre2 features [WIP]
  • Bug fix - Removed Tab Groups option from config. Will always display option to load macros individually.
  • Bug fix - "All Buttons" on Edit Buttons not working - fixed.
  • Add Create Group option to Edit Buttons.
  • Add Delete macro and Rename to Edit Buttons.
  • Option for standardized button sizes.

    v1.1 features (11/17/10)
    • Added "Add Selected" to load screen. Enabled by checking "Show TAB Groups" and "Enable Last Save History". Allows you to add more functions to current screen without having to reselect them.
    • New logo and various interface changes (increase token name font, reduced button size and added bold text to buttons).
    • Add option to auto-save text when loading new window for recovery.
    • Mass Token edit for button tooltips, fonts, colors, ordering. Utilizes re-sort option. adding size and group change.
    • Tools button to handle one shot editing.
    • New intermediary macro naming convention for collapsible macros in Notepadd++.

      Code: Select all

      @@macroName (okay)
      @@ macroName (okay)
      @@ @macroName (okay)
      @@@macroName (okay)
      ...
      !! (okay) 
      Putting a blank space after @@ will cause the start of a collapsible area and ends in !!. Any !! on a line by itself is removed on save. The macroName is filtered for starting @ symbol. The only reason to put the @ symbol is for highlighting purposes at this point.[/color]
    • Added option to load macros in Notepad++ collapsing format.
    • New options for handling text area when loading and some other default loading options.
    v1.0 features (11/09/10) -
    ||| v1.0 Features |||
    • Import and Export code from a frame or dialog window (optional)
    • Resort buttons based on color (optional)
    • Wrap line comments in to a statement (optional)
    • Remembers last save and can open files on next load (optional)
    • Adjustable interface
    • Faster Loading and Saving
    • Optional modes for performance and features
    • Single Button access "Edit Token"
    • Each token maintains it's own setting, but starts with the global setting.
    • All, Group, Last Saved or Individual Macro loading
    • Each Token has it's own window
    • If you manually adjust buttons (move, copy, delete) click "Refresh" or close and reopen token
    • If all else fails, click "setDefaultConfig" and "onCampaignLoad". Please report any bugs or things that confuse you.
[/b]
Last edited by aliasmask on Sat Apr 09, 2011 4:25 pm, edited 26 times in total.

User avatar
aliasmask
RPTools Team
Posts: 9101
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: RPedit - Macro Importer/Exporter and Editor

Post by aliasmask »

ImageRPedit FAQ's:

  • Q: What is Edit Mode?
  • A: Edit Mode will keep the text in the box after begin saved. When it is not on, the text area is cleared after macros are saved. Edit Mode also allows for the option to Reload after Save to the format used when macros are loaded. The reformat will include the full Properties String and any other optional reformat tweaks.

  • Q: Why do I have to reselect which macros to load after I use Reload after Save option?
  • A: Because it doesn't know which macros to load. You can check Enable Last Save History and it will no longer prompt you which macros to load.

  • Q: Why did my macros not load giving me the message: "No macro at index 22"?
  • A: One way to cause this is to open RPedit and then manually copy, delete or move a macro button on the token. Doing this can also cause an unseen and possibly unnoticed error and your load will be missing the new macros. The solution is to either close and reopen that frame, or run "Refresh" for that token. It is recommended that you avoid changing the token buttons manually in the above described manner. But if you need to, then know you have to refresh your frame in the 1 of the 2 methods described.

  • Q: I had some text in the editor and I wanted to add another macro to look at. I loaded and selected the one macro, but it loaded the macro I wanted and some other macros. What happened?
  • A: What happened is that it added the new macros selected and your last current save. The text in your window apparently was not saved before loading the new macro. I will add a feature to always auto save old text before loading new page so it may be recovered. This will effect performance possibly (maybe 1 second extra in extreme cases), so it will be defaulted to off.

  • Q: What is the proper format for saving macros?
  • A: There are several format options. Multiple macros can be saved this way.
    ||| Proper Formats |||
    • Simple

      Code: Select all

      @@macroName1
      ...
      
      @@macroName2
      ...
       
    • Notepad++ Collapsible

      Code: Select all

      @@ @macroName1
      ...
      !!
      @@ @macroName2
      ...
      !! 
    • With props

      Code: Select all

      @@macroName1
      @PROPS@ color=blue;fontColor=yellow;...
      ...
      
      @@ @macroName2
      @PROPS@ color=blue;fontColor=yellow;...
      ...
      !! 
[/b]
  • Q: I have two macros with the same name, but it only shows the one macro, why?
  • A: This is a limitation of RPedit. All the macros should be unique in name.
Last edited by aliasmask on Wed Dec 01, 2010 4:19 pm, edited 11 times in total.

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

Post by wolph42 »

Nice! Can't wait to try it out.

Btw, on our other discussion with your remark on varfromstrprops (or so), I've did some benchmarks on json objects, json arrays and lists (as all three can be used for the same thing) and Lists are by a far longshot faster (which why I don't use e.g. json.eval()). For 'normal' code jsons are perfect to make the coding easier but if your going to do bulk its best to solely rely on string/lists only.
Here's the benchmark test

Edit: first question: What is 'Edit Mode' ?

User avatar
aliasmask
RPTools Team
Posts: 9101
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: RPedit - Macro Importer/Exporter and Editor

Post by aliasmask »

wolph42 wrote:Nice! Can't wait to try it out.

Btw, on our other discussion with your remark on varfromstrprops (or so), I've did some benchmarks on json objects, json arrays and lists (as all three can be used for the same thing) and Lists are by a far longshot faster (which why I don't use e.g. json.eval()). For 'normal' code jsons are perfect to make the coding easier but if your going to do bulk its best to solely rely on string/lists only.
Here's the benchmark test

Edit: first question: What is 'Edit Mode' ?
Yeah, I'm familiar with lists and I'll use where I can. This project in particular uses listAppend for combining the index numbers, but I couldn't using for combining code because of the special characters. Also, use of lists will trim your data and whitespace needs to be preserved. Also, to maintain speed, I did not use encode and decode. It didn't add that much time, but ended up not being necessary using my regex keys. The only formatting issues I had was outputting to the text area. That is much more fickle than to a normal html frame. I had to convert & < \ and /. I need to change / because when used in an html link in the code, maptools will break the text area and create an html link for it when used in the link format. I discovered this randomly using Lindsay's Framework to benchmark RPedit's speed. It's funny, I change my original code for converting \ from replacing with \x8 to it's html entity &#92 and it increased the framework loadtime from 11s to 8s.

Another thing I discovered was when using an array of objects that [foreach:] doesn't handle it like a normal array assigning the value to the index. It assigns the whole array to the index. That is one reason why I went with nested objects. Usually, if I need to use json.get 3 or more times from a single object, I use the Wiki: varsFromStrProp() trick. It's also handy if the object is particularly large and/or complicated. The only limitation is the key values have to be variable naming friendly. The other limitation is the use of ; anywhere in the data. That can be overcome if you do a replace on the code before varsFromStrProp and back after varsFromStrProp because ; is used as a separator. The extra added step didn't add that much time, but isn't worth it for small data sets.


User avatar
aliasmask
RPTools Team
Posts: 9101
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: RPedit - Macro Importer/Exporter and Editor

Post by aliasmask »

You missed my Edit. It's in the FAQs.


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

Bug, request, remark

Post by wolph42 »

Bug:
This:

Code: Select all

[if(atmSize > 5):shift = -floor((atmSize-4)/2);shift = 0] 
notice the "/2" (I know you have problems with that one :wink: )
is exported as this:

Code: Select all

@@test
@PROPS@ fontColor=black;autoExecute=true;fontSize=1.00em;sortBy=;color=default;playerEditable=true;applyToSelected=false;group=Build;tooltip=
[if(atmSize > 5):shift = -floor((atmSize-4)ǘ);shift = 0] 
Request:
It would be nice if the 'Load' settings are remembered, so you don't have to select the right radio button every-time.

Remark:
I noticed that if I create a new macro on a token (manually) its not populated on the 'select individual macro' tab.

User avatar
aliasmask
RPTools Team
Posts: 9101
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: RPedit - Macro Importer/Exporter and Editor

Post by aliasmask »

Here's the fix to the bug:

Code: Select all

@@openFrame
...
   [H: taText = replace(taText,"&","&")]
   [H: taText = replace(taText,"\\\\","\")]
   [H: taText = replace(taText,"<","<")]
   [H: taText = replace(taText,"/","/")]
...
Just put ; (semi-colon) after the numbered replaces. If you put a space after / then it wouldn't do that. I'm assuming &#472 is ǘ (verified).

I have redone the menus somewhat and included existing text area manipulation (ignore,save,load saved with loaded macro,load saved and existing with loaded macros. Now that I'm thinking about it, I should add load existing with selected macros. I have a stable pre-release for v1.1 with those changes. You can try it out and tell me if it works the way you want. The only thing not working is the "tools" button.

edit:
Remark:
I noticed that if I create a new macro on a token (manually) its not populated on the 'select individual macro' tab.

No it's not. There is a blurb on that in the FAQs. Basically, when you manually edit there's no way for the token to know it (without a lot of overhead), so you have to either hit "Refresh" or close and open the frame. I'm adding the refresh to the tools button so there will be no need for another macro button in the campaign window.

edit: I added the option to start the load selection by macro select.


User avatar
aliasmask
RPTools Team
Posts: 9101
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: RPedit - Macro Importer/Exporter and Editor

Post by aliasmask »

Version 1.1 is almost done and the macro button editor is coming along nicely. Just a few more tweaks to process the form submit, maybe some more beautifying of the form and it should be ready to go.

I had use all my macro ninja skills for a fast dynamic table. Here are the highlights following the button color chooser:
Edit Buttons

Code: Select all

[H: colorList = "default,black,blue,cyan,darkgray,gray,lightgray,magenta,orange,pink,red,white,yellow"]
[H: colorProps = "c.default=#ECE9D8; c.black=#000000; c.blue=#0000FF; c.cyan=#00FFFF; c.darkgray=#404040; c.gray=#808080; c.lightgray=#C0C0C0; c.magenta=#FF00FF; c.orange=#FFC800; c.pink=#FFFAFA; c.red=#FF0000; c.white=#FFFFFF; c.yellow=#FFFF00;"]
[H: varsFromStrProp(colorProps)]
[H: t.buttonColorMenu = listFormat(colorList,'<table style="padding 2px;"><tr>%list</tr></table>',
   '<td style="background-color:{c.%item}"><input type="radio" name="color.%{index}" value="%item" checked.c.%item /></td>',"")]
...
         strformat(t.buttonColorMenu),
...
      [H: menuColors = replace(menuColors,strformat("checked[.]c[.]%{color}"),"CHECKED")]
      [H: propMenu = json.evaluate(json.append("",menuColors,menuTooltip))]
      [H: output = json.merge(output,propMenu))]
[dialog("Edit Buttons"): {[R: json.toList(output,"")]}]
 
Now that I have a tools button, I can add debugger options

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

Post by wolph42 »

just tested your pre version and it was a pretty short test as I got a:
Error executing getName, unknown token .
When I clicked on Edit Token...

User avatar
aliasmask
RPTools Team
Posts: 9101
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: RPedit - Macro Importer/Exporter and Editor

Post by aliasmask »

wolph42 wrote:just tested your pre version and it was a pretty short test as I got a:
Error executing getName, unknown token .
When I clicked on Edit Token...
That's an MT bug/feature(?). You have to check the apply to selected and uncheck the Allow Players to Edit after dragging to camp window. I don't recall if I saved the Edit button with the correct setting, but I always have to change the Allow Players option. Don't forget to run onCampaignLoad too.

I'm off to bed now.

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

Post by wolph42 »

aliasmask wrote:
wolph42 wrote:just tested your pre version and it was a pretty short test as I got a:
Error executing getName, unknown token .
When I clicked on Edit Token...
That's an MT bug/feature(?). You have to check the apply to selected and uncheck the Allow Players to Edit after dragging to camp window. I don't recall if I saved the Edit button with the correct setting, but I always have to change the Allow Players option. Don't forget to run onCampaignLoad too.

I'm off to bed now.
ofcours... I thought it was something should have known. thnx.

btw: I had a look at your screenshots, how do you collapse the macros in NP++ ?

Post Reply

Return to “Drop-In Macro Resources”