Early mod support


Recommended Posts

  • Developer

Mod Instructions

This is a preliminary how-to for mod creation.  Please note that we are still in the *very* early stages for supporting mod development, but seeing as people have already begun to customize the game, we wanted to at least provide a way to add a couple things without having to mangle the actual game content.


Running the game in debug

Running the game in debug will unlock a slew of facilities to aid you in development.  It is not strictly necessary to run in debug to either run or develop mods, but it will probably be helpful.  To do this from the Epic launcher, go to Settings > Griftlands and check "Additional Command Line Parameters".  In the edit box, enter --debug.

A description of all the game's debug functionality is beyond the scope of this article, but for our purposes, it is useful to know that CTRL+5 will open a debug panel listing any mods the game has discovered.  Once you create a mod or (eventually) install other user-created mod content, you will see their appearance here.  You can enable or disable them from this panel.  Eventually some of this functionality will be available through proper in-game UI.


Creating an empty mod

Browse to your Griftlands user settings directory.  On windows, this will be in your Users directory under AppData\Roaming\Klei\Griftlands\.  If you see a saves/ directory, a log.txt, and other game-generated files, you will know you are in the right place!  Create a new folder named 'mods' if one doesn't already exist.  This folder houses all local mod content.

Inside the 'mods' folder, create another folder with the name of your mod.

Inside that folder, create a text file called modinit.lua.  This file will be executed when your mod is enabled and installed.  You can call into the game's Content API to add things like cards and modifiers, but beware that things are extremely likely to change at this stage, and there is no official "how-to" for the various pieces of content.  You can refer to the attached examplemod to learn how to add negotiation and battle cards.  The havarian example mod shows the current way to add a new language setting.

When you add or edit your mod files, you can use the CTRL+R hotkey to restart the game and reload content if debugging has been enabled.

Have fun!
 

 

examplemod.zip

havarian.zip

Link to comment
Share on other sites

On 3/31/2020 at 2:43 PM, Kevin said:

We're doing our part to unify the Klei Cinematic Universe.

 

On 3/31/2020 at 2:46 PM, minespatch said:

image.thumb.png.204f8a5633e73b99a535986868ed5b6e.png

-Epic Emmet and Danny Elfman French horn crossover-

you are legally not allowed for this to be "just a joke".

This had better become a reality

Link to comment
Share on other sites

I tried to do something like

engine.asset.Texture("UI/graft_bg.tex")

in my custom mod. However, when this line is called, the game gives an error like this:

17:09.51-Lua: Error calling function from engine: scripts/encounter/encounter.lua:157: ERR running driver:SETTINGS:mods/CrossCharacterCampaign/modinit.lua:120: attempt to index a nil value (field 'asset')

Is there a way to call the game engine in the mods?

Link to comment
Share on other sites

Funny thing, actually. It worked in my other file, where i defined a custom modifier for a custom card, but somehow the exact same syntax crashes my game here.

Apparently calling "engine" in another file and then use "require" to import that file causes no trouble. So the problem might have something to do with the mod loading function itself. Just don't call "engine" in modinit.lua.

Link to comment
Share on other sites

Just finished making my own first card, here's some basic beginner tips from somebody who'd never coded in a dynamic language before this point. If anything is wrong please correct me, otherwise if/when official mod support comes out, feel free to throw this text on in an FAQ/Help section somewhere.

Download Lua. I used https://github.com/rjpcomputing/luaforwindows to install on my windows machine.
 
To see code of base game cards:
1. Unzip a copy of the data folder into a new folder. Make sure this folder is in a separate location from any of the game's files (for example, I put this new folder in my PC's documents folder).
(By default, data will be a ~2,250,000 KB .zip file in Program Files/Epic Games/Griftlands/ )
2. In the unzipped folder, go to /scripts/content . Battle cards are defined in the attacks folder (basic actions are character nonspecific, Sal actions are Sal's cards, rook actions are rook's cards, etc).
Similarly, negotiation cards are under the negotiation folder.
 
My mod doesn't show up in the game!
Check the following list:

You've saved all your currently opened files in your editor.

Check for missing commas or '='.

In my personal experience, often times bad code will just cause your mod to fail entirely (though as of this point I'm only working in a single file). If you just recently added in some code, try commenting it out and restarting the game (CTRL + R will do this if you have debug mode enabled, getting an up-to-date version of your mod files).

Link to comment
Share on other sites

-- This sets what the game refers to this mod as.
-- The game now refers to this mod as "NewExampleMod"
-- Change this to your own mod name.
-- From now on, you can use "NewExampleMod:" to refer to the mod's folder.
-- For example, this modinit.lua is at "NewExampleMod:modinit"
MountModData( "NewExampleMod" )
-- You can put constants, helper functions, and required libraries here.
-- Don't put any game changing code outside of the OnLoad function.

-- This function is called when this mod is loaded. Put everything that can change how the game behave here
-- This way, when you "disable" the mod in-game, the mod is actually disabled.
local function OnLoad()
    -- This code down here loads other files.
    -- You don't want to put code directly under OnLoad unless the code is extremely short.
    -- It is advised to put your code in a seperate file in the mod folder.
    
    -- The directory of where your code is.
    local self_dir = "NewExampleMod:content/"
    
    local LOAD_FILE_ORDER =
    {
        -- Put the file you want to load here.
        -- For example, if you want to load NewExampleMod:negotiation_cards.lua and
        -- NewExampleMod:battle_cards.lua, uncomment the code below

        -- "negotiation_cards",
        -- "battle_cards",
    }
    for k, filepath in ipairs(LOAD_FILE_ORDER) do
        require(self_dir .. filepath)
    end
end

-- Don't touch it.
return {
    OnLoad = OnLoad
}

34343538_newfolder.thumb.png.89fbddd570a7568ea6c81be42543384f.png

474858467_newfile.thumb.png.6051e973fb94dda57369f11caac0520e.png

I am right now writing a comprehensive tutorials for adding negotiation cards to the game. Right now, you should create a new folder under mods and add modinit.lua to that folder, and copy and paste the above code to that file. You could use a code editor like notepad++ or visual studio code, or you can just use notepad. In the meantime, you should look at how some cards works under "[game file location]\data.zip\scripts\content\negotiation".

Link to comment
Share on other sites

1 hour ago, RageLeague said:

-- This sets what the game refers to this mod as.
-- The game now refers to this mod as "NewExampleMod"
-- Change this to your own mod name.
-- From now on, you can use "NewExampleMod:" to refer to the mod's folder.
-- For example, this modinit.lua is at "NewExampleMod:modinit"
MountModData( "NewExampleMod" )
-- You can put constants, helper functions, and required libraries here.
-- Don't put any game changing code outside of the OnLoad function.

-- This function is called when this mod is loaded. Put everything that can change how the game behave here
-- This way, when you "disable" the mod in-game, the mod is actually disabled.
local function OnLoad()
    -- This code down here loads other files.
    -- You don't want to put code directly under OnLoad unless the code is extremely short.
    -- It is advised to put your code in a seperate file in the mod folder.
    
    -- The directory of where your code is.
    local self_dir = "NewExampleMod:content/"
    
    local LOAD_FILE_ORDER =
    {
        -- Put the file you want to load here.
        -- For example, if you want to load NewExampleMod:negotiation_cards.lua and
        -- NewExampleMod:battle_cards.lua, uncomment the code below

        -- "negotiation_cards",
        -- "battle_cards",
    }
    for k, filepath in ipairs(LOAD_FILE_ORDER) do
        require(self_dir .. filepath)
    end
end

-- Don't touch it.
return {
    OnLoad = OnLoad
}

34343538_newfolder.thumb.png.89fbddd570a7568ea6c81be42543384f.png

474858467_newfile.thumb.png.6051e973fb94dda57369f11caac0520e.png

I am right now writing a comprehensive tutorials for adding negotiation cards to the game. Right now, you should create a new folder under mods and add modinit.lua to that folder, and copy and paste the above code to that file. You could use a code editor like notepad++ or visual studio code, or you can just use notepad. In the meantime, you should look at how some cards works under "[game file location]\data.zip\scripts\content\negotiation".

Thanks for this, it is still way above my pay grade. My diploma in C++ was some years back now and it is mostly forgotten, I'll take a look though see if I can make more sense of it once I actually get going. This will be great reference during that procedure. 

:)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.