input() and other new b42 macro functions

Doc requests, organization, and submissions

Moderators: dorpond, trevor, Azhrei

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

Re: the attack macro & critical threats

Post by PyroMancer2k »

h3lrav3n wrote:The attack macro prints "a critical hit!" when the die roll is a natural 20. I was wondering if there was a way to get the attack macro to work with a threat range (For example: a longsword's threat range of 19-20) without a complete rewrite; possibly to be used in conjunction with the weapon edit macro.
Actually it would be very easy to do. First off you would need to add another property to the weapon. For our Example we will use ThreatRange as that property. Then in the case of a longsword it's 19-20 so set "ThreatRange=19;"

Next make a small edit to the code.

Code: Select all

{if(AtkRoll>=ThreatRange+AttackBonus+if(CA,2,0)+MiscAtk, ", a critical hit!", "")} 
And done. Since weapon edit code gets the property list from the weapons themselves adding properties doesn't change that macro at all. Just have to make sure you set all the ThreatRange properties for your weapons now ;). You'll have to manually add it but once you do it'll always appear in the edit list.

User avatar
palmer
Great Wyrm
Posts: 1367
Joined: Sat Sep 06, 2008 7:54 pm

Re: the attack macro & critical threats

Post by palmer »

h3lrav3n wrote:The attack macro prints "a critical hit!" when the die roll is a natural 20. I was wondering if there was a way to get the attack macro to work with a threat range (For example: a longsword's threat range of 19-20) without a complete rewrite; possibly to be used in conjunction with the weapon edit macro.
PyroMancer pretty much has it. I use something of an alternative.
You still need to add a weapon prop for the crit range. Just make it a single number that represents the lower end of the range. Crit 18-20 is just written as 18.

Code: Select all

<Print>
I attack [Target] with my [ItemName].
Attack: [h:AttackRoll = 1d20] [AttackRoll + AttackBonus + if(CA, 2, 0) - ConcPenalty] vs AC. {if(AttackRoll>=CritRange, "Natural " + AttackRoll + ". Critical hit!", "")}
Damage: {if(AttackRoll>=CritRange, CritTotal, DamageTotal))} [Keyword] damage.
The key points here are
A: Make AttackRoll a separate variable
B: if(AttackRoll>=CritRange)

The only real functional difference is that my version will announce "Natural 20!" so all may gaze upon your e-dice rolling skills in awe.
But having that show was helpful during my debugging :)

Mithrus
Cave Troll
Posts: 30
Joined: Fri Sep 12, 2008 11:52 pm

Post by Mithrus »

Code: Select all

[h: n = 5 ][h: list=""][h, C(n): list=listAppend(list, ""+roll(1,10))]
gives me this error: Could not execute the command: Illegal type for argument 1 to listAppend(), expected java.lang.String but got java.math.BigDecimal

knizia.fan
Giant
Posts: 197
Joined: Wed Jul 30, 2008 3:43 pm

Post by knizia.fan »

Mithrus wrote:

Code: Select all

[h: n = 5 ][h: list=""][h, C(n): list=listAppend(list, ""+roll(1,10))]
gives me this error: Could not execute the command: Illegal type for argument 1 to listAppend(), expected java.lang.String but got java.math.BigDecimal
Yes, I mentioned this briefly at the end of my last post. Your example revealed this issue to me. After the first iteration of your loop, the list variable contains a single number "1". When that string is assigned to the list variable, MapTool is automatically converting it to a number, which causes the type error in the second call to listAppend(). I've modified my code so that the list argument to the list functions can be a string or a number. This will hopefully show up in b44.

You were also saying that you had to use "," as a blank list, and that "" wasn't working for you. If you can reproduce that with a simple example, please post it so I can look for a fix. As far as I know, "" should work everywhere.

Mithrus
Cave Troll
Posts: 30
Joined: Fri Sep 12, 2008 11:52 pm

Post by Mithrus »

knizia.fan wrote:Yes, I mentioned this briefly at the end of my last post. Your example revealed this issue to me. After the first iteration of your loop, the list variable contains a single number "1". When that string is assigned to the list variable, MapTool is automatically converting it to a number, which causes the type error in the second call to listAppend(). I've modified my code so that the list argument to the list functions can be a string or a number. This will hopefully show up in b44.

You were also saying that you had to use "," as a blank list, and that "" wasn't working for you. If you can reproduce that with a simple example, please post it so I can look for a fix. As far as I know, "" should work everywhere.
Ok, working on FAR too little sleep (if I had a therapist, they might say I'm OCD on these macros atm...) I wasn't sure if the type issue and the comma issue were directly related. Looks like they are, so can't wait for b44 :)

Syne
Kobold
Posts: 17
Joined: Fri Sep 19, 2008 9:15 am

Post by Syne »

Umm. So does listAppend(listname, inputname, ";") work for anyone else, or is it just me? Is there a way to make it work?

I didn't really get a straight answer. It's really important.

knizia.fan
Giant
Posts: 197
Joined: Wed Jul 30, 2008 3:43 pm

Post by knizia.fan »

Syne wrote:Umm. So does listAppend(listname, inputname, ";") work for anyone else, or is it just me? Is there a way to make it work?

I didn't really get a straight answer. It's really important.
knizia.fan wrote:The list-processing functions already support an optional final argument which defines an alternate list separator (see first post). It's a bit buggy in b43, though. A patch for b44 has been submitted.
To repeat: there are bugs with non-default separators, which should all be fixed in b44.

User avatar
Orchard
Great Wyrm
Posts: 1852
Joined: Fri May 09, 2008 10:45 am
Location: Doylestown PA
Contact:

Post by Orchard »

Mithrus wrote:
knizia.fan wrote:Yes, I mentioned this briefly at the end of my last post. Your example revealed this issue to me. After the first iteration of your loop, the list variable contains a single number "1". When that string is assigned to the list variable, MapTool is automatically converting it to a number, which causes the type error in the second call to listAppend(). I've modified my code so that the list argument to the list functions can be a string or a number. This will hopefully show up in b44.

You were also saying that you had to use "," as a blank list, and that "" wasn't working for you. If you can reproduce that with a simple example, please post it so I can look for a fix. As far as I know, "" should work everywhere.
Ok, working on FAR too little sleep (if I had a therapist, they might say I'm OCD on these macros atm...) I wasn't sure if the type issue and the comma issue were directly related. Looks like they are, so can't wait for b44 :)
Er, I'm not your therapist, but I am a psychologist (okay, to be perfectly honest I'm 1/2 a dissertation away from my PhD in non-clinical psychology, and I'll never be a therapist, so whatever...), so I'll gladly say it: yeah, this is nuts. Just a tad obsessive.

AND WAY FREAKING COOL!

er....

:twisted:
0+0=1, for very unstable CPUs.

Mithrus
Cave Troll
Posts: 30
Joined: Fri Sep 12, 2008 11:52 pm

Post by Mithrus »

I realize b44 is gonna happen soon, but if there is enough time, could you add a first parameter of title to the input() function?

I know I would use it a lot, and in some of my macros, if someone is unfamiliar with the macro's input, I could pass pertinent info in the title that currently would only get displayed AFTER they entered the values. For instance, in WoD, several actions have an equipment mod on them, and while I could list it as a separate input line, I would much rather keep the prompts to "Positive Mod" and "Negative Mod".

Plus, (and maybe more importantly), I'd like the input dialog to display the macro's title. I have a few macros that use multiple input()s, so allowing for a title would also help in this case as well.

Mithrus
Cave Troll
Posts: 30
Joined: Fri Sep 12, 2008 11:52 pm

Post by Mithrus »

This isn't a new idea, but I'm bringing it up again:) If there could be a MEMO input type added that basically would display the value in a multi-line area, it would be awesome! IMO, if the title is left empty, then have it use the full width of the dialog box (span columns like for HTML), otherwise, confine it to the right side.

This could replace the idea I had above for a title parameter. Add options for STYLE=BOLD/ITALIC/NONE (default=NONE)

User avatar
palmer
Great Wyrm
Posts: 1367
Joined: Sat Sep 06, 2008 7:54 pm

Post by palmer »

BUG REPORT

Fairly straightforward.

listFind(list, target)

If target happens to be an integer, the function fails with Could not execute the command: Illegal argument type java.lang.String, expecting java.math.BigDecimal

Thus I cannot craft a list containing numbers
1, 2, 7, 9,

And then listFind it dynamically. I can listFind(List, "7") fine.
But I can't do this

Code: Select all

[h: WpnNum = getStrProp(Private, "DefaultWeapon")]
[h: FindWpn =  listFind(List, WpnNum)]
eval() has a similar issue, which is being looked into over here: http://forums.rptools.net/viewtopic.php?t=5531
Last edited by palmer on Mon Sep 22, 2008 6:04 am, edited 1 time in total.

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

Post by PyroMancer2k »

palmer wrote:BUG REPORT

Fairly straightforward.

listFind(list, target)

If target happens to be an integer, the function fails with Could not execute the command: Illegal argument type java.lang.String, expecting java.math.BigDecimal

Thus I cannot craft a list containing numbers
1, 2, 7, 9,

And then listFind it dynamically. I can listFind(List, "7") fine.
But I can't do this

Code: Select all

[h: WpnNum = getStrProp(Private, "DefaultWeapon")]
[h: FindWpn =  listFind(List, WpnNum)]
eval() has a similar issue, which is being looked into <a>over here</a>
You can make a work around for this. I did a quick test in Chat box with the following code.

Code: Select all

[h: WpnNum = 7]
[H:list="1, 2, 7, 9,"]
[FindWpn =  listFind(List, " " + WpnNum)]
It works fine and returns 2 like you'd expect. The thing is you have to force it to become a string by adding it to another string :).

Dyark
Cave Troll
Posts: 40
Joined: Fri Aug 15, 2008 10:42 am
Location: Montreal, Canada

on the list

Post by Dyark »

there is something i do not understand, how can i have an input field with a list box and extract the index and the name in the list box ??

knizia.fan
Giant
Posts: 197
Joined: Wed Jul 30, 2008 3:43 pm

Re: on the list

Post by knizia.fan »

Dyark wrote:there is something i do not understand, how can i have an input field with a list box and extract the index and the name in the list box ??
If you want to get both the index and the text, you can do something like this.

Code: Select all

[h: list = "a,b,c,d"]
[h: input("n | " + list + " | Pick one | LIST")]
You picked item #{n}, which has the text "{listGet(list, n)}"

knizia.fan
Giant
Posts: 197
Joined: Wed Jul 30, 2008 3:43 pm

Post by knizia.fan »

palmer wrote:FREQ: List sorting
(prompted by this post)

Some kind of list manipulation functionality to automatically sort a list. Basic numerical or character code sorts, in forward or reverse.

It would certainly help for the thread above, and I'm sure that others will have uses for it.
This will be in b44.

Post Reply

Return to “Documentation Requests/Discussion”