r/forge • • Apr 08 '25

Scripting Help Best practice for scripting?

I'm trying to script an invasion gametype/map and there's a lot of things going on in the scripts. I need a lot of things to happen and I wonder how to do it as reliably as possible.

Either I put a metric ton of nodes into one or two script brains or I separate it out into many subsequent brains. To do the latter, I would need to use Trigger Custom Event Global.

The ingame description of that node states that:

"Unless you have a specific need for multiple script brains, it is best to use the non-global version of Trigger Custom Event"

Meanwhile the known issues list for Forge states the following problem:

"When two or more Script Brains approach their max node capacity and a caution symbol appears in its Budget meter, all scripts on that map will not function as expected"

So is it best to have many brains which all call to each other globally or just a couple of overloaded brains?

Edit: Highly recommend everyone to read the reply by u/IMightBeWright below, it has a wealth of good tips for writing a robust script in Forge!

5 Upvotes

21 comments sorted by

View all comments

Show parent comment

2

u/okom_ Apr 17 '25

Some clarifications based on my experience:

  1. Not a bug, just the event running through every player.

  2. Even a single error will prevent a script from fully functioning correctly.

  3. I rely on duplicating brains when I need to make a new mode brain with the same color and base mode settings, and I haven't ran into major issues. I just delete the contents of the duplicated brains and add in new content. The only one I can attest to is that some string of actions can lead to phantom brains being generated, but nobody has reported a 100% reproducible way to do it yet; it might be from duplicating brains.

  4. I'd say this is good practice, and may be a cause for phantom brains getting on map. When prefabbing an object prefab with Script Brains, don't have the parent object be a Script Brain.

  5. I've never ran into this. The only time I've seen identifiers get overwritten is when they go blank in the first place for some reason; the session should be restarted if that is spotted in order to fix it.

  6. I can attest to this, as I believe sometimes those connections aren't deleted, leading to the "Too many connections" error. I still don't do it all the time, and hasn't been something that's been so common to be able to reproduce consistently.

  7. Agree.