Rather simple question regarding macros
Moderators: dorpond, trevor, Azhrei, Gamerdude
Rather simple question regarding macros
So I'm trying to create Beholder from D&D 5E in maptool. I want to make macro which rolls 1d10 and according to it's result, it shows only one proper effect, something like that:
[roll 1d10]
[if 1:
-effect1
if 2:
-effect2
(...)
if 10
-effect 10
]
[roll 1d10]
[if 1:
-effect1
if 2:
-effect2
(...)
if 10
-effect 10
]
Re: Rather simple question regarding macros
Also,
Code: Select all
[H: effects = json.append("",
"effect 1",
"effect 2"
)]
[H: effect = json.get(json.shuffle(effects),0)]
<!-- or -->
[H: effect = json.get(effects,roll(1,json.length(effects))-1)]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Rather simple question regarding macros
@Edit:
Okay, I got it, thank you
How do I include dice rolls in effects if they are plain text due to quotas signs?
Okay, I got it, thank you
How do I include dice rolls in effects if they are plain text due to quotas signs?
Re: Rather simple question regarding macros
Like this?
Code: Select all
[H: die = "1d20"]
[H: result = eval(die)]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Rather simple question regarding macros
Code: Select all
[H: effects = json.append("",
"Desintegrating Ray: Target has to succeed on DC 16 Dexterity saving throw or receive [1d20] damage",
"Effect 2",
"Effect 3"
)]
[effect = json.get(effects,roll(1,json.length(effects))-1)]
[H: die = "1d20"]
[H: result = eval(die)]
Re: Rather simple question regarding macros
Code: Select all
[H: effects = json.append("",
"Desintegrating Ray: Target has to succeed on DC 16 Dexterity saving throw or receive [1d20] damage",
"Effect 2",
"Effect 3"
)]
[H: effect = json.get(effects,roll(1,json.length(effects))-1)]
[R: evalMacro(effect)]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Rather simple question regarding macros
I get error message
Code: Select all
Error in body of roll.
Statement options (if any): R
Statement Body : evalMacro(effect)
Re: Rather simple question regarding macros
Did you copy/paste code? I did and it works in 1.4.
Chris: Effect 2
Chris: Desintegrating Ray: Target has to succeed on DC 16 Dexterity saving throw or receive 6 damage
Chris: Effect 3
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Rather simple question regarding macros
Yes I did. The token which uses the macro is marked as npc and I'm using impersonate option too. Also using 1.4
http://imgur.com/zfKTzwC
http://imgur.com/zfKTzwC
Re: Rather simple question regarding macros
weird, I just copy pasted the code in mt1.9 and it works like a charm.
edit: its a permission thing. Turn off: allow players to edit token(in the 2nd tab of the macro editor)
edit: its a permission thing. Turn off: allow players to edit token(in the 2nd tab of the macro editor)
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Rather simple question regarding macros
Ah, evalMacro is a Trusted Macro and has to have certain things set up. It has to be on a lib:token or be a campaign macro with player editing turned off in options.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Rather simple question regarding macros
Works like charm. I love you guys <3
@Edit:
NVM, it really works!
Can I donate to maptool somehow? Or for your projects
@Edit:
NVM, it really works!
Can I donate to maptool somehow? Or for your projects
Re: Rather simple question regarding macros
nah we all dot it for free...its a female-canine-in-heat!IssLance wrote:Can I donate to maptool somehow? Or for your projects
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Rather simple question regarding macros
Sure. Write some great code and share it with the community.IssLance wrote:Works like charm. I love you guys <3
@Edit:
NVM, it really works!
Can I donate to maptool somehow? Or for your projects
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
-
- Dragon
- Posts: 304
- Joined: Mon Mar 23, 2009 4:48 pm
Re: Rather simple question regarding macros
Another way to deal with this kind of issue is to use tables. Probably not the best way to go for something that is just relevant to a single token, but can be really useful for something like 5e madness. The way I do short-term madness in my 5e framework, for example, is with this simple macro:
There is one other way to do the kind of think you are doing. Instead of
That calls the Short-Term Madness table, which I set to roll a d100, and input the information on page 259 of the DMG. You can do html markup stuff like bolding, but you can't include bracketed dice roll commands (though if you wanted to get really needlessly complicated you could just create a separate result for every possible outcome e.g., if something did d10 damage, you could create ten entries for it, each with a different damage value, since the table involves a roll in the first place and you can make the values whatever you want to create whatever kind of probability distribution you are looking for -- but as I said, there would be no practical reason to do it this way).<b>Short-Term Madness</b><br>
<b>Duration:</b> [1d10] minutes.<br>
<b>Effect:</b> [table("Short-Term Madness")]
There is one other way to do the kind of think you are doing. Instead of
you could do it like this:[if 1:
-effect1
if 2:
-effect2
(...)
if 10
-effect 10
]
The advantage of doing it this way, with the CODE: and braces is that you can include bracketed commands like [d10] or [3d8] or whatever. You can even nest another if branch inside (although I think it will break down if you try to nest more than 1). (There might be some sort of computer sciencey reason why doing it this way is less preferred than a single json command that includes all the outcomes, but this is generally how I code these kinds of situations and I haven't had any problems).[h:roll=d10]
[if(roll == 1),CODE:
{
-effect 1
};{}]
[if(roll == 2),CODE:
{
-effect 2
};{}]
etc.