Step 1 - Create a Harvest mod description fileFrom Harvest version 1.10 and later, there's a new "mods" folder in your Harvest client data folder. This is located in ~/Library/Application Support/Harvest on Mac, and in the installation folder on Windows. The description file should be placed in this "mods" folder and have the extension ".hmd".

The description file currently has one block called "mod" and two values, the name of the mod (displayed in the game) and the mod's folder. For example:

Code:

mod{ name = jeb's Awesome Mod; folder = jebawesome; author = jeb;}

Please note that this is not lua code, so the semi-colons are required.

Step 2 - Create your main.lua fileWhen a player selects to load your mod in the game, the game will attempt to open a file called "main.lua" in the folder you have named in your description file (a sub-folder to "mods", such as "harvestClientData/sandbox/jebawesome"). This is a simple text document containing your lua code. It will be executed as soon as the game starts, either from the menu or through loading a saved game that has been saved with your mod activated.

For example, if you want to start the game with lots and lots of credits, you simply create a main.lua with the following line:

Code:

harvest.addCredits(100000)

Step 3 - Creating an update functionMost of the time you want your mod to be updated every frame loop. You do this by adding a "hook" on the game. Hooks are identified by a hook name, in this case "frameUpdate", and are added by calling hook.add(hookName, function). Here's a really simple example:

Check the other threads for a list of possible hooks and functions that you can call.

Step 4 - Adding support for save and loadA proper mod will need to store its game variables when the game is saved, and then restore them again when it's loaded. This is managed through hooking "gameSave" and "gameLoad". Here's an example that shows how to save the 'myCounter' variable:

However, this way of saving is quite simplistic and only supports simple arrays of variables. If you have longer arrays or matrices, I recommend you serialize your tables first. Harvest includes chillcode's table serialization on startup, which you can use like this:

Step 5 - Publishing your modWhen you're pleased with your mod you should also create a mod icon for it. This is optional, of course, but will make your mod look a lot cooler in the mod list!

The mod icon is a 32x32 TGA file with alpha channel (32 bits) that should be placed in your mod folder. The filename must be "favicon.tga" (case sensitive). If the game finds it you will see it in the mod list when you start a Creative Mode game.

The last step is to zip your mod so that others may use it. Simply use your favourite zip tool to create a package with your .hmd file and the mod's folder. To verify that your mod was zipped correctly, leave the zip file in your mods folder and check the mods list ingame. Your mod should now show up twice (first your .hmd file and then the same version in the zip).

Guest

Post subject: Re: How To Create Mods

Posted: 12 Apr 2008, 23:32

I guess the release is soon?

BroodKiller

Post subject: Re: How To Create Mods

Posted: 13 Apr 2008, 11:34

Joined: 07 Mar 2008, 15:37Posts: 33

We can only hope...

_________________Clean...Simple...Devious...I like it

Feone

Post subject: Re: How To Create Mods

Posted: 13 Apr 2008, 13:48

Joined: 24 Feb 2008, 23:31Posts: 409Location: Netherlands

we can already make them XD but only the testing wil have to wait

_________________Dear Lord, please save us from your followers.

BroodKiller

Post subject: Re: How To Create Mods

Posted: 14 Apr 2008, 12:21

Joined: 07 Mar 2008, 15:37Posts: 33

Well, sure, we can write scripts already, but they will have to be revalidated anyways, since the Oxeye guys may reimplement certain function or hooks or something, so it's better to simply wait for a stable version.

_________________Clean...Simple...Devious...I like it

jeb

Post subject: Re: How To Create Mods

Posted: 28 Apr 2008, 21:46

Site Admin

Joined: 21 Apr 2007, 14:17Posts: 524

Updated with some changes... the mods folder is now it's own "mods" instead of sharing "sandbox".

Feone

Post subject: Re: How To Create Mods

Posted: 04 May 2008, 13:00

Joined: 24 Feb 2008, 23:31Posts: 409Location: Netherlands

another question, how much of the mods can we copy into our own, everything as long as we give credit to the person who made the parts that we copied?

_________________Dear Lord, please save us from your followers.

jeb

Post subject: Re: How To Create Mods

Posted: 04 May 2008, 17:26

Site Admin

Joined: 21 Apr 2007, 14:17Posts: 524

Feone wrote:

another question, how much of the mods can we copy into our own, everything as long as we give credit to the person who made the parts that we copied?

Good question, I guess you should give credit where credit is due. You can copy anything you like from my mods, at least.

Feone

Post subject: Re: How To Create Mods

Posted: 04 May 2008, 18:09

Joined: 24 Feb 2008, 23:31Posts: 409Location: Netherlands

good cause i took the starhawk and normal mode (with credits given to Oxeye)

_________________Dear Lord, please save us from your followers.

Robbis_1

Post subject: Re: How To Create Mods

Posted: 04 May 2008, 18:14

Joined: 11 Dec 2007, 21:12Posts: 47

jeb wrote:

Feone wrote:

another question, how much of the mods can we copy into our own, everything as long as we give credit to the person who made the parts that we copied?

Good question, I guess you should give credit where credit is due. You can copy anything you like from my mods, at least.

Yeah, Lua is open source and released under the GNU General Public License (GPL). So I guess it's the same for scripts unless other specified.

Who is online

Users browsing this forum: No registered users and 0 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum