Sandbox Engine

This plugin series lets the player freely tamper with the terrain according to your rules no matter you want to establish buildings, use it as a furniture system, or as a base for a farming sim!

Event Spawn System included!

Features

  • Let the player freely modify the terrain according to your rules.
  • Define „Blueprints“ including information such as: What can be built, where it can be built, costs, etc.
  • The plugin manages Autotiles and shadows, so you don’t have to deal with them.
  • Event Spawn System included!
  • An excellent build menu that automatically renders your assets (so you don’t have to take pictures for all of them).
  • Mouse and Touch Support!
  • Define preconditions such as materials, required gold, switches, …
  • Define post-build events such as flipping a Switch or running a Common Event.

Trial Version

This plugin offers a free trial version. This is the perfect chance for you to try it out and check whether this plugin works with your current project. It provides all the features from the full version; however, it comes with some limitations:

  • Map changes are not memorized. Changing map, loading a save, or opening the menu leads to map changes being wiped.

Import Plugins and unlock to Full Version

Import these plugins and order them by the „Tier“ tag.

  • MK_MapManipulation
  • MK_MapManipulation_Unlocker (comes with the full version)
  • MK_SpawnEvents
  • MK_SandboxEngine
  • MK_BuildMenu

Unlock full version: The full version comes with a „MK_MapManipulation_Unlocker“ plugin. Just import it into your project.

Get Started

We recommend opening the sample project that comes with your download (It doesn’t matter whether you downloaded the free trial or already purchased the full product).

Source Maps

Everything that the player can build is defined on so called „Source Maps“. Prepend the ! or $ symbol to a map name so the plugin knows that it should preload these maps.

  • When using ! the plugin loads this map when it’s a child map of the map where the player is right now.
  • When using $ the plugin loads this map on game start, so it is always available.
Given the player is on Map001 then maps indicated with the green arrow are pre-loaded

As you can see, you can pre-load multiple source maps as long as they don’t share the same name.

Ensure that you don’t pre-load maps sharing the same name. The plugin treats „! objects“ and „$ objects“ as the same (and therefore does not allow it), although they have different symbols.

Anatomy of a Source Map

Example:

A source map contains at least one row („asset“) which consists of the following:

  • Region tiles are used to fulfill two purposes: Define the dimensions of an asset and assign it to a number. You can use any number as long as you don’t use a number twice within one source map.
  • At least one „matcher“: Those matchers define where this asset can be built later, e.g., floor, carpet, walls, …
  • Exactly one blank area with the size of the region tiles.
  • Exactly one asset: This is what will be built in the game. It may contain events.

Blueprints

A blueprint wraps up an asset and extends it with additional information such as name, category, costs to build, and more. You define them in the plugin manager.

  • Name: Unique name to identify every blueprint.
  • Category: Optional. The build menu can filter by category.
  • Description: The player will see what you type in here.
  • Sourcemap Name: The name of the source map. You can skip the !/$ symbol.
  • Region ID(s): Region ID of your asset on the source map. When you type multiple values, the plugin will always look for the first asset that matches the location where the player is pointing
  • Required Items: Items that the player needs to build this object. Those items are consumed automatically when building.
  • Required Gold: Same as „required items“ but for gold.
  • Conditions:
    • Switch: When given, this switch must be switched to ON.
    • Variable: When given, this variable must be larger or equal to the number from the next parameter.
    • Custom Code: You may use custom code to add your own pre-condition.
  • Post Build Events: Here you can define some events that should happen after the player built something.
  • Initially available?: When true, the player knows about this blueprint already on game start.

Learn and Forget Blueprints

You can choose from two ways to manage blueprints in your game. Choose as you prefer.

Via Note Tags

Add <Blueprint: x> to items in the database. As long as your party owns it the player can use this blueprint.

Via Commands

MZ users: You can use plugin commands to add/remove blueprints.

MV users: You can use these scripts:

$gameParty.learnBlueprint("table")
$gameParty.forgetBlueprint("table")

Build Menu

This suite comes with a build menu that lets the player choose what to build next. But, of course, you can use something else to manage building.

Shovel Mode

When the shovel mode is enabled then the player can transform the map right ahead from him while moving freely. That works best when the asset is a 1×1 tile.

When the shovel mode is disabled then the player is locked at his position, and the asset is positioned by mouse or arrow keys.

Shovel mode: ON
Shovel mode: OFF;
building by arrow keys/mouse

To control the shovel mode, you can use Plugin Commands (MZ only) or these script calls:

MK.Sandbox.setShovelMode(true)
OR
MK.Sandbox.setShovelMode(false)

Putting everything together

We believe that such a plugin should not dictate gameplay rules and instead the game designer should have full control. This means that the plugin does not automatically display buttons or register hotkeys for certain functions. Instead, it offers several interfaces.

To get started, we recommend downloading and opening the demo project. Consider it a suggestion, not a requirement. It is likely that you would do some things differently.

Tips & Tricks

An energy system can easily be implemented with game variables.

  1. In every blueprint you can add a variable „energy“ as a pre-condition.
  2. The plugin does not automatically decrease this variable so we have to do so. In the blueprint(s), set a new common event as post-event.
  3. Call this common event something like „work“ or „consume energy“. In this common event you decrease your variable „energy“ by 1. You can also add sound effects here.
  4. That’s the bare minimum. Now it’s up to you how you want to manage the energy, how it is refueled, how it is displayed on the screen, etc.

Let’s make a quick example: We make a chest that is buildable just once. After that, the player would need to remove the chest until it can be placed again.

Unfortunately, this plugin can not (yet) count how often an asset has been built, but we can count by events on the current map. That means we cannot check whether the player has already built this chest on a different map.

Let’s start:

Open the Event on the Asset Map that you want to count.

In the note field, type something recognizable:

  • Your name must be wrapped with <> symbols
  • Your name must not contain blank spaces: <Ware House>
  • Your name may contain numbers, but not as the first character: <Bank1>, <Bank2>, <1Bank>

We use this name only for the counting. It is not a unique identifier, and it can have any value. It’s not required for the name to match any blueprint name. You can safely use the same name across multiple events, for example when you have numerous chests in various colors.

Now, open your blueprint in the Plugin Manager and go to Conditions -> JS: Custom Code

Copy-paste this:

return $gameMap.events()
  .filter(event => event.event().meta.Bank)
  .length < 2
  • Bank is the name that you put into the event’s note field.
  • 2 is the total number of times the event can appear on the map.

Replace those values accordingly.

When done correctly, the player can not place a 3rd chest. Right now, there’s not yet a good way to prompt a „you have exceeded the total number of this object“ message to the player, but it may come in the future.