RPTools.net

Discussion and Support

Skip to content

It is currently Fri Feb 23, 2018 9:41 pm 






Reply to topic  [ 11 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Kobold
 
Joined: Mon May 09, 2016 6:42 am
Posts: 15
 Post subject: need help with a Simple Marcro based on initiative
PostPosted: Fri May 13, 2016 2:08 am 
Ok, so coding always gave me headaches in college and that was 15 years ago, now it just makes by eyes noodly.

What I am looking for seems simple enough but I am unable to find it already submitted so if someone has pre-existing code or a thread with same/similar enough functions please point me in that direction. Otherwise if one of you macro deities wouldn't mind helping a poor soul out that would be great.

Looking for two things:
The first would ideally happen automatically and would perform a set of skill checks / saves on the token that currently has initiative with the results only being seen by the GM. The rolls would be for things like spot, search, hide, move silently etc. If you could show me the starter code (with iterations) I could fill in the variables from the token property sheets and repeat for as many skills as i need myself. Not hard to replace (propertyName) with what i will call from the sheet i just don't know how to fit it all together without it imploding on me.

The second would be a button that would perform the same duty as the first on a selection of initiatived tokens based on three choices (All, PC, or
NPC). So I could call for saves from all npc's in a combat for example)

Thanks in advance to anyone willing to help!


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Mon Sep 15, 2008 8:27 am
Posts: 1207
Location: Bristol, UK
 Post subject: Re: need help with a Simple Marcro based on initiative
PostPosted: Fri May 13, 2016 4:43 am 
Assuming you want the player to be the one that presses the button and assuming the button has been added to the player's token then what you are asking for sounds quite simple.

A macro on the player's token has access to all the attributes on that token. Plus you have commands that direct output specifically at the gm or hide the output.
Code:
[h:roll=1d20+Perception]
[gm:"Roll is "+roll]
I look around to see what I can see


When the player clicks the button, everyone will see "I look around to see what I can see" in the chat window, but only the GM will see "Roll is 17" etc

Introduction_to_Macro_Writing covers this in more detail.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9485
Location: Netherlands
 Post subject: Re: need help with a Simple Marcro based on initiative
PostPosted: Fri May 13, 2016 7:01 am 
as explained in the PM I've made myself angry 4 years ago and gave birth to my initiative macros and never looked back at them again. Hence no clue how they work, BUT here's the lot:

Code:
@@ @InitiativeHandler
@PROPS@ fontColor=green ; autoExecute=true ; fontSize=11pt ; sortBy=27 ; color=silver ; playerEditable=false ; applyToSelected=false ; group=a. Utils ; tooltip= ; minWidth=96 ;
[h:'<!--------------------------------- InitiativeHandler ------------------------------------------>']
[h:hTokens = getSelectedNames()]

[h, foreach(hTok, hTokens), CODE:{
   [me = hTok]
   [switchToken(me)]
   [InitiativeSet()]
}]

[h:sortInitiative()]

<!-- Start the initiative panel after the first token is added -->
[h,if(getCurrentInitiative() < 0 && hTokens != ""): InitiativeNext()]

<!-- if its still the first round then reset the initiative to the highest init holder == first character in the list -->
[h, if(getInitiativeRound() == 1), CODE:{
   [setState("Initiative", 0, getInitiativeToken())]
   [setCurrentInitiative(0)]
   [setState("Initiative", 1, getInitiativeToken())]
}; {}]

!!
@@ @InitiativeReset
@PROPS@ fontColor=green ; autoExecute=true ; fontSize=11pt ; sortBy=31 ; color=silver ; playerEditable=false ; applyToSelected=false ; group=a. Utils ; tooltip= ; minWidth=96 ;
[h:'<!--------------------------------- InitiativeReset ------------------------------------------>']
<!-- input statement -->
[H: abort(input(
   "clearRecharge|1|Clear 'recharging' on all tokens in initiative panel|CHECK",
   "clearStates|1|Clear all temporary states on all tokens in initiative panel|CHECK",
   "clearTmpStats|1|Clear all temporary stat bonus/penalties on all tokens in initiative panel|CHECK",
   "clearIndefStats|0|Clear all indefinite stat bonus/penalties on all tokens in initiative panel|CHECK",
   "clearPermStats|0|Clear all permanent stat bonus/penalties on all tokens in initiative panel|CHECK"
))]

[h: message = ""]
[h: tokenHeaderList = ""]
   
[h, while(initiativeSize() > 0, ""), CODE:{
   [h: indexList = ""]
   [nextInitiative()]
   [me = getInitiativeToken()]
   [switchToken(me)]
   
   [if(clearRecharge): Recharging = "{}"]
   [if(clearRecharge): message = message + "Any recharges have been reset for "+token.name+"<br>"]

   [tmpStates = States]
   [if(clearStates):stateList = json.fields(tmpStates); stateList = ""]
   [foreach(state, stateList), if(json.get(tmpStates, state)>= 0): endState(state)]
   [if(clearStates): message = message + "Any temporary states have been reset for "+token.name+"<br>"]

   [tmpStatsArray = tmpStats]

   [selectTokens(me)]
   [tokenHeaderList = tokenHeaderList+" "+ "<img src='"+getTokenImage()+"' height='20' width='20' alt='"+token.name+"' />"]
   
   [foreach(tmpStat, tmpStatsArray), CODE:{
      [rounds   = json.get(tmpStat,"rounds")]
      [index = json.indexOf(tmpStatsArray, tmpStat)]
      [h,if(rounds >=  0 && clearTmpStats):    indexList = if(indexList == "", index, indexList + "," + index)]
      [h,if(rounds == -1 && clearIndefStats): indexList = if(indexList == "", index, indexList + "," + index)]
      [h,if(rounds == -2 && clearPermStats):    indexList = if(indexList == "", index, indexList + "," + index)]
   }]

   [h: indexList = string(indexList)]
      
   [h, if(length(indexList) >  0): endTmpStat(indexList)]

   [if(clearTmpStats):      message = message + "All temporary stats have been cleared for "   +token.name+"<br>"]
   [if(clearIndefStats):   message = message + "All indefinite stats have been cleared for "   +token.name+"<br>"]
   [if(clearPermStats):   message = message + "All permanent stats have been cleared for "   +token.name+"<br>"]
   
   [setState("Initiative", 0)]

   [removeFromInitiative()]
   
   <!-- If the token is boarded, make sure that the vehicle does not have the initiative state still set. -->
   <!-- if token is on board but the vehicle is not on the map then erase the onboard settings -->
   [if(findToken(OnBoard)==""): OnBoard = ""]
   [if(OnBoard != ""): setState("Initiative", 0, OnBoard)]

}]

<!-- reset the round counter-->
[h: removeAllFromInitiative()]

[h:headerText   = strformat("<b>Initiative Reset for:</b>")]
<!-- new:   0:message,   1:headertxt,   2:color (bgcolor-txtcolor),   3:userList,   4:token,      5:ManualRolls,   6:target,      7:broadcast      -->
[h, if(message != ""): message(message, headerText, "black", ownergm(),  token.name)]

!!
@@ @InitiativeSet
@PROPS@ fontColor=green ; autoExecute=true ; fontSize=11pt ; sortBy=28 ; color=silver ; playerEditable=false ; applyToSelected=false ; group=a. Utils ; tooltip= ; minWidth=96 ;
[h:'<!--------------------------------- InitiativeSet ------------------------------------------>']

[h:propType = getPropertyType(me)]

[h,switch(propType), CODE:
    case "Vehicle"   :{   
      [initBonus   = 0]
      [initList   = Crew]
      [if(Passengers != ""): initList = listAppend(initList, Passengers)]

      [if(Driver != "" || CoPilot != ""), CODE:{
         [nameDriver = if(Driver != "", Driver, CoPilot)]
         [initList = listDelete(initList, listFind(initList, nameDriver))]
         [InitiativeRoll(nameDriver, initBonus, me)]      
         [switchToken(nameDriver)]
         [iDriver = getInitiative()]
      }; {
         [iDriver = 0]
      }]

      [foreach(tok, initList), CODE:{
         [InitiativeRoll(tok, 0, me)]
         [switchToken(tok)]
         [iTok = getInitiative()]
         [iTok = iDriver - 1 + iTok/100]
         [setInitiative(iTok)]
      }]
   };
    case "Ship"   :{   
      [InitiativeRoll(Captain, floor(Detection/10), me, me)]
   };
    default         :{[InitiativeRoll(me)]}
]

!!
@@ @removeInitiative
@PROPS@ fontColor=green ; autoExecute=true ; fontSize=1.00em ; sortBy=34 ; color=silver ; playerEditable=false ; applyToSelected=true ; group=a. Utils ; tooltip= ; minWidth=96 ;
[h:'<!-- --------------------------------------------- removeInitiative ----------------------------------------------------->']
[h,if(getPropertyType()=="Vehicle"), CODE:{
   [tok = getName(getInitiativeToken())]
   [switchToken(tok)]
   [removeFromInitiative()]
};{
   [removeFromInitiative()]
}]

!!
@@ @delayInitiative
@PROPS@ fontColor=green ; autoExecute=true ; fontSize=1.00em ; sortBy=25 ; color=silver ; playerEditable=false ; applyToSelected=false ; group=a. Utils ; tooltip= ; minWidth=96 ;
[h:'<!--------------------------------- delayInitiative ------------------------------------------>']
[h:tok   = getSelected()]
[h:assert(listCount(tok)==1, "Make sure (only) one token is selected",0)]
[h:switchToken(tok)]
[h:current = getInitiativeHold()]
[h:assert(isNumber(current), string(current),0)]
[h:setInitiativeHold(1-getInitiativeHold())]

[h: message      = token.name + " delays"]
[h, if(isNPC()): users   = ownergm()   ; users = all()]
<!-- new:   0:message,   1:headertxt,   2:color (bgcolor-txtcolor),   3:userList,   4:token,      5:ManualRolls,   6:target,      7:broadcast      -->
[h: message(message, "delays initiative", "black", users,  token.name)]

!!
@@ @getNewInitiative
@PROPS@ fontColor=green ; autoExecute=true ; fontSize=11pt ; sortBy=32 ; color=default ; playerEditable=false ; applyToSelected=false ; group=a. Utils ; tooltip= ; minWidth=96 ;
[h:'<!---------------------- getNewInitiative(Token) --------------------> ']
<!-- this macro returns the initiative of the token. If its not yet set, then the token is added to the initiative and the result is returned -->
[h:                  me            = arg(0)]
[h,token(me):         iTok         = getInitiative()]
[h,if(!isNumber(iTok)):   macro.return   = InitiativeRoll(me) ; macro.return = iTok]

!!
@@ @InitiativeRoll
@PROPS@ fontColor=green ; autoExecute=true ; fontSize=11pt ; sortBy=29 ; color=default ; playerEditable=false ; applyToSelected=false ; group=a. Utils ; tooltip= ; minWidth=96 ;
[h:'<!-- ------------------------------- InitiativeRoll ------------------------------------------>']
[h:me = arg(0)]
[h,if(argCount() > 1), CODE:{
   [initBonus = arg(1)]
   [noFurtherBonus = 1]
}; {
   [initBonus = 0]
   [noFurtherBonus = 0]
}]

[h,if(argCount()>2): vehicle   = arg(2); vehicle   = ""]
[h,if(argCount()>3): ship      = arg(3); ship      = me]
[h: switchToken(me)]
[h, token(ship): addToInitiative()]

<!-- retrieve setting: bcTalentsRule -->
[h:varsFromStrProp(getLibProperty('fwSettings','lib:DH'))]
[h: message   = ""]
[h: lrTxt   = ""]

[h, if(bcTalentsRule && hasTalent("Lightning Reflexes")), CODE: {
   [rollA = 1d10]
   [rollB = 1d10]
   [result = max(rollA, rollB) + initBonus]
   [lrTxt = "(Light. Reflexes: "+rollA+" & "+rollB+")"]
}; {
   [h: result = 1d10 + initBonus]
}]

<!-- modified Lightning Reflexes Rule for BC Lightning Reflexes -->
[h: LR = if(hasTalent("Lightning Reflexes") && !bcTalentsRule, floor(Ag/10), 0)]
[h: WT = if(hasTrait("Wary"), 1, 0)]
<!-- paranoia gives +2 to initiative!-->
[h: PN = 2*hasTalent("Paranoia")]
[h: CF = hasTalent("Combat Formation")]
[h: CS = hasTalent("Combat Sense")]
[h: iM = initiative]

[h: att = "Agility Bonus"]
[h: attBonus = AB]
<!-- subCharbonus is to differentiate between to matching I results, by adding the Agility/100 to the roll-->
[h: subCharBonus = Ag]

[h, if(CF || CS), CODE:{
   [attList = "Agility Bonus"]
   [if(CF): attList = listAppend(attList, "Intelligence Bonus")]
   [if(CS): attList = listAppend(attList, "Perception Bonus")]
   [question = input(
       "junk|<html><b>"+me+"</b></html>|-|LABEL|SPAN=TRUE",
      "att|"+attList+"|Select Attribute to use for rolling Initiative|RADIO|VALUE=STRING"
   )]
   [abort(question)]

   [switch(att), CODE:
      case "Intelligence Bonus": {[attBonus = IB][subCharBonus = Int]};
      case "Perception Bonus"   : {[attBonus = PB][subCharBonus = Per]};
      default               : {[h:'<!-- do nothing -->']};
   ]
}]

[h: ttInitiative = json.set("{}", "Roll 1d10"+lrTxt,result)]
[h,if(noFurtherBonus), CODE:{
   [ttInitiative = json.set(ttInitiative, "Ship Detection Bonus", initBonus)]
}; {
   [ttInitiative = json.set(ttInitiative, att,attBonus)]
   [if(LR):ttInitiative = json.set(ttInitiative, "Lightning reflexes",LR)]
   [if(PN):ttInitiative = json.set(ttInitiative, "Paranoia",PN)]
   [if(WT):ttInitiative = json.set(ttInitiative, "Wary",WT)]
   [if(iM):ttInitiative = json.set(ttInitiative, "Initiative Modifier", iM)]
}]

[h: subCharBonus = min(99,subCharBonus)/100]
[h: ttInitiative = json.set(ttInitiative, "Char. Differentiator",subCharBonus)]

[h: initiativeResult   = formatTooltip(ttInitiative,2)]
[h, token(ship): setInitiative(initiativeResult)]

<!-- output to chat -->
[h: message      = me + "  Result:" + formatTooltip(ttInitiative) +" , added to Initiative!<br>"]
[h: headerText   = if(vehicle == "", "Rolls Initiative", "Rolls Initiative (on board of the <b>"+vehicle+"</b>)")]
[h, if(isNPC()): users   = ownergm()   ; users = all()]
<!-- new:   0:message,   1:headertxt,   2:color (bgcolor-txtcolor),   3:userList,   4:token,      5:ManualRolls,   6:target,      7:broadcast      -->
[h: message(message, headerText, "black", users,  token.name, 0, vehicle)]
[h:macro.return = initiativeResult]

!!
@@ @SelectAndCentre
@PROPS@ fontColor=blue ; autoExecute=true ; fontSize=1.00em ; sortBy=40 ; color=default ; playerEditable=false ; applyToSelected=false ; group=a. Utils ; tooltip= ; minWidth=96 ;
[h:'<!----------------------------------------- SelectAndCentre ----------------------------------------->']
[h:me = arg(0)]
[h:switchToken(me)]
[h:assert(findToken(me) != "", me+" cannot be found on the map",0)]
<!-- if token is on board but the vehicle is not on the map then erase the onboard settings -->
[h,if(findToken(onBoard)==""): onBoard = ""]
[h,if(OnBoard != ""):me = OnBoard]
[h:'<!-- prevent loop! -->']
[h, if(getSelected() != me):selectTokens(me)]
[h, if(getLibProperty('centreOnToken','lib:DH')):goto(me)]

!!
@@ @InitiativeNext
@PROPS@ fontColor=green ; autoExecute=true ; fontSize=11pt ; sortBy=30 ; color=darkgray ; playerEditable=false ; applyToSelected=false ; group=a. Utils ; tooltip= ; minWidth=96 ;
[h:'<!--------------------------------- InitiativeNext ------------------------------------------>']

<!-- Set Token with next initiative in the Initiative window-->
[h:assert(initiativeSize(),"There are no tokens in the initiative panel",0)]
[h:' oldRound = getInitiativeRound()']
[h, if(getCurrentInitiative() != -1): me = getInitiativeToken(); me= ""]
[h, if(me != ""):switchToken(me)]
[h, if(me != ""):setState("Initiative", 0)]

[h:nextInitiative()]
[h:switchToken(getInitiativeToken())]
[h,if(getInitiativeHold()): setInitiativeHold(0)]
[h:'newRound = getInitiativeRound()']

<!-- This wil center the map on the token-->
[h:me = getInitiativeToken()]
[h:selectTokens(me)]
[h:switchToken(me)]
<!-- remove delay if any-->
[h:setInitiativeHold(0)]

<!-- remove/reset dodge and parry states if any -->
[h:setState("Dodged", 0)]
[h:setState("Parried", 0)]

[h:isChar   = if(getPropertyType() == "Character" || getPropertyType() == "Horde" , 1,0)]

<!-- process automatic Regeneration tests -->
[h,if(isChar): canRegen   = if(hasTrait("Regeneration") && (getState("Wounded") || getState("Heavily_Wounded") || getState("Critical")), 1, 0) ; canRegen = 0]
[h, if(canRegen), CODE: {
   [success   = useTalent ("Regeneration")]
   [if (success): setState("Regenerating", 1); setState("Regenerating", 0)]
};{
   [setState("Regenerating", 0)]
}]

[h:pMessage      = ""]
[h:stateList   = json.fields(States)]
[h:numStats      = json.length(tmpStats)]
[h, if(listCount(stateList)>0): pMessage = pMessage + chkState(stateList)]
[h, if(numStats>0): pMessage = pMessage + chkTmpStat(numStats)]

[h,if(!json.isEmpty(Recharging)), CODE:{
   [wpns = json.fields(Recharging)]
   [foreach(wpn, wpns), CODE:{
      [rounds = json.get(Recharging, wpn)]
      [update = if(rounds>0, 1, 0)]
      [if(update): rounds = rounds-1; Recharging = json.remove(Recharging, wpn))]
      [if(update): Recharging = json.set(Recharging, wpn, rounds)]
      [pMessage = pMessage + if(update, wpn+" is recharging", wpn + " is recharged")]
   }]
}; {}]

