Skip to content
aubergine10 edited this page Dec 6, 2015 · 2 revisions

##Overview

The data/grants.lua script defines all the grants available for your mod. It has it's own distinct scripting API library, accessed from the Objective and Game globals.

Note: You can view the base game's main.data/data/grants.lua to see how the default grants are implemented.

##Modding

Start by creating an empty data/grants.lua file within your mod, then add in the script that defines your grants.

For example, if your mod is in a folder called MyFirstMod, then grants.lua would be located here:

MyFirstMod/data/grants.lua

##Script structure

When the script is loaded, the game will trigger the CreateGrants() event to 'install' your grants. This function should call a series of custom global functions, one for each grant that your script defines - this makes it much easier to see what grants are provided and how they are implemented.

function CreateGrants()
  MyFirstGrant()
  MySecondGrant()
end

function MyFirstGrant()
  Objective.CreateGrant( 'Grant_MyFirstGrant', 0, 1000 )
  -- grant script here
end

function MySecondGrant()
  Objective.CreateGrant( 'Grant_MyFirstGrant', 0, 2000 )
  -- grant script here
end

As the script is run in its own Lua environment, you won't get conflicts with other mods that define the same global custom functions (eg. other mods could also define the MyFirstGrant() and MySecondGrant() functions and they wouldn't conflict with your mods functions of the same name).

##Debugging

At the time of writing, there is no known way to open a debug console from a grants.lua script and as such you will have to do blind bug fixing (trial and error).

When developing grant scripts, it's generally best to test every change so that if something breaks you know it's caused by the most recent change.

##See Also

  • Localisation
Clone this wiki locally