Prison Architect

Prison Architect

Not enough ratings
Scenario Mods
By edtg
This Guide will explain almost all the LUA functions for scenario mods and sandbox mods.
   
Award
Favorite
Favorited
Unfavorite
Overview
In This guide There will be all the LUA functions that I know and how to use them.
Then there will be how some can be linked together to create part of a scenario.

This guide is NOT finished and I will be adding more.
Lua function: Game.
There are lots of LUA functions but the one that I use most is "Game." this is then followed by something else.

* = It is explained in more detail at the end

Game.AdviserIncoming("Adviser") - This will tell you someone is calling you for example the Warden or the CEO.

Game.AdviserSay("Adviser","Text") - This tells the person calling you what to say after you answer them. The Adviser is the person Saying it for example the Warden or the CEO. Then the text is what they say, but to avoid writing long sentences you can abreviate it. This will be refered to with the base languages file.

Game.AdviserSayBatch("Adviser","TextBatch") - Same as the last one but the person tells you multiple things instead of just one.

Game.SetMap("MapName") - Tells the mod which map you want to use.

Game.SaveMap("MapName") - This saves the map you are currently on. It is useful for when you change to a different map and want to change back.

Game.CamMove(X,Y,X1,Y1,Speed) - This moves the camera to a certain position on the map. The x and y are the top left corner and x1 and y1 are the bottom right corner. The speed is how long it will take to get there, use 0 to instantly go there and 10 for very slow (you can use any number this is an example). Be careful because it is based of the x and y coordinates from the top left, and if the map is expanded you will end up in a different place.

Game.CamZoom("zoom","speed","bool") - This is used to zoom the camera. the zoom is how much it will be zoomed and the speed is how fast like with "CamMove". The bool tells it to keep going until it gets to the right place.

Game.CamTrack("Object","Zoom","Time") - This can follow an object as it moves. The Object is the name of the object, the Zoom is how zoomed in and the time is how long for.

Game.Unlock("Object/Ability") - I don't know exactly what this one does but I know that you can unlock things for the player to use, like "EmergencyCallouts" which allows the player to call riot police etc.

*Game.Polaroid("Name","FileLocation",X,Y,S1,S2) - This can show polaroids that help to tell a story. The name is what you call the polaroid, the FileLocation is where in your mod folder it can be found. X and Y are the center coordinates and the S1 and S2 is how big it is from the X and Y.

Game.PolaroidTrigger("FileLocation",X,Y,"Function") - This is used to trigger another fuction. The FileLocation is where it is in your mod's folder. The X and Y are the coordinates, There is no way to change the size. The Function is the name of the function it triggers

Game.HidePolaroid("Name") - This hides a certain polaroid. It is useful when the polaroid is not needed.

Game.SendEntityToPos("Entity",X,Y,Up/Down,Left/Right,"Speed") - This Moves a person or object to a coordinate. The Up/Down and Left/Right tells them which way to face using -1,0,1 and the Speed is how fast.

Game.SendEntityToObject("Entity","Object") - This moves a person or object to another object.

Game.SendEntityToRoom("Entity","Room") - Sends a person or object to a room.

*Game.Spawn("Typeofobject","Name",X,Y) - This is used to spawn an entity for example an actor, this is the type of object. The name is what you want to call it. X and Y is where it is spawned. You can't set which way it is facing.

Game.Remove("Entityname") - This removes an entity from the map.

Game.SetSprite("Name","Sprite") - This gives an entity a different look for example a character out of the campaign.

Game.PowerOn/PowerOff("Object") - This does what it says. It powers certain things on or off.

Game.FadeToBlack("Speed",false) - This will fade the screen to black using the speed that you set. I don't know what the false part is yet, but you can experiment.

Game.FadeUp("Speed",false) - This will fade to there being no colour on the screen. Again I don't know what the false does if you change it.

Game.FadeToColour(R,G,B,A,"Speed",false) - This uses a Red Green Blue colour combination to change the colour of the screen. A means Alpha which is how transparent it is.