<!-- MESSAGE OUTPUT -->
[h,if(pMessage != ""): pMessage   = pMessage + "<br>"]
<!-- if token is on board but the vehicle is not on the map then erase the onboard settings -->
[h,if(findToken(OnBoard)==""): OnBoard = ""]
[h, if(OnBoard != ""), CODE:{
   [bMessage   = " and is on board of " + OnBoard]
   [me         = OnBoard]
   [selectTokens(me)]
}; {
   [bMessage   = ""]
}]
[h:altMessage   = token.name+" receives Initiative"]
[h:pMessage   = pMessage + altMessage + bMessage]

<!-- 0:message, 1:headertxt, 2:color (bgcolor-txtcolor), 3:userList, 4:token, 5:tmpManualRolls, 6:target, 7:broadcast,   8:altMessage,   9:altUserList, 10:gmOnly -->
[h: message(pMessage, "receives initiative", "black", ownergm(),  token.name, 0, OnBoard, 1, altMessage, nownergm())]

[h:setState("Initiative", 1, me)]
[h,if(getLibProperty('centreOnToken','lib:DH')):goto(me)]

<!-- This wil center the map on the token at the clients end-->
[h:tokenOwner = getOwners("json",me)]
[h,if(json.length(tokenOwner)==0):tokenOwner = "['no token owner']"]
[h, if(isOwnedByAll(me)), CODE:{
   [onlinePlayers = getAllPlayerNames()]
   [foreach(tokenOwner, onlinePlayers): broadcast(macroLink("", 'SelectAndCentre@Lib:DH', 'none', me ),tokenOwner)]
}; {
   [broadcast(macroLink("", 'SelectAndCentre@Lib:DH', 'none', me ),tokenOwner)]
}]

