Trying to figure out why my pseudo-table macro isn't working

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Voltang
Cave Troll
Posts: 88
Joined: Wed Dec 03, 2008 5:13 pm

Trying to figure out why my pseudo-table macro isn't working

Post by Voltang »

I'm sure there's a much easier way to do this, but I'm curious why the macro breaks down when I use variables instead of numbers for the comparison statements. I was trying to save myself work later by making the numbers here an easily changed template.

Code: Select all

[h: Num1 = 1] [h: Num2 = 3] 
[h: Num3 = 4] [h: Num4 = 12]
[h: Num5 = 13] [h: Num6 = 19]
[h: Num7 = 20] [h: Num8 = 24]
[h: Num9 = 25] [h: Num10 = 29]
[h: Num11 = 30] [h: Num12 = 32]
[h: Num13 = 33] [h: Num14 = 39]
[h: Num15 = 40] [h: Num16 = 44]
[h: Num17 = 45] [h: Num18 = 49]
[h: Num19 = 50 ] [h: Num20 = 54]
[h: Num21 = 55] [h: Num22 = 61]
[h: Num23 = 62] [h: Num24 = 64]
[h: Num25 = 65] [h: Num26 = 67]
[h: Num27 = 68] [h: Num28 = 77]
[h: Num29 = 78] [h: Num30 = 85]
[h: Num31 = 86] [h: Num32 = 92]
[h: Num33 = 93] [h: Num34 = 100]
[h:EncounterChanceRoll = d100]
[h:RandomEncounterRoll = d100]
[h: status=input(
"LastEnc|No,Yes|Was there a random event last month?|RADIO")]
[h,if(LastEnc == 1),code: {[h: EncounterChance = 25]}; {[h: EncounterChance = 75]}]

[h,if(RandomEncounterRoll <= Num2 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d6] [r: "Assassination Attempt"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num3 && RandomEncounterRoll <= Num4 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d4] [r: "Bandit Activity"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num5 && RandomEncounterRoll <= Num6 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d4] [r: "Disaster"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num7 && RandomEncounterRoll <= Num8 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: "Economic Boom"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num9 && RandomEncounterRoll <= Num10 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d6] [r: "Feud"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num11 && RandomEncounterRoll <= Num12 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: "Food Shortage"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num13 && RandomEncounterRoll <= Num14 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d4] [r: "Food Surplus"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num15 && RandomEncounterRoll <= Num16 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: "Good Weather"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num17 && RandomEncounterRoll <= Num18 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: "Monster Attack"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll == Num19 && RandomEncounterRoll == Num20 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d8] [r: "Natural Blessing"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num21 && RandomEncounterRoll <= Num22 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d8] [r: "Outstanding Success"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll == Num23 && RandomEncounterRoll == Num24 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: "Plague"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num25 && RandomEncounterRoll <= Num26 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: "Political Calm"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num27 && RandomEncounterRoll <= Num28 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: "Public Scandal"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num29 && RandomEncounterRoll <= Num30 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: Sensational Crime"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num31 && RandomEncounterRoll <= Num32 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: "New Vassals"] }; {[r:"There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num33 && RandomEncounterRoll <= Num34 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d4] [r: "Visiting Celebrity"] }; {[r:"There are no kingdom events this month."]}]
But the output when I run the macro is this:
[h,if(RandomEncounterRoll >= Num29 && RandomEncounterRoll = Num30 && EncounterChanceRoll = EncounterChance),code: { [h:RandomNumber = 1] [r: Sensational Crime"] }; {[r:"There are no kingdom events this month."]}] [h,if(RandomEncounterRoll >= Num31 && RandomEncounterRoll = Num32 && EncounterChanceRoll = EncounterChance),code: { [h:RandomNumber = 1] [r: "New Vassals"] }; {[r:"There are no kingdom events this month."]}] [h,if(RandomEncounterRoll >= Num33 && RandomEncounterRoll = Num34 && EncounterChanceRoll = EncounterChance),code: { [h:RandomNumber = 1d4] [r: "Visiting Celebrity"] }; {[r:"There are no kingdom events this month."]}]

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by aliasmask »

You missed a quote.

Code: Select all

[r: "Sensational Crime"]
It's good to use a text editor that does comment, quote text hi-lighting. You don't run in to those kind of mistakes very often if you do. Personally, I use Notepad++ but there are plenty of good options around.

Voltang
Cave Troll
Posts: 88
Joined: Wed Dec 03, 2008 5:13 pm

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by Voltang »

Thanks...that would have driven me crazy, trying to spot the quote mark in all of that.

Does Notepad++ work in Linux? The native text program does line by line code well enough but I can't get it to color code or anything fancier.

Voltang
Cave Troll
Posts: 88
Joined: Wed Dec 03, 2008 5:13 pm

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by Voltang »

I put the quote in, but now I don't get any output at all. Is the macro too big to parse? Or did I make more than one silly mistake?

User avatar
mfrizzell
Dragon
Posts: 762
Joined: Sat Feb 13, 2010 2:35 am
Location: California

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by mfrizzell »

Leave off the h, in front of the if statements, it suppresses all output associated with the if statement.
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."

Voltang
Cave Troll
Posts: 88
Joined: Wed Dec 03, 2008 5:13 pm

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by Voltang »

Thanks. I really should have caught that.

User avatar
mfrizzell
Dragon
Posts: 762
Joined: Sat Feb 13, 2010 2:35 am
Location: California

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by mfrizzell »

yep, it's gotten me more than once.
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by aliasmask »

Voltang wrote:Thanks...that would have driven me crazy, trying to spot the quote mark in all of that.

Does Notepad++ work in Linux? The native text program does line by line code well enough but I can't get it to color code or anything fancier.
I'm not a linux person, but I seem to recall something about VIM? Also, Craig made some syntax handling for use with MT. I reposted the syntax plugin, but you may want to read through the rest of the thread for any questions about it.

Voltang
Cave Troll
Posts: 88
Joined: Wed Dec 03, 2008 5:13 pm

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by Voltang »

Hm... I need to rethink this. When I remove the "h" it causes output from all of the IF statements.

EDIT: I think I figured a way around it. If I leave the "h" and turn the output into a variable called output, I can just drip that in at the end, right?

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by aliasmask »

I was actually going to suggest that as a best practice anyway. I usually only have 1 macro that does my output and always as the end of the process. Also, Wiki: strformat() is your friend :)

Voltang
Cave Troll
Posts: 88
Joined: Wed Dec 03, 2008 5:13 pm

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by Voltang »

Okay, this one is turning out to be a bit tricky. I had a random monster macro that worked just fine, but then I had to go and get creative. What you're looking at is meant to be a random event generator that asks if there was a random event the month before and increases the chances from 25% to 75% if there was no event the previous month. Each numbered variable pair is the range for a particular event. I didn't put the numbers in the IF statements because I was hoping to save myself some work later and just change the variables. Might have been a silly idea since this is turning out to be much more work. I'm curious whether the variables are the problem, but I have no way to be sure because I get output now, it's just always the false output. No matter how many times I run it, it's always false.

Code: Select all

[h: Num1 = 1] [h: Num2 = 3]
[h: Num3 = 4] [h: Num4 = 12]
[h: Num5 = 13] [h: Num6 = 19]
[h: Num7 = 20] [h: Num8 = 24]
[h: Num9 = 25] [h: Num10 = 29]
[h: Num11 = 30] [h: Num12 = 32]
[h: Num13 = 33] [h: Num14 = 39]
[h: Num15 = 40] [h: Num16 = 44]
[h: Num17 = 45] [h: Num18 = 49]
[h: Num19 = 50 ] [h: Num20 = 54]
[h: Num21 = 55] [h: Num22 = 61]
[h: Num23 = 62] [h: Num24 = 64]
[h: Num25 = 65] [h: Num26 = 67]
[h: Num27 = 68] [h: Num28 = 77]
[h: Num29 = 78] [h: Num30 = 85]
[h: Num31 = 86] [h: Num32 = 92]
[h: Num33 = 93] [h: Num34 = 100]
[h:EncounterChanceRoll = d100]
[h:RandomEncounterRoll = d100]
[h: status=input(
"LastEnc|No,Yes|Was there a random event last month?|RADIO")]
[h,if(LastEnc == 1),code: {[h: EncounterChance = 25]}; {[h: EncounterChance = 75]}]

[h,if(RandomEncounterRoll <= Num2  && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d6] [r: output = "Assassination Attempt"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num3 && RandomEncounterRoll <= Num4 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d4] [r: output = "Bandit Activity"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num5 && RandomEncounterRoll <= Num6 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d4] [r: output = "Disaster"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num7 && RandomEncounterRoll <= Num8 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: output = "Economic Boom"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num9 && RandomEncounterRoll <= Num10 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d6] [r: output = "Feud"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num11 && RandomEncounterRoll <= Num12 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: output = "Food Shortage"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num13 && RandomEncounterRoll <= Num14 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d4] [r: output = "Food Surplus"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num15 && RandomEncounterRoll <= Num16 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: output = "Good Weather"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num17 && RandomEncounterRoll <= Num18 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: output = "Monster Attack"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll == Num19 && RandomEncounterRoll == Num20 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d8] [r: output = "Natural Blessing"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num21 && RandomEncounterRoll <= Num22 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d8] [r: output = "Outstanding Success"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll == Num23 && RandomEncounterRoll == Num24 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: output = "Plague"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num25 && RandomEncounterRoll <= Num26 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: output = "Political Calm"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num27 && RandomEncounterRoll <= Num28 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: output = "Public Scandal"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num29 && RandomEncounterRoll <= Num30 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: output = "Sensational Crime"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num31 && RandomEncounterRoll <= Num32 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1] [r: output = "New Vassals"] }; {[r:output = "There are no kingdom events this month."]}]

[h,if(RandomEncounterRoll >= Num33 && RandomEncounterRoll <= Num34 && EncounterChanceRoll <= EncounterChance),code: { [h:RandomNumber = 1d4] [r: output = "Visiting Celebrity"] }; {[r:output = "There are no kingdom events this month."]}]

[r: output]

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by aliasmask »

This is one way I could write it:

Code: Select all

[H: encounterChance = json.append("",1,4,13,20,25,30,33,40,45,50,55,62,65,68,78,86,93,101)]
[H: encounterText = json.append("","Assassination Attempt","Bandit Activity","Disaster","Economic Boom","Feud",
   "Food Shortage","Food Surplus","Good Weather","Monster Attack","Natural Blessing","Outstanding Success","Plague",
   "Political Calm","Public Scandal","Sensational Crime","New Vassals","Visiting Celebrity")
]
[H: encounterCount = json.append("","1d6","1d4","1d4","1","1d6","1","1d4","1","1","1d8","1d8","1","1","1","1","1","1d4")]
[h: hasInput = input("lastEnc|No,Yes|Was there a random event last month?|RADIO")]
[H, if(hasInput): encounterChanceTarget = 25 + ((1 - lastEnc) * 50); abort(0)]
[H: encounterChanceRoll = 1d100]
[ if(encounterChanceRoll <= encounterChanceTarget), code: {
   [H: randomEncounterRoll = 1d100]
   [H: index = -1]
   [H, while(randomEncounterRoll >= json.get(encounterChance,index+1)): index = index +1]
   [H: output = strformat("(%s) %s",eval(string(json.get(encounterCount,index))),json.get(encounterText,index))]
};{
   [H: output = "There are no kingdom events this month."]
}]
[R: output] 
Basically, I create 3 arrays using the first one to get the index I want to use for the other 2 arrays with the output and the number of (events?). I nicer way to write it is as a json object, but since there are only really 2 values and it doesn't make things easier I stuck with respective array values. It also doesn't execute any unnecessary code or repetitive code segments. I didn't know how you want your output for the number of events/encounters so I just stuck it in ()'s.

As a side note, all the [r: output = ... statements don't really need the "r" because the "if" has the "h". But for good form and since the line is an assignment and not really an output line, I would use an "H".

And another note on my code. I use "1d6" as a string because I want to evaluate it each time rather than writing a fixed number. I would also write the top variable constants to a lib:token property because I'll only need to code it once (unless I edit it later) and the macro would start with Wiki: getLibProperty() for each of the arrays.

I like to consolidate my variables and code where I'm not doing a lot of repeating and if I need to change something, then I only need to change it in one location. It really helps down the road.

koralas
Kobold
Posts: 24
Joined: Wed Jun 23, 2010 1:19 pm

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by koralas »

Voltang wrote:Thanks...that would have driven me crazy, trying to spot the quote mark in all of that.

Does Notepad++ work in Linux? The native text program does line by line code well enough but I can't get it to color code or anything fancier.
Not natively, no...

So as is later related, you could use a VM to run a windows session, but then you possibly have issues with clipboards not passing between the VM and host.

When switching to using a Linux VM, to run and develop in MapTool, I was lamenting the issue of not having Notepad++, sure I could use other applications and configure them, but this one was working so well for me, why switch. Then I remembered WINE...

I would recommend that you install WINE on your linux station, and then install Notepad++ in Wine. WINE stands for (yes it is recursive) WINE Is Not an Emulator (not Windows Emulator as people often say). It is actually a Windows library implementation within Linux. The distinction here is that it isn't running an emulated bios and then initiating Windows (like a VM does); instead it uses native libraries in Linux to execute the code and output to xWindows for displays. It can use either the code library built by the open source community, or if you have Windows installed on another partition, you can use the native libraries.

You should be able to install it from the package manager for the linux distribution you are using. To learn more, or to get the packages manually, go to http://www.winehq.org. After heading back out to the site to see what was new, I found that there is support for Win64 applications now. Currently WINE supports Win95-XP. Also, there is a huge database of applications that have been tested, and where workarounds have been found for some issues, those are posted. Sadly, many applications are still listed as "garbage", including Outlook, but other are working quite well. You can also tell the gaming community has a strong influence on WINE, as most of the apps tested are games. ;)

I am running Notepad++ on Ubuntu 10.04, and it is working great! In fact, I did the installation to run from a USB stick (event though it is on a USB hard drive), then installed to the same location for both my native WinVista box, and the Ubuntu VM. This way I only have to maintain one location, with all the patches and extensions. Though a standalone installation will work fine. Also note that you will have a new WINE category in your application launcher, and that will have a Programs category, for applications installed with WINE. You can, if you so desire put a launcher on your desktop to run the applications. The WINE launcher also has a C:\ drive browser, which basically mounts the folder that has the base windows system installed by WINE, and additional drive letters pointing to other folders on the system. By default C:points to '../drive_c' and Z: points to '/', but these are configurable. This is configured from an applet provided, it also will link the Windows special Desktop, My Documents, My Pictures, My Music, and My Videos folders to your user home directory, though this is also configurable.

Voltang
Cave Troll
Posts: 88
Joined: Wed Dec 03, 2008 5:13 pm

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by Voltang »

Whoa, Aliasmask...that rocked my world a little. I guess I have to learn how JSON works now since your code looks much more streamlined than mine.

EDIT: Is it possible to trigger additional text with each text output, such as a tooltip giving details and/or the random number rolls as part of an output that says how many build points or unrest points will be added? I left the numbers as a placeholder for a more complicated output once I got the original macro working.

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Trying to figure out why my pseudo-table macro isn't wor

Post by aliasmask »

Voltang wrote:Whoa, Aliasmask...that rocked my world a little. I guess I have to learn how JSON works now since your code looks much more streamlined than mine.

EDIT: Is it possible to trigger additional text with each text output, such as a tooltip giving details and/or the random number rolls as part of an output that says how many build points or unrest points will be added? I left the numbers as a placeholder for a more complicated output once I got the original macro working.
Sure you can use a tooltip. Just replace some of the text in the strformat using this format:

Code: Select all

[H: encounterChance = json.append("",1,4,13,20,25,30,33,40,45,50,55,62,65,68,78,86,93,101)]
[H: encounterText = json.append("","Assassination Attempt","Bandit Activity","Disaster","Economic Boom","Feud",
   "Food Shortage","Food Surplus","Good Weather","Monster Attack","Natural Blessing","Outstanding Success","Plague",
   "Political Calm","Public Scandal","Sensational Crime","New Vassals","Visiting Celebrity")
]
[H: encounterCount = json.append("","1d6","1d4","1d4","1","1d6","1","1d4","1","1","1d8","1d8","1","1","1","1","1","1d4")]
[h: hasInput = input("lastEnc|No,Yes|Was there a random event last month?|RADIO")]
[H, if(hasInput): encounterChanceTarget = 25 + ((1 - lastEnc) * 50); abort(0)]
[H: encounterChanceRoll = 1d100]
[ if(encounterChanceRoll <= encounterChanceTarget), code: {
   [H: randomEncounterRoll = 1d100]
   [H: index = -1]
   [H, while(randomEncounterRoll >= json.get(encounterChance,index+1)): index = index +1]
   [H: numEvents = eval(string(json.get(encounterCount,index)))]
   [H: tooltipText = json.append("","<b>Rolls:</b>",
      strformat("<i>Encounter Chance:</i> %{encounterChanceTarget}"),
      strformat("<i>Encounter Chance Roll:</i> %{encounterChanceRoll}"),
      strformat("<i>Random Encounter Roll:</i> %{randomEncounterRoll}"),
      "<HR>")
   ]
   [H, for(i,0,numEvents): tooltipText = json.append(tooltipText,
      strformat('Event #%d: Plus "whatever" <b>html</b> <i>you</i> want.',roll.count+1))]
   [H: output = strformat('<span title="<html>%s</html>">%s</span>',
      replace(json.toList(tooltipText,"<BR>"),'"',"""),json.get(encounterText,index))]
};{
   [H: output = "There are no kingdom events this month."]
}]
[R: output]  

Post Reply

Return to “Macros”