RPTools.net

Discussion and Support

Skip to content

It is currently Sun May 19, 2013 1:14 am 






Reply to topic  [ 79 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Demigod
 
Joined: Mon Jun 29, 2009 9:37 am
Posts: 2682
Location: Germany
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Fri May 14, 2010 3:11 am 
aliasmask wrote:
this is all CoveredInFish's.

You did some amazing tweaks to this tool i didnt even considered. :)


Btw ... i stress tested the import by trying it on the movepad-lib:token (2650 lines of code) and it didnt went through importing. Following error msg came.
I didnt tested yet to pump up my stack size.

maptool wrote:
java.lang.IndexOutOfBoundsException: Index: 526, Size: 526 error executing expression tLine = json.get(tLines,maxLines).


EDIT: okay - as i hoped - setting the stack size to 6 helped. It went through nicely (took its time though).

_________________
"Cif's html works" (confirmed by independent studies)

most complete list of my maptool stuff


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 5300
Location: Bay Area
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Fri May 14, 2010 8:46 am 
That's odd. I ran the same lib through, you know as a test and I didn't get any errors and I only use a stack of 2. A stack of 6 seems pretty high to me. I'm not too sure about java, but I recall someone posting that anything above 1.6g max mem is outside the range of java.

Doing string manipulation inside of a nested loop can really overload the stack, especially when you nest the function calls. I'll take a look at the code again and separate anything like that out in to separate statements.

Also, that error seems to be related to calling an index of an array that doesn't exist. I'll check my logic and make do a test with some various end of file conditions. It may be a problem with my whitespace filter.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 5300
Location: Bay Area
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Fri May 14, 2010 10:11 am 
Okay, I fixed the logic with the maxLines error. If I had 501 lines, it would change the maxLines to 501 and then try to read line 501 to see if it was the beginning of a macro... but line 501 is really 502.. hence the error. I don't know why it didn't error sooner or changing the stack would help, oh well.

I also broke apart a pretty stack intensive statement
Code:
 [H, if(isCommentLine): tLine = replace(tLine,encode("<!--") + ".*?" + encode("-->"),encode(strformat("[H: '%s']",tTemp)))]

<!-- Changed to -->

[H, if(isCommentLine), code: {
   [H: tRegEx = encode("<!--") + ".*?" + encode("-->")]
   [H: rText = encode(strformat("[H: '%s']",tTemp))]
   [H: tLine = replace(tLine,tRegEx,rText)]
};{}]


edit: Actually, I do know why I didn't see the error before. It only would happen if the code block being transferred was over 500 lines and was the last code block. So, 900 lines would be split in to potentially 500 and 400.. no problem, but 1020 could be 500 and 520 if line 500 was in the middle of the macro. That's when the error would occur. I'm thinking changing the stack had nothing to do with it. The number or lines must have been changed or functions repositioned to avoid the above outcome.

So, I guess here is version 1a which includes my moving of onCampaignLoad to top of output:


MacroIO_v1.0a.rptok [177.72 KiB]
Downloaded 49 times

_________________
Downloads:


Last edited by aliasmask on Sat May 15, 2010 9:24 am, edited 1 time in total.
Top
 Profile  
 
User avatar  Offline
Site Admin
 
Joined: Mon Jun 12, 2006 12:20 pm
Posts: 11622
Location: Tampa, FL
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Fri May 14, 2010 11:52 pm 
Not to be too picky or anything (although I am, I guess!) but HTML comments must have spaces next to the dashes. So "<!--" is not an HTML comment lead-in, but "<!-- " is (notice the trailing space). Ditto for "-->" and " -->" (notice the leading space).

Not a big deal I suppose, but your current code would treat "<!---->" as a comment and technically it isn't. ;)

_________________
Interested in Time Magazine's Best Invention of 2008 Unix-powered laptop? No crashes or lockups. In fact, that series of articles has two such machines. The other is a Dell netbook. :)


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 5300
Location: Bay Area
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Sat May 15, 2010 12:31 am 
That is pretty picky, hehe. I suppose a comment should have content. I guess I would be accounting for ill-formed comments then, like the one at w3schools in their definition and example of comments.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Site Admin
 
Joined: Mon Jun 12, 2006 12:20 pm
Posts: 11622
Location: Tampa, FL
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Sat May 15, 2010 11:00 am 
aliasmask wrote:
That is pretty picky, hehe.

Yepper. But I can tell from the macros you've posted that you're the type who would appreciate doing it The Right Way. ;)

