input() and other new b42 macro functions

Doc requests, organization, and submissions

Moderators: dorpond, trevor, Azhrei

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Post by Rumble »

jfrazierjr wrote:Ugh... I am having trouble getting my syntax right inside my loop. What i want to is to build a CHECK string from a list.

In case you're still fighting with it, I apparently had exactly the same idea, and doped out how to do this exact thing this morning. My code looks like:

Code: Select all

[h:expList="orc 1, orc 2, orc 3, orc 4, orc leader"]

[h:outputString=""]

[h,FOREACH(enemy,expList):outputString=outputString+" 'target"+roll.count+"|0|"+enemy+"|CHECK" + " ' " + ","]

[h:inputString=eval("input("+outPutString+" ' " + "def|AC|defense" + " ' "+ ")")]

[h:status=inputString]

[h:abort(status)]

[h:numEntries=listCount(expList)-1]
Number of items in list: [numEntries]<br>

[h:targList=""]

[h,FOR(i,0,numEntries):targList = if(eval("target"+i), listAppend(targList,listGet(expList,i)),targList)]
This builds a set of checkboxes from a list, then rebuilds a new list based on what was targeted (trimming out any unchecked dudes).

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

Post by lmarkus001 »

NOTE: What is documented here is NOT in B46/47/48. The "B46" changes documented here have not made it in to the build cycle.

User avatar
RPTroll
TheBard
Posts: 3159
Joined: Tue Mar 21, 2006 7:26 pm
Location: Austin, Tx
Contact:

Post by RPTroll »

I should have read the last post first <groan>

User avatar
Daniel
Giant
Posts: 132
Joined: Thu Nov 20, 2008 3:49 am
Location: Germany (GMT +1)

Re: input() and other new b42 macro functions

Post by Daniel »

Specific stuff that is not in, or not working (from my testing):

List operations:
listSort() - undefined function
optional alternative seperator argument for list functions does not seem to work

input():
- TAB type is not recognized


knizia.fan, could you highlight the functions that are not yet included in the current build on the front page? Would probably save a lot of questions and hair pulling on the part of people trying to use these functions. :lol:
"This web of time [...] embraces every possibility. We do not exist in most of them. In some you exist and not I, while in others I do, and you do not. [...] In yet another, I say these very same words, but am an error, a phantom."

J.L. Borges

User avatar
Veggiesama
Dragon
Posts: 619
Joined: Wed Aug 29, 2007 1:18 am

Re: input() and other new b42 macro functions

Post by Veggiesama »

Daniel wrote:Specific stuff that is not in, or not working (from my testing):

List operations:
listSort() - undefined function
optional alternative seperator argument for list functions does not seem to work

input():
- TAB type is not recognized
In addition, strPropFromVars() and formatStrProp() are unrecognized on my end in b48.
My D&D 4e Campaign FrameworkMy Shadowrun 4e Campaign Framework
RPGA#: 5223846427 — Skype: Veggiesama — Fear the ferret.

User avatar
PyroMancer2k
Dragon
Posts: 925
Joined: Thu Sep 11, 2008 2:04 pm

Re: input() and other new b42 macro functions

Post by PyroMancer2k »

Anyone know what happen to K.fan? He seems to have vanished. I know after b46 came out and didn't see the update of the additions he said were going into it he said that he would resubmit them but then no word.

The forum shows his last visited as - which I think means he hasn't logged into the new forums yet. And the last post he made was almost a month ago. Cause it seems without him all these changes he was adding aren't going into the build.

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

Re: input() and other new b42 macro functions

Post by lmarkus001 »

The various bug fixes and enhancements listed in this thread and documented in the first post are generally not in the live version of MapTools (somehow they missed the build process and have not been discovered by Trevor). So here is a synopsis of what is actually in b46-48.

b42
* input() function - asks the user for multiple variables at once.
* abort(val) function - if val is zero, aborts execution and later calculations are not performed
* listGet(list, index) - returns the entry in the index position (first position is index 0)
* listDelete(list, index) - returns a new list with the item at index position deleted.
* listCount(list) - returns the number of list entries
* listFind(list, target) - returns the index of the target string in the list, or -1 if none of the list entries match.
* listAppend(list, target) - adds target to the end of the list
* listInsert(list, index, target) - inserts target before the entry at position index
* listReplace(list, index, target) - replaces the entry at position index with the target
* getStrProp(properties, key) - find a key and return the value, or "" if not found
* setStrProp(properties, key, value) - set the value for a key,inserting it if not present. Returns the new property string.
* deleteStrProp(properties, key) - delete a key. Returns the new property string.
* countStrProp(properties) - returns how many key/value settings are in the string.
* indexKeyStrProp(properties, N) - returns the Nth key in the list.
* indexValueStrProp(properties, N) - returns the Nth value in the list.
* varsFromStrProp(properties) - creates variables for each key and assigns the corresponding value. Returns the number of entries found.

b43
* getStrProp() now accepts an optional 3rd argument which is returned (instead of an empty string) when the key is not found. (Contributed by k.fan)

b46
* New looping options for rolls: WHILE(condition), FOR(var,start,end), FOREACH(var,list)
* New branching options for rolls: IF(condition), SWITCH(expression)
* New code calling options for rolls: MACRO("macro@location"), CODE

User avatar
Plissken
Giant
Posts: 116
Joined: Mon Jan 07, 2008 10:44 pm

Re: input() and other new b42 macro functions

Post by Plissken »

Question about value...

I want to use a default value that is from the player's property sheet. How do I do this?

I tried a few variations (STR is the character's strength score):

1.) [H: input( "Strength | {STR} " ) ]
2.) [H: input( "Strength | [STR] " ) ]


3.) [h: var = STR ]
[H: input( "Strength | var " ) ]

4.) [H: input( "Strength | getProperty( STR ) " ) ]

None work.

Is it not possible to use a default value from the character's property sheet without knowing the value beforehand?

User avatar
tygaran
Dragon
Posts: 358
Joined: Sat Feb 21, 2009 10:56 pm
Contact:

Re: input() and other new b42 macro functions

Post by tygaran »

Plissken wrote:Question about value...
1.) [H: input( "Strength | {STR} " ) ]
2.) [H: input( "Strength | [STR] " ) ]
3.) [h: var = STR ]
[H: input( "Strength | var " ) ]
4.) [H: input( "Strength | getProperty( STR ) " ) ]
None work.
Is it not possible to use a default value from the character's property sheet without knowing the value beforehand?
You Need to use string concatenations. Something like this...

[h: input("Strength|"+STR)]

The value of STR would get added to the inpute string. So, if STR's value was 14, the process would replace +STR with +"14" and make th einpute line's string equivalent to "Strength|14" and give the results you need.

XVRogue
Kobold
Posts: 7
Joined: Wed Jan 19, 2011 5:01 pm

Re: input() and other new b42 macro functions

Post by XVRogue »

Hey everyone, I'm trying to create a macro for a power that allows the use of rerolls.

What I'm looking to do is make a dialogue box that displays the various options for the attack.

i.e. it will ask for incidental bonuses, such as combat advantage, or cover, it will ask if the target is the quarry, if you have prime shot, etc.

All of that works just fine.

The other part of the input box is that it will display what you rolled to hit, and for your damage dice, and ask (using checkboxes) if you want to reroll them.

Now, using the inputs of 0/1 I have if statements later that reroll the dice based on these selections.

My issue is the following:

How can I make an input list display a variable.

Right now when I want it to display the attack roll, I've tried putting in my variable: {d20roll} and also as [d20roll] but it just displays it as a string written identically.

Is there anyway to make these input windows display a variable and not just the word?

EDIT: I figured it out, first I wrap the variable name in Quotes, and then I use + on either end for it to utilize the variable.

Example:

Code: Select all

 "AtkRoll | 1 |"+d20roll+"| CHECK",
 "Die1 | 1 |"+DamageRoll1+"| CHECK",
 "Die2 | 1 |"+DamageRoll2+"| CHECK",
 "Die3 | 1 |"+DamageRoll3+"| CHECK")]

waltotheter
Kobold
Posts: 2
Joined: Wed May 08, 2013 6:41 pm

Re: input() and other new b42 macro functions

Post by waltotheter »

Everything works except for when I execute the attack command the last part of the code error's out. I've read over the forum but still can't figure it out. Here's the error.

   Error in body of roll.       Statement options (if any):       Statement Body : WpnMaxDamage_ + eval(WpnCritDamage_) + MiscDmg

I'm using your default attack code on the front page of this thread.

Let me know if you can help!

Post Reply

Return to “Documentation Requests/Discussion”