Tooltip problem
Moderators: dorpond, trevor, Azhrei, giliath, Gamerdude, jay, Mr.Ice
-
- Kobold
- Posts: 9
- Joined: Tue Oct 26, 2010 8:28 am
Re: Tooltip problem
I copied and pasted the macro code from above into a new macro. (and a separate one for oncampaignload). Guesswork I know...
- CoveredInFish
- Demigod
- Posts: 3104
- Joined: Mon Jun 29, 2009 10:37 am
- Location: Germany
- Contact:
Re: Tooltip problem
Okay. I guess - if you mention onCampaignLoad - you figured it out how to set up the lib:token and defineFunction stuff to make it work.
So now .. what does this function. And how do you use it.
It can sum up a number of name/value pairs like dice rolls and modifiers and display the sum with a detailed tabular tooltip.
It can as well check this versus a DC or target number and show miss or hit.
How do you use it. Lets say you made it so that you can use the UDF FormatTooltip(). This function expects a json object containing these name/value pairs. If this might sound complicated, it actually isnt.
Lookup the wiki for Wiki: json.set(). Note that in this context you can use "" as a "empty" json object.
I hope this somehow explains it...
So now .. what does this function. And how do you use it.
It can sum up a number of name/value pairs like dice rolls and modifiers and display the sum with a detailed tabular tooltip.
It can as well check this versus a DC or target number and show miss or hit.
How do you use it. Lets say you made it so that you can use the UDF FormatTooltip(). This function expects a json object containing these name/value pairs. If this might sound complicated, it actually isnt.
Code: Select all
[h: param = json.set("", "dice roll", 1d20, "bonus 1", 2, "bonus 2", 3)]
<!-- standard usage -->
std: [r: FormatTooltip( param )]
<br>
<!-- verbose usage -->
verbose: [r: FormatTooltip( param, 0 )]
<br>
<!-- dc usage -->
dc: [r: FormatTooltip( param, 1, 15 )]
I hope this somehow explains it...
Re: Tooltip problem
Hey, stumbled across this ... wow .. neat .. awesome ... I've grabbed this code, and done some "minor" tweaking of the formatting (ie I didn't want Verdana font and italics ... just plain text, thanks ..) Thank you so much for this .. it's great!! (with 1 minor issue )
In any case, got the FormatToolTip function defined, and working ...
So in nutshell, (D&D 4e, btw)
- I use SelectedNames() to grab selected targets.
- I loop through each selected target.
- I calc the attack mods, and send the json dump to FormatToolTip to display the result.
- end loop
- display damage.
If I choose only 1 target, as I say, it works fine ... more than 1? Stack overflow.
I'm loathe to just (blindly) increase the stack ... are these html "fancy" solutions, that hard on the stack? or am I just chewing up the stack elsewhere?
FYI: Without the FormatTooltip, I can deal with 8+ targets easy in that loop, no stack issues. This is why I believe it's the extra work of the tooltip function ...
Has anyone else had any issues with this particular UDF ? Or is there a way around it?
My Stack size is currently 1M.
I tried increasing to 2M .. just for testing ... and using the FormatToolTip, it allowed me to get up to 4 targets, but choked on 5 ...
Any suggestions?
Thanks!
In any case, got the FormatToolTip function defined, and working ...
So in nutshell, (D&D 4e, btw)
- I use SelectedNames() to grab selected targets.
- I loop through each selected target.
- I calc the attack mods, and send the json dump to FormatToolTip to display the result.
- end loop
- display damage.
If I choose only 1 target, as I say, it works fine ... more than 1? Stack overflow.
I'm loathe to just (blindly) increase the stack ... are these html "fancy" solutions, that hard on the stack? or am I just chewing up the stack elsewhere?
FYI: Without the FormatTooltip, I can deal with 8+ targets easy in that loop, no stack issues. This is why I believe it's the extra work of the tooltip function ...
Has anyone else had any issues with this particular UDF ? Or is there a way around it?
My Stack size is currently 1M.
I tried increasing to 2M .. just for testing ... and using the FormatToolTip, it allowed me to get up to 4 targets, but choked on 5 ...
Any suggestions?
Thanks!
Re: Tooltip problem
I've had the same problem. This has been thoroughly discussed on this forum. It basically means that you macro is too big. There is a wiki entry where the conclusions of this discussion are mentioned. I suggest you read it. Though if IIRC what you can do is have build a small macro that calls the macro that you now use. Send the resulting chat text output to that macro and have that macro put it in the chat.
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: Tooltip problem
If you're referring to this wiki entry: http://lmwcs.com/rptools/wiki/Stack_Sizewolph42 wrote:I've had the same problem. This has been thoroughly discussed on this forum. It basically means that you macro is too big. There is a wiki entry where the conclusions of this discussion are mentioned. I suggest you read it. Though if IIRC what you can do is have build a small macro that calls the macro that you now use. Send the resulting chat text output to that macro and have that macro put it in the chat.
yeah, I read it a while back ...
What you mention, is essentially what's already happening ... (I think?) .. that UDF is just setting up the URL, my main routine is dumping output to the chat ..
Is this specific tooltip that large? I didn't think it was? I'll try trimming it, in any case ....
Thanks!
Re: Tooltip problem
Im not sure we're understanding eachother correctly. Maybe we do maybe not: what I mean is that your main routine should accumulate all text2chat into a variable e.g. txt2chat and end the routine with:
[r:txt2chat]
Then another routine (lets call it output() ) should call the main routine e.g. [r:mainRoutine()]. This should (most likely) solve the stack problem.
If you're doing that already, than the main routine needs to be split up in smaller macros. Stack overflow basically boils down to: your macro is too big. And e.g loops only make m bigger.
[r:txt2chat]
Then another routine (lets call it output() ) should call the main routine e.g. [r:mainRoutine()]. This should (most likely) solve the stack problem.
If you're doing that already, than the main routine needs to be split up in smaller macros. Stack overflow basically boils down to: your macro is too big. And e.g loops only make m bigger.
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
- jfrazierjr
- Deity
- Posts: 5176
- Joined: Tue Sep 11, 2007 7:31 pm
Re: Tooltip problem
Also.. using strFormat() will help quite a bit for "repeated" sections(such as TR/TD combinations) as it makes your code a lot smaller and thus is much easier on the stack.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.
Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..
Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..
Re: Tooltip problem
From my experience, it's not so much too big of macros but too long of strings with multiple levels of string manipulating functions. So, be aware of the strformat, lower, replace and stuff like that.
As for stack size, I've been using 2M for almost 2 years without the need to increase it. I've only run in to a stack size problem once with my code and as mentioned above, I just split one line in to 2 lines pulling out a lower function and fixed my problem. But even then, I was dealing with a particularly large string.
As for stack size, I've been using 2M for almost 2 years without the need to increase it. I've only run in to a stack size problem once with my code and as mentioned above, I just split one line in to 2 lines pulling out a lower function and fixed my problem. But even then, I was dealing with a particularly large string.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Tooltip problem
ah, ok, I think I understand what you're saying ... let me play with this a bit more ..
my main routine is spitting stuff out as it goes .. so that might be the issue.
Question though ... (perhaps I'll answer this on my own as I work on it, but), how do standard tooltips work when you're stuffing everything into a single string, and then dumping it via [r: string] ??
No tooltips?
my main routine is spitting stuff out as it goes .. so that might be the issue.
Question though ... (perhaps I'll answer this on my own as I work on it, but), how do standard tooltips work when you're stuffing everything into a single string, and then dumping it via [r: string] ??
No tooltips?
- jfrazierjr
- Deity
- Posts: 5176
- Joined: Tue Sep 11, 2007 7:31 pm
Re: Tooltip problem
Google HTML Title attribute on DivDitto wrote:ah, ok, I think I understand what you're saying ... let me play with this a bit more ..
my main routine is spitting stuff out as it goes .. so that might be the issue.
Question though ... (perhaps I'll answer this on my own as I work on it, but), how do standard tooltips work when you're stuffing everything into a single string, and then dumping it via [r: string] ??
No tooltips?
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.
Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..
Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..
Re: Tooltip problem
Ok .. sorry, I'm really trying to understand this, but I'm struggling.
Ok, so my original code looked something like this: (this is just a small snippet, so as not to overwhelm ...)
Now, this works, and later on in the loop, I can handle 8+ targets fine, with only 1M of stack size ... no sweat.
Ok, so then I add the FormatToolTip ...
Only change was to add the tool tip .. and bam .. suddenly it can't handle more than 1 or 2 targets ... ??
Ok .. so suggestions here, say build a string, and use strformat ... ok.
And although this still works, it still bombs after only a couple targets.
Ok, so 1 last thing I saw mentioned ...
I should call another routine to build this string ... then call yet another to display it ...
I'm struggling with figuring out how to pull that off, as for now, I'm building the above macro dynamically from another "Make power" macro ...
If I have to create 2 or 3 macros for each power, that's going to be a crazy amount of clutter!!
Ok, so I know I'm still doing something wrong, but for the life of me, I just can't seem to wrap my head around this ...
Any advice would be appreciated ...
Thanks!
Ok, so my original code looked something like this: (this is just a small snippet, so as not to overwhelm ...)
Code: Select all
[h: thisPower = "Testing" ]
[h: pAction = "Standard" ]
[h: pVS = "AC" ]
[h: AttMod = 5 ]
[h: AttMod2 = 2 ]
[h: Misc = 1 ]
[h: targetlist = getSelectedNames()]
[h: abort(length(targetlist))]
<table border='0'>
<tr bgcolor='#004F00'> <!-- at-will -->
<table width='100%'>
<tr>
<td style='padding:0px 5px;'>
<span style='color:white'><b>[r:thisPower] </b></font>
</td>
<td style='padding:0px 5px;' align=right>
<span style='color:white'>Action Type: [r:pAction]</font>
</td>
</tr>
</table>
</tr>
<tr>
<td>
[r,foreach(target, targetlist, '<br>'),CODE:
{
[h: AtkRoll=1d20]
<b>Attack ([r:target])</b>: [t:AtkRoll+AttMod+AttMod2+Misc] vs. [r:pVS]
}]
</td>
</tr>
</table>
Ok, so then I add the FormatToolTip ...
Code: Select all
[h: thisPower = "Testing" ]
[h: pAction = "Standard" ]
[h: pVS = "AC" ]
[h: AttMod = 5 ]
[h: AttMod2 = 2 ]
[h: Misc = 1 ]
[h: targetlist = getSelectedNames()]
[h: abort(length(targetlist))]
<table border='0'>
<tr bgcolor='#004F00'> <!-- at-will -->
<table width='100%'>
<tr>
<td style='padding:0px 5px;'>
<span style='color:white'><b>[r:thisPower] </b></font>
</td>
<td style='padding:0px 5px;' align=right>
<span style='color:white'>Action Type: [r:pAction]</font>
</td>
</tr>
</table>
</tr>
<tr>
<td>
[r,foreach(target, targetlist, '<br>'),CODE:
{
[h: AtkRoll=1d20]
[h: RollParams = json.set("", "Attack Roll", AtkRoll, "Modifier 1", AttMod, "Modifier 2", AttMod2, "Modifier 3", Misc)]
<b>Attack ([r:target])</b>: [r: f_FormatToolTip ( RollParams )] vs. [r: pVS]
}]
</td>
</tr>
</table>
Ok .. so suggestions here, say build a string, and use strformat ... ok.
Code: Select all
[h: thisPower = "Testing" ]
[h: pAction = "Standard" ]
[h: pVS = "AC" ]
[h: AttMod = 5 ]
[h: AttMod2 = 2 ]
[h: Misc = 1 ]
[h: targetlist = getSelectedNames()]
[h: abort(length(targetlist))]
[h: txt2chat = "
<table border='0'>
<tr bgcolor='#004F00'> <!-- at-will -->
<table width='100%'>"]
[h: txt2chat = txt2chat + strformat(" <tr>
<td style='padding:0px 5px;'>
<span style='color:white'><b> %s </b></font>", thisPower)]
[h: txt2chat = txt2chat + strformat(" </td>
<td style='padding:0px 5px;' align=right>
<span style='color:white'>Action Type: %s </font>", pAction)]
[h: txt2chat = txt2chat + " </td>
</tr>
</table>
</tr>
<tr>
<td>"]
[r,foreach(target, targetlist, '<br>'),CODE:
{
[h: AtkRoll=1d20]
[h: RollParams = json.set("", "Attack Roll", AtkRoll, "Modifier 1", AttMod, "Modifier 2", AttMod2, "Modifier 3", Misc)]
[h: txt2chat = txt2chat + strformat("<b>Attack ( %s )</b>: %s vs. %s <br>", target, f_FormatToolTip ( RollParams ), pVS)]
}]
[h: txt2chat = txt2chat + " </td>
</tr>
</table>", 1d20)]
[r: txt2chat ]
Ok, so 1 last thing I saw mentioned ...
I should call another routine to build this string ... then call yet another to display it ...
I'm struggling with figuring out how to pull that off, as for now, I'm building the above macro dynamically from another "Make power" macro ...
If I have to create 2 or 3 macros for each power, that's going to be a crazy amount of clutter!!
Ok, so I know I'm still doing something wrong, but for the life of me, I just can't seem to wrap my head around this ...
Any advice would be appreciated ...
Thanks!
Re: Tooltip problem
If its difficult Try to defer the output to another macro. So create the txt2Chat var and give that as an argument to erm forgot the name... Search the wiki for 'defer'. Should explain 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: Tooltip problem
Does your macro have "Apply to Selected Tokens" because the code goes through the Selected tokens already. This is a common mistake and will cause problems when selecting more than 1 token. Basically, the work load is geometric because you're processing all the tokens on each token.Ditto wrote:Only change was to add the tool tip .. and bam .. suddenly it can't handle more than 1 or 2 targets ... ??
Ok .. so suggestions here, say build a string, and use strformat ... ok.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Tooltip problem
execLink() ?? Hmm, might be a thought .. I'll play with that .. thanks!wolph42 wrote:If its difficult Try to defer the output to another macro. So create the txt2Chat var and give that as an argument to erm forgot the name... Search the wiki for 'defer'. Should explain it.
No, Apply to Selected is not checked ...aliasmask wrote: Does your macro have "Apply to Selected Tokens" because the code goes through the Selected tokens already.
I have some macros with it, and understand that feature now .. but yeah, fair question
I'm going to try restructuring it a bit, and maybe try that execLink() mentioned.
Oh yeah, thought of 1 more question ...
With this format tooltip, essentially, you mimic/expand on the [t: feature ... what about if you only want to show the tool tip to the GM? ie [t,gt: ??
What would have to change to do that?
Re: Tooltip problem
Yeah, I do this in my framework. You basically have 2 different outputs. This is one reason why it's good to put output in to a variable. The tricky part is determining who the GM is from a player's perspective. One solution is to write to a property on a lib token during onCampaignLoad. Since, this is not supported, the developers don't recommend this. One reason is when loading the campaign on a map that doesn't have your lib (like when you save on a different map then reload) then the lib token is duplicated. There is a map switching trick that can be done (getcurrent map, switch to lib map, write property, switch back to current map). The map switching doesn't really affect load time much and I find it worth it to keep track of gm names in a property for just this reason (separate outputs).Ditto wrote:With this format tooltip, essentially, you mimic/expand on the [t: feature ... what about if you only want to show the tool tip to the GM? ie [t,gt: ??
What would have to change to do that?
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools