r/FoundryVTT • u/Exact-Challenge9213 • Dec 01 '25
Discussion Vibecoding Macros is game changing
One of the things I’ve loved so much about Foundry since converting from Roll20 is the sheer variety of user-made content for it, both free and paid. But when I find something I wish I could do, and can’t seem to find the right module or macro for, I just go ahead and vibecode it and it works great! I am a novice programmer, but I have only worked with C# and python, and using an LLM to generate code for macros has completely changed how I run my games!
I started with a macro to show happy and sad goblins on critical successes and failures. Then, since I’m playing rime of the Frostmaiden, I made a macro to restrict player vision during a blizzard and make the fog of war white instead of black, and then to reset vision to what it’s supposed to be. Then, most recently, I decided to develop a macro for the Twilight clerics Twilight Sanctuary ability (I know other macros exist, in fact I purchased one and played around with it but had trouble getting it to do what I wanted) largely as a challenge since it’s a kind of complex ability, with lots of moving parts. I swear it probably only took 1-2 hours of vibe coding before I had it working exactly how I wanted it.
11
u/FoundryVTT-ModTeam Dec 01 '25
Reminder: you may freely discuss your views on AI - both positive and negative.
However abusive comments towards other users will not be tolerated.
Attack the argument, not the person.
2
u/ghrian3 GM Dec 01 '25
Serious question as I assume the mod message is for a reason.
Why the negativity?
16
u/Voelsungr Dec 01 '25
If you chekc the foundry discord server, you'll find a message mentioning they prohibit chatting about generated code, here the small FAQ:
Why no AI?
Chat-GPT and other AI-generated code does not understand Foundry VTT's API and likely never will.
What if I train the AI using Foundry VTT's API?
This would violate our license agreement, please don't.2
u/Exact-Challenge9213 Dec 01 '25
This is just so false? It totally works for me
11
u/Excellent-Sweet1838 Foundry User Dec 01 '25
Someone trained at least one model on FoundryVTT against the wishes of the people who made it.
The corpo scumsuckers who run openAI and companies like it do not care about intellectual property laws, and I'll be shocked shitless if they ever face a single consequence for it.
1
u/Exact-Challenge9213 Dec 01 '25
My guess is it just scraped publicly shared user made macros off Reddit and github and guessed the api from that
0
3
u/Cergorach Dec 01 '25
Well... That statement is relatively old, some of the LLMs (or all of them) might very well have been trained on the FVTT API (or even the entire code base of FVTT and all the publicly available modules), which they say is against the license agreement...
That it works for you is great for you, but you have been doing relatively simple stuff with macros AND you have some background in C# and Python,
somemost of the people doing the vibecoding have zero programming experience. This will result in garbage one way or another in most cases, when it Fs-up FVTT, it's FVTT that's getting the blame, not the vibecoder or the person that downloaded and installed that module...Now imagine already having 5000 modules in the database and not wanting TONs of vibecoded module garbage to infest that same database... I think it was smart for them to squash that idea in their official discussion channel (Discord), this Reddit on the other hand is unofficial, so it's all right to discuss it here. ;)
As for training an LLM on FVTT's API is apparently against the license terms, no idea if that would hold up in court. But what if you use RAG to let the LLM use the API documentation and the existing code base as references, this is not training the AI on that material...
It's interesting, but I haven't had the need to use it yet.
1
u/paulcheeba Pi Hosted GM Dec 06 '25
Yeah this is what I thought too, regarding modern AI versions. They don't need to learn or be trained on Foundry's API, because the API is a public document and AIs can now reference online documentation in realtime. You just point it to FVTT's API and give the AI search terms and instructions.
3
u/buttonpushertv Module Author Dec 01 '25
For a time, when ChatGPT was still on v3, the FVTT API changed but the LLM for ChatGPT-3 was still trained on the older API. Many vibe-coded macros were just wrong or didn’t work because the underlying API and JS code didn’t work. People then started posting their questions on the Discord and all of the sudden the macro help channel was inundated with people who didn’t know (or were trying to learn) how to code a macro, asking all sorts of questions, that it got over run with folks who didn’t understand what they had wrong and there just weren’t enough knowledgeable people to take on the work load.
So, they took the strong anti-AI/vibe-coding stance. Well…that and the FVVT terms explicitly state that you can’t train an LLM on their API.
OpenAI clearly don’t care about who’s IP they steal and fold into their LLMs, so there’s not much to be done except the official FVTT services banning discussion of AI/vibe-coded macros and scripts.
3
u/Voelsungr Dec 01 '25
Probably because someone else already broke license agreement for you.
I'd also bet that, based on the few examples you've given, your macros dont actually dig too deep into foundrys actual nitty gritty, which is what LLMs shouldnt know about, so to say nothing special or complicated, which isnt meant to be an attack if it sounds like one, just an assassment.
1
u/ohyouretough Dec 01 '25
It depends on what version you’re using and what you’re trying to get it to do. I’ve used it to make some macros and it worked fine and others for which it could never get to work.
1
0
Dec 01 '25
[removed] — view removed comment
-1
Dec 02 '25
[removed] — view removed comment
1
Dec 02 '25
[removed] — view removed comment
0
Dec 03 '25
[removed] — view removed comment
1
u/Wintoli Dec 03 '25
I don’t know if you’re being willfully ignorant to what generative AI is but it’s pretty much all theft.
Likewise using it for Foundry related stuff is breaking the license agreement, plain and simple, that’s not up for debate lol
1
u/jubuki Dec 05 '25
Again, you are misrepresenting what Foundry actually states and assuming I am doing things I am not.
Your delusion is not reality.
7
u/ghrian3 GM Dec 01 '25
This is out of context (either a mistake or intentional).
The FAQ does not forbid chatting about vibe coding in foundry discord. It forbids posting AI generated code in the channel macro-polo.
2
u/Exact-Challenge9213 Dec 01 '25
I think it’s just preemptive, I hadn’t received a negative comment
1
u/ghrian3 GM Dec 01 '25
Ok. As there is a difference between someone with a deep developer background using AI to get into another language / api to a complete newbie.
1
u/Exact-Challenge9213 Dec 01 '25
I wouldn’t say I have a deep developer background, I’m just proficient in a couple languages related to my work. But I do agree with this that you shouldn’t use ai to generate code you could never make yourself because you’ll just have an impossible time debugging, and I also believe in looking for other people’s content before AI generating it, and believe in paying for things on patreon and dm’s guild because I want to reward the work I think is neat.
5
u/jubuki Dec 01 '25
I always find it hilarious when people that produce software products think they can control how others use them.
Foundry may not like or even want to admit that GPT can easily, productively, and quickly build scripts that allow for those of us who can build code to implement things, but we are doing it now and will continue to do it and build our tables as we see fit; they cannot stop us.
Much of the code we generate has no need to understand the Foundry API, that is a silly hill to die upon in my opinion. Even if I choose to ground an AI system in the Foundry API, again, there is no way for the company to even know, much less take action.
I do not use and will not use creative source content generated by AI, I am meticulous in how I do that, all creative output, images, prose, etc., is not AI at my table.
I use AI though to build scripts all the time, I can build and populate scenes in seconds thanks to the scripts AI has helped me create and polish, in record time for a language I abhor and don't care to really learn.
People can get as upset as they like about these facts, but they will not really change, I have worked with software for close to 30 years, users will do what they like.
2
u/Airilsai Dec 01 '25
How tho. I don't know how to code, and every time I've tried to use AI to code something for foundry it hasn't worked.
1
u/WACKY_ALL_CAPS_NAME Dec 08 '25
I used ChatGPT to write a Macro that automatically changes the token image whenever a polymorph type effect is applied in PF2e. I had to give very specific instructions about the directory the token images were stored in and how the file names were formatted but it works very well. I run it once at the beginning of the session and it just works.
1
u/Excellent-Sweet1838 Foundry User Dec 01 '25
The discord keeps saying that AI cannot write macros because it doesn't understand the foundry API. I'm guessing that's no longer true?
3
Dec 02 '25
[removed] — view removed comment
1
u/paulcheeba Pi Hosted GM Dec 06 '25 edited Dec 06 '25
The issue with randomly removed code, and hallucinations can be easily avoided using a VSCode + GitHub copilot environment. I had many many many issues with using chatGPT in its own chat based website or app, building code that was losing chunks or being redacted. It was infinity infuriating.
My solution was to give copilot a local environment to store it's found data solutions in a devRef.md file. Plus having actual files to read and write to locally reduced the hallucinations and drift by almost 100%. The issue as I have learned was that each time you send a prompt into chatAI, they need to read the entire chat conversation to formulate the answer, every time.
I've read that AIs are limited by their context retrieval window and in long chat sessions that window drops older communications from the current context. Plus, I've found that without a local document to read/write, AIs get tripped up on their repeated erroneous coding attempts that are listed in the conversation history. This caused the AI to think what they wrote in the past to be a correct reference even if it was told otherwise.
The devRef.md file helps by keeping current reference documentation separate from the chat context. Add in "GitHub Instructions" and you can set a mini prompt to run at the start of your prompt by running a "do-this-first.prompt" in front of your next request. This Instruction would tell your AI to reference the doc first before applying and code changes etc. This greatly reduces the size of the actual chat history, keeping more of the session within the context window, increasing the accuracy and normalizing the formatting of the generated code.
And, if your chat session starts to drift, you just start a new session and and continue to use the same devRef.md to stay on track and continue Dev without interuption.
My typical local reference files are:
devRef.md -> stores curated reference documentation for immediate use.
initial.prompt -> my starting prompt for my dev cycle or project.
nextSession.prompt -> a prompt generated by the current session AI to tell the next session what was done and what is required next.
changelog.md -> logs all changes per version and documents the journey, including mistakes to avoid in the future.
The last thing I do, (I host via a Pi) is create install a local version of FVTT and use simlinks to pull my VSCode FVTT folders to the data folder (data/modules, data/scripts) so whenever I make a change in VSCode, all I need to do is refresh close the local instance and rerun it and the changes are there right away. Once everything is working perfectly, no console errors or warnings and the code is behaving as intended, I can push it to my actual online FVTT instances.
Seriously this was a game changer for me and the results were awesome. It's not a perfect system, and there are still errors and some drift but those are very few now in comparison. Previously I was doing this all on GitHub and creating a new branch for every change in case things went sideways. I'd have 80+ branches of WIP code (which is admittedly a PITA to clean up). Now I have less branches and each represents a "final" working version of that state. Keep in mind, strict versioning of your code iterations as you go helps this process a lot.
Edit: some text reformatted for clarity.
1
u/Subject97 Dec 01 '25
One of my friends was struggling to figure out how to change a damage type for one of his kineticist abilities. He later had a dream where he troubleshooted it until he found a solution, and the solution worked irl
2
4
u/Quicknoob Dec 01 '25
Okay so this is an area of Foundry I want to get into. I just don't understand how Macro's are used. ...are they all fired exclusively from the macro bar? So they all are effectively an on/off manual switch ...or can I have macros that fire off when a token enters a specific area or does something ...and if so how?
I'm looking for some direction here as to how I can get started with building macros.
Also OP could you share some of your scripts?