b48 Macro Additions

Doc requests, organization, and submissions

Moderators: dorpond, trevor, Azhrei

Post Reply
Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

b48 Macro Additions

Post by Craig »

Here is a list of all the new functions coming in b48. There are quite a few so I doubt anyone is going to read through them in one sitting so I have tried to split them up into semi logical categories that way you can just pick the areas that you would like to start using first.

String functions
  • replace(source, pattern, value [, times])
    Returns a string with the occurances of pattern in source
    replaced by value. If times is specified then the
    replacement will not occur more than the specified number of times,
    if it is not specified then all occurances of the pattern are replaced.

    Examples

    Code: Select all

        [replace("This is a test", " ", "-")]
        Hero: This-is-a-test
    
        [replace("This is a test", " ", "-", 2)]
        Hero: This-is-a test
      
  • stringToList(source, pattern [, delim])
    Creates a string list from the source string splitting the string
    into a list based on pattern if delim is specified then
    it is used as the delimiter for the new list, otherwise the default value
    of ',' is used.

    Examples

    Code: Select all

        [stringToList("This is a test", " ")]
        Hero: This,is,a,test
        
        [stringToList("1,2,3,4", ",", ":")]
        Hero: 1:2:3:4
      
  • substring(source, start [, end])
    Returns the substring of source starting at start and ending
    at end. If end is not specified then the substring extends
    to the end of the source string.

    Examples

    Code: Select all

        [substring("This is a test", 5)]
        Hero: is a test
    
        [substring("This is a test", 5, 7)]
        Hero: is
      
  • length(string)
    Returns the length of string

    Examples

    Code: Select all

        [length("")]
        Hero: 0
    
        [length("hello there")]
        Hero: 11
      
  • upper(string [, number])
    Returns an uppercase version of string. If number is
    specified then the number of characters that are converted to uppercase
    are limited number.

    Examples

    Code: Select all

        [upper("hello")]
        Hero: HELLO
        
        [upper("hello"), 1]
        Hero: Hello
      
  • lower(string [, number])
    Returns an lowercase version of string. If number is
    specified then the number of characters that are converted to lowercase
    are limited number.

    Examples

    Code: Select all

        [lower("HELLO")]
        Hero: hello
        
        [upper("HELLO"), 1]
        Hero: hELLO
      
  • indexOf(string, substring [, start])
    Returns the index of substring in string. If substring
    does not occur within string then -1 is returned. If start is
    specified then the search will start from that position, otherwise it will
    start the search from the beginning of the string.

    Examples

    Code: Select all

        [indexOf("this is a test", "is")]
        Hero: 2
    
        [indexOf("this is a test", "is", 3)]
        Hero: 5
    
        [indexOf("this is a test", "x")]
        Hero: -1
      
  • lastIndexOf(string, substring)
    Returns the index of the last occurance of substring within
    string. If substring is not found then -1 is returned.

    Examples

    Code: Select all

        [lastIndexOf("this is a test", "is")]
        Hero: 5
    
        [lastIndexOf("this is a test", "x")]
        Hero: -1
      
  • trim(string)
    Returns a copy of string with the leading and trailing whitespace
    removed.

    Examples

    Code: Select all

        [trim("			 This is a test			 ")]
        Hero: This is a test
        
        [length(trim("   a   "))]
        Hero: 1
      
  • strformat(format [, arguments...])
    Returns a formatted string.

    The format can contain special instructions that are introduced with
    the % symbol.

    The easiest and probably most useful format instruction is %{varname} which
    inserts the value of varname into the string.
    Example

    Code: Select all

    	 [h: weaponName = "Long Sword"]
    	 [h: maxDam = 8]
    	 [strformat("Weapon Name=%{weaponName}; Max Damage=%{maxDam}")]
    	 Hero: Weapon Name=Long Sword; Max Damage=8
      
    The following formats are also supported (lower case format arguments perform
    the same conversion as the lowercase letters but return the result in
    uppercase).
    • %h, %H, %x, %X
      Inserts the hexadecimal representation of the corresponding
      argument which must be an integer.
    • %s, %S
      Inserts the string representation of the corresponding argument.
    • %d
      Inserts the decimal integer representation of the corresponding argument
      that must be an integer value.
    • %e, %E
      Inserts the floating point value from the corresponding argument in
      computerized scientific notion.
    • %f
      Inserts the floating point value from the corresponding argument.
    • %g, %G
      Inserts the floating point value from the corresponding argument in
      computerized scientific notion or decimal format.
    • %a, %A
      Inserts the floating point value from the corresponding argument
      as a hexadecimal floating-point number with a significand and an exponent
    • %%
      Inserts a percent symbol.
    • %n
      Inserts a new line.
    Flags for format conversions
    • - left justified
    • + will always contain a sign character
    • (space) will include leading space for positive values
    • 0 will be zero padded
    • ( will enclose negative numbers in parentheses
    Examples

    Code: Select all

        [strformat("%d", 10)] [strformat("%05d", 10)] [strformat("%+d", 10)]
        Hero: 10 00010 +10
    
        [strformat("%f", -10.502)] [strformat("%g", -10.502)] 
        [strformat("%+e", -10.502)] [strformat("%5.1f", -10.502)] 
        [strformat("%(5.1f", -10.502)]
        Hero: -10.502000 -10.5020 -1.050200e+01 -10.5 (10.5)
      
  • matches(string, pattern)
    Returns 1 if string matches pattern or 0 if it does not.

    Examples

    Code: Select all

        [matches("This is a test", "test")]
        Hero: 0
      
        [matches("test", "test")]
        Hero: 1
      
  • encode(string)
    Encodes a string so that it can safely be embedding withing a property list.
  • decode(string)
    Decodes a string that was encoded with encode().
    Examples

    Code: Select all

        [h: props1 = "a=1;b=2"]
        [h: props2 = "c=3;d=4"]
        [h: props= ";"]
        [h: props = setStrProp(props, "First", encode(props1))]
        [h: props = setStrProp(props, "Second", encode(props2))]
        [decode(getStrProp(props, "First"))] 
        
        Hero: a=1;b=2
      
String functions and Regular expressions
The replace(), stringToList(), and matches() functions all accept a
regular expression as their pattern argument.

For more information on regular expressions read the following
(warning this is advanced so you may have more luck aasking on the
forums on how to achieve what you are trying to do if you don't
usually program).
http://java.sun.com/javase/6/docs/api/j ... ttern.html
http://www.regular-expressions.info/tutorial.html
http://www.tek-tips.com/faqs.cfm?fid=2689
http://java.sun.com/developer/technical ... /1.4regex/

The java code in the above pages can be ignored, the important part is the
regular expression descriptions.

There is also one more string function that deals exclusivley with
regular expressions. strfind(string, pattern).
This function is used to match a pattern agaisnt an input string and
extract all of the capture groups. The function returns an id which
can be used with other functions to extract the information.

Functions related to strfind()
  • getFindCount(id)
    Returns the number of times that strfind() was able to match the input string.
    id is the id returned by the strfind() function.
  • getGroupCount(id)
    Returns the number of capture groups from strfind(). id is the id
    returned by the strfind() function.
  • getGroup(id, matchNo, groupNo)
    Returns the capture group groupNo for the match number specified by
    matchNo. id is the id returned by the strfind() function.
  • getGroupStart(id, matchNo, groupNo)
    Returns the start of capture group groupNo for the match number
    specified by matchNo. id is the id returned by the strfind()
    function.
  • getGroupEnd(id, matchNo, groupNo)
    Returns the end of capture group groupNo for the match number
    specified by matchNo. id is the id returned by the strfind()
    function.
Last edited by Craig on Tue Dec 02, 2008 3:10 am, edited 1 time in total.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Post by Craig »

Token Functions
  • getPropertyNames([delim])
    Returns a string list of the property names for the current token.
    Note, if the token has not had any of its properties edited then it
    will return an empty string.
    If delim is specified then it is used as the delimiter of the list.

    Examples

    Code: Select all

        [getPropertyNames()]
        Hero: Movement,Charisma,HP,Wisdom,Description,Defense,Intelligence,Constitution,Dexterity,Strength,AC,Elevation
        [getPropertyNames(':')]
        Hero: Movement:Charisma:HP:Wisdom:Description:Defense:Intelligence:Constitution:Dexterity:Strength:AC:ElevationA
      
  • getAllPropertyNames([type [, delim]])
    Returns all the valid property names. If type is sepcified then
    it will return all the property names for that type.

    If delim is specified then the output list is delimited with the
    its value. If you want all properties and a delimiter then you can
    specify the type as the special value "*".

    Examples

    Code: Select all

        [getAllPropertyNames()]
        Hero: Items,Weapons,Strength,Dexterity,Constitution,Intelligence,Wisdom,Charisma,HP,AC,Defense,Movement,Elevation,Description,Items,Weapons
        [getAllPropertyNames("Inventory")]
        Hero: Items,Weapons
        [getAllPropertyNames('*', ':')]
        Hero: Items:Weapons:Strength:Dexterity:Constitution:Intelligence:Wisdom:Charisma:HP:AC:Defense:Movement:Elevation:Description:Items:Weapons
        [getAllPropertyNames("Inventory", ":")]
        Hero: Items:Weapons
      
  • hasProperty(name)
    Returns 1 if the token has the property name or 0 if it does not.

    Examples

    Code: Select all

        [hasProperty("HP")]
        Hero: 1
        [hasProperty("dsafasdf")]
        Hero: 0
      
  • isNPC()
    Returns 1 if the token is an NPC or 0 if it is not.
  • isPC()
    Returns 1 if the token is a PC or 0 if it is not.
  • setPC(pc)
    Sets if the token is a PC token or NPC token. If pc is none zerp
    then the token is changed to a PC other wise it is changed to a NPC.

    Examples

    Code: Select all

        [h: setPC(1)] is PC = [isPC()], is NPC = [isNPC()]
        Hero: is PC = 1, is NPC = 0
        [h: setPC(0)] is PC = [isPC()], is NPC = [isNPC()]
        Hero: is PC = 1, is NPC = 0
      
  • getLayer()
    Returns the layer that the token is on.
    The layer is one of
    • TOKEN
    • BACKGROUND
    • GM
    • OBJECT
    Examples

    Code: Select all

        [getLayer()]
        Hero: TOKEN
      
  • setLayer(layerName)
    Sets the layer that the token is on.
    layerName should be one of the following (case is not important)
    • TOKEN
    • BACKGROUND
    • GM (or HIDDEN)
    • OBJECT

    Examples

    Code: Select all

        [h: setLayer("object")] [getLayer()]
        Hero: OBJECT
      
  • getSize()
    Returns the size of the token.

    The sizes returned are
    • Diminutive
    • Tiny
    • Small
    • Medium
    • Large
    • Huge
    • Giant
    • Gargantuan
    • Colossal
    Examples

    Code: Select all

        [getSize()]
        Hero: Medium
      
  • setSize(size)
    Sets the size of the token, the value of size is not case sensitive.
    Valid sizes are
    • Diminutive
    • Tiny
    • Small
    • Medium
    • Large
    • Huge
    • Giant
    • Gargantuan
    • Colossal
    Examples

    Code: Select all

        [setSize("large")]
      
  • getOwners(delim)
    Gets a list of the owners for the token. If delim is provided then
    it is used as the delimiter to the list.

    Examples

    Code: Select all

        [getOwners()]
        Hero: JoeBlow,JohnDoe
        [getOwners(';')]
        Hero: JoeBlow;JohnDoe
      
  • isOwnedByAll()
    Returns 1 if owned by all is set for the token, or 0 if it is not.
  • isOwner(playerName)
    Returns 1 if the player playerName is an owner of the token
    (this includes if it is owned by all) or 0 otherwise.

    Examples

    Code: Select all

        [isOwnedBy("JoeBlow")]
        Hero: 1
        [isOwnedBy"MrNobody")]
        Hero: 0
      
  • resetProperty(propertyName)
    Resets the property so that it contains nothing. (That is nothing, not
    an empty string).
  • getProperty(name)
    Returns the value of the property. If the property contains nothing then
    an empty string ("") is returned. This function will not return the
    default value for a property if it is empty.

    Examples

    Code: Select all

        [getProperty("HP")]
        Hero: 10
      
  • setProperty(name, value)
    Sets the value of a property. This can be used to set the value of a
    property that does not exists in the campaign properties so you can create
    variables on your Lib: tokens. Although you can use it to set properties
    that don't exist on other tokens you probably shouldn't.

    Code: Select all

        [h: setProperty("HP", 23)] [HP]
        Hero: 23
      
  • isPropertyEmpty(name)
    Returns 1 if the property is empty or 0 if it is not. An empty string ("")
    will return 1 as its not an empty ptoperty.

    Examples

    Code: Select all

        [h: HP=4][isPropertyEmpty("HP")]
        Hero: 0
        [h: resetProperty("HP")] [isPropertyEmpty("HP")]
        Hero: 1
        [h: HP=""] [isPropertyEmpty("HP")]
        Hero: 0
      
  • getPropertyDefault(name)
    Returns the campaign default for the proeprty. If there is no campaign
    default value for the property then an empty string ("") is returned.

    Code: Select all

        [getPropertyDefault("Movement")]
        Hero: 6
       
  • sendToBack()
    Places the token behind all other tokens on the layer.
  • bringToFront()
    Places the token infront of all other tokens on the layer.
  • getNotes()
    Returns the notes for the token.

    Examples

    Code: Select all

        [getNotes()]
        Hero: Golden Hair, perfect teeth, etc..
      
  • getGMNotes()

    Code: Select all

        [getGMNotes()]
        Hero: Note from GM, your golden hair and perfect teeth are annoying me.
      
  • setNotes(str)
    Sets the player notes for the token.
  • setGMNotes(str)
    Sets the GM notes for the token. This is a trusted only function.
  • getPropertyType()
    Gets the property type of the token.
  • setPropertyType(type)
    Sets the property type of the token.
  • setTokenImage(image)
    Sets the image for the token. (and there were many cheers to be heard)

    image can either be an asset id as returned by getTokenImage()
    or tblImage() etc. Or the name of an "image" token. Image tokens
    start with image: (e.g. image:elf-dead).

    If you specify an image token then the search follows the same rules
    as Lib: tokens. The token can be on any map (and there can only be
    one token with the same name).

    Examples

    Code: Select all

        [img = tblImage("tokenImages", 1)] [setTokenImage(img)]
        [setTokenImage("image:elf-dead")]
      