_________________
Interested in Time Magazine's Best Invention of 2008 Unix-powered laptop? No crashes or lockups. In fact, that series of articles has two such machines. The other is a Dell netbook. :)


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 5300
Location: Bay Area
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Sat May 15, 2010 12:21 pm 
I'm tempted to make the change because you're right, but I do use <!-----------> as a visual spacer sometimes and the whole point of putting the comment in a hidden tag is because maptool doesn't hide comments or visual spacers. So, that's why during a function that sometimes has output and sometimes doesn't will just post a blank giving away gm activities. So, putting the text string in a hidden maptool tag will just leave the whitespace which is trimmed and doesn't produce output. Well, in most cases with the exception of using execLink where it always outputs at least a blank even with no output when using the "all" parameter and [if:] statements with no false branch specified.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 5300
Location: Bay Area
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Wed May 19, 2010 10:25 am 
I found something that is potentially a problem. I had the habit of copying the props from another macro when making a new macro not thinking about the "index" prop. Oops. I was wondering why my macros were disappearing. This can also happen if you export from one lib to another lib where one index will overwrite the other. So, I here is my change to fix that:
Code:
@@createOrEditMacro
@PROPS@ autoExecute=true ; color=default ; fontColor=black ; group= ; includeLabel=false ; sortBy=0 ; index=7 ; fontSize=1.00em ; minWidth= ; playerEditable=false ; maxWidth= ; tooltip= ; applyToSelected=false ;
[h: id = json.get( macro.args, "id" )]
[h: label = json.get(macro.args, "label")]
[h: switchToken(id)]
[h, if(label != ""), code: {
   [h, if( hasMacro(label) ), code: {
      [h, foreach(index, getMacroIndexes(label)): removeMacro(index)]
   };{}]
   [H: macro.args = json.remove(macro.args,"index")]
   [h: createMacro(macro.args)]
};{}]


Basically, I just delete the index so a new one is created.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 5300
Location: Bay Area
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Fri Jun 04, 2010 1:53 pm 
I made a slight update, which includes the fix above.

  • Fixed import/export spacing. All white space will eventually be 1 line with multiple import exports.
  • Forced line break between macros.
  • Fixed loss of macros when the props index was the wrong number.
  • Macro names with commas won't break exporter.

Check the version before you download.

edit: Odd, I just noticed the size difference in 1.3b63. Anyway, newer version is a couple of posts down. It's compatible with 63 and above.

Attachment:
File comment: 1.3b63
MacroIO_v1.0b.rptok [337.47 KiB]
Downloaded 39 times

Attachment:
File comment: 1.3b68
MacroIO_v1.0b.rptok [170.47 KiB]
Downloaded 38 times

_________________
Downloads:


Last edited by aliasmask on Sun Jun 13, 2010 12:38 am, edited 4 times in total.

Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 2603
Location: West Palm Beach, FL
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Fri Jun 04, 2010 9:37 pm 
aliasmask wrote:
I made a slight update, which includes the fix above.


Thanks for the update, but I'm getting a very strange error when I try to drag that rptok onto my map:

java.lang.InstantiationError: java.util.Map$Entry
at sun.reflect.GeneratedSerializationConstructorAccessor149.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.thoughtworks.xstream.converters.reflection.Sun14ReflectionProvider.newInstance(Sun14ReflectionProvider.java:62)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.instantiateNewInstance(AbstractReflectionConverter.java:257)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:124)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:66)
at com.thoughtworks.xstream.converters.collections.MapConverter.populateMap(MapConverter.java:63)
at com.thoughtworks.xstream.converters.collections.MapConverter.unmarshal(MapConverter.java:54)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.unmarshallField(AnnotationReflectionConverter.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:188)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:125)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:117)
at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.unmarshal(ReferenceByXPathMarshallingStrategy.java:29)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:846)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:833)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:789)
at net.rptools.lib.io.PackedFile.getContent(PackedFile.java:138)
at net.rptools.lib.io.PackedFile.getContent(PackedFile.java:123)
at net.rptools.maptool.util.PersistenceUtil.loadToken(PersistenceUtil.java:400)
at net.rptools.maptool.client.ui.assetpanel.ImageFileImagePanelModel.getTransferable(ImageFileImagePanelModel.java:98)
at net.rptools.maptool.client.ui.assetpanel.AssetPanel$3.getTransferable(AssetPanel.java:261)
at net.rptools.lib.swing.ImagePanel.dragGestureRecognized(ImagePanel.java:395)
at java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(Unknown Source)
at sun.awt.windows.WMouseDragGestureRecognizer.mouseDragged(Unknown Source)
at java.awt.AWTEventMulticaster.mouseDragged(Unknown Source)
at java.awt.Component.processMouseMotionEvent(Unknown Source)
at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:24)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