!!

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
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


Top
 Profile  
 
 Offline
Kobold
 
Joined: Mon May 09, 2016 6:42 am
Posts: 15
 Post subject: Re: need help with a Simple Marcro based on initiative
PostPosted: Sat May 14, 2016 2:20 am 
Thank you both for your replies.

To: Jagged - Actually want them to be on the gm side only because if i want a player to know i am checking for something i'll just have them roll :) but the code looks simple enough to breakdown as long as I don't need to impersonate every token i want to roll on. The question becomes how do I get that to fire automatically when a token gains initiative? See I am lazy in game and like to know what a characters rolls are just in case i need them so that it doesn't interfere with the suspense of the story by asking for a spot check which gets everyone's attention for something they may not actually have noticed.
I'll have a look at that link you posted and see if I have enough Excedrin for migraines on hand :P

Wolf - my god man as always you give 1000% :) I will have to spend some time looking through that code and testing things to see what all works for me, but that is A LOT of code, thank goodness you made a few comment notes to follow :)


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Mon Sep 15, 2008 8:27 am
Posts: 1207
Location: Bristol, UK
 Post subject: Re: need help with a Simple Marcro based on initiative
PostPosted: Sat May 14, 2016 3:53 am 
If you want them to fire off automatically then you need to look at Wolph42's post, he has the event stuff nicely coded.