Game.Sound("SoundType","Sound") - This is used to play sound effects or music. Read the Sounds.txt to find out about the sounds you can play.

Game.StopSound("SoundType","Sound") - This is used to stop a specific sound from playing.

Game.Pause(Seconds) - This Is used to stop the player from doing anything. It is useful for cutscenes and when advisers are speaking.

*Game.Delivery("DeliveryID", "Quantity","Object") - This is used to deliver items to your prison. The deliveryID is the truck or bus, the quantity is the amount of items and the object is the item to be delivered.

Game.GiveEquipment("Entity","Item") - This gives an entity or actor an item to hold. First you need the entity's name then the item's name (It is case sensitive so you can look in "Objects.spritebank" to find items).

Game.DropEquipment("Entity") - This can make any entity drop any equipment it is carrying.

Game.Damage("TargetEntity","Damage","AttackingEntity") - This can be used to kill or injure entities. The Target entity is the entity that is taking damage and the attacking entity is the entity giving damage. The damage is an integer that has to be over the target entity's toughness points to kill them.

Game.GameOver() - This ends the scenario

These are all the functions I have used but I will add more as I learn about more.
Lua functions: Objective. (Objectives)
Objectives are a big part of scenarios and sandbox mods. There are lots of functions, but I will only use the ones I know and use.

Objective.Create("Name") - This creates a new objective and that you can name.

Objective.RequireRoom("Room",Number) - This means the objective requires a certain room to be built and all the objects needed to be placed. The number is how many rooms you want the player to create.

Objective.RequireObject("Object",Number) - The same as the last one but using objects instead of rooms.

Objective.RequireBuilding(bool) - This means there needs to be a building. I recommend using "Objective.TargetArea" with this.

Objective.TargetArea(X,Y,X1,Y1) - This is used to say where you need to build something etc. The X and Y are the top left and the X1 and Y1 are the bottom right corners.

Objective.RequirePrisonersUnderControl(X,Y,X1,Y1) - This is useful for a scenario about stopping a riot. X, Y X1 and Y1 are the corners for the are which the prisoners need to be under control.

There Are lots more Objective. functions but I do not know how they work. When I start to use them and find out about them I will Update this.
Lua function: Trigger.
The Trigger function has the least functions but is very effective.

Trigger.Create("Name") - This is used to start the trigger. The Name is also the name of the next function

Trigger.RequireObjectives("ObjectiveName") - This means when all the objectives are complete it will trigger the next function.

There is only one more function, but i don't know how to use it.

Trigger.PreserveObjectives()

I will update this when I learn how to use it.
Other LUA functions
For your scenario everything is in a function. You start the script off by typing:

function BeginChapter()

--Then you add other functions like
Game.AdviserIncoming ("CEO")

--Then another function
Game.AdviserSay ("CEO", "Line1")

--Then we end the function
end

You can copy and paste this if you want. The "--" means that line is commented so it won't be read as a function.

We can then create our own function like this:
(This function is used in the prison Architect campaign to have actors shoot at something else)

function FireVolley( attacker, target, numShots, reloadTime, pause, coverMarker, coverOrientationX, coverOrientationY )

for i = 1, numShots do
Game.UseWeapon( attacker, target )
Game.Pause(reloadTime)
end

Game.SendEntityToObject( attacker, coverMarker, coverOrientationX, coverOrientationY, -1 )

Game.Pause(pause)
end


All you need to do now is type:

FireVolley( "guard", "prisoner", "2", "1", 0, "I don't Know about this", 0, 1" )

That is an example and you can change everything in the speech marks. I do not know about the cover marker though because I got this from the games code.
Advisers
Another thing that you need to know is the Advisers and what they are.

You can find some in each campaign folder and some in the advisers folder.

What they do

Advisers are the people that are speaking to you when you get a call. You can even create your own if you can get or make a picture for them.

List of advisers

formatting:
"Real name" = "Adviser name"

CEO = CEO
Warden = Warden
Folder setup Scenario
the setup for the folders for your scenario is simple.

First we need to find your introversion folder. For windows Use "Windows key" and R and type "%appdata%" (not including the speech marks). Then go back a folder and go to local. then find the folder named "Introversion" Go into it and into the folder called "Prison Architect". There should be a mods folder but if there isn't create one.

Now we need to create a new folder and call it the name of your mod. Then inside that create a text Document called manifest.txt and copy and paste this text into it:

Name ""
Author ""
Description ""
Version ""
Date ""

Then you can fill in the speech marks.

We now need another folder called "data".
And an image for your mod called "Thumbnail.png"

In the data folder we need 2 folders. one called "campaign" and the other called "language". In the language folder you need a text document called "base-language.txt". This will contain all the strings that are said by people or describing objectives.

Back to the data folder. go to the campaign folder and create a text document called "start.txt"
The most important part is that we change it from ".txt" to ".lua" or it won't work.
In that document type:

function Begin()
Game.SetChapter ( "" )
end

Then fill in the speech marks with your chapter's name. We won't need to use this document again.

Now we need another folder with the same name as you put in the speech marks.

Finally you can make another text document called "Script" and change it to ".lua". Then you can copy and paste a map from your saves folder (near the mods folder) and it will be used in your mod.


After all this the folder structure should look like this:

ModName
--manifest.txt
--thumbnail.png
--data
--campaign
--start.lua
--ChapterName
--Script.lua
--MapName.prison
--language
--base-language.txt
Extra functions
You can find extra functions on the internet or in other peoples code.

On the internet I use http://devwiki.introversion.co.uk/pa/index.php/Lua for help with my code.

To find your campaign folder you need to go to wherever you have installed your steam games, then go to Steamapps/common/Prison Architect Then after that go to main.dat and extract the folders to somewhere else like your desktop. In here you can go to campaign and look in the folders for each chapter. There will be 2 types of files: .LUA and .Prison you need the .LUA files
Base Language
For all the text in your mod you will need a Base-Language.txt file. This puts all the text into your mod.

When you first add an objective and test your mod it will just say Objective_HoldingCell or whatever you named it. In the Base-Language.txt file you would type:

Objective_HoldingCell Build a holding cell

This makes it easier for people to understand what you have to do.

For text that people say you need to do the same thing. First it will say Intro1 or whatever you named the line of text. In Base-Language.txt you would type:

Intro1 Hello

This text can be very long or very short but you shouldn't make it too long.
Explaining extra things
Here I will explain what each * is for.


File locations:

Example: Game.Polarid
The file location is needed to show which polariod you want to appear.
You need to type: data/"Your mod's name"/"Image Name".png


Actors:

Example: Game.Spawn
The actor means it is controlled by you and won't go wandering around unless you tell it to.


Deliveries:

Example: Game.Delivery
I have included this because it is useful but I don't know how it works. There are other places that you can look to find this.


I will update this for every new star I add so keep looking back here.
Sprites
There are lots off different sprites in Prison Architect.
This is a list of them:

Warden
Doctor
CEO
Mayor
ArmedGuard
RiotGuard
guard
morgan
morganIRL
benedict
benedictIRL
edward


I will add more soon.
Software for code
There are lots of different text editing softwares but the ones that I use are:

Notepad (For base language files and looking at other code)
Notepad++ (For the scripts files)

These are both free to download.

Notepad++ https://notepad-plus-plus.org/
Thank You
Thank you for reading this guide. It is my first one and I want to share all my knowledge about modding prison architect with the world. If you have any questions write them in the comments and I will answer them.

I'm looking forwards to seeing all of your mods.
I will be releasing my first scenario mod soon. I have been working on it for almost 3 months.

My first mod has been released. It is called Security Enforcement. Hope you all enjoy it.
Get it here: https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=636604883&searchtext=

By the way I would love to hear if you know about more of the LUA functions.
2 Comments
Chinbob 19 Mar, 2016 @ 2:57pm 
I scraped all of the sprites from the data files, so I can message you that if you want.
edtg  [author] 21 Feb, 2016 @ 8:09am 
[Duckie] Thundermaker300
You could try

Objective.Create ("HoldingCell")
Objective.RequireRoom ("HoldingCell",1)