global search and replace through MT script

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

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

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

global search and replace through MT script

Post by wolph42 »

I was contemplating to send this as a pm to aliasmask but i figured that its a topic interesting to more then just me.
anyhoo...

The issue at hand is this: I like to have the BoT compatible with both MOTE and MT, however when converting to MOTE it s/r a couple of macro functions which they renamed (for the better I must add!). Point is that *I* too have redefined those functions e.g. getTokenFacing() to bot_getTokenFacing, which annoyed the hell out of me with the +/- 180 return value. Point is bot_getTokenfacing() ALSO gets s/r into the new function name: facing.getDegrees(). I've discussed this with MOTE and they adjusted the s/r to not make *that* mistake but there's another: table().

here the API change in mote
getTokenFacing, setTokenFacing, and removeTokenFacing have been deprecated in favor of facing.getDegrees, facing.setDegrees, and facing.clear, respectively. Calls to the former functions will no longer be recognized by the parser.
Table-related function moved under the Tables group.
table (with alias tbl), tableImage (with alias tblImage) have also been deprecated in favor of tables.getResult, and tables.getImage. As stated above, calls to the old functions will no longer be recognized by the interpreter.
Hence I need to re-s/r my script AFTER conversion onCampaignload when MOTE is detected. Now rpedit exists which proves that it can't be done. But for the love of some deity I'm utterly clueless how to achieve this. Any suggestions?

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

Re: global search and replace through MT script

Post by aliasmask »

Maybe their parser sees the _ as a break in the function name. Try either no _ or try . instead. You can use something like notepad++ to do your own search and replace throughout your code so the macros are the same in MT and MOTE. Use RPEdit to load and save changes.

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

Re: global search and replace through MT script

Post by wolph42 »

aliasmask wrote:Maybe their parser sees the _ as a break in the function name. Try either no _ or try . instead. You can use something like notepad++ to do your own search and replace throughout your code so the macros are the same in MT and MOTE. Use RPEdit to load and save changes.
1. they do and they fixed that part, but they can't use regex so that makes it rather tricky
2. obviously im aware of that. point is: i want to do an automatic s/r through a macro. This would most likely call on the functionality of rpedit, but i don't know how.

Let me rephrase the question:

how can i do a global s/r lets say: "tables.getimage --> tables" in the current mt script AUTOMATICALLY (e.g. oncampaignload), either from scratch or by using functions of rpedit ?

The MOTE issue is a current example, but I've ran in other issues as well, where this can be a useful function to have in a macro. Sure rpedit and an external editor can be used, but I want to do it from within, but i don't know how.

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

Re: global search and replace through MT script

Post by lmarkus001 »

I am confused. You are seeking to dynamically change your macro code based on the current client?

So far, I find loading a MapTool campaign into Mote has that campaign processed by Mote and replacements made for me. Then from that point forward the Mote based campaign file is good to go. So they are doing the conversion for me.

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

Re: global search and replace through MT script

Post by wolph42 »

lmarkus001 wrote:I am confused. You are seeking to dynamically change your macro code based on the current client?

So far, I find loading a MapTool campaign into Mote has that campaign processed by Mote and replacements made for me. Then from that point forward the Mote based campaign file is good to go. So they are doing the conversion for me.
yes and they also do it for me, but not in all cases correctly (e.g. bot_table() is replace by bot_tables.getResult()), hence I need to fix that. Now there are other ways, but a general script s/r from WITHIN mt is something i've been wanting for a longer time, so its NOT specifically for MOTE (although it helps) its also a general request

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

Re: global search and replace through MT script

Post by aliasmask »

I think the simplest solution is for you to change the name of your macros so it doesn't get changed for looking like one of their converted macro name. Scanning the version of server and find and replacing all affected macros just seems silly to me when there's a lowtech simple solution available.

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

Re: global search and replace through MT script

Post by wolph42 »

aliasmask wrote:I think the simplest solution is for you to change the name of your macros so it doesn't get changed for looking like one of their converted macro name. Scanning the version of server and find and replacing all affected macros just seems silly to me when there's a lowtech simple solution available.
I've realised that as well, but I see other application as well hence the rephrase of the question

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

Re: global search and replace through MT script

Post by aliasmask »

I don't do any of my macro editing in MT so Notepad++ has all the tools I need. MOTE has a pretty decent IDE. Do they have a search and replace feature? MT is just a basic WYSIWYG text-only editor. I imagine text editing is very low priority for them since there are too many apps out there that do the job better. But without something like RPEdit, the process would be way more tedious. I'm guessing many people who program macros don't even use it. I couldn't live/program without it.

Post Reply

Return to “Macros”