I'm not doing anything different than I normally would and can deploy the 1.0a rptok just fine the same way.

_________________
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 5300
Location: Bay Area
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Fri Jun 04, 2010 10:18 pm 
Full Bleed wrote:
aliasmask wrote:
I made a slight update, which includes the fix above.


Thanks for the update, but I'm getting a very strange error when I try to drag that rptok onto my map:

java.lang.InstantiationError: java.util.Map$Entry
at sun.reflect.GeneratedSerializationConstructorAccessor149.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.thoughtworks.xstream.converters.reflection.Sun14ReflectionProvider.newInstance(Sun14ReflectionProvider.java:62)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.instantiateNewInstance(AbstractReflectionConverter.java:257)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:124)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:66)
at com.thoughtworks.xstream.converters.collections.MapConverter.populateMap(MapConverter.java:63)
at com.thoughtworks.xstream.converters.collections.MapConverter.unmarshal(MapConverter.java:54)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.unmarshallField(AnnotationReflectionConverter.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:188)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:125)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:117)
at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.unmarshal(ReferenceByXPathMarshallingStrategy.java:29)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:846)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:833)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:789)
at net.rptools.lib.io.PackedFile.getContent(PackedFile.java:138)
at net.rptools.lib.io.PackedFile.getContent(PackedFile.java:123)
at net.rptools.maptool.util.PersistenceUtil.loadToken(PersistenceUtil.java:400)
at net.rptools.maptool.client.ui.assetpanel.ImageFileImagePanelModel.getTransferable(ImageFileImagePanelModel.java:98)
at net.rptools.maptool.client.ui.assetpanel.AssetPanel$3.getTransferable(AssetPanel.java:261)
at net.rptools.lib.swing.ImagePanel.dragGestureRecognized(ImagePanel.java:395)
at java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(Unknown Source)
at sun.awt.windows.WMouseDragGestureRecognizer.mouseDragged(Unknown Source)
at java.awt.AWTEventMulticaster.mouseDragged(Unknown Source)
at java.awt.Component.processMouseMotionEvent(Unknown Source)
at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:24)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


I'm not doing anything different than I normally would and can deploy the 1.0a rptok just fine the same way.


That might be because I created it in 1.3b68... I'll export the macros and create it in 1.3b63 after dinner and see how it works for you.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Fri Dec 18, 2009 2:33 am
Posts: 382
Location: San Diego
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Sat Jun 12, 2010 11:36 pm 
Question: Why does the dumpMacros macro need to use manual string concatenation instead of Wiki: strformat()? I believe that it does, because I've been trying to re-write it using strformat in hopes of it going faster, but that throws errors. I just wondered if someone who knows more about encode/decode can explain why.

_________________
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G. K. Chesterton

Wonderful HTML/CSS reference * Color Manager * Token Manager 2.0


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 5300
Location: Bay Area
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Sun Jun 13, 2010 12:31 am 
Raoden wrote:
Question: Why does the dumpMacros macro need to use manual string concatenation instead of Wiki: strformat()? I believe that it does, because I've been trying to re-write it using strformat in hopes of it going faster, but that throws errors. I just wondered if someone who knows more about encode/decode can explain why.

Apparently [if:] doesn't like Wiki: strformat(). I don't know if this is any faster, but it takes about 6-7 seconds to output 2500 lines.

Here is the updated version:


MacroIO_v1.0c.rptok [177.78 KiB]
Downloaded 51 times

_________________
Downloads:
Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Fri Dec 18, 2009 2:33 am
Posts: 382
Location: San Diego
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Sun Jun 13, 2010 12:40 am 
Cool. Also, what's the value of inserting [h:] around comment lines?

_________________
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G. K. Chesterton

Wonderful HTML/CSS reference * Color Manager * Token Manager 2.0


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 5300
Location: Bay Area
 Post subject: Re: Batch Macro Import and Export via Copy&Paste
PostPosted: Sun Jun 13, 2010 1:33 am 
No output, ie blank lines when you don't want them.

_________________
Downloads:


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 79 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 1 guest





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman