[COUNT(): inside a [COUNT():
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
[COUNT(): inside a [COUNT():
Am I correct in assuming that you can't place a COUNT statement inside another COUNT statement?
I am trying to code a dialog screen that builds a table(grid) with 4 rows of 8 collumns.
The number of cells depends on a var that is from 1 to 32.
I tried using a COUNT(8) inside a COUNT(4) but doesn't seem to work. Is it becuase I am putting the counts inside a count?
Anyone else ever attempt something like this? If so how did you go about it?
I am trying to code a dialog screen that builds a table(grid) with 4 rows of 8 collumns.
The number of cells depends on a var that is from 1 to 32.
I tried using a COUNT(8) inside a COUNT(4) but doesn't seem to work. Is it becuase I am putting the counts inside a count?
Anyone else ever attempt something like this? If so how did you go about it?
- Bone White
- Great Wyrm
- Posts: 1124
- Joined: Tue Aug 23, 2011 11:41 am
- Location: Cornwall, UK
Re: [COUNT(): inside a [COUNT():
Are you sure it's not because you have more than two nested code_(roll_option)?
Roll options which will do an identical (similar?) thing are :
and
Roll options which will do an identical (similar?) thing are :
Code: Select all
for(i,1,8), code :{
code here}
Code: Select all
countVar = 0
while (countVar < 8), code :{
code here
countVar = countVar+1}
Re: [COUNT(): inside a [COUNT():
Can you post the code?Sydious wrote:Am I correct in assuming that you can't place a COUNT statement inside another COUNT statement?
I am trying to code a dialog screen that builds a table(grid) with 4 rows of 8 collumns.
The number of cells depends on a var that is from 1 to 32.
I tried using a COUNT(8) inside a COUNT(4) but doesn't seem to work. Is it becuase I am putting the counts inside a count?
Anyone else ever attempt something like this? If so how did you go about it?
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: [COUNT(): inside a [COUNT():
Here is an example of what I think I need to do....Doesn't work.
Code: Select all
[r, COUNT(4, ""):<tr>[r, COUNT(8, ""):<td>"Cell"</td>]</tr>]
Re: [COUNT(): inside a [COUNT():
Nope, won't work. You can't nest roll options like that. What you'd need to do is:Sydious wrote:Here is an example of what I think I need to do....Doesn't work.
Code: Select all
[r, COUNT(4, ""):<tr>[r, COUNT(8, ""):<td>"Cell"</td>]</tr>]
Code: Select all
[r,count(4,""),code:
{
<tr>[r,count(8,""):"<td>Cell</td>"]</tr>
}]
- Bone White
- Great Wyrm
- Posts: 1124
- Joined: Tue Aug 23, 2011 11:41 am
- Location: Cornwall, UK
Re: [COUNT(): inside a [COUNT():
Because of the code nesting limitation, you'll only be able to put two counts inside each other (three if the last count doesn't contain the code roll option)Rumble wrote:Roll options must use CODE to nest, as well as adhere to all nesting limits. Basically, unless it's part of a quote-enclosed string, a set of [ ] cannot be inside another set of [ ] without some { } in between.
Re: [COUNT(): inside a [COUNT():
Ok.. So if I were to use...
Would I be able to replace CELL with and image button?
I tried inputing the following code provided by Ali from a previous post and not getting favorable results.
I replaced CELL with [r: inputButton]
Code: Select all
[r,count(4,""),code:
{
<tr>[r,count(8,""):"<td>CELL</td>"]</tr>
}]
I tried inputing the following code provided by Ali from a previous post and not getting favorable results.
Code: Select all
[H: inputButton = strformat('<input type="image" src="%s" name="btnMove" value="UP">',getImage("image:Arrow_Up"))]
- CoveredInFish
- Demigod
- Posts: 3104
- Joined: Mon Jun 29, 2009 10:37 am
- Location: Germany
- Contact:
Re: [COUNT(): inside a [COUNT():
You can add strings. You dont need to use [r:] more than once to build a single string.
You can either use + or strformat.
You can either use + or strformat.
Code: Select all
[r, roll(8,""): strformat('<td><input type="image" src="%s" name="btnMove" value="UP"></td>',getImage("image:Arrow_Up"))]
Re: [COUNT(): inside a [COUNT():
Ok with your help i have reached this and am successful at createing all the buttons. (with that same image)
I need to randomize the image on each button. All the images are stored on image:tokens and have the naming convention like image:token_1 thru image:token_32.
If I can't implant code{} in the second count statement, how do I advance a var +1 each time to change the image on each button?
Code: Select all
[h: button = strformat('<td><input type="image" src="%s" name="btnMove" value="UP"></td>',getImage("image:" + tokenName))]
<table border = "1">
[r,count(6,""),code:
{
<tr>
[r, count(6,""): button ]
</tr>
}]
</table>
If I can't implant code{} in the second count statement, how do I advance a var +1 each time to change the image on each button?
Re: [COUNT(): inside a [COUNT():
You can implement a code statement in the second statement. You can have two nested code levels. If you go beyond that you need to create a user defined function and call that one in your inner statement. Your UDF contains the code with more code statements
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: [COUNT(): inside a [COUNT():
But when I try to put a code statement in like this:wolph42 wrote:You can implement a code statement in the second statement. You can have two nested code levels. If you go beyond that you need to create a user defined function and call that one in your inner statement. Your UDF contains the code with more code statements
Code: Select all
[r,count(6,""),code:
{
<tr>
[r, count(6,""), code:{
[r: button]
}
]
</tr>
}]
Re: [COUNT(): inside a [COUNT():
?? What's the error?
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
- Bone White
- Great Wyrm
- Posts: 1124
- Joined: Tue Aug 23, 2011 11:41 am
- Location: Cornwall, UK
Re: [COUNT(): inside a [COUNT():
You can do code :{code :{ [h: statement1][h: statement2] } }
use a count statement like:
firstCount = 1
count 36
if (roll.count / 6) == integer
firstCount = (roll.count / 6) + 1
(you can mix count and if and code statements altogether, to save code nesting)
use a count statement like:
firstCount = 1
count 36
if (roll.count / 6) == integer
firstCount = (roll.count / 6) + 1
(you can mix count and if and code statements altogether, to save code nesting)
- CoveredInFish
- Demigod
- Posts: 3104
- Joined: Mon Jun 29, 2009 10:37 am
- Location: Germany
- Contact:
Re: [COUNT(): inside a [COUNT():
I can not test it right where I am now, but I *think*
COUNT uses a special variable roll.count and it is known that on some
occasions this variable gets overwritten. Is it safe to use nested COUNTs at
all?
You can very easily use [for:] instead or just use a own index variable for your computations (you have to increment it manually of course).
COUNT uses a special variable roll.count and it is known that on some
occasions this variable gets overwritten. Is it safe to use nested COUNTs at
all?
You can very easily use [for:] instead or just use a own index variable for your computations (you have to increment it manually of course).
Re: [COUNT(): inside a [COUNT():
wolph42 wrote:?? What's the error?
Error in body of roll. Statement options (if any): dialog("Treasure Chamber", "width=700; height=650; temporary=1; input=0; noframe=1") Statement Body (first 200 characters): {
[h: tokenNameList = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32"] [h: tokenName = "Treasure_Token_1"] [h: button = strformat('