Mods:Bare Bones
Creating a mod for Logic World is fairly easy, and quite fun. This guide will get you started with a very simple mod. However, this guide will not show you how to setup a proper environment for modding, which you probably want to do. Refer to Setting up your IDE if you want a proper modding environment.
File structure
There is really only one file structure you can use for your mods due to how Logic World compiles mods.
Note that the two following "diagrams" are based on the Windows tree command output, which shows folders and files. Files have suffixes like .jecs, while folders are just regular names.
YourModName -- The main folder of your mod. This is what you distribute / put in your GameData folder.
│
├──manifest.jecs -- The metadata of your mod.
│
├──components
│ └──<JECS component files> -- These define a component's shape, color, inputs, outputs, and scripts.
│
├──languages -- Translation files map an internal component name to a human readable name.
│ ├──English
│ │ └─ English.jecs
│ │
│ ├──Spanish
│ │ └──Spanish.jecs
│ │
│ └──<other language folders>
│
└──src -- Contains all C# source files, which will be compiled when starting the game.
├──client
│ └──<C# source files>
│
└──server
└──<C# source files>Our mod's file structure is going to look like this:
YourModName
│
├──manifest.jecs
│
├──components
│ └──LogicGates.jecs
│
├──languages
│ └──English
│ └─ English.jecs
│
└──src
└──server
├──SrLatch.cs
└──Loader.cs
C# and JECS code
manifest.jecs
ID: YourName.YourModName
Name: YourModName
Author: YourName
Version: 1.0.0
# Unless you have an incredibly good reason WHILE ALSO KNOWING WHAT EXACTLY you are doing, keep this at, or near zero.
# DO NOT EVER CHOOSE VALUES NEAR THE UPPER OR LOWER ENDS OF THIS RANGE (-100 TO 100), AS THIS SHOULD BE RESERVED FOR MODS THAT MODIFY THE GAME LOADING PROCESS.
Priority: 0
LogicGates.jecs
SrLatch:
column: "Logic"
category: "CustomComponents"
prefab:
blocks:
-
scale: (2, 1, 1)
position: (0.5, 0, 0)
color: 7FCB5A
inputs:
-
position: (0, 0.5, -0.5)
rotation: (-90, 0, 0)
length: 0.62
-
position: (1, 0.5, -0.5)
rotation: (-90, 0, 0)
length: 0.62
outputs:
-
position: (1, 0.5, 0.5)
rotation: (90, 0, 0)
-
position: (-1, 0.5, 0.5)
rotation: (90, 0, 0)
logicCode: YourName.YourModName.SrLatch
placingRules:
offsetDimensions: (2, 1)
gridPlacingDimensions: (2, 2)
allowFineRotation: false
canBeFlipped: true
flippingPointHeight: 0.5
English.jecs
# No need for columns since we use the built in Logic column
# Categorys
ComponentCategory.CustomComponents : "Custom Components"
# Components
YourName.YourModName.SrLatch : "SR-Latch"
SrLatch.cs
using LogicAPI.Server.Components;
using System;
namespace YourName.YourModName.Server
{
public class SrLatch : LogicComponent
{
private bool q;
protected override void DoLogicUpdate()
{
bool s = Inputs[0].On;
bool r = Inputs[1].On;
if (s && !r)
q = true;
else if (!s && r)
q = false;
Outputs[0].On = q;
Outputs[1].On = !q;
}
}
}
The namespace MUST match your mod ID located in manifest.jecs if you want your mod to actually work.
Loader.cs
using LogicAPI.Server;
namespace YourName.YourModName.Server
{
public class Loader : ServerMod
{
protected override void Initialize()
{
this.Logger.Info("YourModName has been initialized!");
}
}
}
This is required for your mod to get loaded into Logic World.
Loading into Logic World
To get your mod into Logic World, you must first find your Logic World installation directory.
To locate it, open Steam, click on Logic World, which is located in the left of your library in Steam, Either right-click on it or click on the little gear icon near the bottom-right of the game's banner art, Hover your mouse on Manage, and click Browse local files.
You should now have a file browser window open to Logic Worlds installation folder. What you are looking for is the GameData folder. Drag and drop / copy your mods main folder (refer to the file structure earlier) into the GameData folder.
Now when you launch Logic World, if you go into a sandbox and open your component selection menu, you should see your component!
If it didn't crash: Congratulations, you have just made your first mod for Logic World!