# Using the Puck API

Now that we have our development environment set up, we can start adding dependency libraries to our project in order to interact with the Puck API.\


1.  Let's create a new `libs` folder within our project in which we will be placing our libraries.\


    <figure><img src="https://2911841908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8ZDIsNKdEz0IT73wepog%2Fuploads%2FHKQ2Z8gygTkBiIgd2XTA%2Fimage.png?alt=media&#x26;token=31952c20-93b4-42f9-8830-ac6a5d97b3d6" alt=""><figcaption></figcaption></figure>
2.  Now we need to navigate to the directory where Puck is installed. This can be quickly done via Steam's `Browse local files`.\


    <figure><img src="https://2911841908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8ZDIsNKdEz0IT73wepog%2Fuploads%2FKQljELFG80CZ42V80GId%2Fimage.png?alt=media&#x26;token=07ba7d96-a72b-4af9-82a0-89965b9b31b1" alt=""><figcaption></figcaption></figure>
3.  Open the `Puck_Data` folder and within it, open the `Managed` folder as well. The absolute path where the game's libraries are stores will look as follows: `C:\Program Files (x86)\Steam\steamapps\common\Puck\Puck_Data\Managed`.\


    <figure><img src="https://2911841908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8ZDIsNKdEz0IT73wepog%2Fuploads%2F7Nm9NxNdtlbLOTjcHO6d%2Fimage.png?alt=media&#x26;token=abf4dad4-a366-4539-ae46-2b179f5a0729" alt=""><figcaption></figcaption></figure>
4.  Copy all of the contents from the `Managed` folder to your project's `libs` folder.\


    <figure><img src="https://2911841908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8ZDIsNKdEz0IT73wepog%2Fuploads%2FoqMAO9Za3688Z6yjmcOy%2Fimage.png?alt=media&#x26;token=af9d0697-93c3-44d7-82c6-7e4370b71bf6" alt=""><figcaption></figcaption></figure>
5.  In order for our project to be aware of the added libraries, let's also add the the following to our `MyPuckMod.csproj` file:

    ```xml
    <ItemGroup>
      <Libs Include="libs\*.dll" Exclude="libs\System.*.dll" />

      <Reference Include="@(Libs)">
        <HintPath>%(Libs.FullPath)</HintPath>
        <Private>false</Private>
      </Reference>
    </ItemGroup>
    ```

    This `ItemGroup` gathers all .dll files in our `libs` folder and references them in our project. The `Private` flag ensures the referenced libraries are not included in our final build.\
    \
    The resulting `MyPuckMod.csproj` should now look as follows:

    ```xml
    <Project Sdk="Microsoft.NET.Sdk">

      <PropertyGroup>
        <TargetFramework>net4.8</TargetFramework>
      </PropertyGroup>

      <ItemGroup>
        <Libs Include="libs\*.dll" Exclude="libs\System.*.dll" />

        <Reference Include="@(Libs)">
          <HintPath>%(Libs.FullPath)</HintPath>
          <Private>false</Private>
        </Reference>
      </ItemGroup>

    </Project>
    ```


6.  Let's update our `Class1.cs` file to make use of the `IPuckMod` interface:

    ```csharp
    using UnityEngine;

    namespace MyPuckMod {
        public class Class1 : IPuckMod
        {
            public bool OnEnable()
            {
                Debug.Log("Hello world from MyPuckMod!");
                return true;
            }

            public bool OnDisable()
            {
                return true;
            }
        }
    }
    ```

    \
    The `IPuckMod` interface is what Puck looks for when loading your .dll. Make sure your mod also provides an `OnEnable` and `OnDisable` functions. Puck will call those functions internally when enabling/disabling your mod in the UI, when joining/disconnecting from a modded server and so on.\
    \
    Note that both `OnEnable` and `OnDisable` return `true`. This is a status indicator for Puck to know that your mod initialized or shutdown successfully. For any failures, make sure to return `false`, as other system rely on this response to operate correctly!\
    \
    For the sake of keeping this guide simple, let's print out a simple "Hello world!" to the console.\

7.  Build the project with `dotnet build`:\


    <figure><img src="https://2911841908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8ZDIsNKdEz0IT73wepog%2Fuploads%2Fxv5eSWtRdSrfLj50obpi%2Fimage.png?alt=media&#x26;token=4fb80839-b289-4f8e-bafa-1c7843eda2b4" alt=""><figcaption></figcaption></figure>

Great! Your mod now has access to the Puck API along with any libraries Puck itself depends on by default. Head over to the next section to see how we can actually run your mod within the game.
