d54 each number has an if (Stack Overflow)

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
craftomega
Kobold
Posts: 1
Joined: Wed Apr 29, 2015 12:58 am

d54 each number has an if (Stack Overflow)

Post by craftomega »

I am trying to make a card roller for pathfinder based on the harrow, I am very new to using maptools macro's. I have looked at http://lmwcs.com/rptools/wiki/Stack_Size and modified my: MAXMEMSZ="768m"
MINMEMSZ="32m"
STACKSZ="2m"

to higher numbers yet I still get the same error.

Error Code:
<html>A stack overflow has occurred.<p>This is commonly because a macro being used has exceeded the stack space specified when MapTool was executed.<br>Please run MapTool again and specify a larger stack size

Code that I am using:

Code: Select all

<b><i>--- Draw a Card----</i></b><br>
[h: d54roll = d54]
<span style="color:red"><b><i>
[h,if(d54roll == 1),r: ""]</b>The Avalanche</i></span>
[h,if(d54roll == 2),r: ""]</b>The Bear</i></span>
[h,if(d54roll == 3),r: ""]</b>The Beating</i></span>
[h,if(d54roll == 4),r: ""]</b>The Betrayal</i></span>
[h,if(d54roll == 5),r: ""]</b>The Big Sky</i></span>
[h,if(d54roll == 6),r: ""]</b>The Brass-Dwarf</i></span>
[h,if(d54roll == 7),r: ""]</b>The Carnival</i></span>
[h,if(d54roll == 8),r: ""]</b>The Courtesan</i></span>
[h,if(d54roll == 9),r: ""]</b>The Cricket</i></span>
[h,if(d54roll == 10),r: ""]</b>The Crows</i></span>
[h,if(d54roll == 11),r: ""]</b>The Cyclone</i></span>
[h,if(d54roll == 12),r: ""]</b>The Dance</i></span>
[h,if(d54roll == 13),r: ""]</b>The Demon's Lantern</i></span>
[h,if(d54roll == 14),r: ""]</b>The Desert</i></span>
[h,if(d54roll == 15),r: ""]</b>The Eclipse</i></span>
[h,if(d54roll == 16),r: ""]</b>The Empty Throne</i></span>
[h,if(d54roll == 17),r: ""]</b>The Fiend</i></span>
[h,if(d54roll == 18),r: ""]</b>The Foreign Trader</i></span>
[h,if(d54roll == 19),r: ""]</b>The Forge</i></span>
[h,if(d54roll == 20),r: ""]</b>The Hidden Truth</i></span>
[h,if(d54roll == 21),r: ""]</b>The Idiot</i></span>
[h,if(d54roll == 22),r: ""]</b>The Inquisitor</i></span>
[h,if(d54roll == 23),r: ""]</b>The Joke</i></span>
[h,if(d54roll == 24),r: ""]</b>The Juggler</i></span>
[h,if(d54roll == 25),r: ""]</b>The Keep</i></span>
[h,if(d54roll == 26),r: ""]</b>The Liar</i></span>
[h,if(d54roll == 27),r: ""]</b>The Locksmith</i></span>
[h,if(d54roll == 28),r: ""]</b>The Lost</i></span>
[h,if(d54roll == 29),r: ""]</b>The Marriage</i></span>
[h,if(d54roll == 30),r: ""]</b>The Midwife</i></span>
[h,if(d54roll == 31),r: ""]</b>The Mountain Man</i></span>
[h,if(d54roll == 32),r: ""]</b>The Mute Hag</i></span>
[h,if(d54roll == 33),r: ""]</b>The Owl</i></span>
[h,if(d54roll == 34),r: ""]</b>The Paladin</i></span>
[h,if(d54roll == 35),r: ""]</b>The Peacock</i></span>
[h,if(d54roll == 36),r: ""]</b>The Publican</i></span>
[h,if(d54roll == 37),r: ""]</b>The Queen Mother</i></span>
[h,if(d54roll == 38),r: ""]</b>The Rabbit Prince</i></span>
[h,if(d54roll == 39),r: ""]</b>The Rakshasa</i></span>
[h,if(d54roll == 40),r: ""]</b>The Sickness</i></span>
[h,if(d54roll == 41),r: ""]</b>The Snakebite</i></span>
[h,if(d54roll == 42),r: ""]</b>The Survivor</i></span>
[h,if(d54roll == 43),r: ""]</b>The Tangled Briar</i></span>
[h,if(d54roll == 44),r: ""]</b>The Teamster</i></span>
[h,if(d54roll == 45),r: ""]</b>The Theater</i></span>
[h,if(d54roll == 46),r: ""]</b>The Trumpet</i></span>
[h,if(d54roll == 47),r: ""]</b>The Twin</i></span>
[h,if(d54roll == 48),r: ""]</b>The Tyrant</i></span>
[h,if(d54roll == 49),r: ""]</b>The Unicorn</i></span>
[h,if(d54roll == 50),r: ""]</b>The Uprising</i></span>
[h,if(d54roll == 51),r: ""]</b>The Vision</i></span>
[h,if(d54roll == 52),r: ""]</b>The Wanderer</i></span>
[h,if(d54roll == 53),r: ""]</b>The Waxworks</i></span>
[h,if(d54roll == 54),r: ""]</b>The Winged Serpent</i></span>
Last edited by wolph42 on Wed Apr 29, 2015 3:00 am, edited 1 time in total.
Reason: added code tags

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: d54 each number has an if (Stack Overflow)

Post by Full Bleed »

Set your stack to 4. It doesn't throw a stack error for me at that setting.

That said, your syntax is quite messed up and it's not going to do what you want it to do. You should take a look at using a Table for this sort of thing. You could even add images from the deck to the table and call them in your macro.

Here is a table tutorial video.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: d54 each number has an if (Stack Overflow)

Post by wolph42 »

Full Bleed wrote:your syntax is quite messed up
indeed. In my signature, the last link 'READ THIS' so what it says (after you clicked on the link that is... 8) )

by the way: due to your wrong syntax you get the stack overflow. On *some* systems (still no clue why when or how) MT overflows if massive amounts of text is ported to the chat, as you do with your 'code'.

@FB: interestingly enough, I don't think that his syntax would render an error. He uses 3 options which you should be able to interchange, it *does* however makes little sense indeed.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: d54 each number has an if (Stack Overflow)

Post by Full Bleed »

wolph42 wrote:@FB: interestingly enough, I don't think that his syntax would render an error. He uses 3 options which you should be able to interchange, it *does* however makes little sense indeed.
I know it doesn't throw a stack overflow on my setup (though I'm using a 64bit OS/Java, 2048M max, and a 4M stack). It does, however, output the entire deck to chat and it's not formatted the way I'm sure he wants. Fixable, but he should probably use the SWITCH Option or a table.

I think using a table would be the best option.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

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

Re: d54 each number has an if (Stack Overflow)

Post by aliasmask »

I wouldn't bother with a table. A simple json array or string list would be simplest. If you want to make it like a deck where when you draw a card that card is removed then the json array is definitely better.

Code: Select all

[H: output = '<b><i>--- Draw a Card----</i></b><br>']
[H: deck = json.append("","The Avalanche","The Bear","The Beating")]
[H: deck = json.shuffle(deck)]
[H: card = json.get(deck,0)]
[H: deckSize = json.length(deck)]
[H, if(deckSize): deck = json.remove(deck,0)]
[H: output = output + strformat('<span style="color:red"><b><i>%card</i></b></span>')]
[R: output]
I put deckSize in there as a reminder that if the deck is 0 you can't removed a card. You really should have functions for deck creation, drawing a card and other card functions. I only put 3 items in the deck, but you get the idea.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: d54 each number has an if (Stack Overflow)

Post by wolph42 »

@AM: I don't think that you should suggest json arrays for a beginner user (using the above syntax).
@FB. Yes as I said on *some* systems. As it turns out. large quantities of text straight from macro to chat can generate a stack overflow with different stack settings at different machines. Took me a while to figure that out and we still don't know why.(And believe me we did quite some different tests).

@OP (original poster): although AM's suggestion is by far the most elegant and (when working with a card deck) the way to go.
To remain a bit more in your own learning curve I would follow the suggestion of FB: either use tables or [switch:]
edit: then again, you can go for the shortcut and just copy paste hist code and update the list (as he implies in the post below).

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

Re: d54 each number has an if (Stack Overflow)

Post by aliasmask »

I would have gave a list example but shuffle is a json function. Plus I just did all the heavy lifting in my example.

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: d54 each number has an if (Stack Overflow)

Post by JamzTheMan »

Unless you really want to do it yourself, I believe there is a Harrow Deck in LM's Pathfinder Framework. You can probably just copy it from there. Pics are included IIRC.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

Post Reply

Return to “MapTool”