Page 12 of 13

Posted: Thu Nov 27, 2008 8:45 am
by Daniel
Hi all.

Using a minimally adapted version of k.fan's original character sheet macro, I get an error message telling me that

Code: Select all

Could not execute the command: Invalid input type 'TAB' in the parameter string 'TabBasics | Basics | Stufe, LE, etc. | TAB'
It plain doesn't let me use the TAB option...?

My code is (abbreviated some input lines identical to the one saying "Dukaten")

Code: Select all

[H: status = input(
    "TabBasics | Basics | Stufe, LE, etc. | TAB",
 "bla | | Grundlegendes | LABEL",
      "bla |"+ token.name +" | Name | LABEL",
      "Dukaten_ | " + Dukaten + " | Dukaten | TEXT | width=3",
    "TabSkills | Handwerk | Handwerkliche Talente | TAB",
      "bla | Blubbediblubb | Note | LABEL"
)]
[H: abort(status)]

Posted: Thu Nov 27, 2008 10:51 am
by lmarkus001
It appears the changes/additions referred to in the doc posts of this thread are not in the current build. I think there was some build confusion as a number of rather old (stuff that was done shortly after b45 went live) fixes did not make it in to the b46/47 build.

So I would recommend referencing an older version of the docs (which you would have had to print out...).

Posted: Thu Nov 27, 2008 10:57 am
by Daniel
Ah, I see... so it's mainly a matter of waiting for b48(+) when all the documented features are actually in. :lol:

I can live with that (barely). No seriously, macros have gotten lots of loving in recent builds, and the thing I was trying to write would really just be icing on the cake.

Thanks to all programmers making this happen.

Posted: Thu Nov 27, 2008 2:18 pm
by jfrazierjr
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.

validTargets is a token Property. In another macro, I add a list of "creatures" who fill in validTargets.

Code: Select all

[h: numTargets = listCount(validTargets)]

<MACRO> 
[h: attackTargets = '']
[h: targetString= '']

[H,C(numTargets),CODE: { 
	[h: eval( targetNumber +roll.count) = ''  ]
}]


[H,C(numTargets),CODE: { 
	[h: targetString = targetString + " 0 |" + listGet(validTargets, roll.count) + "| CHECK"   ]
}]

[h: succces = input(targetString )
[h:abort(success)]
Once I can get this working, I should be able to check for checked targets, append them to a temp list in the macro, and then use this temp list to power the actual attack macro with crit detection.

Posted: Thu Nov 27, 2008 2:58 pm
by Lindharin
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.
I've got to run (picking up in-laws for dinner tonight), so I can't put this into MT and test it, but on a quick look the following loop has a problem:

[H,C(numTargets),CODE: {
[h: targetString = targetString + " 0 |" + listGet(validTargets, roll.count) + "| CHECK" ]
}]

In the internal statement, you need a variable in the first spot, before the 0. Something like:

[h: targetString = targetString + "target" + roll.count+ " | 0 |" + listGet(validTargets, roll.count) + "| CHECK" ]


Then you will have a bunch of variables, target0 through target12 (if you had 13 possible targets), which are set to either 0 if unchecked or 1 if checked.

Then you'd add a new loop to go through them and figure out which ones are set to 1.

Posted: Thu Nov 27, 2008 4:13 pm
by jfrazierjr
Lindharin wrote:
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.
I've got to run (picking up in-laws for dinner tonight), so I can't put this into MT and test it, but on a quick look the following loop has a problem:

[H,C(numTargets),CODE: {
[h: targetString = targetString + " 0 |" + listGet(validTargets, roll.count) + "| CHECK" ]
}]

In the internal statement, you need a variable in the first spot, before the 0. Something like:

[h: targetString = targetString + "target" + roll.count+ " | 0 |" + listGet(validTargets, roll.count) + "| CHECK" ]


Then you will have a bunch of variables, target0 through target12 (if you had 13 possible targets), which are set to either 0 if unchecked or 1 if checked.

Then you'd add a new loop to go through them and figure out which ones are set to 1.

Thanks, I had already figured that out (I copied the wrong thing), but the problem is that the input string I don't know how to get it properly quoted. Each option to Input needs to be quoted, followed by a comma for the next option. Soo.. how do I get quotes in there since the normal delimiter for string contact is quotes? As far as I know, there is no "escape" character which would allow me to embed a literal quote.

Posted: Thu Nov 27, 2008 4:58 pm
by Kzintzi
jfrazierjr wrote:
Thanks, I had already figured that out (I copied the wrong thing), but the problem is that the input string I don't know how to get it properly quoted. Each option to Input needs to be quoted, followed by a comma for the next option. Soo.. how do I get quotes in there since the normal delimiter for string contact is quotes? As far as I know, there is no "escape" character which would allow me to embed a literal quote.
I think I read somewhere in here that you can use double quotes to enquote single quotes and then the parser will place the single quotes into the resulting string but will evaluate the single quotes as quotes when the string itself is evaluated (ie using html like color='red' ).. assuming it hasn't been changed from the build it was written against this has the info in it:

http://forums.rptools.net/viewtopic.php?t=5177

heres the relevant text:
An important note: you can use either double or single quotes to indicate a string. Note that I had to use both types in the <span> tag below, because I wanted a quoted string 'color:red' to be inside the larger string. If I had used the same kind of quote in both places, MapTool would become quite confused and give me the unhelpful error message "Could not execute the command: null".

it's the macro sticky and the relevant section is under WRITING MACROS (about 2/3 of the way down)

Posted: Thu Nov 27, 2008 6:18 pm
by jfrazierjr
Ok... I am really darn close now. This spits out the right string, which I can copy/paste manually into an input(). But when I call the input directly in the macro with targetString as the argument, it barfs... Help?

Code: Select all

[h: numTargets = listCount(validTargets)]

<!--    MACRO SCOPPED VARIABLES --> 
[h: attackTargets = ""]
[h: targetString= ""]
Targets: {numTargets}<br>
[H,C(numTargets),CODE: { 
	[h:  foo = eval( "targetNumber" +roll.count   +   "=" +  "''")   ];
}]


[H,C(numTargets),CODE: { 
	[h: targetString = targetString +    "'targetNumber" +  roll.count + " | 0 | " + listGet(validTargets, roll.count) + " | CHECK'<br> " + if(numTargets >  (roll.count+1) , " , " , "   ") ] 
}]
{targetString}
 

Posted: Thu Nov 27, 2008 7:09 pm
by Lindharin
**** EDIT: Ignore this. I missed your prior post, so you're already past this stage. ****
jfrazierjr wrote: Thanks, I had already figured that out (I copied the wrong thing), but the problem is that the input string I don't know how to get it properly quoted. Each option to Input needs to be quoted, followed by a comma for the next option. Soo.. how do I get quotes in there since the normal delimiter for string contact is quotes? As far as I know, there is no "escape" character which would allow me to embed a literal quote.
Ah, try this:

[h: targetString = targetString + " ' target" + roll.count+ " | 0 |" + listGet(validTargets, roll.count) + "| CHECK ' , " ]

That's a single quote at the start of the line, and a single quote at the end, followed by the comma.

Because it ends with a comma after the last iteration of the loop, though, you need to add one more line after the end of the loop. It can be something just to fill the space, though, like:

[h: targetString = targetString + " ' blah |---------------- | --------------| LABEL ' "]

Posted: Thu Nov 27, 2008 7:13 pm
by Lindharin
jfrazierjr wrote:Ok... I am really darn close now. This spits out the right string, which I can copy/paste manually into an input(). But when I call the input directly in the macro with targetString as the argument, it barfs... Help?
I'm not sure the input function would like the <br> inside the targetString.

Posted: Fri Nov 28, 2008 12:23 am
by PyroMancer2k
jfrazierjr wrote:Ok... I am really darn close now. This spits out the right string, which I can copy/paste manually into an input(). But when I call the input directly in the macro with targetString as the argument, it barfs... Help?
Yea I think it looks right in chat but I think two things are wrong. First off like Lindharin said input() probably doesn't like <br>. The second problem is that you have ' in the string. But I'm pretty sure input() requires you to have " in it.

I'm guessing this is what you want?

Code: Select all

[H: validTargets = "Ork, Goblin, Kobold"]
[h: numTargets = listCount(validTargets)]

<!--    MACRO SCOPPED VARIABLES -->
[h: attackTargets = ""]
[h: targetString= "input("]
Targets: {numTargets}<br>
[H,C(numTargets),CODE: {
   [h:  foo = eval( "targetNumber" +roll.count   +   "=" +  "''")   ];
}]

[C(numTargets,'<BR>'),CODE: {
   [h: targetString = targetString + ' "targetNumber' + roll.count + ' | 0 | ' + listGet(validTargets, roll.count) + ' | CHECK " ' + if(numTargets >  (roll.count+1) , " , " , "   ") ]
}]
[H: targetString = targetString + ")"]
{targetString}<BR>
[eval(targetString)]

Posted: Fri Nov 28, 2008 2:24 pm
by jfrazierjr
Ok.. thanks to everyone, I have gotten a bit further. Now, I am having trouble with embedding a CODE block inside an if statement:

Code: Select all

[h: numTargets = listCount(validTargets)]

<MACRO>
[h: attackTargets = ""]
[h: allTargets = ""]
[h: targetString= "input("]
[H,C(numTargets),CODE: {
   [h:  foo = eval( "targetNumber" +roll.count   +   "=" +  "''")   ];
}]

[C(numTargets,'<BR>'),CODE: {
   [h: targetString = targetString + ' "targetNumber' + roll.count + ' | 0 | ' + listGet(validTargets, roll.count) + ' | CHECK " ' + if(numTargets >  (roll.count+1) , " , " , "   ") ]
}]
[H: targetString = targetString + ")"]
[h: eval(targetString)]


[FOR(i ,0,listCount(validTargets)-1), CODE: {
 	[h: thisRoll = eval("rollNum" + roll.count +   "=" + d20)  ]
	[h: attackString = if((eval("targetNumber" + roll.count) == 1), CODE:{["foo"]} , "bar" 	)] 
	[attackString]	
}]
If I replace that if statement inside the FOR loop to have "foo" instead of CODE:{["foo"]} (or any variation I have tried) it works and spits out the expected output based on which check boxes were selected.

Posted: Fri Nov 28, 2008 3:59 pm
by PyroMancer2k
jfrazierjr wrote: If I replace that if statement inside the FOR loop to have "foo" instead of CODE:{["foo"]} (or any variation I have tried) it works and spits out the expected output based on which check boxes were selected.
That's cause you can't have CODE blocks in the middle of an if(). You need to set it up an an [if():] block like so.

Code: Select all

 [h,if(eval("targetNumber" + roll.count) == 1),CODE: {
  [attackString = "foo"]
 };{
  [attackString = "bar"]
 }]  

Posted: Tue Dec 02, 2008 6:14 pm
by PyroMancer2k
b48 is out and your new options still aren't in the build yet. I was kinda looking forward to the TAB option as a way to improve some input displays.

Posted: Tue Dec 02, 2008 6:23 pm
by mmbutter
I noticed that listSort() still doesn't exist in b48, either...