FoundryVTT Macros 101

Sdílet
Vložit
  • čas přidán 2. 09. 2020
  • I had planned like five macros for this video, and after the first realized it was already 30 min long. So the Macro videos will be split into a couple parts.
    All the code that I go over in them will be found here: github.com/spacemandev-git/fv...
    Please let me know in the comments what you'd like to see me cover next!

Komentáře • 90

  • @mikemcmahon67
    @mikemcmahon67 Před 3 lety +5

    Can't thank you enough for this video! I have a limited programming background (started with Basic in 1983!), But no prior experience with JavaScript and your video bridged some major gaps in finding the data objects I needed. Looking forward to watching the series!

  • @dennyw17
    @dennyw17 Před 3 lety +8

    Excellent! Exactly what I needed to get started with macros. Learning about the game object was pure gold. Thanks!

  • @HughMacLeod42
    @HughMacLeod42 Před 3 lety +3

    Very helpful. Excellent teaching as well as great foundry tips. This content is crucial for amateur developers like myself. Learned a lot about JS and FVTT. Thanks

  • @ErkIsEpic
    @ErkIsEpic Před rokem +2

    Even with a few stuff being out of date, I was still able to learn from the video. Good content.

  • @VickyCarterR
    @VickyCarterR Před 3 lety +6

    Thank you so much for this clear and excellent run-through of creating a macro. I've learnt so much and it's really helped me understand macro writing for foundry. Onwards to 102.

  • @ptanstaafl
    @ptanstaafl Před 3 lety +1

    Great seeing the examples in simple world building. Thanks for your tutorials.

  • @leegamble1589
    @leegamble1589 Před 10 měsíci +1

    been struggling with getting to grips with macros in Foundry coming from using Roll20 Chat Macros regularly. This video gave me enough to get my first macro in Foundry up and running! Very helpful and really struggled to find anything else so informative

  • @brevbomb
    @brevbomb Před 3 lety

    This was just what I needed. It helped me so much. Please consider making some more videos 💕👍

  • @samleonard2557
    @samleonard2557 Před 3 lety

    ooooh I struggled to get through that. I couldn't have done it without you. This is relatively new to me, the difference between the template you were using, and the dnd5e template was significant for somebody without the proper background in syntax. But I got through it. Great video! Still works March 30th 2021

  • @drabodows
    @drabodows Před 2 lety

    Nice work here. Thanks for the tutorial. It was helpful to see you use of the console for debugging.

  • @Dani_Cano
    @Dani_Cano Před 2 měsíci

    Nicee info man. I'm trying to learn to make modules and even system in Foundry. Glad I've found this!

  • @WanderingHusk
    @WanderingHusk Před 2 lety

    I enjoy Foundry and this video has been so helpful, thankyou.

  • @Mike-gz8gy
    @Mike-gz8gy Před 3 lety

    Great content! Thank you for making these!

  • @RainNoh
    @RainNoh Před 3 lety

    Great video! Very well and clearly explained!

  • @Michael-ls9eu
    @Michael-ls9eu Před 6 měsíci

    Thanks for this video! I was having trouble figuring out where to start to explore the data model, the bit starting at 2:28 helped a lot to find the right objects :)

  • @daimononvrosis61
    @daimononvrosis61 Před 3 lety

    Thank you very much for your effort and great work!

  • @elduderoni7630
    @elduderoni7630 Před rokem

    Dude is legendary. I've been avoiding writing macros (and have been having AI write them for me) because I have no experience with coding. Thank you for explaining how to read and use them. I definitely feel like I have a good idea of what I'm looking at now when I'm reading macros.

    • @gorebello
      @gorebello Před rokem

      how do you do it with ai? chat GPT failed to give me anything that works.

  • @KammaKhazi
    @KammaKhazi Před 3 lety +1

    excellent video thank you...not coded in 15+ years and coming from VB5 i was really struggling with some of the strange syntax in java.

  • @papatraildoc
    @papatraildoc Před 3 lety +2

    Excellent video... thank you so much for taking the time to educate us on macros for Foundry VTT. I do have a wish list item though. I would like to understand how to increment items in a character's inventory based on a roll. For example, if a character looks for 'special stones', they would make a nature roll. if they succeed, they would roll again for a number of special stones they find. This number would then automatically increment the quantity of the item (in inventory) special stones by the number found. Ugh... hope that makes sense.

  • @Mark-yi2vo
    @Mark-yi2vo Před 3 lety +1

    This video is getting a lot closer to what I was hoping you'd be doing! Thank you for making these and I hope you keep it up! I want to see something more akin to module development. For example, in the context of this video, how do we give Bad Actor a new attribute of Fullness because he drank too many potions?

    • @Devenish97
      @Devenish97  Před 3 lety +2

      Yup yup i wanted to work up to the more complex topics.
      To answer the specific question, in simple world building that's easy because it allows for a dynamic lists of attributes for characters but in other systems it might be better done as a flag. Flags will be covered in a future video

  • @cauespirolla
    @cauespirolla Před 3 lety +12

    Amazing!! I wish you could teach us a macro to update the amount of rations/water each character has by the passing of the days.

  • @kkuroni
    @kkuroni Před 2 lety

    Thx!Your video helped me a lot

  • @xXAkirhaXx
    @xXAkirhaXx Před 3 měsíci

    Amazing video, thank you sir.

  • @crapphone7744
    @crapphone7744 Před 3 lety +1

    Ditto on the please make more. How to set up visual studio to code for foundry vtt would be awesome too! Thanks for doing this.

  • @mtgcarver
    @mtgcarver Před 3 lety +1

    This is absolutely awesome. Really informative and helpful to the foundry community. Thank you for taking the time to make this. Looking forward to more.
    I'm curious how I would write a macro to roll high variance dice. For example, a d10 HV dice has these sides : 1,1,2,3,4,7,8,9,9,10.
    A d20 HV dice has : 1,1,2,2,3,4,5,6,7,8,13,14,15,16,17,18,19,19,20,20

  • @7h3mon
    @7h3mon Před 11 měsíci

    Thank you for the video!

  • @ebranden
    @ebranden Před 3 lety

    Great tutorial!

  • @silkyslimification
    @silkyslimification Před 3 lety +1

    A video on how to create a module that can install journal entries similar to the card module you used as an example would be extremely helpful.

  • @TheTheronal
    @TheTheronal Před 2 měsíci

    Good video!

  • @darleth
    @darleth Před 3 lety

    Amazing video...thanks a lot.

  • @MrVarelaluca
    @MrVarelaluca Před 3 lety

    Thanks a lot this is awesome !

  • @Kram994
    @Kram994 Před 3 lety

    I’m a complete coding beginner that was really clear explanation, thanks.Could you cover how to use ‘hooks’ in a future video?

  • @gertjanfilarski3601
    @gertjanfilarski3601 Před 3 lety +7

    Great video, learning a lot! At 19:20 you remark "don't worry about my autocomplete". Well I do :) How do you set that up? It'll make development a lot easier.

  • @redmokah803
    @redmokah803 Před 2 lety

    Are you going to do more video tutorials on macros? The world needs you lol.

  • @miguelangelgarzon5104
    @miguelangelgarzon5104 Před 2 lety

    the best video on macros!. you are an excellent teacher too. do you plan to teach to code? it would be great!

  • @TheNAT30s
    @TheNAT30s Před 3 lety

    Thank you, thank you, thank you!!

  • @NahrAlma
    @NahrAlma Před 2 lety

    I've got a bit of experience with js, html, cs even a tiny bit of json, but NONE with the console. This is gonna help massively.

  • @drewc1001
    @drewc1001 Před 3 lety +8

    How do you get MS VS Code to auto complete like the FVTT console?? That's incredible!

  • @SebGedge
    @SebGedge Před 3 lety

    This is great really helpful and insightful information, how do you include formula such as /r 2d4 + 2 in something like this is there oob function that can be called to roll the dice and get the value, then add that value to the actors health?

  • @kraegandragon
    @kraegandragon Před 8 měsíci +1

    Need a new one of these since V10+ has changed the data model so severly.

  • @mikehewitson9914
    @mikehewitson9914 Před 3 lety

    Hi, Fantastic tutorial, I learned a lot and your style is very clear. One point confuses me though, and it's with the system rather than your tutorial but I thought you may be able to answer it. Once this line of code "let healthpotion = actor.items.find(item => item.data.name == "Health Potion");" has been executed and you have a reference to the item, why does it then need the two 'data' steps in 'healthpotion.data.data.attributes.hp_restore.value' to get to the hp_restore property? That suggests it's still only pointing at the 'actor' object to need the two 'data' steps.
    Cheers

  • @PhilWaller
    @PhilWaller Před 3 lety

    Thanks very much for the video. Could you show how to modify to heal other players or give potions to other players in a macro. There is a module but it doesn't work for the simple world-building.

  • @andrewyurick7758
    @andrewyurick7758 Před 7 měsíci

    wish the macro text wasn't blurry, but still good info.

  • @josemanuelcaballero1162
    @josemanuelcaballero1162 Před 3 lety +3

    For the potion macro, would nt the conditional " if (canvas.tokens.controlled.length != 1 ) would suffice for te check?

  • @mikk01975
    @mikk01975 Před 3 lety

    Thank you for this! So, the obvious question would be: how do we wrap this macro with the actual potion? When we give the player a potion, it should come with the action to use it. I have not done it, but I feel this could be doable at least with modules like midi-qol and combat utility belt?

    • @anthonycollignon2472
      @anthonycollignon2472 Před 3 lety

      Hello. I have been trying to answer this question as well. Any clue on a possible solution?

  • @fantasy3518
    @fantasy3518 Před 2 lety

    What would happen if you put if(canvas.tokens.controlled.length1)

  • @mtgcarver
    @mtgcarver Před 3 lety

    It works great on characters... but for NPCs / monsters I get an error even though it looks like it works.
    Sheet value not initialized yet, please change one resource value to update it.
    Dunno what that means but it does look like it works...

  • @sleepinxonxbed
    @sleepinxonxbed Před 2 lety

    does this not work anymore? I cant even get past the first step when doing the drinking potion macro i get something like
    Uncaught (in promise) SyntaxError: Unexpected token ')'
    at Function ()
    at Macro._executeScript (foundry.js:14802)
    at Macro.execute (foundry.js:14765)
    at MacroConfig._onExecute (foundry.js:25943)
    _executeScript @ foundry.js:14802
    execute @ foundry.js:14765
    _onExecute @ foundry.js:25943
    async function (async)
    _onExecute @ foundry.js:25942
    dispatch @ jquery.min.js:2
    v.handle @ jquery.min.js:2

  • @codewolf444
    @codewolf444 Před rokem

    I noticed you are using Visual Studio. Which product are you using and how do you have it setup so that it will prompt the objects?

    • @codewolf444
      @codewolf444 Před rokem

      i see now that it is VS Code. Thanks I will try to get mine setup.

  • @Fjuron
    @Fjuron Před 3 lety

    Problem: actor.update did not work for me. Line 43: await actor.update({"data.health.value": newHealth});
    It only worked once I put a modification to th newHealth variable in there, like so:
    ({"data.health.value": newHealth+1});
    can anybody explain why?

  • @Kram994
    @Kram994 Před 3 lety +3

    'Alt-Cmd i' to open developer tools on a Mac

  • @r2roberts
    @r2roberts Před 3 lety

    I would like to see a similar video for module creation. Have I missed one from you?

    • @Devenish97
      @Devenish97  Před 3 lety +1

      Working up to modules wanted to cover the basics first

    • @r2roberts
      @r2roberts Před 3 lety

      @@Devenish97 Enjoying your series. Lots of tidbits I didn't know about.

  • @Freeze014
    @Freeze014 Před 3 lety

    Is there a reason to not use tick marks (`) for all strings instead of normal quotes(" or ') even when not using the string to include a function?
    Also the tutorial isn't quite systems agnostic, as attributes are a bit different from Simple World to say 5e.

    • @Devenish97
      @Devenish97  Před 3 lety +2

      No reason not to use back ticks all the time except they are a bit awkward to reach when typing code.
      And as for system agnostic, I hear you, but I was hoping you can use the first methods taught in the video to look up system data for 5e and and use its attributes in the same exact way for Simple Worldbuilding

    • @Freeze014
      @Freeze014 Před 3 lety +2

      @@Devenish97 That was successful indeed! Made my potion to be a 2d4 + 2 healing potion in 5e.

    • @MrSour1
      @MrSour1 Před 2 lety

      @@Freeze014 i'm trying to figure out how to add the rolls. can you let me know how you did it?

  • @AlucardWoA
    @AlucardWoA Před rokem

    Truly awesome work but I followed your code to the tee and it didn't work. VSC also doesn't let me use main() keeps trying to change it. I got fustrated after couple of hours messing with it

  • @andrewmitchell3289
    @andrewmitchell3289 Před 2 měsíci

    Great intro, but model out of data after V10 Foundry. I muddled through the new model and got it working for V11

  • @Roll3Motion
    @Roll3Motion Před 3 lety

    Hello, I have made a macro to damage and heal any token. In “game master” mode everything is working fine. But players get this notification: “User {PC name} lacks permission to update Tokens in parent.” Do you know of a way to override permissions without giving GM control to players?

    • @WolfDeity
      @WolfDeity Před 3 lety

      You need to check "Execute Macro As GM" otherwise it won't let a player change anything besides their own character sheet.

  • @chrissteele7472
    @chrissteele7472 Před 3 lety +1

    Is there a reason you need to create and call the function within the macro box? What's the difference if you just write the code without the function wrapper?

    • @Devenish97
      @Devenish97  Před 3 lety

      without calling the function you're just defining a function, not executing it.

    • @chrissteele7472
      @chrissteele7472 Před 3 lety

      Sure - but it seems I can just write “naked code” and it executed as expected with no function wrapper. In other words, it appears like the macro is already wrapped in a function, and creating the inner function (and calling it) is redundant. But I must be missing something, right?

    • @Devenish97
      @Devenish97  Před 3 lety

      @@chrissteele7472 yes you can do that, but that's bad code principles for anything more than simple 2-15 lines macros. like if you're writing anything even medium length it's better to break it down into functions to for better debugging and modularity. writing monolithic "naked" code becomes really hard to maintain
      but yes, if you're only writing some small 2-15 line quick macro, writing naked code is fine

    • @chrissteele7472
      @chrissteele7472 Před 3 lety

      @@Devenish97 Thanks, I think that's what I was looking for. I certainly understand the advantages of breaking code up (I've been a developer for 35 years), but adding in a random IIFE or main() function for no reason seems, well, unnecessary. I also asked because few (if any) of the community macros (github.com/foundry-vtt-community/macros/tree/master/5e) appear to do this either. I wasn't sure if there was some reason foundry preferred it. I suspect there is more of a history here.

    • @chrissteele7472
      @chrissteele7472 Před 3 lety

      oh, and @spacemandev - this is an excellent video - thank you for putting this and the others out there. I'm new to foundry and your videos are the first I've come across that actually give me the level of detail I'm looking for. Great work!

  • @mikeet207
    @mikeet207 Před 3 lety

    I tried the following roll /r 1d20 + @health.value and received a message in the game "@health.value was not present in the provided data". I had the token selected. Not sure why it isn't working.

    • @hadifalex
      @hadifalex Před 3 lety +1

      Hi there!
      i'm following this tutorial as well and i think it is because foundry has been updated ever since and it now has an added layer of structure.
      Try this instead while having a token selected
      /r 1d20 + @attributes.hp.value

    • @hadifalex
      @hadifalex Před 3 lety

      If you use the console (F12 and use the console tab) to do what he recommended at the very start and simply explore what it looks like in terms of structure, you can then alter these values whenever there is a change. it is very possible that a lot of people were a bit angry seeing how their macros got destroyed when the update happened!

  • @Tigersight0
    @Tigersight0 Před 6 měsíci

    I know this video is ancient, but I have to say, you absolutely threw me for a loop at 26:19, casually tossing that out that [[ actor.items.find(item => item.data.name == "Health Potion") ]]
    There is so much javascript nonsense going on there I had to dig through multiple pages of documentation to find out that its array searching works off of running extra functions within functions, which aren't written like functions. And which return values different from what the functions themselves return. All that instead of, I don't know, just doing string comparisons like I've seen in basically every other language I've worked with.

  • @p-leif630
    @p-leif630 Před 3 lety

    How would I creat a Master-Macro for a Hex crael like in "The Dark of Hot Spring Island" with location selection that roles on a table to see if it is a beast / intelligent / or elemental then roels on a table for the exact monster and the motivation for the greater typ

  • @3di17
    @3di17 Před 3 měsíci

    Sorry to ruin the 999 upvotes with an additional one :/

  • @OptimusGPrime
    @OptimusGPrime Před 3 lety

    What flavour cotton candy do you smear into your hair?

  • @NateMcCloud
    @NateMcCloud Před rokem

    Great video! But...couldn't you simplify the new health code to this?
    let newHealth = min(actor.data.data.health.value + healthpotion.data.data.attributes.hp_restore.value, actor.data.data.health.max)

  • @SuperLamarrio64DS
    @SuperLamarrio64DS Před 2 lety

    I cant get " /r 1d20 + @health.value " to work
    the console says "Assertion failed: Input argument is not an HTMLInputElement"

    • @willrichardson6344
      @willrichardson6344 Před rokem

      I think your macro is set to script. Try changing it to chat

    • @miennai9448
      @miennai9448 Před rokem

      You have to re-interpret as somethings have changed, and it changes even more if you are using a different system. I'm testing in Dnd 5e, on version 9, and I have to type "/r 1d20 + @attributes.hp.value"