If you want to keep it simple, you can put the macro in the campaign window and have it run on selected tokens. Just check that you have no output thats not gm only.
Obviously you'd then have to select the token and press the button yourself, but one step at a time :mrgreen:


Top
 Profile  
 
 Offline
Kobold
 
Joined: Mon May 09, 2016 6:42 am
Posts: 15
 Post subject: Re: need help with a Simple Marcro based on initiative
PostPosted: Sat May 14, 2016 5:03 am 
Ok, I think I figured out the basics for the skill check on initiative. I am sure there is a better way to code this but it seems to work. For now it only includes two properties as a test.

Button Pressed:
Code:
[h: nextInitiative()]
[h: who = getInitiativeToken()]
[h: selectTokens(who)]
[h: name = getTokenNames(",", '{Selected:1}')]
gm: <b> [name] has initiative! </b><br>
[MACRO("skillCheck@campaign"): who]


Called Macro:
Code:
[h: who = macro.args]

[h: vspot = getProperty("Spot",who)]
[h: vhide = getProperty("Hide",who)]

gm: Skill Checks: <br>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<b>Hide</b>: [1d20+vhide] <b>Spot</b>: [1d20+vspot]


For the group checks i am having a hard time understanding how to do a "for" loop, but I'll mess with it this weekend.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9485
Location: Netherlands
 Post subject: Re: need help with a Simple Marcro based on initiative
PostPosted: Sat May 14, 2016 6:34 am 
You might be better of usina g [foreach:] loop

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
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


Top
 Profile  
 
 Offline
Kobold
 
Joined: Mon May 09, 2016 6:42 am
Posts: 15
 Post subject: Re: need help with a Simple Marcro based on initiative
PostPosted: Wed May 25, 2016 9:12 am 
While expanding on this macro I ran into an issue that I cannot figure out.

Trying to trigger events if the d20 roll is a 1 or a 20, but his code keeps failing and I cannot see why...

Code:
[h: vspot = 1d20]
[h: switch(vspot), code:
case 20: {
    [h: vspot = 30]
  };
case 1: {
    [h: vspot = -10]
  };
]


If I remove the 1d20 and replace it with a fixed number it works. What am I missing?


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9485
Location: Netherlands
 Post subject: Re: need help with a Simple Marcro based on initiative
PostPosted: Wed May 25, 2016 9:15 am 
You need to add the default case

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
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


Top
 Profile  
 
 Offline
Kobold
 
Joined: Mon May 09, 2016 6:42 am
Posts: 15
 Post subject: Re: need help with a Simple Marcro based on initiative
PostPosted: Wed May 25, 2016 9:27 am 
Of course! the case without the trailing ;

Thanks!


Top
 Profile  
 
 Offline
Kobold
 
Joined: Mon May 09, 2016 6:42 am
Posts: 15
 Post subject: Re: need help with a Simple Marcro based on initiative
PostPosted: Wed May 25, 2016 9:39 am 
Ok, First I know this is ugly as sin (from a programming standpoint) but I am not a programmer and the for loops gave me a migraine that i could not get past. so here is what I have:

Code:
[h: nextInitiative()]
[h: who = getInitiativeToken()]
[h: selectTokens(who)]
[h: name = getTokenNames(",", '{Selected:1}')]

[g: "<b>" +name +"</b> Has Initiative!"]
[MACRO("skillCheck@campaign"): who]


Code:
[h: who = macro.args]

[h: vspot = 1d20]
[switch(vspot), code:
case 20: {
    [h: vspot = 30]
  };
case 1: {
    [h: vspot = -10]
  };
default: {
}]
[h: vspot = vspot + getProperty("Spot",who)]


[h: vhide = 1d20]
[switch(vhide), code:
case 20: {
    [h: vhide = 30]
  };
case 1: {
    [h: vhide = -10]
  };
default: {
}]
[h: vhide = vhide + getProperty("Hide",who)]

[h: vlis = 1d20]
[switch(vlis), code:
case 20: {
    [h: vlis = 30]
  };
case 1: {
    [h: vlis = -10]
  };
default: {
}]
[h: vlis = vlis + getProperty("Listen",who)]

[h: vMS = 1d20]
[switch(vMS), code:
case 20: {
    [h: vMS = 30]
  };
case 1: {
    [h: vMS = -10]
  };
default: {
}]
[h: vMS =  vMS + getProperty("MoveSilently",who)]

[h: vSearch = 1d20]
[switch(vSearch), code:
case 20: {
    [h: vSearch = 30]
  };
case 1: {
    [h: vSearch = -10]
  };
default: {
}]
[h: vSearch = vSearch + getProperty("Search",who)]

[g: "<br>--Skill Checks--"]
[g: "<br><b>Hide</b>: " +vhide]
[g: "<br><b>Listen</b>: " +vlis]
[g: "<br><b>Move Sliently</b>:  "+vMS]
[g: "<br><b>Search</b>: " +vSearch]
[g: "<br><b>Spot</b>: " +vspot]


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 11 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 1 guest





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman