This article is part of a directory: Battlefield 2042: Complete Guide And Walkthrough
Table of contents

Quick Links

One of the greatest additions to Battlefield 2042 is Portal, a game mode that allows the player base to create custom game modes using 2042 and remastered content from older Battlefield titles. Beyond basic server tweaks, players can use Portal's logic editor to create custom logic through a visual programming system.

Related: Battlefield 2042: Specialist Guide

We've already covered the very basics of Portal, but there are a few tricks you can use with the logic editor to ease the learning curve. We'll be talking about some basic tips and tricks today, ranging from developer comments to a way you can force vehicles to spawn in TDM. More advanced tricks and guides will be released over the next few weeks. Stay tuned.

Use Subroutines

Battlefield 2042 Portal UpdateUI Example

While most of your logic editor code is going to be entered and executed in Rule blocks, creating dozens or even hundreds of Rule blocks for a complex game mode is nothing short of a mess. Thankfully, you can create Subroutines to make your project cleaner and easier to understand. It also makes troubleshooting and updating your code far easier.

Subroutines are effectively reusable Rule blocks that don't need to be connected to your project's "Mod" block—a grey container that activates your custom code. Creating a Subroutine is fairly easy:

  • Scroll down to the very bottom of the logic editor's list of choices.
  • Select the "Subroutine" category.
  • Click "Create Subroutine."
  • Name your Subroutine.
    • Be specific with its name.

You'll now have an orange Subroutine block in the logic editor window. Just like the Rule block, you can start slotting in logic, Condition requirements, and other bits of code.

Related: Battlefield 2042: The Biggest Fixes The Game Needs

Some good uses of Subroutines include:

  • Adding or updating multiple UI elements at once.
  • Creating and storing information within an Array.
  • Altering information in the "GetPlayers" Array.
  • Creating mechanics for your game mode that are repeatedly used.
    • Adding an in-game store, infecting a dead player, checking for killstreak eligibility, etc.

In the example below, we use the logic editor to add a ton of UI elements to the player's screen. To make the code easier to read and reuse, we convert this Rule into a Subroutine named "UpdateUI." This is just one of many ways you can use Subroutines to clean up your code and save on time making your game mode.

Adding Comments

Battlefield 2042 Portal Comment

If you've used or looked at any programming language, you might have seen lines of text like this:

//Clears then displays five custom messages on the player's HUD.

This is known as a comment, a way for developers to quickly explain what a piece of code is doing—or in the case above, vent their frustration. Unfortunately, Portal's logic editor doesn't have a proper comment command, but there is a way you can add annotations to your code through Strings.

If you head to the "Literal" tab in the logic editor, you should see a "Text" block. Drop that beside the block of code you wish to comment, then write a quick sentence explaining what the code does. If you want to make comments easier to locate, add two forward dashes (//) before the sentence.

Even if you don't plan to share your code with anyone, this is a fantastic way to document how your various Rule and Subroutine blocks work, making it much easier to troubleshoot and generally understand how your game mode works.

Adding Vehicles To TDM

Battlefield 2042 Portal Vehicle Spawn Settings

A quick tip that doesn't directly relate to the logic editor: it's possible to enable vehicles in Team Deathmatch through Portal's server settings. Make your way to the vehicle tab in the server settings. Look for the "Vehicle Spawn" tab. Click the dropdown menu, then select "Spawns On Map." This will force vehicles to spawn on the map, provided the map has vehicle spawns. Larger maps have more vehicles to toy around with.

Related: Battlefield 2042: Hazard Zone Guide

Note: This setting disables the Call-In System, although call-ins don't work for TDM or FFA as of writing.

Making Ongoing Rules Reusable

Battlefield 2042 Portal UpdateUI Subroutine In Use

When you create a Rule block in Portal, you'll need to select its Condition and Scope—what can trigger the block. By default, Rule blocks are configured as "Ongoing" and "Global." This does not mean the Rule block is always active, however. Without a Condition block, your Rule logic will only activate once for the entire match.

Condition blocks can be found in the "Rules" tab of the logic editor. These blue blocks require logic arguments to function, checking if something is true, false, greater than, less than, etc. Even with a Condition block, the Condition must become false than true again for a Rule block to reactivate. For example, let's say your Condition is when the player is crouching. When your character squats down, that makes the StateBool become "True," causing the Rule block to fire. Standing up makes the StateBool "False," allowing the Rule block to trigger again the next time you crouch.

Battlefield-2042-Portal-Crouch-Check-1

In essence, just make sure that any Ongoing Rule blocks you make have some sort of Condition that toggles between true and false throughout a match. Oh, and don't create a Condition that's always true (say placing a Literal with the "True" value as your only argument); your code will only activate once.

Enhancing Portal's Functionality

Battlefield 2042 Portal Extension

If you're someone who plans to spend dozens of hours messing with Portal's logic editor, we highly encourage you to install LennardF1989's BF2042 Portal Extensions web browser add-on. This extension adds additional functionality to Portal, including the ability to comment, copy and paste blocks, collapse and expand sections of code, and more. It won't allow you to edit Conquest or accomplish coding feats that standard Portal doesn't allow, but this extension adds so many quality of life improvements that virtually every creator can benefit from.

Next: Battlefield 2042: Complete Guide And Walkthrough