Prison Architect

Prison Architect

Not enough ratings
Research.txt – Overview – Prison Architect
By leftbehind
The research.txt file defines all the research tasks that appear on the Bureaucracy screen. This guide explains how to define your own research tasks.
   
Award
Favorite
Favorited
Unfavorite
What does it do?
The Bureaucracy screen lists all research tasks that are available in your prison; these are all defined in research.txt.

Almost all other aspects of the game can be made dependent on research being completed, for example you could block access to a room, refrom program or object until certain research has been completed.

What can be defined?

There are two flavours of research: Entity and Ability.

An Ability research is used to unlock other features in the game (objects, rooms, grants, etc).

An Entity research is the same as Ability but is used to semantically indicate that the purpose of the research is to gain access to a new member of staff. The corresponding entity (and what, if any, research it requires to become available) must be defined in materials.txt; for more information see Materials.txt – Entities.

How do I make things require my research?

In the various other text files, such as materials.txt, reform_programs.txt, etc., you add a "Research <name>" (where <name> is replaced with the name of your resarch) property to your definitions. Whatever is being defined will now require your research task to be completed before whatever is associated with that definition is enabled.

In terms of scripting, the only script environment that currently interfaces with research is grants.lua (and possibly scenarios too – not checked).
How does it work?
As it's name suggests, research.txt is just a text file. It needs to be in the right location and contain the right information for it to actually do anything...

File location

To add or update research tasks, you'll first need to create a research.txt file in the 'data' folder of your mod.

For example, if your mod is called "Your Mod", the path to research.txt would be something like this:

..../Prison Architect/mods/YourMod/data/research.txt

Note that the filename 'research.txt' is in lowercase; it won't work any other way.

Example definition

Once you've made a research.txt, you can start defining research tasks. Here's an example of one of the research tasks that comes with the game:

BEGIN Research Name GroundsKeeping Type Entity Requires Maintainance Admin Maintainance Sprite Gardener Cost -2000 Time 360 X 160 Y 420 NonWideX 160 NonWideY 360 END

Structure of a definition

Each research task is wrapped in a BEGIN .. END statement like this:

BEGIN Research .... END

The various properties of the research task are then defined between those two lines (where the .... is).

Property types

Currently, all properties are in the form of a "name value" pair, like this:

Name GroundsKeeping Type Entity Requires Maintainance

The first word is the property name, then there's at least one space, then the value. In the example above we've defined the "Name" property to have a value of "GroundsKeeping", the "Type" property to have a value of "Entity" and the "Requires" property to have a value of "Maintainance".

It doesn't matter how many spaces (if any) appear at the start of the line, or how many spaces are between the property name and it's value (as long as there is at least one space). It's convention to use spaces to indent all the property names and to align all their values.
Name & Localisation
Name

Every definition in research.txt must have a Name property that defines it's unique ID in the game.
  • Mandatory: Must be specified for every definition
  • Value type: String (should be TitleCase with no spaces)
  • Singleton: Can appear only once per definition
  • Lua Scripts: ??
Although it doesn't matter where the name appears in the definition, everyone always puts it as the first item immediately after the "BEGIN Research" line.

Example of a correclty defined name:

BEGIN Research Name BaconButty

Examples of incorrectly defined names:

Name Bacon Butty -- spaces in name (causes errors) Name baconbutty -- lowercase (breaks naming convention)

If you specify a name of a research task that already exists then your definition will replace the existing definition.

If you specify a name that doesn't exist, you'll create a completely new research task with the specified name.

Localisation

To ensure the name is correctly displayed in the game (eg. on the menu, tooltips, etc) you should define it's translation in ..../YourMod/data/Language/base-language.txt.

In the case of the BaconButty example above, the language strings would be defined as follows:

research_BaconButty Bacon Butties researchtooltip_BaconButty The food of the gods.\nBacon for everyone!

As you can see there are two items. The first one is used to provide the localisation of the Name property itself. The second one is optional and can be used to add some descriptive text to the tooltip when hovering over the research task (a "\n" in it's value will make the text after it start on a new line).
Research Attributes
These attributes define your research task...

Type

Is this an Ability or Entity?
  • Mandatory: Must be specified for every definition
  • Value type: Enum (Ability or Entity)
  • Singleton: Can be used only once per definition
  • Lua script: Not accessible
Example:

Type Ability

As mentioned at the start of the guide, an Ability is a general research task. It's like a flag that, once set by completing the research, can be used to enable other features in the game.

Type Entity

The Entity type is the same as an Ability but semantically has the sole purpose of enabling a new member of staff on the Staff menu. The icon on the Staff menu will get an overlay indicating how many of that entity type that is currently hired.

Bug #9758[bugs.introversion.co.uk]: It's not currently possible to define the hiring limit (the game currently hard-codes limits for special entities like Warden and Foreman).

The actual enabling of the entity is handled by the "Research" property of the entity definition; it's up to you whether you want the entity to require some research before it can be hired. For more details see Materials.txt – Entities.

Requires

Before starting your research task, does the user have to complete some other research task?
  • Optional-ish: Defaults to None, but it will be inconsistent with the game if your research doesn't require completion of some other research first.
  • Value type: Name of a research task
  • Singleton: Can be used only once per definition
  • Lua script: Not accessible
Example:

Requires Security

In the example above, the user would have to research Security before they could research your task.

Admin

Who performs the research?
  • Mandatory? All other tasks require a member of administration staff so I assume it's mandatory.
  • Value type: Name of any entity object that has "Properties Administration"
  • Singleton: Can be used only once per definition
  • Lua script: Not accessible
Example:

Admin Security

Because the research is performed in an office, and only Administration staff can be assigned to offices, the entity has to have the property "Properties Administration".

You can define your own Administration staff in materials.txt. For more information see Materials.txt – Entities.

Cost

How much does this research cost?
  • Optional: Defaults to 0 (free)
  • Value type: Negative integer <= 0 (eg. -1000 would mean $1000)
  • Singleton: Can be used only once per definition
  • Lua script: Not accessible
Example:

Cost -1000

If you want to provide a reward for completing research, do that via grants.lua.

Time

How long does the research take (in game minutes)?
  • Optional: Defaults to 0
  • Value type: Integer >= 0 (eg. 60 would mean 1 game hour)
  • Singleton: Can be used only once per definition
  • Lua script: Not accessible
Example (6 game hours):

Time 360
Appearance Attributes
These define how the research task appears on the Bureaucracy screen.

X and Y position

What is the fixed position (from top-left corner, in pixels) of the postit note on the Bureaucracy screen?
  • Mandatory: Must be specified for every research definition
  • Value type: Integer >= 0 (pixels)
  • Singleton: The properties can be used only once per definition
  • Lua scripting: Not accessible
Example:

X 160 Y 360

Since Alpha 34 there are two additional propterties which define the position when the game is viewed on a smaller display:

NonWideX 160 NonWideY 300

The use of hard-coded positions is utterly stupid. A bug has been reported to get it changed, please comment/support it: Bug #9597[bugs.introversion.co.uk].

Sprite

Should the postit note have an icon on it?
  • Optional: Defaults to no icon (and a smaller postit note)
  • Value type: Sprite name as defined in the spritebank
  • Singleton: Can be used only one per definition
  • Lua script: Not accessible
Example:

Sprite Gardener

It's not currently possible to define your own sprite using sprites.png, which makes it very difficult to get your own icon shown on the postit note (while it's possible to update the game's spritebank and associated image files, it's too error prone to be worth it). A bug has been reported to get this fixed, please comment/support it: Bug #9596[bugs.introversion.co.uk].