Last edited by Craig on Tue Dec 02, 2008 6:55 pm, edited 2 times in total.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Post by Craig »

Light and Sight
  • hasSight()
    Returns 1 if the token has sight or 0 if it does not have sight.
  • setHasSight(val)
    Sets if the token has sight or not. If val is non zero then
    the token will have sight otherwise it will not. You can not change
    the has sight value of a token if it is an NPC.
  • getSightType()
    Returns the type of sight that the token has.

    Examples

    Code: Select all

        [getSightType()]
        Hero: Normal
      
  • setSightType(type)
    Sets the type of sight for the token.

    Examples

    Code: Select all

        [h: setSightType("Darkvision")]
      
  • hasLightSource([type [,name]])
    Checks the token for light sources, it will return 1 if the
    token has any light sources that match or 0 if it doesn't.

    If type and name are specified then then token
    is checked to see if it has the light source name in
    category type.

    if type is specified and name is not then the
    token is checked to see if it has any light source from the
    category type.

    If neither type or name are specified then the
    token is checked for any light source.

    Examples

    Code: Select all

        [h: clearLights()]
        [h: setLight("D20", "Lamp - 15", 1)]
        [hasLightSource()]
        Hero: 1
        [hasLightSource("D20")]
        Hero: 1
        [hasLightSource("D20", "Lamp - 15")]
        Hero: 1
        [hasLightSource("Generic")]
        Hero: 0
      
  • clearLights()
    Clears all the light sources for the token.

    Examples

    Code: Select all

        [h: clearLights()] [hasLightSource()]
        Hero: 0
      
  • setLight(type, name, val)
    Sets the light source to on if val is non zero or off if
    val is zero.

    Examples

    Code: Select all

        [h: clearLights()]
        [h: setLight("D20", "Lamp - 15", 1)]
        [hasLightSource()]
        Hero: 1
        [hasLightSource("D20")]
        Hero: 1
        [hasLightSource("D20", "Lamp - 15")]
        Hero: 1
        [hasLightSource("Generic")]
        Hero: 0
      
  • getLights(type [, delim])
    Gets the names of the light sources that are on for the current token.

    if type is not specified then the name of all lights that
    are on are returned. If it is specified then only the name of lights
    that are on in that category are returned.

    If you want to sepcify a delimiter but still get the all light
    sources that are on you can use the special value of "*" for type


    Examples

    Code: Select all

        [h: clearLights()]
        [h: setLight("D20", "Lamp - 15", 1)]
        [h: setLight("Generic", "30", 1)]
        [getLights()]
        Hero: Lamp - 15,30
        [getLights("D20")]
        Hero: Lamp - 15
        [getLights("*", ";")]
        Hero: Lamp - 15;30
        [getLights("D20",";")]
        Hero: Lamp - 15
      
Last edited by Craig on Tue Dec 02, 2008 3:13 am, edited 1 time in total.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Post by Craig »

Macro Related Functions
  • isTrusted()
    Returns 1 if the macro is being run in trusted mode, or 0 if it is
    not being running in trusted mode.
  • macroLink(text, macro [, output [, args [, target]]])
    Creates the HTML for a link which will run the specified macro when
    clicked on.

    text is the text to display for the link.
    macro is the name of the macro to run when the link is clicked.
    The macro is in the same format that is used for [macro(...): ...]
    e.g. Test@Lib:test
    output contains who the output of the macro should go to, values are
    • self - Display only to person who clicked on the link.
    • gm - Display to GM.
    • none - discard any output.
    Defaults to none
    args Any arguments to be passed to the macro when it is called.
    target Which tokens to run the macro on.
    if target is impersonated then it is run on the impersonated
    token.
    if target is selected then it is run on the selected token(s).
    Otherwise target contains a list of tokens to run the macro
    on.

    Examples

    Code: Select all

        [macroLink("Click Here", "macro@Lib:Test", "none", "val=3;b=2", "selected
    ")]
      
    Will create a link that says "Click Here" that will run the macro called
    macro on token Lib:Test with the argument "val=3;b=2". When the macro is
    run it will be run against all selected tokens and the output will be
    discarded.
  • macroLinkText(macro [, output [, args [, target]]])
    See macroLink() function above. This function does is similar to
    macroLink() but instead of creating the HTML for the link it creates
    the text for the link without the surrounding HTML. This function is
    used if you want to format the link yourself and callbacks for
    dialog/frame functions.

    Examples

    Code: Select all

        [macroLinkText("macro@Lib:Test", "none", "val=3;b=2", "selected")]
        Hero: macro://macro@Lib:Test/none/selected?val%3D3&b%3D2
      
  • hasImpersonated()
    Returns 1 if there is an impersonated token, or 0 if there is no
    impersonated token.
  • switchToken(token)
    Changes the token that is being operated on for the remainder of the
    macro.
    This function can only be called from a trusted macro.

    token can be either the name, GMName, or id of the token.

    Example

    Code: Select all

        [switchToken("AnitHero")] [getName()]
        Hero: AnitHero
      
    Notes:
    You can only refer to tokens on the current map with switchToken().
    If you have tokens of the same name on the map then you will not
    be able to use this function to refer to all of them.
  • getMacroName()
    Returns the name of the macro being excuted via [macro(): ].
    If the macro was called from chat or by clicking on a macro button
    or token popup menu it will return "chat"
  • getMacroLocation()
    Returns then location of the macro being excuted via [macro(): ].
    If the macro was called from chat or by clicking on a macro button
    or token popup menu it will return "chat"
  • hasMacro(name)
    Returns 1 if the token has a macro called name or 0 otherwise.
  • getMacros(delim)
    Returns a list of the macros on the token. If delim is specified
    then it is used as a delimiter for the list.
  • createMacro(label, command, [props, [delim]])
    Creates a new macro button on the token.
    label is the label for the macro button.
    command is the command to execute when button is clicked.
    props is a property list for button properties
    (see setMacroProps() for more information).
    delim is the delimiter for the property list (defaults to ";")
  • setMacroProps(button, props [, delim])
    Sets the properties for the macro button on a token.
    button is the index of the button or the button label,
    if you specify a button label then all buttons
    with that label are modified.
    props a property list for the properties to set on the button.
    delim the delimiter for the property list if it is no tthe default
    value of ";"

    See getMacroProps() for the different macro properties.
  • getMacroProps(index, [, delim])
    Gets the properties for the specified macro button. If delim is
    specified then it is used as a delimiter for the property list.

    Valid properties that can be set (all properties are case insensitive).
    • autoExec - true/false - Will the macro be automatically executed
      when the button is clicked on.
    • color - The name of the color for the button.
    • fontColor - The name of the font color for the button.
    • includeLabel true/false - Will the label be output when button is
      clicked.
    • group - The name of the group for the button.
    • sortBy - The sort by value of the button.
    • index - (Read only) the index of the button.
    • label - The label of the button.
    • fontSize - The size of the font for the button.
    • minWidth - The minimum widht of the button.
  • getMacroIndexes(name [, [delim]])
    Gets the indexes for all macros with label name. If
    delim is specified then it is used as the delimiter for
    the list.
  • setMacroCommand(index, command)
    Sets the command for the token macro button.
  • getMacroCommand(index)
    Gets the command for a token macro button.
Last edited by Craig on Tue Dec 02, 2008 3:15 am, edited 1 time in total.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Post by Craig »

Finding Tokens
  • findToken(name)
    Finds a token by the name or GMName and returns its id.
    If the token is not found then an empty string is returned.

    This function can only be called from trusted macros.


    Example

    Code: Select all

          [findToken("AnitHero")]
          Hero: C0A80003D80F2AC497020000C0280000
        
  • getTokens([delim]) / getTokenNames([delim])
    Gets a list of all of the tokens on the current map. If delim is
    specified then it is used as the delimiter for the list.

    This function can only be called from trusted macros.

    getTokens() returns token ids
    getTokenNames() returns token names

    Example

    Code: Select all

          [getTokens()]
          Hero: C0A80003D70F2AC492020000C0280003,C0A80003D70F2AC493020000C0280003
          [getTokens(";")]
          Hero: C0A80003D70F2AC492020000C0280003;C0A80003D70F2AC493020000C0280003
          [getTokens()]
          Hero: Hero,AnitHero,By Stander
          [getTokens(";")]
          Hero: Hero;AnitHero;By Stander
        
  • getImpersonated() / getImpersonatedName()
    Gets the impersonated token.

    getImpersonated() returns the id of the token.
    getImpersonatedName() returns the name of the impersoanted token.

    This function can only be called from trusted macros.
  • currentToken()
    Returns the id of the current token. In most cases this will return the
    same as the getImpersonated() function. The difference is when it
    is called in [token(): ] or after a switch token, in both these cases
    it will return the id of the token being operated on while
    getImpersonated() will return the impersonated token.

    This function can only be called from trusted macros.
  • getSelected([delim]) / getSelectedNames([delim])
    Gets a list of the seelcted tokens. If delim is specified then
    then it is used as the delimiter for the list.

    This function can only be called from trusted macros.

    getSelected() returns token ids.
    getSelectedNames() returns the token names.
  • getPCs([delim]) / getPCNames([delim])
    Gets a list of all the PC tokens. If delim is specified then it is
    used for the delimiter for the list.

    This function can only be called from trusted macros.

    getPC() returns token ids.
    getPCNames() returns the token names.
  • getNPCs([delim]) / getNPCNames([delim])
    Gets a list of all the PC tokens. If delim is specified then it is
    used for the delimiter for the list.

    This function can only be called from trusted macros.

    getPC() returns token ids.
    getPCNames() returns the token names.
  • getExposedTokens([delim]) / getExposedTokenNames([delim])
    Gets a list of all of the tokens not hidden by fog of war.
    if delim is specified then it is used as the delimiter to the list.

    This function can only be called from trusted macros.

    getExposedTokens() returns token ids.
    getExposedTokenNames() returns the token names.
  • getWithState(state [,delim]) / getWithStateNames(state [,delim])
    Gets a list of all the tokens with the state state is set.
    if delim is specified then it is used as the delimiter to the list.

    This function can only be called from trusted macros.

    getWithState() returns token ids.
    getWithStateNames() returns the token names.
  • getOwned(name [,delim]) / getOwnedNames(state [,delim])
    Gets a list of all the tokens with owner name is set.
    if delim is specified then it is used as the delimiter to the list.

    This function can only be called from trusted macros.

    getOwned() returns token ids.
    getOwnedNames() returns the token names.
Last edited by Craig on Tue Dec 02, 2008 3:16 am, edited 1 time in total.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Post by Craig »

Misc Functions
  • getPlayerName()
    Returns the name of the player.
  • getAllPlayerNames([delim])
    Returns a list of all the players names. If delim is
    specified then it is used as the delimiter for the list.
  • getSpeech(name)
    Returns the speech value for the token for name.
    If there are no speeches with name then an empty string ("")
    is returned.
  • setSpeech(name, speech)
    Sets the speech valuf for the token for name.
  • getSpeechNames([delim])
    Gets the list of speeches for the token. If delim is specified
    then it is used as the delimiter for the list.
  • number(val)
    Returns val as a number.
  • string(val)
    Returns val as a string.
  • isNumber(val)
    Returns 1 if val is a valid number or 0 if it is not.
  • getLibProperty(name [, lib])
    Returns the value of property name from the library token.
    If lib is not specified then the property will be retrieved
    from the lib: token that the macro is currently running from.
    The format for lib is lib:tokenname.

    This function can only be called from trusted macros.
  • setLibProperty(name, value [, lib])
    Sets the value of property name from the library token.
    If lib is not specified then the property will be retrieved
    from the lib: token that the macro is currently running on.
    The format for lib is lib:tokenname.

    This function can only be called from trusted macros.

    Warning!
    Danger, Will Robinson!
    If multiple people are accesing the token library and using
    getLibProperty() to get a value then setLibProperty() to set it
    after changing it then you will probably run into trouble since
    there is nothing to stop multiple clients from trying to update
    at the same time.

    One possible solution to this is to code checks to make sure only
    a certain player can access the macro, then after they have accesed
    it allow another person to do so.
  • getImage(imageToken [, size])
    Gets the asset id for the image of an "image" token. An "image"
    token can be on any map and the name starts with "image:".


    Examples
    To display the image from a token called image:Map do

    Code: Select all

        <img src='[r: getImage("image:Map")]'></img>
      
Last edited by Craig on Tue Dec 02, 2008 3:16 am, edited 1 time in total.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Post by Craig »

New Roll Types and Other Odds and Ends
  • [token(token): ]
    Executes the roll against the specified token.
    token can either be the token name or id.
  • Macros and @this
    When you create libraries you will often find that you will
    want one of your macros in the library to call another one.
    Instead of specifying the name of the library again when you
    call a macro you can use @this.
    Example
    You have a macro CheckHit@Lib:Attack that calls GetAC@Lib:Attack
    In the CheckHit@Lib:Attack macro you can use
    [macro("GetAC@this"): "" ]
    which would be the same as
    [macro("GetAC@Lib:Attack"): "" ]

    When calling a macro in the same Lib: token you should use
    @this, so if you distribute your token to others and they
    rename it all the macro calls will still work correctly.
  • [frame(name [, properties]): { }]
  • [dialog(name [, properties]): { }]
    Creates a frame or dialog for output. Dialogs and Frames always
    use { } braces that you can place code in.

    Valid properties are
    • input - If 1 the dialog is an input dialog and will close
      when the form is submitted.
    • temporary - After closing the dialog or frame will be disposed.
    • width - The width of the dialog (first time only)
    • height - The height of the or dialog (first time only)
    • title - The height of the frame or dialog

    Both dialogs and frames allow you to specify the CSS used within
    the frame. You can specify the CSS using

    Code: Select all

        <link rel='stylesheet' type='text/css' href='Test1Css@Lib:Test'></link>
        

    The href points to the macro name on the Lib: macro which contains the
    CSS. You can not use @this for the CSS as it only works for calling
    macros. You can get the same functionality though by builing the CSS
    string, e.g.

    Code: Select all

        [h: cssHREF = 'Test1Css@' + getMacroLocation()]
        
    You can also specify a macro to call when certain changes are using the
    format.

    Code: Select all

        <link rel='onChangeImpersonated' type='macro' href='[i]macroLink[/i]'>
        <link rel='onChangeSelection' type='macro' href='[i]macroLink[/i]'>
        <link rel='onChangeToken' type='macro' href='[i]macroLink[/i]'>
        

    If you insert the above lines into the HTML for the dialog or frame
    then the macroLink (which you create via the macroLinkText()
    function) will be called.

    onChangeSelection - Is called when the list of selected tokens
    is changed, you may get this more than once if a new list is
    selected (once for the delsection of old tokens, and once for new
    selection).

    onChangeImpersonated - Is called when a new token is impersonated
    or the current token is no longer impersonated.

    onChangeToken - Should be called when ever a change is made to a
    token, but it doesn't always work out that way at the moment
    (I am still looking at how to fix this).


    The <title> tag can be used to set the title of a dialog or frame
    from within the HTML.


    You can create input forms with the normal html <form> tag.

    Code: Select all

        <form name='blah' action='[i]macroLink[/i]'>
        </form>
        

    macroLink should be created with the macroLinkText() function.
    When the user clicks on an input of type submit the macro is called
    passing a string property list that contains the values of the input
    fields in the form.

    Other tags that can be used for dialogs
    You can set the temporary status of dialogs or the input status of
    dialogs using the <meta> tag in the HTML they will display.

    Code: Select all

        <meta name="input" content="true">
        <meta name="temporary" content="true">
        
  • Trusted Macros
    Trusted macros are macros that meet any of the following criteria.
    • Typed in by GM.
    • Button clicked by GM.
    • Macro called by [macro(): ] that lives on a Lib: Token that
      can not be changed by players (i.e. is not owned by anyone
      who is not a GM), regardless of if it is a player or GM
      that runs it.
    So GMs can set up macros on lib:tokens that can be called by
    players that only GMs cane edit which can access functions that
    players would not normally be able to access. This allows GMs
    to create macros that use [token():] or the switchToken()
    function to modify or read values from NPC tokens that players
    do not own (among many other trusted macro only functions).
Last edited by Craig on Wed Dec 03, 2008 12:37 am, edited 3 times in total.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Post by Craig »

I had planned to write some small tutorials on how to do things to go with the documentation above but the patch and documentation took a little longer than I expected. I will put some small tutorials together over the next couple of days to make some of the changes clearer.

User avatar
PyroMancer2k
Dragon
Posts: 925
Joined: Thu Sep 11, 2008 2:04 pm

Post by PyroMancer2k »

... WOW ... That's a LOT of stuff. I read the first 2 post then I started to skim and it just kept going, and going, and going.

jimb
Kobold
Posts: 22
Joined: Mon Sep 29, 2008 5:46 pm

Post by jimb »

Six more hours till Trevor builds...
Five hours, Fifty nine minutes and fifty seconds...

I'm not excited, am I :D

Truthfully...

Craig while I can still think of more macros to add, this list will make it possible to automate almost EVERYTHING in my game system of choice.

Thanks!!!

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Post by Craig »

jimb wrote:Six more hours till Trevor builds...
Five hours, Fifty nine minutes and fifty seconds...

I'm not excited, am I :D

Truthfully...

Craig while I can still think of more macros to add, this list will make it possible to automate almost EVERYTHING in my game system of choice.

Thanks!!!
What macros are you thinking of that you would like added?

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Post by Rumble »

So wait...if I had an attack macro that said something like:

Code: Select all

[token(BadGuy): targetAC=getProperty(AC)]

[attack=1d20+Bonus]

[hit=if(attack>=targetAC, "A most palpable hit!", "Big whiffa!")]

Outcome: [hit]
Would that let me compare my attack against the target's AC? Because if so...



ZOMG.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Post by Craig »

Rumble wrote:So wait...if I had an attack macro that said something like:

Code: Select all

[token(BadGuy): targetAC=getProperty(AC)]

[attack=1d20+Bonus]

[hit=if(attack>=targetAC, "A most palpable hit!", "Big whiffa!")]

Outcome: [hit]
Would that let me compare my attack against the target's AC? Because if so...



ZOMG.
As long as it runs in a trusted macro, yes. So players would not be able to type the above in their own macros since it wont let them use [token():].
But if you create a macro in a Lib:token that they can not edit (i.e. not owned by any players) you can place the above code in it and get the players token macros to call it with [macro():].

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Post by Rumble »

As long as it runs in a trusted macro, yes. So players would not be able to type the above in their own macros since it wont let them use [token():].
But if you create a macro in a Lib:token that they can not edit (i.e. not owned by any players) you can place the above code in it and get the players token macros to call it with [macro():].


Aha...in that case, SQUEE!


Ahem. Pardon me.

DevoDog
Dragon
Posts: 456
Joined: Sat Jul 12, 2008 9:56 am

Post by DevoDog »

To clarify(?):

These would allow for:

Parsing out the number of dice and dice size if a property is 2d4 (using the String functions)?

Changing the color of a macro button for an Encounter Power when it's used to indicate that it's used?

Allow you to create a macro where you select the target and then use and adjust the target values?

Post Reply

Return to “Documentation Requests/Discussion”