http://wiki.offgridthegame.com/api.php?action=feedcontributions&user=Dominic&feedformat=atomOff Grid Wiki - User contributions [en]2024-03-28T18:24:30ZUser contributionsMediaWiki 1.41.0http://wiki.offgridthegame.com/index.php?title=Mission_Objects&diff=341Mission Objects2017-09-09T15:11:56Z<p>Dominic: typo</p>
<hr />
<div><br />
== Mission Objects ==<br />
<br />
Mission Objects, as the name suggests, are objects that are found within a level, with their purpose being to help the player complete the mission. Mission Objects can include many things like player spawns, interactable items, hackable devices, and triggers - all vital features that most levels will need.<br />
<br />
[[File:MissionObjects.png|400px|thumb|none|Examples of what some Mission Objects look like in Unity]]<br />
<br />
=== Triggers ===<br />
<br />
Triggers are Mission Objects which are used to start an event (like a conversation pop-up window) when a player walks into the trigger zone. They are a very commonly used Mission Object and have many uses, like starting conversations, triggering a sound to play, mission objective updates, and much more. For a detailed guide on how to create triggers, and for more on what they can be used for, read the [[Triggers and Examples]] page.<br />
<br />
=== Spawns ===<br />
<br />
Spawns are a Mission Object simply used to tell the game where exactly to spawn into the level the characters that have been defined in the Mission Script - this includes the player, but also NPCs like Guards. For more on creating working spawns, read up on the [[Configuring Spawnpoints]] page.<br />
<br />
=== Interactable Objects ===<br />
<br />
Interactable objects are Mission Objects that are found within the level that the player can interact with, this includes objects that the player can grab and put into their Inventory, but also objects like door handles, and keycard scanners to gain entry into a room. Interactable objects will be commonly found within levels to progress through the objectives, and to progress through levels themselves. If you want to read on how to implement interactable objects into your level, read the [[Adding Interactable Objects]] page.<br />
<br />
=== Hackable Devices ===<br />
<br />
Hackable objects are a core feature of ''Off Grid'', they come in many shapes and sizes, including phones, cameras, refrigerators... the list is endless, anything can be turned into a hackable object and hackable objects are again a very common Mission Object, mainly because one of the main features of the game is to hack into things! Hackable devices are interacted with by using the SSH Connection app and the access, UI, and function of each hackable device can be very varied and easily modified by modders. For a detailed run-through of hackable devices, take a look at the [[Hackable Devices]] page.<br />
<br />
== Creating a Mission Object in your level ==<br />
<br />
=== Adding in a pre-made Mission Object ===<br />
<br />
In the Hierarchy tab, click Create and then navigate to the directory shown in the image below, then click on the Mission Object which you are looking to create. <br />
<br />
[[File:TriggerCreate.png|400px|thumb|none|Adding Mission Objects]]<br />
<br />
Depending on which Mission Object you want to create, you will need to take a different approach on editing the components. For example, creating a working spawn and creating a working trigger need different ways to make them functional. As such, if you want to see a detailed page for creating specific Mission Objects (like hackable objects, or triggers), look at the section for the Mission Object you are looking for above and follow the link to the page which show you how to implement the Mission Object into your level.<br />
<br />
=== Manually creating a Mission Object ===<br />
<br />
Let's say you've created a model for a stapler and now you want to configure it such that it acts as an object that the player could pick up. In this scenario, you would want to turn the stapler into a Mission Object, specifically an interactable object that the player will grab. To make this work, there is another way you could configure it, rather than adding many components into the pre-made Grab Interaction object.<br />
<br />
To start with, place the model into your level. We'll use the stapler as our example, so once the stapler has been placed into the level, the object should only have a couple of components (those that make it act as a static model). <br />
<br />
From here on, it's quite simple on configuring it to be an interactable object, just click on the Add Component button in the Inspector View for the object, and add the Mission Object component to the model as shown below.<br />
<br />
[[File:MissionObjectComp.png|400px|thumb|none|Adding the Mission Object component]]<br />
<br />
Next it will start off as a Generic Mission Object, just click on the drop down button for Mission Objective Type and change it to Interaction. Now you have manually created an interactable Mission Object! Look at the image below for what your object should now look like, highlighted in red are things you may want to consider changing, and also parts you will need to add in to make it function properly - since it hasn't been configured properly yet to act as an interactable (to see how to do that just read the [[Interactables|interactable items]] page).<br />
<br />
[[File:InteractableExample.png|400px|thumb|none|A manually-created interactable Mission Object]]</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Mission_Objects&diff=340Mission Objects2017-09-09T15:11:27Z<p>Dominic: typo</p>
<hr />
<div><br />
== Mission Objects ==<br />
<br />
Mission Objects, as the name suggests, are objects that are found within a level, with their purpose being to help the player complete the mission. Mission Objects can include many things like player spawns, interactable items, hackable devices, and triggers - all vital features that most levels will need.<br />
<br />
[[File:MissionObjects.png|400px|thumb|none|Examples of what some Mission Objects look like in Unity]]<br />
<br />
=== Triggers ===<br />
<br />
Triggers are Mission Objects which are used to start an event (like a conversation pop-up window) when a player walks into the trigger zone. They are a very commonly used Mission Object and have many uses, like starting vonversations, triggering a sound to play, mission objective updates, and much more. For a detailed guide on how to create triggers, and for what they can be used for, read the [[Triggers and Examples]] page.<br />
<br />
=== Spawns ===<br />
<br />
Spawns are a Mission Object simply used to tell the game where exactly to spawn into the level the characters that have been defined in the Mission Script - this includes the player, but also NPCs like Guards. For more on creating working spawns, read up on the [[Configuring Spawnpoints]] page.<br />
<br />
=== Interactable Objects ===<br />
<br />
Interactable objects are Mission Objects that are found within the level that the player can interact with, this includes objects that the player can grab and put into their Inventory, but also objects like door handles, and keycard scanners to gain entry into a room. Interactable objects will be commonly found within levels to progress through the objectives, and to progress through levels themselves. If you want to read on how to implement interactable objects into your level, read the [[Adding Interactable Objects]] page.<br />
<br />
=== Hackable Devices ===<br />
<br />
Hackable objects are a core feature of ''Off Grid'', they come in many shapes and sizes, including phones, cameras, refrigerators... the list is endless, anything can be turned into a hackable object and hackable objects are again a very common Mission Object, mainly because one of the main features of the game is to hack into things! Hackable devices are interacted with by using the SSH Connection app and the access, UI, and function of each hackable device can be very varied and easily modified by modders. For a detailed run-through of hackable devices, take a look at the [[Hackable Devices]] page.<br />
<br />
== Creating a Mission Object in your level ==<br />
<br />
=== Adding in a pre-made Mission Object ===<br />
<br />
In the Hierarchy tab, click Create and then navigate to the directory shown in the image below, then click on the Mission Object which you are looking to create. <br />
<br />
[[File:TriggerCreate.png|400px|thumb|none|Adding Mission Objects]]<br />
<br />
Depending on which Mission Object you want to create, you will need to take a different approach on editing the components. For example, creating a working spawn and creating a working trigger need different ways to make them functional. As such, if you want to see a detailed page for creating specific Mission Objects (like hackable objects, or triggers), look at the section for the Mission Object you are looking for above and follow the link to the page which show you how to implement the Mission Object into your level.<br />
<br />
=== Manually creating a Mission Object ===<br />
<br />
Let's say you've created a model for a stapler and now you want to configure it such that it acts as an object that the player could pick up. In this scenario, you would want to turn the stapler into a Mission Object, specifically an interactable object that the player will grab. To make this work, there is another way you could configure it, rather than adding many components into the pre-made Grab Interaction object.<br />
<br />
To start with, place the model into your level. We'll use the stapler as our example, so once the stapler has been placed into the level, the object should only have a couple of components (those that make it act as a static model). <br />
<br />
From here on, it's quite simple on configuring it to be an interactable object, just click on the Add Component button in the Inspector View for the object, and add the Mission Object component to the model as shown below.<br />
<br />
[[File:MissionObjectComp.png|400px|thumb|none|Adding the Mission Object component]]<br />
<br />
Next it will start off as a Generic Mission Object, just click on the drop down button for Mission Objective Type and change it to Interaction. Now you have manually created an interactable Mission Object! Look at the image below for what your object should now look like, highlighted in red are things you may want to consider changing, and also parts you will need to add in to make it function properly - since it hasn't been configured properly yet to act as an interactable (to see how to do that just read the [[Interactables|interactable items]] page).<br />
<br />
[[File:InteractableExample.png|400px|thumb|none|A manually-created interactable Mission Object]]</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Mission_Objects&diff=339Mission Objects2017-09-09T15:10:46Z<p>Dominic: Created page with " == Mission Objects == Mission Objects, as the name suggests, are objects that are found within a level, with their purpose being to help the player complete the mission. Mis..."</p>
<hr />
<div><br />
== Mission Objects ==<br />
<br />
Mission Objects, as the name suggests, are objects that are found within a level, with their purpose being to help the player complete the mission. Mission Objects can include many things like player spawns, interactable items, hackable devices, and triggers - all vital features that most levels will need.<br />
<br />
[[File:MissionObjects.png|400px|thumb|none|Examples of what some Mission Objects look like in Unity]]<br />
<br />
=== Triggers ===<br />
<br />
Triggers are Mission Objects which are used to start an event (like a conversation pop-up window) when a player walks into the trigger zone. They are a very commonly used Mission Objective and have many uses, like starting vonversations, triggering a sound to play, mission objective updates, and much more. For a detailed guide on how to create triggers, and for what they can be used for, read the [[Triggers and Examples]] page.<br />
<br />
=== Spawns ===<br />
<br />
Spawns are a Mission Object simply used to tell the game where exactly to spawn into the level the characters that have been defined in the Mission Script - this includes the player, but also NPCs like Guards. For more on creating working spawns, read up on the [[Configuring Spawnpoints]] page.<br />
<br />
=== Interactable Objects ===<br />
<br />
Interactable objects are Mission Objects that are found within the level that the player can interact with, this includes objects that the player can grab and put into their Inventory, but also objects like door handles, and keycard scanners to gain entry into a room. Interactable objects will be commonly found within levels to progress through the objectives, and to progress through levels themselves. If you want to read on how to implement interactable objects into your level, read the [[Adding Interactable Objects]] page.<br />
<br />
=== Hackable Devices ===<br />
<br />
Hackable objects are a core feature of ''Off Grid'', they come in many shapes and sizes, including phones, cameras, refrigerators... the list is endless, anything can be turned into a hackable object and hackable objects are again a very common Mission Object, mainly because one of the main features of the game is to hack into things! Hackable devices are interacted with by using the SSH Connection app and the access, UI, and function of each hackable device can be very varied and easily modified by modders. For a detailed run-through of hackable devices, take a look at the [[Hackable Devices]] page.<br />
<br />
== Creating a Mission Object in your level ==<br />
<br />
=== Adding in a pre-made Mission Object ===<br />
<br />
In the Hierarchy tab, click Create and then navigate to the directory shown in the image below, then click on the Mission Object which you are looking to create. <br />
<br />
[[File:TriggerCreate.png|400px|thumb|none|Adding Mission Objects]]<br />
<br />
Depending on which Mission Object you want to create, you will need to take a different approach on editing the components. For example, creating a working spawn and creating a working trigger need different ways to make them functional. As such, if you want to see a detailed page for creating specific Mission Objects (like hackable objects, or triggers), look at the section for the Mission Object you are looking for above and follow the link to the page which show you how to implement the Mission Object into your level.<br />
<br />
=== Manually creating a Mission Object ===<br />
<br />
Let's say you've created a model for a stapler and now you want to configure it such that it acts as an object that the player could pick up. In this scenario, you would want to turn the stapler into a Mission Object, specifically an interactable object that the player will grab. To make this work, there is another way you could configure it, rather than adding many components into the pre-made Grab Interaction object.<br />
<br />
To start with, place the model into your level. We'll use the stapler as our example, so once the stapler has been placed into the level, the object should only have a couple of components (those that make it act as a static model). <br />
<br />
From here on, it's quite simple on configuring it to be an interactable object, just click on the Add Component button in the Inspector View for the object, and add the Mission Object component to the model as shown below.<br />
<br />
[[File:MissionObjectComp.png|400px|thumb|none|Adding the Mission Object component]]<br />
<br />
Next it will start off as a Generic Mission Object, just click on the drop down button for Mission Objective Type and change it to Interaction. Now you have manually created an interactable Mission Object! Look at the image below for what your object should now look like, highlighted in red are things you may want to consider changing, and also parts you will need to add in to make it function properly - since it hasn't been configured properly yet to act as an interactable (to see how to do that just read the [[Interactables|interactable items]] page).<br />
<br />
[[File:InteractableExample.png|400px|thumb|none|A manually-created interactable Mission Object]]</div>Dominichttp://wiki.offgridthegame.com/index.php?title=File:InteractableExample.png&diff=338File:InteractableExample.png2017-09-09T14:34:17Z<p>Dominic: A manually created interactable object</p>
<hr />
<div>A manually created interactable object</div>Dominichttp://wiki.offgridthegame.com/index.php?title=File:MissionObjectComp.png&diff=337File:MissionObjectComp.png2017-09-09T14:21:36Z<p>Dominic: Adding the Mission Object component</p>
<hr />
<div>Adding the Mission Object component</div>Dominichttp://wiki.offgridthegame.com/index.php?title=File:MissionObjects.png&diff=336File:MissionObjects.png2017-09-09T13:51:34Z<p>Dominic: Examples of Mission Objects</p>
<hr />
<div>Examples of Mission Objects</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Triggers_and_Examples&diff=226Triggers and Examples2017-07-25T16:59:10Z<p>Dominic: /* Setting up Triggers */</p>
<hr />
<div><br />
== Setting up a Trigger ==<br />
<br />
Triggers are an important part of modding because they allow the level to react and change depending on the player's interactions with the level. They have many uses, including but not limited to: conversation prompts, objective updates, and some sounds which may be activated by the player like a floorboard creak or security barrier beep.<br />
<br />
Setting up a trigger is a fairly simple process. Firstly in the Hierarchy tab, click Create and navigate and click on Trigger as shown below, this will place the trigger into your level.<br />
<br />
[[File:TriggerCreate.png|400px|thumb|none|How to create the trigger]]<br />
<br />
Now in the Inspector view you will see that there are already some components added into the trigger object. At this point in time you might want to change the shape of the trigger to fit a doorway, or corridor either in the 3D View or in the Transform component of the trigger - you will want to bear in mind that as soon as the player has touched one part of the trigger zone, it will activate its function, hence make sure that it is suitably shaped so that it will only trigger where it is intended to be interacted with. You should also give the trigger an appropriate name relating to its function, for example I've called this trigger (see below) 'OfficeObjectiveStart', because as the name suggests, it will start the Office Objective when the player walks into the trigger zone. I've also made sure that 'Trigger Only Once' is ticked because I don't want the player to reactivate the objective if they have already completed it, nor do I want the objective to keep appearing on the player's screen.<br />
<br />
[[File:TriggerInspectorView.png|400px|thumb|none|An example of a possible objective trigger]]<br />
<br />
Now the trigger is set up, when the player walks into the trigger zone the trigger will be activated. The only problem at this point is that the trigger isn't actually set to do anything. For us to give it a function we will need to use some Lua, the Lua we use differs for what you are trying to achieve so look at the next section for specific triggers.<br />
<br />
== Examples of Triggers ==<br />
<br />
=== Triggering an Objective ===<br />
<br />
For this we'll use the trigger that we set up earlier in this guide, 'OfficeObjectiveStart'. In the Mission Script within the <code>mission</code> table you should have a table called <code>objectives</code> with code like the following:<br />
<br />
<syntaxhighlight source lang="lua" line start=52><br />
-- Mission objectives:<br />
objectives = {<br />
enterTheBuilding = {<br />
name = "Enter the building",<br />
onStart = function()<br />
print("Player must now enter the building")<br />
end,<br />
onCompleted = function()<br />
print("The player is now in the building!")<br />
end,<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
To start let's change the code to match what our objective a bit more. To start we can change the <code>enterTheBuilding</code> table to something like <code>enterOffice</code>. We can also change some of the text to match our objective of entering the office. Once you have personalised the code a bit, you should have something like what is shown below. The lines where text is printed is mainly for testing purposes and doesn't actually do anything that the player will see, as when the objective is started, only <code>Enter the building</code> will be outputted to the player's screen, and <code>Player must now enter the building</code> will instead be outputted to the console.<br />
<br />
<syntaxhighlight source lang="lua" line start=52><br />
-- Mission objectives:<br />
objectives = {<br />
enterOffice = {<br />
name = "Enter the office",<br />
onStart = function()<br />
print("Player must now enter the office")<br />
end,<br />
onCompleted = function()<br />
print("The player is now in the office!")<br />
end,<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The objective is now created, we only have one thing to do now, and that is to link the trigger we created in our level with this objective, and to do that, it only requires a small section of code which you can see below.<br />
<br />
<syntaxhighlight source lang="lua" line start=184><br />
MissionObjects["OfficeObjectiveStart"].OnTriggerEnter = function(name)<br />
if name == Player.GetName() then<br />
Mission.StartObjective(mission.objectives.enterOffice)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
The trigger that would be used in the code above would be <code>OfficeObjectiveStart</code> which is the one I created earlier. If you then wanted to add another objective trigger to follow this objective, you only need to change a small part to the code template which you can see below. We'll be assuming that this Alleyway Objective follows the Office Objective - remember to create the <code>enterAlleyway</code> table has been created in your Mission Script!<br />
<br />
<syntaxhighlight source lang="lua" line start=190><br />
MissionObjects["AlleywayObjBegin"].OnTriggerEnter = function(name)<br />
if name == Player.GetName() then<br />
Mission.CompleteObjective(mission.objectives.enterOffice)<br />
Mission.StartObjective(mission.objectives.enterAlleyway)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
As you can see, when the player enters the 'AlleywayObjBegin' trigger, it will check if your character is the one entering the trigger zone, and if it is your character it will firstly complete the Office Objective, and then begin the Alleyway Objective.<br />
<br />
=== Triggering Conversations and Sounds ===<br />
<br />
If you are interested in creating triggers for conversations and sounds, you might want to read up on the following pages.<br />
<br />
http://wiki.offgridthegame.com/index.php?title=Conversations<br />
<br />
http://wiki.offgridthegame.com/index.php?title=Triggering_Sounds</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Triggers_and_Examples&diff=225Triggers and Examples2017-07-25T16:58:51Z<p>Dominic: polishing</p>
<hr />
<div><br />
== Setting up Triggers ==<br />
<br />
Triggers are an important part of modding because they allow the level to react and change depending on the player's interactions with the level. They have many uses, including but not limited to: conversation prompts, objective updates, and some sounds which may be activated by the player like a floorboard creak or security barrier beep.<br />
<br />
Setting up a trigger is a fairly simple process. Firstly in the Hierarchy tab, click Create and navigate and click on Trigger as shown below, this will place the trigger into your level.<br />
<br />
[[File:TriggerCreate.png|400px|thumb|none|How to create the trigger]]<br />
<br />
Now in the Inspector view you will see that there are already some components added into the trigger object. At this point in time you might want to change the shape of the trigger to fit a doorway, or corridor either in the 3D View or in the Transform component of the trigger - you will want to bear in mind that as soon as the player has touched one part of the trigger zone, it will activate its function, hence make sure that it is suitably shaped so that it will only trigger where it is intended to be interacted with. You should also give the trigger an appropriate name relating to its function, for example I've called this trigger (see below) 'OfficeObjectiveStart', because as the name suggests, it will start the Office Objective when the player walks into the trigger zone. I've also made sure that 'Trigger Only Once' is ticked because I don't want the player to reactivate the objective if they have already completed it, nor do I want the objective to keep appearing on the player's screen.<br />
<br />
[[File:TriggerInspectorView.png|400px|thumb|none|An example of a possible objective trigger]]<br />
<br />
Now the trigger is set up, when the player walks into the trigger zone the trigger will be activated. The only problem at this point is that the trigger isn't actually set to do anything. For us to give it a function we will need to use some Lua, the Lua we use differs for what you are trying to achieve so look at the next section for specific triggers.<br />
<br />
== Examples of Triggers ==<br />
<br />
=== Triggering an Objective ===<br />
<br />
For this we'll use the trigger that we set up earlier in this guide, 'OfficeObjectiveStart'. In the Mission Script within the <code>mission</code> table you should have a table called <code>objectives</code> with code like the following:<br />
<br />
<syntaxhighlight source lang="lua" line start=52><br />
-- Mission objectives:<br />
objectives = {<br />
enterTheBuilding = {<br />
name = "Enter the building",<br />
onStart = function()<br />
print("Player must now enter the building")<br />
end,<br />
onCompleted = function()<br />
print("The player is now in the building!")<br />
end,<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
To start let's change the code to match what our objective a bit more. To start we can change the <code>enterTheBuilding</code> table to something like <code>enterOffice</code>. We can also change some of the text to match our objective of entering the office. Once you have personalised the code a bit, you should have something like what is shown below. The lines where text is printed is mainly for testing purposes and doesn't actually do anything that the player will see, as when the objective is started, only <code>Enter the building</code> will be outputted to the player's screen, and <code>Player must now enter the building</code> will instead be outputted to the console.<br />
<br />
<syntaxhighlight source lang="lua" line start=52><br />
-- Mission objectives:<br />
objectives = {<br />
enterOffice = {<br />
name = "Enter the office",<br />
onStart = function()<br />
print("Player must now enter the office")<br />
end,<br />
onCompleted = function()<br />
print("The player is now in the office!")<br />
end,<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The objective is now created, we only have one thing to do now, and that is to link the trigger we created in our level with this objective, and to do that, it only requires a small section of code which you can see below.<br />
<br />
<syntaxhighlight source lang="lua" line start=184><br />
MissionObjects["OfficeObjectiveStart"].OnTriggerEnter = function(name)<br />
if name == Player.GetName() then<br />
Mission.StartObjective(mission.objectives.enterOffice)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
The trigger that would be used in the code above would be <code>OfficeObjectiveStart</code> which is the one I created earlier. If you then wanted to add another objective trigger to follow this objective, you only need to change a small part to the code template which you can see below. We'll be assuming that this Alleyway Objective follows the Office Objective - remember to create the <code>enterAlleyway</code> table has been created in your Mission Script!<br />
<br />
<syntaxhighlight source lang="lua" line start=190><br />
MissionObjects["AlleywayObjBegin"].OnTriggerEnter = function(name)<br />
if name == Player.GetName() then<br />
Mission.CompleteObjective(mission.objectives.enterOffice)<br />
Mission.StartObjective(mission.objectives.enterAlleyway)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
As you can see, when the player enters the 'AlleywayObjBegin' trigger, it will check if your character is the one entering the trigger zone, and if it is your character it will firstly complete the Office Objective, and then begin the Alleyway Objective.<br />
<br />
=== Triggering Conversations and Sounds ===<br />
<br />
If you are interested in creating triggers for conversations and sounds, you might want to read up on the following pages.<br />
<br />
http://wiki.offgridthegame.com/index.php?title=Conversations<br />
<br />
http://wiki.offgridthegame.com/index.php?title=Triggering_Sounds</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Triggers_and_Examples&diff=224Triggers and Examples2017-07-25T16:48:19Z<p>Dominic: finished section</p>
<hr />
<div><br />
== Setting up Triggers ==<br />
<br />
Triggers are an important part of modding because they allow the level to react and change depending on the player's actions and interactions and they have many uses, including but not limited to: conversation prompts, objective updates, and some sounds which may be activated by the player like a floorboard creak or security barrier beep.<br />
<br />
Setting up a trigger is a simple process. Firstly in the Hierarchy tab, click Create and navigate and click on Trigger as shown below, this will place the trigger into your level.<br />
<br />
[[File:TriggerCreate.png|400px|thumb|none|How to create the trigger]]<br />
<br />
Now in the Inspector view you will see that there are already some components added into the trigger object. At this point in time you might want to change the shape of the trigger to fit a doorway, or corridor either in the 3D View or in the Transform component bear in mind that as soon as the player has touched one part of the trigger zone, it will activate its function, hence make sure that it is suitably shaped so that it will only trigger where it is intended to be interacted with. You should also give the trigger an appropriate name relating to its function, for example I've called this trigger (see below) OfficeObjectiveStart, because as the name suggests, it will start the Office Objective when the player walks into the trigger zone. I've also made sure that Trigger Only Once is ticked because I don't want the player to reactivate the objective if they have already completed it.<br />
<br />
[[File:TriggerInspectorView.png|400px|thumb|none|An example of a possible objective trigger]]<br />
<br />
Now the trigger is set up, when the player walks into the trigger zone the trigger will be activated. The only problem at this point is that the trigger isn't actually set to do anything. For us to give it a function we will need to use some Lua, the Lua we use differs for what you are trying to achieve so look at the next section for specific triggers.<br />
<br />
== Examples of Triggers ==<br />
<br />
=== Triggering an objective ===<br />
<br />
For this we'll use the trigger that we set up earlier in this guide, 'OfficeObjectiveStart'. In the Mission Script within the <code>mission</code> table you should have a table called <code>objectives</code> with code like the following:<br />
<br />
<syntaxhighlight source lang="lua" line start=52><br />
-- Mission objectives:<br />
objectives = {<br />
enterTheBuilding = {<br />
name = "Enter the building",<br />
onStart = function()<br />
print("Player must now enter the building")<br />
end,<br />
onCompleted = function()<br />
print("The player is now in the building!")<br />
end,<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
To start let's change the code to match what our objective a bit more. To start we can change the <code>enterTheBuilding</code> table to something like <code>enterOffice</code>. We can also change some of the text to match our objective of entering the office. Once you have personalised the code a bit, you should have something like what is shown below. The lines where text is printed is mainly for testing purposes and doesn't actually do anything that the player will see, as when the objective is started, only <code>Enter the building</code> will be outputted to the player's HUD, and <code>Player must now enter the building</code> will instead be outputted to the console.<br />
<br />
<syntaxhighlight source lang="lua" line start=52><br />
-- Mission objectives:<br />
objectives = {<br />
enterOffice = {<br />
name = "Enter the office",<br />
onStart = function()<br />
print("Player must now enter the office")<br />
end,<br />
onCompleted = function()<br />
print("The player is now in the office!")<br />
end,<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The objective is now created, we only have one thing to do now, and that is to link the trigger we created in our level with this objective, and to do that, it only requires a small section of code which you can see below.<br />
<br />
<syntaxhighlight source lang="lua" line start=184><br />
MissionObjects["OfficeObjectiveStart"].OnTriggerEnter = function(name)<br />
if name == Player.GetName() then<br />
Mission.StartObjective(mission.objectives.enterOffice)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
The trigger that would be used in the code above would be <code>OfficeObjectiveStart</code> which is the one I created earlier. If you then wanted to add another objective trigger to follow this objective, you only need to change a small part to the code template which you can see below. We'll be assuming that this Alleyway Objective follows the Office Objective, and make sure that the enterAlleyway table has been created in the Mission Script!<br />
<br />
<syntaxhighlight source lang="lua" line start=184><br />
MissionObjects["AlleywayObjBegin"].OnTriggerEnter = function(name)<br />
if name == Player.GetName() then<br />
Mission.CompleteObjective(mission.objectives.enterOffice)<br />
Mission.StartObjective(mission.objectives.enterAlleyway)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
As you can see, when the "AlleywayObjBegin" trigger is entered, it will check to see if your character is the one entering, and if it is, it will firstly complete the Office Objective, and then begin the next objective.<br />
<br />
=== Triggering conversations and sounds ===<br />
<br />
If you are interested in creating triggers for conversations and sounds, you might want to read up on the following pages.<br />
<br />
http://wiki.offgridthegame.com/index.php?title=Conversations<br />
<br />
http://wiki.offgridthegame.com/index.php?title=Triggering_Sounds</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Triggers_and_Examples&diff=223Triggers and Examples2017-07-25T16:09:26Z<p>Dominic: tidy up</p>
<hr />
<div><br />
== Setting up Triggers ==<br />
<br />
Triggers are an important part of modding because they allow the level to react and change depending on the player's actions and interactions and they have many uses, including but not limited to: conversation prompts, objective updates, and some sounds which may be activated by the player like a floorboard creak or security barrier beep.<br />
<br />
Setting up a trigger is a simple process. Firstly in the Hierarchy tab, click Create and navigate and click on Trigger as shown below, this will place the trigger into your level.<br />
<br />
[[File:TriggerCreate.png|400px|thumb|none|How to create the trigger]]<br />
<br />
Now in the Inspector view you will see that there are already some components added into the trigger object. At this point in time you might want to change the shape of the trigger to fit a doorway, or corridor either in the 3D View or in the Transform component bear in mind that as soon as the player has touched one part of the trigger zone, it will activate its function, hence make sure that it is suitably shaped so that it will only trigger where it is intended to be interacted with. You should also give the trigger an appropriate name relating to its function, for example I've called this trigger (see below) OfficeObjectiveStart, because as the name suggests, it will start the Office Objective when the player walks into the trigger zone. I've also made sure that Trigger Only Once is ticked because I don't want the player to reactivate the objective if they have already completed it.<br />
<br />
[[File:TriggerInspectorView.png|400px|thumb|none|An example of a possible objective trigger]]<br />
<br />
Now the trigger is set up, when the player walks into the trigger zone the trigger will be activated. The only problem at this point is that the trigger isn't actually set to do anything. For us to give it a function we will need to use some Lua, the Lua we use differs for what you are trying to achieve so look at the next section for specific triggers.<br />
<br />
== Examples of Triggers ==<br />
<br />
bobobobobobobo<br />
<br />
=== Triggering an objective ===<br />
<br />
bobobobobobobo<br />
<br />
=== Triggering a conversation ===<br />
<br />
bobobobobobobo<br />
<br />
=== Triggering sounds ===<br />
<br />
merge?<br />
<br />
http://wiki.offgridthegame.com/index.php?title=Triggering_Sounds</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Triggers_and_Examples&diff=222Triggers and Examples2017-07-25T16:08:03Z<p>Dominic: /* Examples of Triggers */</p>
<hr />
<div>== Setting up Triggers ==<br />
Triggers are an important part of modding because they allow the level to react and change depending on the player's actions and interactions and they have many uses, including but not limited to: conversation prompts, objective updates, and some sounds which may be activated by the player like a floorboard creak or security barrier beep.<br />
<br />
Setting up a trigger is a simple process. Firstly in the Hierarchy tab, click Create and navigate and click on Trigger as shown below, this will place the trigger into your level.<br />
<br />
[[File:TriggerCreate.png|400px|thumb|none|How to create the trigger]]<br />
<br />
Now in the Inspector view you will see that there are already some components added into the trigger object. At this point in time you might want to change the shape of the trigger to fit a doorway, or corridor either in the 3D View or in the Transform component bear in mind that as soon as the player has touched one part of the trigger zone, it will activate its function, hence make sure that it is suitably shaped so that it will only trigger where it is intended to be interacted with. You should also give the trigger an appropriate name relating to its function, for example I've called this trigger (see below) OfficeObjectiveStart, because as the name suggests, it will start the Office Objective when the player walks into the trigger zone. I've also made sure that Trigger Only Once is ticked because I don't want the player to reactivate the objective if they have already completed it.<br />
<br />
[[File:TriggerInspectorView.png|400px|thumb|none|An example of a possible objective trigger]]<br />
<br />
Now the trigger is set up, when the player walks into the trigger zone the trigger will be activated. The only problem at this point is that the trigger isn't actually set to do anything. For us to give it a function we will need to use some Lua, the Lua we use differs for what you are trying to achieve so look at the next section for specific triggers.<br />
<br />
== Examples of Triggers ==<br />
<br />
bobobobobobobo<br />
<br />
=== Triggering an objective ===<br />
<br />
bobobobobobobo<br />
<br />
=== Triggering a conversation ===<br />
<br />
bobobobobobobo<br />
<br />
=== Triggering sounds ===<br />
<br />
merge?<br />
<br />
http://wiki.offgridthegame.com/index.php?title=Triggering_Sounds</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Triggers_and_Examples&diff=221Triggers and Examples2017-07-25T16:06:26Z<p>Dominic: tidy up</p>
<hr />
<div>== Setting up Triggers ==<br />
Triggers are an important part of modding because they allow the level to react and change depending on the player's actions and interactions and they have many uses, including but not limited to: conversation prompts, objective updates, and some sounds which may be activated by the player like a floorboard creak or security barrier beep.<br />
<br />
Setting up a trigger is a simple process. Firstly in the Hierarchy tab, click Create and navigate and click on Trigger as shown below, this will place the trigger into your level.<br />
<br />
[[File:TriggerCreate.png|400px|thumb|none|How to create the trigger]]<br />
<br />
Now in the Inspector view you will see that there are already some components added into the trigger object. At this point in time you might want to change the shape of the trigger to fit a doorway, or corridor either in the 3D View or in the Transform component bear in mind that as soon as the player has touched one part of the trigger zone, it will activate its function, hence make sure that it is suitably shaped so that it will only trigger where it is intended to be interacted with. You should also give the trigger an appropriate name relating to its function, for example I've called this trigger (see below) OfficeObjectiveStart, because as the name suggests, it will start the Office Objective when the player walks into the trigger zone. I've also made sure that Trigger Only Once is ticked because I don't want the player to reactivate the objective if they have already completed it.<br />
<br />
[[File:TriggerInspectorView.png|400px|thumb|none|An example of a possible objective trigger]]<br />
<br />
Now the trigger is set up, when the player walks into the trigger zone the trigger will be activated. The only problem at this point is that the trigger isn't actually set to do anything. For us to give it a function we will need to use some Lua, the Lua we use differs for what you are trying to achieve so look at the next section for specific triggers.<br />
<br />
== Examples of Triggers ==<br />
bobobobobobobo<br />
<br />
=== Triggering an objective ===<br />
bobobobobobobo<br />
<br />
=== Triggering a conversation ===<br />
bobobobobobobo</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Triggers_and_Examples&diff=220Triggers and Examples2017-07-25T16:04:19Z<p>Dominic: finished section</p>
<hr />
<div>== Setting up Triggers ==<br />
Triggers are an important part of modding because they allow the level to react and change depending on the player's actions and interactions and they have many uses, including but not limited to: conversation prompts, objective updates, and some sounds which may be activated by the player like a floorboard creak or security barrier beep.<br />
<br />
Setting up a trigger is a simple process. Firstly in the Hierarchy tab, click Create and navigate and click on Trigger as shown below, this will place the trigger entity into your level.<br />
<br />
[[File:TriggerCreate.png|400px|thumb|none|How to create the trigger entity]]<br />
<br />
Now in the Inspector view you will see that there are already some components added into the trigger object. At this point in time you might want to change the shape of the trigger to fit a doorway, or corridor either in the 3D View or in the Transform component bear in mind that as soon as the player has touched one part of the trigger zone, it will activate its function, hence make sure that it is suitably shaped so that it will only trigger where it is intended to be interacted with. You should also give the trigger an appropriate name relating to its function, for example I've called this trigger (see below) OfficeObjectiveStart, because as the name suggests, it will start the Office Objective when the player walks into the trigger zone. I've also made sure that Trigger Only Once is ticked because I don't want the player to reactivate the objective if they have already completed it.<br />
<br />
[[File:TriggerInspectorView.png|400px|thumb|none|An example of a possible objective trigger]]<br />
<br />
Now the trigger is set up, when the player walks into the trigger zone the trigger will be activated. The only problem at this point is that the trigger isn't actually set to do anything. For us to do this we will need to use some Lua, it differs for what you are trying to achieve so look at the next section for specific triggers.<br />
<br />
== Examples of Triggers ==<br />
bobobobobobobo<br />
<br />
=== Triggering an objective ===<br />
bobobobobobobo<br />
<br />
=== Triggering a conversation ===<br />
bobobobobobobo</div>Dominichttp://wiki.offgridthegame.com/index.php?title=File:TriggerInspectorView.png&diff=219File:TriggerInspectorView.png2017-07-25T15:58:43Z<p>Dominic: </p>
<hr />
<div></div>Dominichttp://wiki.offgridthegame.com/index.php?title=File:TriggerCreate.png&diff=218File:TriggerCreate.png2017-07-25T15:45:29Z<p>Dominic: </p>
<hr />
<div></div>Dominichttp://wiki.offgridthegame.com/index.php?title=Triggers_and_Examples&diff=217Triggers and Examples2017-07-25T15:35:49Z<p>Dominic: /* Setting up Triggers */</p>
<hr />
<div>== Setting up Triggers ==<br />
Triggers are an important part of modding because they allow the level to react and change depending on the player's actions and interactions and they have many uses, including but not limited to: conversation prompts, objective updates, and some sounds which may be activated by the player like a floorboard creak or security barrier beep.<br />
<br />
Setting up a trigger is a simple process. Firstly you will want to<br />
<br />
Hierarchy, adjust transform, rename, no function, see below.<br />
<br />
== Examples of Triggers ==<br />
bobobobobobobo<br />
<br />
=== Triggering an objective ===<br />
bobobobobobobo<br />
<br />
=== Triggering a conversation ===<br />
bobobobobobobo</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Triggers_and_Examples&diff=216Triggers and Examples2017-07-25T15:34:09Z<p>Dominic: /* Setting up Triggers */</p>
<hr />
<div>== Setting up Triggers ==<br />
Triggers are an important part of modding because they allow the level to react and change depending on the player's actions and interactions and they have many uses, including but not limited to: conversation prompts, objective updates, and '''EXAMPLE'''.<br />
<br />
Setting up a trigger is a simple process. Firstly you will want to<br />
<br />
Hierarchy, adjust transform, rename, no function, see below.<br />
<br />
== Examples of Triggers ==<br />
bobobobobobobo<br />
<br />
=== Triggering an objective ===<br />
bobobobobobobo<br />
<br />
=== Triggering a conversation ===<br />
bobobobobobobo</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Setting_up_Doors&diff=215Setting up Doors2017-07-25T15:28:48Z<p>Dominic: /* Changing the opening animation direction */</p>
<hr />
<div><br />
== Adding the door into your scene ==<br />
<br />
Firstly you need to add the door prefab to your level and position it as you'd like it to appear in-game. To do this in your Project Folder you need to navigate to the Doors folder (see below) and choose the prefab which you prefer by dragging it into your Scene. For this tutorial we'll use a Swinging Door with Scanners so that once set up properly, it will require a correct ID Card to open. Once you have placed and positioned the door in a doorway you will be able to see it in-game and it should open if you used a door prefab - you will know if you have used the correct prefab because when in the Inspector view if you click on your door, it should already have an Animator and Door Script component.<br />
<br />
[[File:DoorPrefabFolder.png|400px|thumb|none|The folder that contains the door prefabs]]<br />
<br />
== Getting access to a locked door by using hackable objects ==<br />
<br />
If you wanted your door to be locked when you begin playing your level, click on your door and in the Inspector view under Door (Script) tick the box next to IsLocked. Now when you load into your level your player will not be able to open the door unless they have key access to the Zone Default.<br />
<br />
Next you will want to set the Zone of the door to something unique, for now we'll call it "admin". <br />
<br />
[[File:DoorState.png|400px|thumb|none|Here you can change the Zone of the door, and whether it is locked or open upon starting your level in-game]]<br />
<br />
Now we will want to create a hackable object (link?) in both our scene and our mission script. Once you have set up and connected the hackable object to a network, as well as [[Mission Scripting#Adding in Networks|connecting the door to the network]] we can now edit the hackable object's script to give us access to a specific Zone that a door is using.<br />
<br />
In this guide, 'adminkey' will be the key that is related to the Zone 'admin' to make sure this has been set up check your mission script has this line of code: <code>Doors.SetZoneKeys("admin", {"adminkey"})</code>. By default the player will not have access the key "adminkey" unless we give it to the player straight away in SetupMission(). However we don't want the key to be given to the player, we want the player to gain access to the key by having to hack into a device. <br />
<br />
We will use the same variable and file names as the [[Mission Scripting]] tutorial. This will include the following:<br />
<br />
<syntaxhighlight source lang="lua" line start=66><br />
devices = {<br />
laptop = {<br />
internalName = "laptop",<br />
script = "Scripts/Devices/laptop.lua",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Our device will be in the table <code>laptop</code>, and the script for the device will be found in <code>laptop.lua</code>. It will be assumed that the hackable device has been added to SetupMission(), check the [[Mission Scripting]] tutorial if you need help on this.<br />
<br />
In the <code>laptop.lua</code> file we will have the following code.<br />
<br />
<syntaxhighlight source lang="lua" line start=1><br />
device = {<br />
canAccess = function()<br />
return true<br />
end,<br />
gui = {<br />
type = "ncurses",<br />
updateEveryFrame = false,<br />
header = [[Office door system]],<br />
backgroundColour = {0.0, 0.0196, 0.7765},<br />
highlightColour = {0.8863, 0.0, 0.0627},<br />
buttons = {<br />
{<br />
name = "user",<br />
subButtons = {<br />
{<br />
name = "admin",<br />
},<br />
{<br />
name = "internship at security department.doc",<br />
},<br />
},<br />
},<br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
},<br />
},<br />
},<br />
}<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
At this point the device will be hackable though the player will not be able to actually trigger anything from hacking into the device. To do this you will want to add this below a sub-button, we'll put it below the <code>"admin_door_access.pgp"</code> sub-button.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
print("clicked")<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Finally we want it so that when the <code>"admin_door_access.pgp"</code> is clicked, the player gets access to the key "adminkey", which has been set up to open doors of the Zone "admin" - essentially meaning that the player will be then be able to open and close the door we have created. To do this we just add a small line of code inside the function as shown below.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
RunMissionCommand([[Doors.AssignKeyToCharacter("adminkey", mission.characters.joe)]])<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
This is assigning the key <code>"adminkey"</code> to the character <code>joe</code> which if you remember is the player: you! So now if you try and interact with your door which is of the Zone "admin", it will unlock and open like in the GIF below!<br />
<br />
[[File:KeycardDoorOpen.gif|400px|thumb|none|(Click to see) The door opening as seen in-game]]<br />
<br />
== Changing the opening animation direction ==<br />
<br />
If for example you are in a narrow corridor and you want to open a door, it would be convenient for the door to open outwards away from you, otherwise the door will push towards and into you, disrupting your movement and potentially your vision ahead.<br />
<br />
To change the direction of which the door opens is quite simple, though the procedure slightly differs between doors with and without keycard scanners.<br />
<br />
=== For doors without keycard scanners ===<br />
Firstly you need to click on the handle of your door - make sure you are selecting the handle which is the one that the player will be interacting with to open the door. Then under the 'Mission Object (Script)' click on the tickbox underneath the 'On Interaction Start' (see below), it may or may not be ticked already, either way reversing its current status will reverse the opening direction. If the player might interact with the door again, you should ideally do the exact same to the handle on the other side of the door. <br />
<br />
[[File:DoorHandleOpen.png|400px|thumb|none|The red circle shows the tickbox that you should click to reverse the opening direction of the door when interacting with that handle]]<br />
<br />
=== For doors with keycard scanners ===<br />
<br />
Likewise to doors without keycard scanners, it is just a matter of ticking or unticking a tickbox, however this time we are selecting the actual keycard scanner and not the handle. If the door currently opens inwards towards the player, select the keycard scanner which the player is interacting with and you should see components in the Inspector view similar to the ones seen in the picture below. All you do now is click on the tickbox for 'Is Front' (circled in red below), so if the tickbox was ticked, you just need to untick it, and vice versa for if it was unticked.<br />
<br />
[[File:ScannerOpen.png|400px|thumb|none|The red circle shows the tickbox that you should click to reverse the opening direction of the door when interacting with that keycard scanner]]</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Setting_up_Doors&diff=214Setting up Doors2017-07-25T15:24:18Z<p>Dominic: fixed grammar</p>
<hr />
<div><br />
== Adding the door into your scene ==<br />
<br />
Firstly you need to add the door prefab to your level and position it as you'd like it to appear in-game. To do this in your Project Folder you need to navigate to the Doors folder (see below) and choose the prefab which you prefer by dragging it into your Scene. For this tutorial we'll use a Swinging Door with Scanners so that once set up properly, it will require a correct ID Card to open. Once you have placed and positioned the door in a doorway you will be able to see it in-game and it should open if you used a door prefab - you will know if you have used the correct prefab because when in the Inspector view if you click on your door, it should already have an Animator and Door Script component.<br />
<br />
[[File:DoorPrefabFolder.png|400px|thumb|none|The folder that contains the door prefabs]]<br />
<br />
== Getting access to a locked door by using hackable objects ==<br />
<br />
If you wanted your door to be locked when you begin playing your level, click on your door and in the Inspector view under Door (Script) tick the box next to IsLocked. Now when you load into your level your player will not be able to open the door unless they have key access to the Zone Default.<br />
<br />
Next you will want to set the Zone of the door to something unique, for now we'll call it "admin". <br />
<br />
[[File:DoorState.png|400px|thumb|none|Here you can change the Zone of the door, and whether it is locked or open upon starting your level in-game]]<br />
<br />
Now we will want to create a hackable object (link?) in both our scene and our mission script. Once you have set up and connected the hackable object to a network, as well as [[Mission Scripting#Adding in Networks|connecting the door to the network]] we can now edit the hackable object's script to give us access to a specific Zone that a door is using.<br />
<br />
In this guide, 'adminkey' will be the key that is related to the Zone 'admin' to make sure this has been set up check your mission script has this line of code: <code>Doors.SetZoneKeys("admin", {"adminkey"})</code>. By default the player will not have access the key "adminkey" unless we give it to the player straight away in SetupMission(). However we don't want the key to be given to the player, we want the player to gain access to the key by having to hack into a device. <br />
<br />
We will use the same variable and file names as the [[Mission Scripting]] tutorial. This will include the following:<br />
<br />
<syntaxhighlight source lang="lua" line start=66><br />
devices = {<br />
laptop = {<br />
internalName = "laptop",<br />
script = "Scripts/Devices/laptop.lua",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Our device will be in the table <code>laptop</code>, and the script for the device will be found in <code>laptop.lua</code>. It will be assumed that the hackable device has been added to SetupMission(), check the [[Mission Scripting]] tutorial if you need help on this.<br />
<br />
In the <code>laptop.lua</code> file we will have the following code.<br />
<br />
<syntaxhighlight source lang="lua" line start=1><br />
device = {<br />
canAccess = function()<br />
return true<br />
end,<br />
gui = {<br />
type = "ncurses",<br />
updateEveryFrame = false,<br />
header = [[Office door system]],<br />
backgroundColour = {0.0, 0.0196, 0.7765},<br />
highlightColour = {0.8863, 0.0, 0.0627},<br />
buttons = {<br />
{<br />
name = "user",<br />
subButtons = {<br />
{<br />
name = "admin",<br />
},<br />
{<br />
name = "internship at security department.doc",<br />
},<br />
},<br />
},<br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
},<br />
},<br />
},<br />
}<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
At this point the device will be hackable though the player will not be able to actually trigger anything from hacking into the device. To do this you will want to add this below a sub-button, we'll put it below the <code>"admin_door_access.pgp"</code> sub-button.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
print("clicked")<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Finally we want it so that when the <code>"admin_door_access.pgp"</code> is clicked, the player gets access to the key "adminkey", which has been set up to open doors of the Zone "admin" - essentially meaning that the player will be then be able to open and close the door we have created. To do this we just add a small line of code inside the function as shown below.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
RunMissionCommand([[Doors.AssignKeyToCharacter("adminkey", mission.characters.joe)]])<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
This is assigning the key <code>"adminkey"</code> to the character <code>joe</code> which if you remember is the player: you! So now if you try and interact with your door which is of the Zone "admin", it will unlock and open like in the GIF below!<br />
<br />
[[File:KeycardDoorOpen.gif|400px|thumb|none|(Click to see) The door opening as seen in-game]]<br />
<br />
== Changing the opening animation direction ==<br />
<br />
If for example you are in a narrow corridor and you want to open a door, it would be convenient for the door to open outwards away from you, otherwise the door will push towards and into you, disrupting your movement and potentially your vision ahead.<br />
<br />
To change the direction of which the door opens is quite simple, the procedure slightly differs between doors with and without keycard scanners.<br />
<br />
=== For doors without keycard scanners ===<br />
Firstly you need to click on the handle of your door - make sure you are selecting the handle which is the one that the player will be interacting with to open the door. Then under the 'Mission Object (Script)' click on the tickbox underneath the 'On Interaction Start' (see below), it may or may not be ticked already, either way reversing its current status will reverse the opening direction. If the player might interact with the door again, you should ideally do the exact same to the handle on the other side of the door. <br />
<br />
[[File:DoorHandleOpen.png|400px|thumb|none|The red circle shows the tickbox that you should click to reverse the opening direction of the door when interacting with that handle]]<br />
<br />
=== For doors with keycard scanners ===<br />
<br />
Likewise to doors without keycard scanners, it is just a matter of ticking or unticking a tickbox, however this time we are selecting the actual keycard scanner and not the handle. If the door currently opens inwards towards the player, select the keycard scanner which the player is interacting with and you should see components in the Inspector view similar to the ones seen in the picture below. All you do now is click on the tickbox for 'Is Front' (circled in red below), so if the tickbox was ticked, you just need to untick it, and vice versa for if it was unticked.<br />
<br />
[[File:ScannerOpen.png|400px|thumb|none|The red circle shows the tickbox that you should click to reverse the opening direction of the door when interacting with that keycard scanner]]</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Triggers_and_Examples&diff=213Triggers and Examples2017-07-25T15:01:12Z<p>Dominic: </p>
<hr />
<div>== Setting up Triggers ==<br />
dodododododo<br />
<br />
== Examples of Triggers ==<br />
bobobobobobobo<br />
<br />
=== Triggering an objective ===<br />
bobobobobobobo<br />
<br />
=== Triggering a conversation ===<br />
bobobobobobobo</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Triggers_and_Examples&diff=212Triggers and Examples2017-07-25T15:00:29Z<p>Dominic: Created page with "== Setting up Triggers == dodododododo == Uses of Triggers == bobobobobobobo === Triggering an objective === bobobobobobobo === Triggering a conversation === bobobobobobobo"</p>
<hr />
<div>== Setting up Triggers ==<br />
dodododododo<br />
<br />
== Uses of Triggers ==<br />
bobobobobobobo<br />
<br />
=== Triggering an objective ===<br />
bobobobobobobo<br />
<br />
=== Triggering a conversation ===<br />
bobobobobobobo</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Setting_up_Doors&diff=207Setting up Doors2017-06-30T13:57:09Z<p>Dominic: /* Changing the opening animation direction */</p>
<hr />
<div><br />
== Adding the door into your scene ==<br />
<br />
Firstly you need to add the door prefab to your level and position it as you'd like it to appear in-game. To do this in your Project Folder you need to navigate to the Doors folder (see below) and choose the prefab which you prefer by dragging it into your Scene. For this tutorial we'll use a Swinging Door with Scanners so that once set up properly, it will require a correct ID Card to open. Once you have placed and positioned the door in a doorway you will be able to see it in-game and it should open if you used a door prefab - you will know if you have used the correct prefab because when in the Inspector view if you click on your door, it should already have an Animator and Door Script component.<br />
<br />
[[File:DoorPrefabFolder.png|400px|thumb|none|The folder that contains the door prefabs]]<br />
<br />
== Getting access to a locked door by using hackable objects ==<br />
<br />
If you wanted your door to be locked when you begin playing your level, click on your door and in the Inspector view under Door (Script) tick the box next to IsLocked. Now when you load into your level your player will not be able to open the door unless they have key access to the Zone Default.<br />
<br />
Next you will want to set Zone of the door to something unique, for now we'll call it "admin". <br />
<br />
[[File:DoorState.png|400px|thumb|none|Here you can change the Zone of the door, and whether it is locked or open upon starting your level in-game]]<br />
<br />
Now we will want to create a hackable object (link?) in both our scene and our mission script. Once you have set up and connected the hackable object to a network, as well as [[Mission Scripting#Adding in Networks|connecting the door to the network]] we can now edit the hackable object's script to give us access to a specific Zone that a door is using.<br />
<br />
In this guide, 'adminkey' will be the key that is related to the Zone 'admin' to make sure this has been set up check your mission script has this line of code: <code>Doors.SetZoneKeys("admin", {"adminkey"})</code>. By default the player will not have access the key "adminkey" unless we give it to the player straight away in SetupMission(). However we don't want the key to be given to the player, we want the player to gain access to the key by having to hack into a device. <br />
<br />
We will use the same variable and file names as the [[Mission Scripting]] tutorial. This will include the following:<br />
<br />
<syntaxhighlight source lang="lua" line start=66><br />
devices = {<br />
laptop = {<br />
internalName = "laptop",<br />
script = "Scripts/Devices/laptop.lua",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Our device will be in the table <code>laptop</code>, and the script for the device will be found in <code>laptop.lua</code>. It will be assumed that the hackable device has been added to SetupMission(), check the [[Mission Scripting]] tutorial if you need help on this.<br />
<br />
In the <code>laptop.lua</code> file we will have the following code.<br />
<br />
<syntaxhighlight source lang="lua" line start=1><br />
device = {<br />
canAccess = function()<br />
return true<br />
end,<br />
gui = {<br />
type = "ncurses",<br />
updateEveryFrame = false,<br />
header = [[Office door system]],<br />
backgroundColour = {0.0, 0.0196, 0.7765},<br />
highlightColour = {0.8863, 0.0, 0.0627},<br />
buttons = {<br />
{<br />
name = "user",<br />
subButtons = {<br />
{<br />
name = "admin",<br />
},<br />
{<br />
name = "internship at security department.doc",<br />
},<br />
},<br />
},<br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
},<br />
},<br />
},<br />
}<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
At this point the device will be hackable though the player will not be able to actually trigger anything from hacking into the device. To do this you will want to add this below a sub-button, we'll put it below the <code>"admin_door_access.pgp"</code> sub-button.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
print("clicked")<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Finally we want it so that when the <code>"admin_door_access.pgp"</code> is clicked, the player gets access to the key "adminkey", which has been set up to open doors of the Zone "admin" - essentially meaning that the player will be then be able to open and close the door we have created. To do this we just add a small line of code inside the function as shown below.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
RunMissionCommand([[Doors.AssignKeyToCharacter("adminkey", mission.characters.joe)]])<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
This is assigning the key <code>"adminkey"</code> to the character <code>joe</code> which if you remember is the player: you! So now if you try and interact with your door which is of the Zone "admin", it will unlock and open like in the GIF below!<br />
<br />
[[File:KeycardDoorOpen.gif|400px|thumb|none|(Click to see) The door opening as seen in-game]]<br />
<br />
== Changing the opening animation direction ==<br />
<br />
If for example you are in a narrow corridor and you want to open a door, it would be convenient for the door to open outwards away from you, otherwise the door will push towards and into you, disrupting your movement and potentially your vision ahead.<br />
<br />
To change the direction of which the door opens is quite simple, the procedure slightly differs between doors with and without keycard scanners.<br />
<br />
=== For doors without keycard scanners ===<br />
Firstly you need to click on the handle of your door - make sure you are selecting the handle which is the one that the player will be interacting with to open the door. Then under the 'Mission Object (Script)' click on the tickbox underneath the 'On Interaction Start' (see below), it may or may not be ticked already, either way reversing its current status will reverse the opening direction. If the player might interact with the door again, you should ideally do the exact same to the handle on the other side of the door. <br />
<br />
[[File:DoorHandleOpen.png|400px|thumb|none|The red circle shows the tickbox that you should click to reverse the opening direction of the door when interacting with that handle]]<br />
<br />
=== For doors with keycard scanners ===<br />
<br />
Likewise to doors without keycard scanners, it is just a matter of ticking or unticking a tickbox, however this time we are selecting the actual keycard scanner and not the handle. If the door currently opens inwards towards the player, select the keycard scanner which the player is interacting with and you should see components in the Inspector view similar to the ones seen in the picture below. All you do now is click on the tickbox for 'Is Front' (circled in red below), so if the tickbox was ticked, you just need to untick it, and vice versa for if it was unticked.<br />
<br />
[[File:ScannerOpen.png|400px|thumb|none|The red circle shows the tickbox that you should click to reverse the opening direction of the door when interacting with that keycard scanner]]</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Setting_up_Doors&diff=206Setting up Doors2017-06-30T13:19:25Z<p>Dominic: /* Getting access to a locked door by using hackable objects */</p>
<hr />
<div><br />
== Adding the door into your scene ==<br />
<br />
Firstly you need to add the door prefab to your level and position it as you'd like it to appear in-game. To do this in your Project Folder you need to navigate to the Doors folder (see below) and choose the prefab which you prefer by dragging it into your Scene. For this tutorial we'll use a Swinging Door with Scanners so that once set up properly, it will require a correct ID Card to open. Once you have placed and positioned the door in a doorway you will be able to see it in-game and it should open if you used a door prefab - you will know if you have used the correct prefab because when in the Inspector view if you click on your door, it should already have an Animator and Door Script component.<br />
<br />
[[File:DoorPrefabFolder.png|400px|thumb|none|The folder that contains the door prefabs]]<br />
<br />
== Getting access to a locked door by using hackable objects ==<br />
<br />
If you wanted your door to be locked when you begin playing your level, click on your door and in the Inspector view under Door (Script) tick the box next to IsLocked. Now when you load into your level your player will not be able to open the door unless they have key access to the Zone Default.<br />
<br />
Next you will want to set Zone of the door to something unique, for now we'll call it "admin". <br />
<br />
[[File:DoorState.png|400px|thumb|none|Here you can change the Zone of the door, and whether it is locked or open upon starting your level in-game]]<br />
<br />
Now we will want to create a hackable object (link?) in both our scene and our mission script. Once you have set up and connected the hackable object to a network, as well as [[Mission Scripting#Adding in Networks|connecting the door to the network]] we can now edit the hackable object's script to give us access to a specific Zone that a door is using.<br />
<br />
In this guide, 'adminkey' will be the key that is related to the Zone 'admin' to make sure this has been set up check your mission script has this line of code: <code>Doors.SetZoneKeys("admin", {"adminkey"})</code>. By default the player will not have access the key "adminkey" unless we give it to the player straight away in SetupMission(). However we don't want the key to be given to the player, we want the player to gain access to the key by having to hack into a device. <br />
<br />
We will use the same variable and file names as the [[Mission Scripting]] tutorial. This will include the following:<br />
<br />
<syntaxhighlight source lang="lua" line start=66><br />
devices = {<br />
laptop = {<br />
internalName = "laptop",<br />
script = "Scripts/Devices/laptop.lua",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Our device will be in the table <code>laptop</code>, and the script for the device will be found in <code>laptop.lua</code>. It will be assumed that the hackable device has been added to SetupMission(), check the [[Mission Scripting]] tutorial if you need help on this.<br />
<br />
In the <code>laptop.lua</code> file we will have the following code.<br />
<br />
<syntaxhighlight source lang="lua" line start=1><br />
device = {<br />
canAccess = function()<br />
return true<br />
end,<br />
gui = {<br />
type = "ncurses",<br />
updateEveryFrame = false,<br />
header = [[Office door system]],<br />
backgroundColour = {0.0, 0.0196, 0.7765},<br />
highlightColour = {0.8863, 0.0, 0.0627},<br />
buttons = {<br />
{<br />
name = "user",<br />
subButtons = {<br />
{<br />
name = "admin",<br />
},<br />
{<br />
name = "internship at security department.doc",<br />
},<br />
},<br />
},<br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
},<br />
},<br />
},<br />
}<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
At this point the device will be hackable though the player will not be able to actually trigger anything from hacking into the device. To do this you will want to add this below a sub-button, we'll put it below the <code>"admin_door_access.pgp"</code> sub-button.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
print("clicked")<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Finally we want it so that when the <code>"admin_door_access.pgp"</code> is clicked, the player gets access to the key "adminkey", which has been set up to open doors of the Zone "admin" - essentially meaning that the player will be then be able to open and close the door we have created. To do this we just add a small line of code inside the function as shown below.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
RunMissionCommand([[Doors.AssignKeyToCharacter("adminkey", mission.characters.joe)]])<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
This is assigning the key <code>"adminkey"</code> to the character <code>joe</code> which if you remember is the player: you! So now if you try and interact with your door which is of the Zone "admin", it will unlock and open like in the GIF below!<br />
<br />
[[File:KeycardDoorOpen.gif|400px|thumb|none|(Click to see) The door opening as seen in-game]]<br />
<br />
== Changing the opening animation direction ==<br />
<br />
If for example you are in a narrow corridor and you want to open a door, it would be convenient for the door to open outwards away from you, otherwise the door will push towards and into you, disrupting your movement and potentially vision.<br />
<br />
To change the direction of which the door opens is quite simple, the procedure slightly differs between doors with and without keycard scanners.<br />
<br />
=== For doors without keycard scanners ===<br />
Firstly you need to click on the handle of your door - make sure you are selecting the handle which is the one that the player will be interacting with to open the door. Then under the 'Mission Object (Script)' click on the tickbox underneath the 'On Interaction Start' (see below), it may or may not be ticked already, either way reversing its current status will reverse the opening direction. If the player might interact with the door again, you should ideally do the exact same to the handle on the other side of the door. <br />
<br />
[[File:DoorHandleOpen.png|400px|thumb|none|The red circle shows the tickbox that you should click to reverse the opening direction of the door when interacting with that handle]]<br />
<br />
=== For doors with keycard scanners ===<br />
<br />
Likewise to doors without keycard scanners, it is just a matter of ticking or unticking a tickbox, however this time we are selecting the actual keycard scanner and not the handle. If the door currently opens inwards towards the player, select the keycard scanner which the player is interacting with and you should see components in the Inspector view similar to the ones seen in the picture below. All you do now is click on the tickbox for 'Is Front' (circled in red below), so if the tickbox was ticked, you just need to untick it, and vice versa for if it was unticked.<br />
<br />
[[File:ScannerOpen.png|400px|thumb|none|The red circle shows the tickbox that you should click to reverse the opening direction of the door when interacting with that keycard scanner]]</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Setting_up_Doors&diff=205Setting up Doors2017-06-30T13:18:16Z<p>Dominic: </p>
<hr />
<div><br />
== Adding the door into your scene ==<br />
<br />
Firstly you need to add the door prefab to your level and position it as you'd like it to appear in-game. To do this in your Project Folder you need to navigate to the Doors folder (see below) and choose the prefab which you prefer by dragging it into your Scene. For this tutorial we'll use a Swinging Door with Scanners so that once set up properly, it will require a correct ID Card to open. Once you have placed and positioned the door in a doorway you will be able to see it in-game and it should open if you used a door prefab - you will know if you have used the correct prefab because when in the Inspector view if you click on your door, it should already have an Animator and Door Script component.<br />
<br />
[[File:DoorPrefabFolder.png|400px|thumb|none|The folder that contains the door prefabs]]<br />
<br />
== Getting access to a locked door by using hackable objects ==<br />
<br />
If you wanted your door to be locked when you begin playing your level, click on your door and in the Inspector view under Door (Script) tick the box next to IsLocked. Now when you load into your level your player will not be able to open the door unless they have key access to the Zone Default.<br />
<br />
Next you will want to set Zone of the door to something unique, for now we'll call it "admin". <br />
<br />
[[File:DoorState.png|400px|thumb|none|Here you can change the Zone of the door, and whether it is locked or open upon starting your level in-game]]<br />
<br />
Now we will want to create a hackable object (link?) in both our scene and our mission script. Once you have set up and connected the hackable object to a network, as well as [[Mission Scripting#Adding in Networks|connecting the door to the network]] we can now edit the hackable object's script to give us access to a specific Zone that a door is using.<br />
<br />
In this guide, 'adminkey' will be the key that is related to the Zone 'admin' to make sure this has been set up check your mission script has this line of code: <code>Doors.SetZoneKeys("admin", {"adminkey"})</code>. By default the player will not have access the key "adminkey" unless we give it to the player straight away in SetupMission(). However we don't want the key to be given to the player, we want the player to gain access to the key by having to hack into a device. <br />
<br />
We will use the same variable and file names as the [[Mission Scripting]] tutorial. This will include the following:<br />
<br />
<syntaxhighlight source lang="lua" line start=66><br />
devices = {<br />
laptop = {<br />
internalName = "laptop",<br />
script = "Scripts/Devices/laptop.lua",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Our device will be in the table <code>laptop</code>, and the script for the device will be found in <code>laptop.lua</code>. It will be assumed that the hackable device has been added to SetupMission(), check the [[Mission Scripting]] tutorial if you need help on this.<br />
<br />
In the <code>laptop.lua</code> file we will have the following code.<br />
<br />
<syntaxhighlight source lang="lua" line start=1><br />
device = {<br />
canAccess = function()<br />
return true<br />
end,<br />
gui = {<br />
type = "ncurses",<br />
updateEveryFrame = false,<br />
header = [[Office door system]],<br />
backgroundColour = {0.0, 0.0196, 0.7765},<br />
highlightColour = {0.8863, 0.0, 0.0627},<br />
buttons = {<br />
{<br />
name = "user",<br />
subButtons = {<br />
{<br />
name = "admin",<br />
},<br />
{<br />
name = "internship at security department.doc",<br />
},<br />
},<br />
},<br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
},<br />
},<br />
},<br />
}<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
At this point the device will be hackable though the player will not be able to actually trigger anything from hacking into the device. To do this you will want to add this below a sub-button, we'll put it below the <code>"admin_door_access.pgp"</code> sub-button.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
print("clicked")<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Finally we want it so that when the <code>"admin_door_access.pgp"</code> is clicked, the player gets access to the key "adminkey", which has been set up to open doors of the Zone "admin" - essentially meaning that the player will be then be able to open and close the door we have created. To do this we just add a small line of code inside the function as shown below.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
RunMissionCommand([[Doors.AssignKeyToCharacter("adminkey", mission.characters.joe)]])<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
This is assigning the key <code>"adminkey"</code> to the character <code>joe</code> which if you remember is the player: you! So now if you try and interact with your door which is of the Zone "admin", it will unlock and open like in the GIF below!<br />
<br />
[[File:KeycardDoorOpen.gif|400px|thumb|none|(Click to watch) The door opening as seen in-game]]<br />
<br />
== Changing the opening animation direction ==<br />
<br />
If for example you are in a narrow corridor and you want to open a door, it would be convenient for the door to open outwards away from you, otherwise the door will push towards and into you, disrupting your movement and potentially vision.<br />
<br />
To change the direction of which the door opens is quite simple, the procedure slightly differs between doors with and without keycard scanners.<br />
<br />
=== For doors without keycard scanners ===<br />
Firstly you need to click on the handle of your door - make sure you are selecting the handle which is the one that the player will be interacting with to open the door. Then under the 'Mission Object (Script)' click on the tickbox underneath the 'On Interaction Start' (see below), it may or may not be ticked already, either way reversing its current status will reverse the opening direction. If the player might interact with the door again, you should ideally do the exact same to the handle on the other side of the door. <br />
<br />
[[File:DoorHandleOpen.png|400px|thumb|none|The red circle shows the tickbox that you should click to reverse the opening direction of the door when interacting with that handle]]<br />
<br />
=== For doors with keycard scanners ===<br />
<br />
Likewise to doors without keycard scanners, it is just a matter of ticking or unticking a tickbox, however this time we are selecting the actual keycard scanner and not the handle. If the door currently opens inwards towards the player, select the keycard scanner which the player is interacting with and you should see components in the Inspector view similar to the ones seen in the picture below. All you do now is click on the tickbox for 'Is Front' (circled in red below), so if the tickbox was ticked, you just need to untick it, and vice versa for if it was unticked.<br />
<br />
[[File:ScannerOpen.png|400px|thumb|none|The red circle shows the tickbox that you should click to reverse the opening direction of the door when interacting with that keycard scanner]]</div>Dominichttp://wiki.offgridthegame.com/index.php?title=File:KeycardDoorOpen.gif&diff=204File:KeycardDoorOpen.gif2017-06-30T13:17:04Z<p>Dominic: Door opening</p>
<hr />
<div>Door opening</div>Dominichttp://wiki.offgridthegame.com/index.php?title=File:ScannerOpen.png&diff=203File:ScannerOpen.png2017-06-30T12:58:33Z<p>Dominic: Open direction of scanner doors</p>
<hr />
<div>Open direction of scanner doors</div>Dominichttp://wiki.offgridthegame.com/index.php?title=File:DoorHandleOpen.png&diff=202File:DoorHandleOpen.png2017-06-30T12:38:05Z<p>Dominic: Reversing opening direction</p>
<hr />
<div>Reversing opening direction</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Setting_up_Doors&diff=201Setting up Doors2017-06-30T12:30:19Z<p>Dominic: </p>
<hr />
<div>{{OffGridDocStart}}<br />
<br />
== Adding the door into your scene ==<br />
<br />
Firstly you need to add the door prefab to your level and position it as you'd like it to appear in-game. To do this in your Project Folder you need to navigate to the Doors folder (see below) and choose the prefab which you prefer by dragging it into your Scene. For this tutorial we'll use a Swinging Door with Scanners so that once set up properly, it will require a correct ID Card to open. Once you have placed and positioned the door in a doorway you will be able to see it in-game and it should open if you used a door prefab - you will know if you have used the correct prefab because when in the Inspector view if you click on your door, it should already have an Animator and Door Script component.<br />
<br />
[[File:DoorPrefabFolder.png|400px|thumb|none|The folder that contains the door prefabs]]<br />
<br />
== Getting access to a locked door by using hackable objects ==<br />
<br />
If you wanted your door to be locked when you begin playing your level, click on your door and in the Inspector view under Door (Script) tick the box next to IsLocked. Now when you load into your level your player will not be able to open the door unless they have key access to the Zone Default.<br />
<br />
Next you will want to set Zone of the door to something unique, for now we'll call it "admin". <br />
<br />
[[File:DoorState.png|400px|thumb|none|Here you can change the Zone of the door, and whether it is locked or open upon starting your level in-game]]<br />
<br />
Now we will want to create a hackable object (link?) in both our scene and our mission script. Once you have set up and connected the hackable object to a network, as well as [[Mission Scripting#Adding in Networks|connecting the door to the network]] we can now edit the hackable object's script to give us access to a specific Zone that a door is using.<br />
<br />
In this guide, 'adminkey' will be the key that is related to the Zone 'admin' to make sure this has been set up check your mission script has this line of code: <code>Doors.SetZoneKeys("admin", {"adminkey"})</code>. By default the player will not have access the key "adminkey" unless we give it to the player straight away in SetupMission(). However we don't want the key to be given to the player, we want the player to gain access to the key by having to hack into a device. <br />
<br />
We will use the same variable and file names as the [[Mission Scripting]] tutorial. This will include the following:<br />
<br />
<syntaxhighlight source lang="lua" line start=66><br />
devices = {<br />
laptop = {<br />
internalName = "laptop",<br />
script = "Scripts/Devices/laptop.lua",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Our device will be in the table <code>laptop</code>, and the script for the device will be found in <code>laptop.lua</code>. It will be assumed that the hackable device has been added to SetupMission(), check the [[Mission Scripting]] tutorial if you need help on this.<br />
<br />
In the <code>laptop.lua</code> file we will have the following code.<br />
<br />
<syntaxhighlight source lang="lua" line start=1><br />
device = {<br />
canAccess = function()<br />
return true<br />
end,<br />
gui = {<br />
type = "ncurses",<br />
updateEveryFrame = false,<br />
header = [[Office door system]],<br />
backgroundColour = {0.0, 0.0196, 0.7765},<br />
highlightColour = {0.8863, 0.0, 0.0627},<br />
buttons = {<br />
{<br />
name = "user",<br />
subButtons = {<br />
{<br />
name = "admin",<br />
},<br />
{<br />
name = "internship at security department.doc",<br />
},<br />
},<br />
},<br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
},<br />
},<br />
},<br />
}<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
At this point the device will be hackable though the player will not be able to actually trigger anything from hacking into the device. To do this you will want to add this below a sub-button, we'll put it below the <code>"admin_door_access.pgp"</code> sub-button.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
print("clicked")<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Finally we want it so that when the <code>"admin_door_access.pgp"</code> is clicked, the player gets access to the key "adminkey", which has been set up to open doors of the Zone "admin" - essentially meaning that the player will be then be able to open and close the door we have created. To do this we just add a small line of code inside the function as shown below.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
RunMissionCommand([[Doors.AssignKeyToCharacter("adminkey", mission.characters.joe)]])<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
This is assigning the key <code>"adminkey"</code> to the character <code>joe</code> which if you remember is the player: you! So now if you try and interact with your door which is of the Zone "admin", it will unlock and open.<br />
<br />
<br />
<br />
changing opening face direction</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Setting_up_Doors&diff=200Setting up Doors2017-06-30T12:29:13Z<p>Dominic: /* Getting access to a locked door by using hackable objects */</p>
<hr />
<div><br />
== Adding the door into your scene ==<br />
<br />
Firstly you need to add the door prefab to your level and position it as you'd like it to appear in-game. To do this in your Project Folder you need to navigate to the Doors folder (see below) and choose the prefab which you prefer by dragging it into your Scene. For this tutorial we'll use a Swinging Door with Scanners so that once set up properly, it will require a correct ID Card to open. Once you have placed and positioned the door in a doorway you will be able to see it in-game and it should open if you used a door prefab - you will know if you have used the correct prefab because when in the Inspector view if you click on your door, it should already have an Animator and Door Script component.<br />
<br />
[[File:DoorPrefabFolder.png|400px|thumb|none|The folder that contains the door prefabs]]<br />
<br />
== Getting access to a locked door by using hackable objects ==<br />
<br />
If you wanted your door to be locked when you begin playing your level, click on your door and in the Inspector view under Door (Script) tick the box next to IsLocked. Now when you load into your level your player will not be able to open the door unless they have key access to the Zone Default.<br />
<br />
Next you will want to set Zone of the door to something unique, for now we'll call it "admin". <br />
<br />
[[File:DoorState.png|400px|thumb|none|Here you can change the Zone of the door, and whether it is locked or open upon starting your level in-game]]<br />
<br />
Now we will want to create a hackable object (link?) in both our scene and our mission script. Once you have set up and connected the hackable object to a network, as well as [[Mission Scripting#Adding in Networks|connecting the door to the network]] we can now edit the hackable object's script to give us access to a specific Zone that a door is using.<br />
<br />
In this guide, 'adminkey' will be the key that is related to the Zone 'admin' to make sure this has been set up check your mission script has this line of code: <code>Doors.SetZoneKeys("admin", {"adminkey"})</code>. By default the player will not have access the key "adminkey" unless we give it to the player straight away in SetupMission(). However we don't want the key to be given to the player, we want the player to gain access to the key by having to hack into a device. <br />
<br />
We will use the same variable and file names as the [[Mission Scripting]] tutorial. This will include the following:<br />
<br />
<syntaxhighlight source lang="lua" line start=66><br />
devices = {<br />
laptop = {<br />
internalName = "laptop",<br />
script = "Scripts/Devices/laptop.lua",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Our device will be in the table <code>laptop</code>, and the script for the device will be found in <code>laptop.lua</code>. It will be assumed that the hackable device has been added to SetupMission(), check the [[Mission Scripting]] tutorial if you need help on this.<br />
<br />
In the <code>laptop.lua</code> file we will have the following code.<br />
<br />
<syntaxhighlight source lang="lua" line start=1><br />
device = {<br />
canAccess = function()<br />
return true<br />
end,<br />
gui = {<br />
type = "ncurses",<br />
updateEveryFrame = false,<br />
header = [[Office door system]],<br />
backgroundColour = {0.0, 0.0196, 0.7765},<br />
highlightColour = {0.8863, 0.0, 0.0627},<br />
buttons = {<br />
{<br />
name = "user",<br />
subButtons = {<br />
{<br />
name = "admin",<br />
},<br />
{<br />
name = "internship at security department.doc",<br />
},<br />
},<br />
},<br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
},<br />
},<br />
},<br />
}<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
At this point the device will be hackable though the player will not be able to actually trigger anything from hacking into the device. To do this you will want to add this below a sub-button, we'll put it below the <code>"admin_door_access.pgp"</code> sub-button.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
print("clicked")<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Finally we want it so that when the <code>"admin_door_access.pgp"</code> is clicked, the player gets access to the key "adminkey", which has been set up to open doors of the Zone "admin" - essentially meaning that the player will be then be able to open and close the door we have created. To do this we just add a small line of code inside the function as shown below.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
RunMissionCommand([[Doors.AssignKeyToCharacter("adminkey", mission.characters.joe)]])<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
This is assigning the key <code>"adminkey"</code> to the character <code>joe</code> which if you remember is the player: you! So now if you try and interact with your door which is of the Zone "admin", it will unlock and open.<br />
<br />
<br />
<br />
changing opening face direction</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Setting_up_Doors&diff=199Setting up Doors2017-06-30T12:27:07Z<p>Dominic: updated</p>
<hr />
<div><br />
== Adding the door into your scene ==<br />
<br />
Firstly you need to add the door prefab to your level and position it as you'd like it to appear in-game. To do this in your Project Folder you need to navigate to the Doors folder (see below) and choose the prefab which you prefer by dragging it into your Scene. For this tutorial we'll use a Swinging Door with Scanners so that once set up properly, it will require a correct ID Card to open. Once you have placed and positioned the door in a doorway you will be able to see it in-game and it should open if you used a door prefab - you will know if you have used the correct prefab because when in the Inspector view if you click on your door, it should already have an Animator and Door Script component.<br />
<br />
[[File:DoorPrefabFolder.png|400px|thumb|none|The folder that contains the door prefabs]]<br />
<br />
== Getting access to a locked door by using hackable objects ==<br />
<br />
If you wanted your door to be locked when you begin playing your level, click on your door and in the Inspector view under Door (Script) tick the box next to IsLocked. Now when you load into your level your player will not be able to open the door unless they have key access to the Zone Default.<br />
<br />
Next you will want to set Zone of the door to something unique, for now we'll call it "admin". <br />
<br />
[[File:DoorState.png|400px|thumb|none|Here you can change the Zone of the door, and whether it is locked or open upon starting your level in-game]]<br />
<br />
Now we will want to create a hackable object (link?) in both our scene and our mission script. Once you have set up and connected the hackable object to a network, as well as [[Mission Scripting#Adding in Networks|connecting the door to the network]] we can now edit the hackable object's script to give us access to a specific Zone that a door is using.<br />
<br />
In this guide, 'adminkey' will be the key that is related to the Zone 'admin' to make sure this has been set up check your mission script has this line of code: <code>Doors.SetZoneKeys("admin", {"adminkey"})</code>. By default the player will not have access the key "adminkey" unless we give it to the player straight away in SetupMission(). However we don't want the key to be given to the player, we want the player to gain access to the key by having to hack into a device. <br />
<br />
We will use the same variable and file names as the [[Mission Scripting]] tutorial. This will include the following:<br />
<br />
<syntaxhighlight source lang="lua" line start=66><br />
devices = {<br />
laptop = {<br />
internalName = "laptop",<br />
script = "Scripts/Devices/laptop.lua",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Our device will be in the table <code>laptop</code>, and the script for the device will be found in <code>laptop.lua</code>. It will be assumed that the hackable device has been added to SetupMission(), check the [[Mission Scripting]] tutorial if you need help on this.<br />
<br />
In the <code>laptop.lua</code> file we will have the following code.<br />
<br />
<syntaxhighlight source lang="lua" line start=1><br />
device = {<br />
canAccess = function()<br />
return true<br />
end,<br />
gui = {<br />
type = "ncurses",<br />
updateEveryFrame = false,<br />
header = [[Office door system]],<br />
backgroundColour = {0.0, 0.0196, 0.7765},<br />
highlightColour = {0.8863, 0.0, 0.0627},<br />
buttons = {<br />
{<br />
name = "user",<br />
subButtons = {<br />
{<br />
name = "admin",<br />
},<br />
{<br />
name = "internship at security department.doc",<br />
},<br />
},<br />
},<br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
},<br />
},<br />
},<br />
}<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
At this point the device will be hackable though the player will not be able to actually trigger anything from hacking into the device. To do this you will want to add this below a sub-button, we'll put it below the <code>"admin_door_access.pgp"</code> sub-button.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
print("clicked")<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
Finally we want it so that when the <code>"admin_door_access.pgp"</code> is clicked, the player gets access to the key "adminkey", which has been set up to open doors of the Zone "admin" - essentially meaning that the player will be then be able to open and close the door we have created. To do this we just add a small line of code inside the function as shown below.<br />
<br />
<syntaxhighlight source lang="lua" line start=12><br />
{<br />
name = "access_data",<br />
subButtons = {<br />
{<br />
name = "admin_door_access.pgp",<br />
onClick = function()<br />
RunMissionCommand([[Doors.AssignKeyToCharacter("adminkey", mission.characters.joe)]])<br />
end,<br />
},<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
This is assigning the key to the character <code>joe</code> which if you remember is the player: you! So now if you try and interact with your door which is of the Zone "admin", it will unlock and open.<br />
<br />
changing opening face direction<br />
locked/open<br />
linking to network</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Mission_Scripting&diff=198Mission Scripting2017-06-30T11:21:05Z<p>Dominic: /* Adding in Networks */</p>
<hr />
<div>{{OffGridDocStart}}<br />
<br />
== Intro ==<br />
<br />
This article will describe everything you need to know in order to understand how to write and modify missions scripts in Off Grid!<br />
Mission scripts can get a little bit large but don't let that overwhelm you, they're deceptively simple, we promise!<br />
<br />
== Pre-requisites ==<br />
All modding scripts for Off Grid are written in Lua, it's a lovely little language which is simple ( ''don't tell it I said that'' ) and extensible thanks to the marvellous [http://www.moonsharp.org MoonSharp].<br />
<br />
Lua is quite easy to pick up, even people with no programming experience should be able to get hacking in next to no time!<br />
<br />
You'll need the following tools for editing and writing new mission scripts:<br />
<br />
=== IDE ===<br />
Firstly you'll need an [https://en.wikipedia.org/wiki/Integrated_development_environment IDE], we recommend the [https://atom.io/ Atom] with the following extensions:<br />
{| class="wikitable"<br />
| [https://atom.io/packages/language-lua language-lua] || Syntax highlighting for Lua<br />
|-<br />
| [https://atom.io/packages/autocomplete-lua autocomplete-lua] || Auto-complete support for Lua, we recommend enabling the "Override lower priority providers" in the plugin settings<br />
|-<br />
|}<br />
<br />
=== LevelKit & Game ===<br />
Both of these are needed in order to run and test and scripts you create<br />
<br />
'''TO DO'''<br />
<br />
== The Mission Script Structure ==<br />
As mentioned above, mission scripts can get rather large so this article will attempt to break down all the little sub elements, it can be helpful to try and think of the mission script in the same way you might think of a film script.<br />
The vast majority of the script is simply defining what is in the world of the mission you've created.<br />
Enough talking, lets jump into an example! Rather than posting an entire example script, we'll go from top to bottom exploring what each element does.<br />
<br />
=== Initial Mission State ===<br />
<syntaxhighlight source lang="lua" line><br />
mission = {<br />
<br />
-- Mission info<br />
startTime = {2009, 04, 27, 21, 13, 00},<br />
<br />
</syntaxhighlight><br />
<br />
In this first code block we create the ''mission'' Lua table and define its first value.<br />
<br />
{| class="wikitable"<br />
! Name !! Description<br />
|-<br />
| ''startTime'' || The start time of the mission in the game world (Year, Month, Day, Hour, Mins, Secs)<br />
|}<br />
<br />
startTime doesn't have to be the current date, you can set your mission in any time you desire.<br />
<br />
=== Characters ===<br />
<br />
<syntaxhighlight source lang="lua" line start=5><br />
-- Character definitions:<br />
characters = {<br />
joe = {<br />
displayName = "Joe Harman",<br />
internalName = "Joe",<br />
characterType = "player",<br />
prefab = "player",<br />
spawnpoint = "PlayerSpawn",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
This is the first example of us creating a sub table in the ''mission'' table, the ''characters'' table contains all the information about the characters in your mission!<br />
In this example we've added Joe, the protagonist of Off Grid. Here's a break down of what the value of Joe's table means:<br />
{| class="wikitable"<br />
!colspan="2" | Character Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''displayName'' || The name that will be used any game UI referencing the character <br />
|-<br />
| ''internalName'' || The internalName can be thought of as the id for the character, you'll reference the character by this value in a few places including conversations (Must be unique!)<br />
|- <br />
| ''characterType'' || The 'type' of the character, see [[Character Types and Prefabs]] for more information on possible values<br />
|-<br />
| 'prefab' || The prefab for the character, see [[Character Types and Prefabs]] for more information on possible values<br />
|-<br />
| ''spawnpoint'' || The name of the spawn mission object, the position of this object will be where the character is spawned<br />
|}<br />
<br />
The ''characters'' table can hold information on as many characters as you'd like to fill the mission with, they won't be spawned into the mission until you decide (more on that later)<br />
<br />
=== Physical Items ===<br />
<br />
<syntaxhighlight source lang="lua" line start=15><br />
-- Inventory items:<br />
items = {<br />
usbkey = {<br />
internalName = "USBDongle",<br />
displayName = "USB dongle",<br />
description = "Modified USB Bluetooth dongle given to you by the hackers",<br />
uiSpriteName = "usbdongle.png",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The ''items'' table contains information about physical items that the player will be able to add to their inventory over the course of the mission, in this example we're marking up a USB dongle that the player can plug into computers<br />
{| class="wikitable"<br />
!colspan="2" | Item Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''internalName'' || The internalName we'll use to identify this item (Must be unique!)<br />
|-<br />
| ''displayName'' || The display name of the item, this is what will be displayed in the games UI<br />
|- <br />
| ''description'' || The description of the item, this will be displayed to users in the players inventory UI<br />
|-<br />
| ''uiSpriteName'' || The path to the items sprite, this is the image that will be used in the games UI<br />
|}<br />
<br />
=== Data ===<br />
<br />
<syntaxhighlight source lang="lua" line start=24><br />
--[[ Data files:<br />
Available data types: generic, text, SMS, encrypted, audio, video, location, key, UUID<br />
]]--<br />
data = {<br />
PlayerPGPKey = {<br />
internalName = "PlayerPGPKey",<br />
name = "Personal PGP encryption key",<br />
immutable = true,<br />
dataType = 7,<br />
creatorName = "Player",<br />
dataString = "PGP Fingerprint: 1d7d ef54 7a63 5756 63a7 cf14 fbd8 775c c39d 4e51",<br />
description = "AES 256-bit",<br />
dataColor = {0.0, 0.6, 1.0, 0.3},<br />
},<br />
<br />
},<br />
</syntaxhighlight><br />
<br />
The data table contains data that's specific to your mission, in this example we're defining the players [https://en.wikipedia.org/wiki/Pretty_Good_Privacy PGP] encryption key <br />
<br />
{| class="wikitable"<br />
!colspan="2"| Data Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''internalName'' || The internalName we'll use to identify this data (Must be unique!)<br />
|-<br />
| ''name'' || The display name of the data, this is what will be displayed in the games UI<br />
|-<br />
| ''immutable'' || Is the data immutable? If true the player won't be able to delete it, this is useful for data items that are part of mission objectives<br />
|- <br />
| ''dataType'' || The type of the data, this is used for displaying the data correctly <br />
|- <br />
| ''creatorName'' || The name of the data's creator (displayed in the UI)<br />
|-<br />
| ''dataString'' || The contents of the data file<br />
|- <br />
| ''description'' || A description of the data file<br />
|-<br />
| ''dataColor'' || RGBA value that's used as the colour of the data point when visible in the players data view<br />
|}<br />
<br />
=== Networks ===<br />
<br />
<syntaxhighlight source lang="lua" line start=40><br />
-- Networks:<br />
--[[ types: 0 = mobile, 1 = WiFi, 2 = mesh ]]--<br />
networks = {<br />
Semaeopus4G = {<br />
name = "Semaeopus4G",<br />
networkType = 0,<br />
allowPlayerDisconnect = false,<br />
userAccessKey = "user",<br />
adminAccessKey = "admin",<br />
rootAccessKey = "root",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The networks table contains all the information about the possible networks in your game, networks can be of different types such as mobile networks, WiFi, and mesh<br />
{| class="wikitable"<br />
!colspan="2" | Network Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''name'' || The name of the network (Must be unique!)<br />
|-<br />
| ''networkType'' || The type of the network (mobile - 0, WiFi - 1, mesh - 2)<br />
|-<br />
| ''allowPlayerDisconnect'' || Is the player allowed to disconnect from the network?<br />
|- <br />
| ''userAccessKey'' || The password for user access to the network<br />
|- <br />
| ''adminAccessKey'' || The password for admin access to the network<br />
|-<br />
| ''rootAccessKey'' || The password for root access to the network<br />
|}<br />
<br />
Data sent at higher access levels across a network won't be visible to devices that are connected at a lower access level.<br />
<br />
=== Objectives ===<br />
<br />
<syntaxhighlight source lang="lua" line start=52><br />
-- Mission objectives:<br />
objectives = {<br />
enterTheBuilding = {<br />
name = "Enter the building",<br />
onStart = function()<br />
print("Player must now enter the building")<br />
end,<br />
onCompleted = function()<br />
print("The player is now in the building!")<br />
end,<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The objectives table contains all the tasks that the player should complete before your mission is finished.<br />
<br />
{| class="wikitable"<br />
!colspan="2" | Objective Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''name'' || The name of the objective (should be unique)<br />
|-<br />
| ''onStart'' || A callback function that's triggered when the objective is started<br />
|-<br />
| ''onCompleted'' || A callback function that's triggered when the objective is completed<br />
|}<br />
<br />
=== Devices ===<br />
<br />
<syntaxhighlight source lang="lua" line start=66><br />
devices = {<br />
laptop = {<br />
internalName = "laptop",<br />
script = "Scripts/Devices/laptop.lua",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
{| class="wikitable"<br />
!colspan="2" | Device Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''internalName'' || The name of the device. Must be unique and match the MissionObject in the scene<br />
|-<br />
| ''script'' || The script that defines the gui and the behaviour of the device ( See [[Mission Scripting/Device Scripting|Device Scripting]] for more information )<br />
|}<br />
<br />
=== Mission Setup ===<br />
<br />
<syntaxhighlight source lang="lua" line start=73><br />
function SetupMission()<br />
-- add player and guards:<br />
Mission.AddCharacter(mission.characters.joe)<br />
-- these two below add in the guards which you might not have created yet!<br />
Mission.AddCharacter(mission.characters.jack)<br />
Mission.AddCharacter(mission.characters.john)<br />
<br />
-- set up hackable devices<br />
Mission.AddHackableDevice(mission.devices.laptop)<br />
<br />
-- set up networks:<br />
Mission.AddNetwork(mission.networks.Semaeopus4G)<br />
Mission.ConnectToNetwork(mission.devices.laptop, mission.networks.Semaeopus4G.name, mission.networks.Semaeopus4G.userAccessKey)<br />
Doors.SetNetwork(mission.networks.Semaeopus4G)<br />
Doors.SetZoneKeys("admin", {"adminkey"})<br />
<br />
-- misc.<br />
-- Player.SetInvisible(true)<br />
<br />
Mission.MissionStarted()<br />
end<br />
</syntaxhighlight><br />
<br />
This will add in all of your created elements into your level, below you will see what the function of each part of this code will do.<br />
<br />
==== Adding in Characters ====<br />
<br />
<syntaxhighlight source lang="lua" line start=74><br />
-- add player and guards:<br />
Mission.AddCharacter(mission.characters.joe)<br />
-- these two below add in the guards which you might not have created yet!<br />
Mission.AddCharacter(mission.characters.jack)<br />
Mission.AddCharacter(mission.characters.john)<br />
</syntaxhighlight><br />
<br />
This part of the code shows the format of adding in characters - this includes the player and any NPCs like the guards, which you will have created further up in your Mission Script. If the title of your character table for your player was called <code>jenson</code>, you would simply change <code>Mission.AddCharacter(mission.characters.joe)</code> to <code>Mission.AddCharacter(mission.characters.jenson)</code>, this would now let your player spawn in.<br />
<br />
==== Adding in Hackable Devices ====<br />
<br />
<syntaxhighlight source lang="lua" line start=80><br />
-- set up hackable devices<br />
Mission.AddHackableDevice(mission.devices.laptop)<br />
</syntaxhighlight><br />
<br />
Once you have set up some hackable devices, by adding this to your SetupMission() the hackable devices will now be added into your level. Similarly to adding in the characters as seen above, to customise this for your own devices, you only need to change the last part inside the brackets. So if the title of one of your devices tables was <code>vendingmachine</code>, you could just change <code>Mission.AddHackableDevice(mission.devices.laptop)</code> to <code>Mission.AddHackableDevice(mission.devices.vendingmachine)</code>.<br />
<br />
==== Adding in Networks ====<br />
<br />
<syntaxhighlight source lang="lua" line start=83><br />
-- set up networks:<br />
Mission.AddNetwork(mission.networks.Semaeopus4G)<br />
Mission.ConnectToNetwork(mission.devices.laptop, mission.networks.Semaeopus4G.name, mission.networks.Semaeopus4G.userAccessKey)<br />
Doors.SetNetwork(mission.networks.Semaeopus4G)<br />
Doors.SetZoneKeys("admin", {"adminkey"})<br />
</syntaxhighlight><br />
<br />
You will have already created a network in your networks table. Now to add it into the game you need to just add in <code>Mission.AddNetwork(mission.networks.NETWORKNAME)</code> where <code>NETWORKNAME</code> is the title of the table you created in your networks table, in this tutorial it was defined as <code>Semaeopus4G</code>. To then connect your hackable devices to your network you just need to add in what you see on line 86, where <code>laptop</code> can be replaced with the hackable devices table name, though in our example the table of our hackable device is called <code>laptop</code>, so we'll keep it as it is.<br />
<br />
Once you have [[Setting up Doors|created doors]] you can then also add them to a network. By adding them to a network you can make it so that the player cannot open the door unless they have a key. Firstly you add the door to a network, then you can set the door's zone to require a specific key to open it. In our example where we set the zone's required key: <code>Doors.SetZoneKeys("admin", {"adminkey"})</code>, <code>"admin"</code> is the name of the zone the door is assigned to, and <code>"adminkey"</code> is the name of the key that will allow the player to unlock the doors of the zone <code>"admin"</code>.<br />
<br />
==== Adding in Other Changes====<br />
<br />
<syntaxhighlight source lang="lua" line start=89><br />
-- misc.<br />
-- Player.SetInvisible(true)<br />
</syntaxhighlight><br />
<br />
Whilst modding you might get to a point in development where you need to test features like the patrol routes of guards, so a useful line of code you can add to your MissionSetup() is <code>Player.SetInvisible(true)</code>, this will make your player invisible to the Guards which can certainly be handy for testing your level without being spotted!</div>Dominichttp://wiki.offgridthegame.com/index.php?title=File:DoorState.png&diff=197File:DoorState.png2017-06-30T11:00:38Z<p>Dominic: Dominic uploaded a new version of File:DoorState.png</p>
<hr />
<div>Door script</div>Dominichttp://wiki.offgridthegame.com/index.php?title=File:DoorState.png&diff=196File:DoorState.png2017-06-30T10:54:15Z<p>Dominic: Dominic uploaded a new version of File:DoorState.png</p>
<hr />
<div>Door script</div>Dominichttp://wiki.offgridthegame.com/index.php?title=File:DoorState.png&diff=195File:DoorState.png2017-06-30T10:50:23Z<p>Dominic: Door script</p>
<hr />
<div>Door script</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Setting_up_Doors&diff=194Setting up Doors2017-06-30T10:40:55Z<p>Dominic: Created page with " == Add the door into your scene == Firstly you need to add the door prefab to your level and position it as you'd like it to appear in-game. To do this in your Project Folde..."</p>
<hr />
<div><br />
== Add the door into your scene ==<br />
<br />
Firstly you need to add the door prefab to your level and position it as you'd like it to appear in-game. To do this in your Project Folder you need to navigate to the Doors folder (see below) and choose the prefab which you prefer by dragging it into your Scene. For this tutorial we'll use a Swinging Door with Scanners so that once set up properly, it will require a correct ID Card to open. Once you have placed and positioned the door in a doorway you will be able to see it in-game and it should open if you used a door prefab - you will know if you have used the correct prefab because when in the Inspector view if you click on your door, it should already have an Animator and Door Script component.<br />
<br />
[[File:DoorPrefabFolder.png|400px|thumb|none|The folder that contains the door prefabs]]<br />
<br />
== Making your door specific ==<br />
<br />
changing opening face direction<br />
locked/open<br />
linking to network</div>Dominichttp://wiki.offgridthegame.com/index.php?title=File:DoorPrefabFolder.png&diff=193File:DoorPrefabFolder.png2017-06-30T10:30:38Z<p>Dominic: The folder that contains the door prefabs</p>
<hr />
<div>The folder that contains the door prefabs</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Mission_Scripting&diff=192Mission Scripting2017-06-30T10:07:18Z<p>Dominic: /* Mission Setup */</p>
<hr />
<div>{{OffGridDocStart}}<br />
<br />
== Intro ==<br />
<br />
This article will describe everything you need to know in order to understand how to write and modify missions scripts in Off Grid!<br />
Mission scripts can get a little bit large but don't let that overwhelm you, they're deceptively simple, we promise!<br />
<br />
== Pre-requisites ==<br />
All modding scripts for Off Grid are written in Lua, it's a lovely little language which is simple ( ''don't tell it I said that'' ) and extensible thanks to the marvellous [http://www.moonsharp.org MoonSharp].<br />
<br />
Lua is quite easy to pick up, even people with no programming experience should be able to get hacking in next to no time!<br />
<br />
You'll need the following tools for editing and writing new mission scripts:<br />
<br />
=== IDE ===<br />
Firstly you'll need an [https://en.wikipedia.org/wiki/Integrated_development_environment IDE], we recommend the [https://atom.io/ Atom] with the following extensions:<br />
{| class="wikitable"<br />
| [https://atom.io/packages/language-lua language-lua] || Syntax highlighting for Lua<br />
|-<br />
| [https://atom.io/packages/autocomplete-lua autocomplete-lua] || Auto-complete support for Lua, we recommend enabling the "Override lower priority providers" in the plugin settings<br />
|-<br />
|}<br />
<br />
=== LevelKit & Game ===<br />
Both of these are needed in order to run and test and scripts you create<br />
<br />
'''TO DO'''<br />
<br />
== The Mission Script Structure ==<br />
As mentioned above, mission scripts can get rather large so this article will attempt to break down all the little sub elements, it can be helpful to try and think of the mission script in the same way you might think of a film script.<br />
The vast majority of the script is simply defining what is in the world of the mission you've created.<br />
Enough talking, lets jump into an example! Rather than posting an entire example script, we'll go from top to bottom exploring what each element does.<br />
<br />
=== Initial Mission State ===<br />
<syntaxhighlight source lang="lua" line><br />
mission = {<br />
<br />
-- Mission info<br />
startTime = {2009, 04, 27, 21, 13, 00},<br />
<br />
</syntaxhighlight><br />
<br />
In this first code block we create the ''mission'' Lua table and define its first value.<br />
<br />
{| class="wikitable"<br />
! Name !! Description<br />
|-<br />
| ''startTime'' || The start time of the mission in the game world (Year, Month, Day, Hour, Mins, Secs)<br />
|}<br />
<br />
startTime doesn't have to be the current date, you can set your mission in any time you desire.<br />
<br />
=== Characters ===<br />
<br />
<syntaxhighlight source lang="lua" line start=5><br />
-- Character definitions:<br />
characters = {<br />
joe = {<br />
displayName = "Joe Harman",<br />
internalName = "Joe",<br />
characterType = "player",<br />
prefab = "player",<br />
spawnpoint = "PlayerSpawn",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
This is the first example of us creating a sub table in the ''mission'' table, the ''characters'' table contains all the information about the characters in your mission!<br />
In this example we've added Joe, the protagonist of Off Grid. Here's a break down of what the value of Joe's table means:<br />
{| class="wikitable"<br />
!colspan="2" | Character Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''displayName'' || The name that will be used any game UI referencing the character <br />
|-<br />
| ''internalName'' || The internalName can be thought of as the id for the character, you'll reference the character by this value in a few places including conversations (Must be unique!)<br />
|- <br />
| ''characterType'' || The 'type' of the character, see [[Character Types and Prefabs]] for more information on possible values<br />
|-<br />
| 'prefab' || The prefab for the character, see [[Character Types and Prefabs]] for more information on possible values<br />
|-<br />
| ''spawnpoint'' || The name of the spawn mission object, the position of this object will be where the character is spawned<br />
|}<br />
<br />
The ''characters'' table can hold information on as many characters as you'd like to fill the mission with, they won't be spawned into the mission until you decide (more on that later)<br />
<br />
=== Physical Items ===<br />
<br />
<syntaxhighlight source lang="lua" line start=15><br />
-- Inventory items:<br />
items = {<br />
usbkey = {<br />
internalName = "USBDongle",<br />
displayName = "USB dongle",<br />
description = "Modified USB Bluetooth dongle given to you by the hackers",<br />
uiSpriteName = "usbdongle.png",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The ''items'' table contains information about physical items that the player will be able to add to their inventory over the course of the mission, in this example we're marking up a USB dongle that the player can plug into computers<br />
{| class="wikitable"<br />
!colspan="2" | Item Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''internalName'' || The internalName we'll use to identify this item (Must be unique!)<br />
|-<br />
| ''displayName'' || The display name of the item, this is what will be displayed in the games UI<br />
|- <br />
| ''description'' || The description of the item, this will be displayed to users in the players inventory UI<br />
|-<br />
| ''uiSpriteName'' || The path to the items sprite, this is the image that will be used in the games UI<br />
|}<br />
<br />
=== Data ===<br />
<br />
<syntaxhighlight source lang="lua" line start=24><br />
--[[ Data files:<br />
Available data types: generic, text, SMS, encrypted, audio, video, location, key, UUID<br />
]]--<br />
data = {<br />
PlayerPGPKey = {<br />
internalName = "PlayerPGPKey",<br />
name = "Personal PGP encryption key",<br />
immutable = true,<br />
dataType = 7,<br />
creatorName = "Player",<br />
dataString = "PGP Fingerprint: 1d7d ef54 7a63 5756 63a7 cf14 fbd8 775c c39d 4e51",<br />
description = "AES 256-bit",<br />
dataColor = {0.0, 0.6, 1.0, 0.3},<br />
},<br />
<br />
},<br />
</syntaxhighlight><br />
<br />
The data table contains data that's specific to your mission, in this example we're defining the players [https://en.wikipedia.org/wiki/Pretty_Good_Privacy PGP] encryption key <br />
<br />
{| class="wikitable"<br />
!colspan="2"| Data Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''internalName'' || The internalName we'll use to identify this data (Must be unique!)<br />
|-<br />
| ''name'' || The display name of the data, this is what will be displayed in the games UI<br />
|-<br />
| ''immutable'' || Is the data immutable? If true the player won't be able to delete it, this is useful for data items that are part of mission objectives<br />
|- <br />
| ''dataType'' || The type of the data, this is used for displaying the data correctly <br />
|- <br />
| ''creatorName'' || The name of the data's creator (displayed in the UI)<br />
|-<br />
| ''dataString'' || The contents of the data file<br />
|- <br />
| ''description'' || A description of the data file<br />
|-<br />
| ''dataColor'' || RGBA value that's used as the colour of the data point when visible in the players data view<br />
|}<br />
<br />
=== Networks ===<br />
<br />
<syntaxhighlight source lang="lua" line start=40><br />
-- Networks:<br />
--[[ types: 0 = mobile, 1 = WiFi, 2 = mesh ]]--<br />
networks = {<br />
Semaeopus4G = {<br />
name = "Semaeopus4G",<br />
networkType = 0,<br />
allowPlayerDisconnect = false,<br />
userAccessKey = "user",<br />
adminAccessKey = "admin",<br />
rootAccessKey = "root",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The networks table contains all the information about the possible networks in your game, networks can be of different types such as mobile networks, WiFi, and mesh<br />
{| class="wikitable"<br />
!colspan="2" | Network Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''name'' || The name of the network (Must be unique!)<br />
|-<br />
| ''networkType'' || The type of the network (mobile - 0, WiFi - 1, mesh - 2)<br />
|-<br />
| ''allowPlayerDisconnect'' || Is the player allowed to disconnect from the network?<br />
|- <br />
| ''userAccessKey'' || The password for user access to the network<br />
|- <br />
| ''adminAccessKey'' || The password for admin access to the network<br />
|-<br />
| ''rootAccessKey'' || The password for root access to the network<br />
|}<br />
<br />
Data sent at higher access levels across a network won't be visible to devices that are connected at a lower access level.<br />
<br />
=== Objectives ===<br />
<br />
<syntaxhighlight source lang="lua" line start=52><br />
-- Mission objectives:<br />
objectives = {<br />
enterTheBuilding = {<br />
name = "Enter the building",<br />
onStart = function()<br />
print("Player must now enter the building")<br />
end,<br />
onCompleted = function()<br />
print("The player is now in the building!")<br />
end,<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The objectives table contains all the tasks that the player should complete before your mission is finished.<br />
<br />
{| class="wikitable"<br />
!colspan="2" | Objective Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''name'' || The name of the objective (should be unique)<br />
|-<br />
| ''onStart'' || A callback function that's triggered when the objective is started<br />
|-<br />
| ''onCompleted'' || A callback function that's triggered when the objective is completed<br />
|}<br />
<br />
=== Devices ===<br />
<br />
<syntaxhighlight source lang="lua" line start=66><br />
devices = {<br />
laptop = {<br />
internalName = "laptop",<br />
script = "Scripts/Devices/laptop.lua",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
{| class="wikitable"<br />
!colspan="2" | Device Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''internalName'' || The name of the device. Must be unique and match the MissionObject in the scene<br />
|-<br />
| ''script'' || The script that defines the gui and the behaviour of the device ( See [[Mission Scripting/Device Scripting|Device Scripting]] for more information )<br />
|}<br />
<br />
=== Mission Setup ===<br />
<br />
<syntaxhighlight source lang="lua" line start=73><br />
function SetupMission()<br />
-- add player and guards:<br />
Mission.AddCharacter(mission.characters.joe)<br />
-- these two below add in the guards which you might not have created yet!<br />
Mission.AddCharacter(mission.characters.jack)<br />
Mission.AddCharacter(mission.characters.john)<br />
<br />
-- set up hackable devices<br />
Mission.AddHackableDevice(mission.devices.laptop)<br />
<br />
-- set up networks:<br />
Mission.AddNetwork(mission.networks.Semaeopus4G)<br />
Mission.ConnectToNetwork(mission.devices.laptop, mission.networks.Semaeopus4G.name, mission.networks.Semaeopus4G.userAccessKey)<br />
Doors.SetNetwork(mission.networks.Semaeopus4G)<br />
Doors.SetZoneKeys("admin", {"adminkey"})<br />
<br />
-- misc.<br />
-- Player.SetInvisible(true)<br />
<br />
Mission.MissionStarted()<br />
end<br />
</syntaxhighlight><br />
<br />
This will add in all of your created elements into your level, below you will see what the function of each part of this code will do.<br />
<br />
==== Adding in Characters ====<br />
<br />
<syntaxhighlight source lang="lua" line start=74><br />
-- add player and guards:<br />
Mission.AddCharacter(mission.characters.joe)<br />
-- these two below add in the guards which you might not have created yet!<br />
Mission.AddCharacter(mission.characters.jack)<br />
Mission.AddCharacter(mission.characters.john)<br />
</syntaxhighlight><br />
<br />
This part of the code shows the format of adding in characters - this includes the player and any NPCs like the guards, which you will have created further up in your Mission Script. If the title of your character table for your player was called <code>jenson</code>, you would simply change <code>Mission.AddCharacter(mission.characters.joe)</code> to <code>Mission.AddCharacter(mission.characters.jenson)</code>, this would now let your player spawn in.<br />
<br />
==== Adding in Hackable Devices ====<br />
<br />
<syntaxhighlight source lang="lua" line start=80><br />
-- set up hackable devices<br />
Mission.AddHackableDevice(mission.devices.laptop)<br />
</syntaxhighlight><br />
<br />
Once you have set up some hackable devices, by adding this to your SetupMission() the hackable devices will now be added into your level. Similarly to adding in the characters as seen above, to customise this for your own devices, you only need to change the last part inside the brackets. So if the title of one of your devices tables was <code>vendingmachine</code>, you could just change <code>Mission.AddHackableDevice(mission.devices.laptop)</code> to <code>Mission.AddHackableDevice(mission.devices.vendingmachine)</code>.<br />
<br />
==== Adding in Networks ====<br />
<br />
<syntaxhighlight source lang="lua" line start=83><br />
-- set up networks:<br />
Mission.AddNetwork(mission.networks.Semaeopus4G)<br />
Mission.ConnectToNetwork(mission.devices.laptop, mission.networks.Semaeopus4G.name, mission.networks.Semaeopus4G.userAccessKey)<br />
Doors.SetNetwork(mission.networks.Semaeopus4G)<br />
Doors.SetZoneKeys("admin", {"adminkey"})<br />
</syntaxhighlight><br />
<br />
You will have already created a network in your networks table. Now to add it into the game you need to just add in <code>Mission.AddNetwork(mission.networks.NETWORKNAME)</code> where <code>NETWORKNAME</code> is the title of the table you created in your networks table, in this tutorial it was defined as <code>Semaeopus4G</code>. To then connect your hackable devices to your network you just need to add in what you see on line 86, where <code>laptop</code> can be replaced with the hackable devices table name, though in our example the table of our hackable device is called <code>laptop</code>, so we'll keep it as it is.<br />
<br />
Once you have created doors (link?) you can then also add them to a network. By adding them to a network you can make it so that the player cannot open the door unless they have a key. Firstly you add the door to a network, then you can set the door's zone to require a specific key to open it. In our example where we set the zone's required key: <code>Doors.SetZoneKeys("admin", {"adminkey"})</code>, <code>"admin"</code> is the name of the zone the door is assigned to, and <code>"adminkey"</code> is the name of the key that will allow the player to unlock the doors of the zone <code>"admin"</code>.<br />
<br />
==== Adding in Other Changes====<br />
<br />
<syntaxhighlight source lang="lua" line start=89><br />
-- misc.<br />
-- Player.SetInvisible(true)<br />
</syntaxhighlight><br />
<br />
Whilst modding you might get to a point in development where you need to test features like the patrol routes of guards, so a useful line of code you can add to your MissionSetup() is <code>Player.SetInvisible(true)</code>, this will make your player invisible to the Guards which can certainly be handy for testing your level without being spotted!</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Mission_Scripting&diff=191Mission Scripting2017-06-29T15:23:41Z<p>Dominic: added characters and hackable devices to mission setup</p>
<hr />
<div>{{OffGridDocStart}}<br />
<br />
== Intro ==<br />
<br />
This article will describe everything you need to know in order to understand how to write and modify missions scripts in Off Grid!<br />
Mission scripts can get a little bit large but don't let that overwhelm you, they're deceptively simple, we promise!<br />
<br />
== Pre-requisites ==<br />
All modding scripts for Off Grid are written in Lua, it's a lovely little language which is simple ( ''don't tell it I said that'' ) and extensible thanks to the marvellous [http://www.moonsharp.org MoonSharp].<br />
<br />
Lua is quite easy to pick up, even people with no programming experience should be able to get hacking in next to no time!<br />
<br />
You'll need the following tools for editing and writing new mission scripts:<br />
<br />
=== IDE ===<br />
Firstly you'll need an [https://en.wikipedia.org/wiki/Integrated_development_environment IDE], we recommend the [https://atom.io/ Atom] with the following extensions:<br />
{| class="wikitable"<br />
| [https://atom.io/packages/language-lua language-lua] || Syntax highlighting for Lua<br />
|-<br />
| [https://atom.io/packages/autocomplete-lua autocomplete-lua] || Auto-complete support for Lua, we recommend enabling the "Override lower priority providers" in the plugin settings<br />
|-<br />
|}<br />
<br />
=== LevelKit & Game ===<br />
Both of these are needed in order to run and test and scripts you create<br />
<br />
'''TO DO'''<br />
<br />
== The Mission Script Structure ==<br />
As mentioned above, mission scripts can get rather large so this article will attempt to break down all the little sub elements, it can be helpful to try and think of the mission script in the same way you might think of a film script.<br />
The vast majority of the script is simply defining what is in the world of the mission you've created.<br />
Enough talking, lets jump into an example! Rather than posting an entire example script, we'll go from top to bottom exploring what each element does.<br />
<br />
=== Initial Mission State ===<br />
<syntaxhighlight source lang="lua" line><br />
mission = {<br />
<br />
-- Mission info<br />
startTime = {2009, 04, 27, 21, 13, 00},<br />
<br />
</syntaxhighlight><br />
<br />
In this first code block we create the ''mission'' Lua table and define its first value.<br />
<br />
{| class="wikitable"<br />
! Name !! Description<br />
|-<br />
| ''startTime'' || The start time of the mission in the game world (Year, Month, Day, Hour, Mins, Secs)<br />
|}<br />
<br />
startTime doesn't have to be the current date, you can set your mission in any time you desire.<br />
<br />
=== Characters ===<br />
<br />
<syntaxhighlight source lang="lua" line start=5><br />
-- Character definitions:<br />
characters = {<br />
joe = {<br />
displayName = "Joe Harman",<br />
internalName = "Joe",<br />
characterType = "player",<br />
prefab = "player",<br />
spawnpoint = "PlayerSpawn",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
This is the first example of us creating a sub table in the ''mission'' table, the ''characters'' table contains all the information about the characters in your mission!<br />
In this example we've added Joe, the protagonist of Off Grid. Here's a break down of what the value of Joe's table means:<br />
{| class="wikitable"<br />
!colspan="2" | Character Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''displayName'' || The name that will be used any game UI referencing the character <br />
|-<br />
| ''internalName'' || The internalName can be thought of as the id for the character, you'll reference the character by this value in a few places including conversations (Must be unique!)<br />
|- <br />
| ''characterType'' || The 'type' of the character, see [[Character Types and Prefabs]] for more information on possible values<br />
|-<br />
| 'prefab' || The prefab for the character, see [[Character Types and Prefabs]] for more information on possible values<br />
|-<br />
| ''spawnpoint'' || The name of the spawn mission object, the position of this object will be where the character is spawned<br />
|}<br />
<br />
The ''characters'' table can hold information on as many characters as you'd like to fill the mission with, they won't be spawned into the mission until you decide (more on that later)<br />
<br />
=== Physical Items ===<br />
<br />
<syntaxhighlight source lang="lua" line start=15><br />
-- Inventory items:<br />
items = {<br />
usbkey = {<br />
internalName = "USBDongle",<br />
displayName = "USB dongle",<br />
description = "Modified USB Bluetooth dongle given to you by the hackers",<br />
uiSpriteName = "usbdongle.png",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The ''items'' table contains information about physical items that the player will be able to add to their inventory over the course of the mission, in this example we're marking up a USB dongle that the player can plug into computers<br />
{| class="wikitable"<br />
!colspan="2" | Item Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''internalName'' || The internalName we'll use to identify this item (Must be unique!)<br />
|-<br />
| ''displayName'' || The display name of the item, this is what will be displayed in the games UI<br />
|- <br />
| ''description'' || The description of the item, this will be displayed to users in the players inventory UI<br />
|-<br />
| ''uiSpriteName'' || The path to the items sprite, this is the image that will be used in the games UI<br />
|}<br />
<br />
=== Data ===<br />
<br />
<syntaxhighlight source lang="lua" line start=24><br />
--[[ Data files:<br />
Available data types: generic, text, SMS, encrypted, audio, video, location, key, UUID<br />
]]--<br />
data = {<br />
PlayerPGPKey = {<br />
internalName = "PlayerPGPKey",<br />
name = "Personal PGP encryption key",<br />
immutable = true,<br />
dataType = 7,<br />
creatorName = "Player",<br />
dataString = "PGP Fingerprint: 1d7d ef54 7a63 5756 63a7 cf14 fbd8 775c c39d 4e51",<br />
description = "AES 256-bit",<br />
dataColor = {0.0, 0.6, 1.0, 0.3},<br />
},<br />
<br />
},<br />
</syntaxhighlight><br />
<br />
The data table contains data that's specific to your mission, in this example we're defining the players [https://en.wikipedia.org/wiki/Pretty_Good_Privacy PGP] encryption key <br />
<br />
{| class="wikitable"<br />
!colspan="2"| Data Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''internalName'' || The internalName we'll use to identify this data (Must be unique!)<br />
|-<br />
| ''name'' || The display name of the data, this is what will be displayed in the games UI<br />
|-<br />
| ''immutable'' || Is the data immutable? If true the player won't be able to delete it, this is useful for data items that are part of mission objectives<br />
|- <br />
| ''dataType'' || The type of the data, this is used for displaying the data correctly <br />
|- <br />
| ''creatorName'' || The name of the data's creator (displayed in the UI)<br />
|-<br />
| ''dataString'' || The contents of the data file<br />
|- <br />
| ''description'' || A description of the data file<br />
|-<br />
| ''dataColor'' || RGBA value that's used as the colour of the data point when visible in the players data view<br />
|}<br />
<br />
=== Networks ===<br />
<br />
<syntaxhighlight source lang="lua" line start=40><br />
-- Networks:<br />
--[[ types: 0 = mobile, 1 = WiFi, 2 = mesh ]]--<br />
networks = {<br />
Semaeopus4G = {<br />
name = "Semaeopus4G",<br />
networkType = 0,<br />
allowPlayerDisconnect = false,<br />
userAccessKey = "user",<br />
adminAccessKey = "admin",<br />
rootAccessKey = "root",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The networks table contains all the information about the possible networks in your game, networks can be of different types such as mobile networks, WiFi, and mesh<br />
{| class="wikitable"<br />
!colspan="2" | Network Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''name'' || The name of the network (Must be unique!)<br />
|-<br />
| ''networkType'' || The type of the network (mobile - 0, WiFi - 1, mesh - 2)<br />
|-<br />
| ''allowPlayerDisconnect'' || Is the player allowed to disconnect from the network?<br />
|- <br />
| ''userAccessKey'' || The password for user access to the network<br />
|- <br />
| ''adminAccessKey'' || The password for admin access to the network<br />
|-<br />
| ''rootAccessKey'' || The password for root access to the network<br />
|}<br />
<br />
Data sent at higher access levels across a network won't be visible to devices that are connected at a lower access level.<br />
<br />
=== Objectives ===<br />
<br />
<syntaxhighlight source lang="lua" line start=52><br />
-- Mission objectives:<br />
objectives = {<br />
enterTheBuilding = {<br />
name = "Enter the building",<br />
onStart = function()<br />
print("Player must now enter the building")<br />
end,<br />
onCompleted = function()<br />
print("The player is now in the building!")<br />
end,<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The objectives table contains all the tasks that the player should complete before your mission is finished.<br />
<br />
{| class="wikitable"<br />
!colspan="2" | Objective Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''name'' || The name of the objective (should be unique)<br />
|-<br />
| ''onStart'' || A callback function that's triggered when the objective is started<br />
|-<br />
| ''onCompleted'' || A callback function that's triggered when the objective is completed<br />
|}<br />
<br />
=== Devices ===<br />
<br />
<syntaxhighlight source lang="lua" line start=66><br />
devices = {<br />
laptop = {<br />
internalName = "laptop",<br />
script = "Scripts/Devices/laptop.lua",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
{| class="wikitable"<br />
!colspan="2" | Device Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''internalName'' || The name of the device. Must be unique and match the MissionObject in the scene<br />
|-<br />
| ''script'' || The script that defines the gui and the behaviour of the device ( See [[Mission Scripting/Device Scripting|Device Scripting]] for more information )<br />
|}<br />
<br />
=== Mission Setup ===<br />
<br />
<syntaxhighlight source lang="lua" line start=73><br />
function SetupMission()<br />
-- add player and guards:<br />
Mission.AddCharacter(mission.characters.joe)<br />
-- these two below add in the guards which you might not have created yet!<br />
Mission.AddCharacter(mission.characters.jack)<br />
Mission.AddCharacter(mission.characters.john)<br />
<br />
-- set up hackable devices<br />
Mission.AddHackableDevice(mission.devices.OfficeComputerHack)<br />
Mission.AddHackableDevice(mission.devices.PanelHack) <br />
<br />
-- set up networks:<br />
Mission.AddNetwork(mission.networks.Semaeopus4G)<br />
Mission.ConnectToNetwork(mission.devices.OfficeComputerHack, mission.networks.Semaeopus4G.name, mission.networks.Semaeopus4G.userAccessKey)<br />
Mission.ConnectToNetwork(mission.devices.PanelHack, mission.networks.Semaeopus4G.name, mission.networks.Semaeopus4G.userAccessKey)<br />
Doors.SetNetwork(mission.networks.Semaeopus4G)<br />
Doors.SetZoneKeys("admin", {"adminkey"})<br />
Doors.SetZoneKeys("general", {"generalkey"})<br />
-- Player.SetInvisible(true)<br />
Mission.MissionStarted()<br />
end<br />
</syntaxhighlight><br />
<br />
This will add in all of your created elements into your level, below you will see what the function of each part of this block is.<br />
==== Adding in Characters ====<br />
<br />
<syntaxhighlight source lang="lua" line start=73><br />
-- add player and guards:<br />
Mission.AddCharacter(mission.characters.joe)<br />
-- these two below add in the guards which you might not have created yet!<br />
Mission.AddCharacter(mission.characters.jack)<br />
Mission.AddCharacter(mission.characters.john)<br />
</syntaxhighlight><br />
<br />
This part of the code shows the format of adding in characters - this includes the player and any NPCs like the guards, which you will have created further up in your Mission Script. If the title of your character table for your player was called <code>jenson</code>, you would simply change <code>Mission.AddCharacter(mission.characters.joe)</code> to <code>Mission.AddCharacter(mission.characters.jenson)</code>, this would now let your player spawn in.<br />
<br />
==== Adding in Hackable Devices ====<br />
<br />
<syntaxhighlight source lang="lua" line start=73><br />
-- set up hackable devices<br />
Mission.AddHackableDevice(mission.devices.OfficeComputerHack)<br />
Mission.AddHackableDevice(mission.devices.PanelHack) <br />
</syntaxhighlight><br />
<br />
Once you have set up some hackable devices, by adding this to your SetupMission() the hackable devices will now be added into your level. Similarly to adding in the characters as seen above, to customise this for your own devices, you only need to change the last part inside the brackets. So if the title of one of your devices tables was <code>laptop</code>, you could just change <code>Mission.AddHackableDevice(mission.devices.OfficeComputerHack)</code> to <code>Mission.AddHackableDevice(mission.devices.laptop)</code>.</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Mission_Scripting&diff=190Mission Scripting2017-06-29T14:44:02Z<p>Dominic: added Mission Setup section</p>
<hr />
<div>{{OffGridDocStart}}<br />
<br />
== Intro ==<br />
<br />
This article will describe everything you need to know in order to understand how to write and modify missions scripts in Off Grid!<br />
Mission scripts can get a little bit large but don't let that overwhelm you, they're deceptively simple, we promise!<br />
<br />
== Pre-requisites ==<br />
All modding scripts for Off Grid are written in Lua, it's a lovely little language which is simple ( ''don't tell it I said that'' ) and extensible thanks to the marvellous [http://www.moonsharp.org MoonSharp].<br />
<br />
Lua is quite easy to pick up, even people with no programming experience should be able to get hacking in next to no time!<br />
<br />
You'll need the following tools for editing and writing new mission scripts:<br />
<br />
=== IDE ===<br />
Firstly you'll need an [https://en.wikipedia.org/wiki/Integrated_development_environment IDE], we recommend the [https://atom.io/ Atom] with the following extensions:<br />
{| class="wikitable"<br />
| [https://atom.io/packages/language-lua language-lua] || Syntax highlighting for Lua<br />
|-<br />
| [https://atom.io/packages/autocomplete-lua autocomplete-lua] || Auto-complete support for Lua, we recommend enabling the "Override lower priority providers" in the plugin settings<br />
|-<br />
|}<br />
<br />
=== LevelKit & Game ===<br />
Both of these are needed in order to run and test and scripts you create<br />
<br />
'''TO DO'''<br />
<br />
== The Mission Script Structure ==<br />
As mentioned above, mission scripts can get rather large so this article will attempt to break down all the little sub elements, it can be helpful to try and think of the mission script in the same way you might think of a film script.<br />
The vast majority of the script is simply defining what is in the world of the mission you've created.<br />
Enough talking, lets jump into an example! Rather than posting an entire example script, we'll go from top to bottom exploring what each element does.<br />
<br />
=== Initial Mission State ===<br />
<syntaxhighlight source lang="lua" line><br />
mission = {<br />
<br />
-- Mission info<br />
startTime = {2009, 04, 27, 21, 13, 00},<br />
<br />
</syntaxhighlight><br />
<br />
In this first code block we create the ''mission'' Lua table and define its first value.<br />
<br />
{| class="wikitable"<br />
! Name !! Description<br />
|-<br />
| ''startTime'' || The start time of the mission in the game world (Year, Month, Day, Hour, Mins, Secs)<br />
|}<br />
<br />
startTime doesn't have to be the current date, you can set your mission in any time you desire.<br />
<br />
=== Characters ===<br />
<br />
<syntaxhighlight source lang="lua" line start=5><br />
-- Character definitions:<br />
characters = {<br />
joe = {<br />
displayName = "Joe Harman",<br />
internalName = "Joe",<br />
characterType = "player",<br />
prefab = "player",<br />
spawnpoint = "PlayerSpawn",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
This is the first example of us creating a sub table in the ''mission'' table, the ''characters'' table contains all the information about the characters in your mission!<br />
In this example we've added Joe, the protagonist of Off Grid. Here's a break down of what the value of Joe's table means:<br />
{| class="wikitable"<br />
!colspan="2" | Character Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''displayName'' || The name that will be used any game UI referencing the character <br />
|-<br />
| ''internalName'' || The internalName can be thought of as the id for the character, you'll reference the character by this value in a few places including conversations (Must be unique!)<br />
|- <br />
| ''characterType'' || The 'type' of the character, see [[Character Types and Prefabs]] for more information on possible values<br />
|-<br />
| 'prefab' || The prefab for the character, see [[Character Types and Prefabs]] for more information on possible values<br />
|-<br />
| ''spawnpoint'' || The name of the spawn mission object, the position of this object will be where the character is spawned<br />
|}<br />
<br />
The ''characters'' table can hold information on as many characters as you'd like to fill the mission with, they won't be spawned into the mission until you decide (more on that later)<br />
<br />
=== Physical Items ===<br />
<br />
<syntaxhighlight source lang="lua" line start=15><br />
-- Inventory items:<br />
items = {<br />
usbkey = {<br />
internalName = "USBDongle",<br />
displayName = "USB dongle",<br />
description = "Modified USB Bluetooth dongle given to you by the hackers",<br />
uiSpriteName = "usbdongle.png",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The ''items'' table contains information about physical items that the player will be able to add to their inventory over the course of the mission, in this example we're marking up a USB dongle that the player can plug into computers<br />
{| class="wikitable"<br />
!colspan="2" | Item Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''internalName'' || The internalName we'll use to identify this item (Must be unique!)<br />
|-<br />
| ''displayName'' || The display name of the item, this is what will be displayed in the games UI<br />
|- <br />
| ''description'' || The description of the item, this will be displayed to users in the players inventory UI<br />
|-<br />
| ''uiSpriteName'' || The path to the items sprite, this is the image that will be used in the games UI<br />
|}<br />
<br />
=== Data ===<br />
<br />
<syntaxhighlight source lang="lua" line start=24><br />
--[[ Data files:<br />
Available data types: generic, text, SMS, encrypted, audio, video, location, key, UUID<br />
]]--<br />
data = {<br />
PlayerPGPKey = {<br />
internalName = "PlayerPGPKey",<br />
name = "Personal PGP encryption key",<br />
immutable = true,<br />
dataType = 7,<br />
creatorName = "Player",<br />
dataString = "PGP Fingerprint: 1d7d ef54 7a63 5756 63a7 cf14 fbd8 775c c39d 4e51",<br />
description = "AES 256-bit",<br />
dataColor = {0.0, 0.6, 1.0, 0.3},<br />
},<br />
<br />
},<br />
</syntaxhighlight><br />
<br />
The data table contains data that's specific to your mission, in this example we're defining the players [https://en.wikipedia.org/wiki/Pretty_Good_Privacy PGP] encryption key <br />
<br />
{| class="wikitable"<br />
!colspan="2"| Data Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''internalName'' || The internalName we'll use to identify this data (Must be unique!)<br />
|-<br />
| ''name'' || The display name of the data, this is what will be displayed in the games UI<br />
|-<br />
| ''immutable'' || Is the data immutable? If true the player won't be able to delete it, this is useful for data items that are part of mission objectives<br />
|- <br />
| ''dataType'' || The type of the data, this is used for displaying the data correctly <br />
|- <br />
| ''creatorName'' || The name of the data's creator (displayed in the UI)<br />
|-<br />
| ''dataString'' || The contents of the data file<br />
|- <br />
| ''description'' || A description of the data file<br />
|-<br />
| ''dataColor'' || RGBA value that's used as the colour of the data point when visible in the players data view<br />
|}<br />
<br />
=== Networks ===<br />
<br />
<syntaxhighlight source lang="lua" line start=40><br />
-- Networks:<br />
--[[ types: 0 = mobile, 1 = WiFi, 2 = mesh ]]--<br />
networks = {<br />
Semaeopus4G = {<br />
name = "Semaeopus4G",<br />
networkType = 0,<br />
allowPlayerDisconnect = false,<br />
userAccessKey = "user",<br />
adminAccessKey = "admin",<br />
rootAccessKey = "root",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The networks table contains all the information about the possible networks in your game, networks can be of different types such as mobile networks, WiFi, and mesh<br />
{| class="wikitable"<br />
!colspan="2" | Network Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''name'' || The name of the network (Must be unique!)<br />
|-<br />
| ''networkType'' || The type of the network (mobile - 0, WiFi - 1, mesh - 2)<br />
|-<br />
| ''allowPlayerDisconnect'' || Is the player allowed to disconnect from the network?<br />
|- <br />
| ''userAccessKey'' || The password for user access to the network<br />
|- <br />
| ''adminAccessKey'' || The password for admin access to the network<br />
|-<br />
| ''rootAccessKey'' || The password for root access to the network<br />
|}<br />
<br />
Data sent at higher access levels across a network won't be visible to devices that are connected at a lower access level.<br />
<br />
=== Objectives ===<br />
<br />
<syntaxhighlight source lang="lua" line start=52><br />
-- Mission objectives:<br />
objectives = {<br />
enterTheBuilding = {<br />
name = "Enter the building",<br />
onStart = function()<br />
print("Player must now enter the building")<br />
end,<br />
onCompleted = function()<br />
print("The player is now in the building!")<br />
end,<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
The objectives table contains all the tasks that the player should complete before your mission is finished.<br />
<br />
{| class="wikitable"<br />
!colspan="2" | Objective Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''name'' || The name of the objective (should be unique)<br />
|-<br />
| ''onStart'' || A callback function that's triggered when the objective is started<br />
|-<br />
| ''onCompleted'' || A callback function that's triggered when the objective is completed<br />
|}<br />
<br />
=== Devices ===<br />
<br />
<syntaxhighlight source lang="lua" line start=66><br />
devices = {<br />
laptop = {<br />
internalName = "laptop",<br />
script = "Scripts/Devices/laptop.lua",<br />
},<br />
},<br />
</syntaxhighlight><br />
<br />
{| class="wikitable"<br />
!colspan="2" | Device Table<br />
|- <br />
! Name !! Description<br />
|-<br />
| ''internalName'' || The name of the device. Must be unique and match the MissionObject in the scene<br />
|-<br />
| ''script'' || The script that defines the gui and the behaviour of the device ( See [[Mission Scripting/Device Scripting|Device Scripting]] for more information )<br />
|}<br />
<br />
=== Mission Setup ===<br />
<br />
<syntaxhighlight source lang="lua" line start=73><br />
--[[ Mission Setup ]]--<br />
-- Is called every time the mission is loaded, set up characters, networks, devices etc.<br />
-- Do not add to inventories, connect to networks etc this state is for StartMission<br />
function SetupMission()<br />
-- Add Player:<br />
Mission.AddCharacter(mission.characters.joe)<br />
Mission.AddCharacter(mission.characters.jack)<br />
Mission.AddCharacter(mission.characters.john)<br />
<br />
-- set up networks:<br />
Mission.AddNetwork(mission.networks.Semaeopus4G)<br />
Mission.AddHackableDevice(mission.devices.OfficeComputerHack)<br />
Mission.AddHackableDevice(mission.devices.PanelHack)<br />
Mission.ConnectToNetwork(mission.devices.OfficeComputerHack, mission.networks.Semaeopus4G.name, mission.networks.Semaeopus4G.userAccessKey)<br />
Mission.ConnectToNetwork(mission.devices.PanelHack, mission.networks.Semaeopus4G.name, mission.networks.Semaeopus4G.userAccessKey)<br />
Doors.SetNetwork(mission.networks.Semaeopus4G)<br />
Doors.SetZoneKeys("admin", {"adminkey"})<br />
Doors.SetZoneKeys("general", {"generalkey"})<br />
Player.SetInvisible(true)<br />
Mission.MissionStarted()<br />
end<br />
</syntaxhighlight><br />
<br />
tt</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Conversations&diff=189Conversations2017-06-29T14:01:04Z<p>Dominic: </p>
<hr />
<div><br />
== How to write up a crypto chat conversation ==<br />
<br />
The in game conversations through cryptochat are an important way to deliver narrative context, tutorialisation of tools and mechanics, or telegraphing the goals and objectives you might need to, to a player playing your level. <br />
<br />
To start building your own conversations you only need to know the locations of two lua scripts, <br />
<br />
our old friend the 'Mission Script' which as a reminder sits in <code> Assets\StreamingAssets\Levels\*YourLevelName*\Scripts </code><br />
<br />
and then a new script, or actually scripts, you see each conversation is its own lua script found in <code> Assets\StreamingAssets\Levels\NewsPaperOffice\Conversations </code><br />
<br />
Create a new file for your new conversation and give it a name, it can be anything, it is only used a reference for starting the conversation, tieing the name to an objective or event can make it easier to keep in your head when and where the conversation will be called while editing them. The example we are using here is **testConversation.lua**<br />
<br />
[[File:ConversationsLua.png|400px|thumb|none|The file path for the conversations lua files]]<br />
<br />
Conversations can be triggered in many different ways but the most basic example is by a trigger volume such as a mission object.<br />
<br />
==Set up a trigger volume==<br />
<br />
Create a game object and give it a name, in this example "MissionObject_1_1" <br />
<br />
Give it a mission object component, set the drop down to trigger<br />
<br />
Make sure the game object has a box collider, and tick the isTrigger box. <br />
<br />
==In the mission script, create the trigger==<br />
<br />
<syntaxhighlight source lang="lua" line><br />
<br />
-- [[ Mission triggers & interactions]] --<br />
<br />
MissionObjects["MissionObject_1_1"].OnTriggerEnter = function(name)<br />
if name == Player.GetName() then<br />
Mission.StartObjective(mission.objectives.enterbuilding)<br />
end<br />
end<br />
<br />
</syntaxhighlight><br />
<br />
This will fire off the objective on player entry.<br />
<br />
== Create the objective ==<br />
<br />
Here we create the 'enterbuilding' (or objective name of your choosing) objective.<br />
<br />
<syntaxhighlight source lang="lua" line><br />
<br />
-- Mission objectives:<br />
objectives = {<br />
--[[ Find way into the building ]]--<br />
enterbuilding = {<br />
name = "theapostle_obj_enterbuilding_name",<br />
description = "theapostle_obj_enterbuilding_desc",<br />
hints = {<br />
"theapostle_obj_enterbuilding_hint_1",<br />
"theapostle_obj_enterbuilding_hint_2",<br />
},<br />
messages = {<br />
"theapostle_obj_enterbuilding_msg_1",<br />
},<br />
onStart = function()<br />
print("Started objective 'enterbuilding'")<br />
**Conversation.StartScript("testConversation")**<br />
end,<br />
onCompleted = function()<br />
print("Completed objective 'enterbuilding'")<br />
end,<br />
},<br />
<br />
</syntaxhighlight><br />
<br />
The operative part of the objective here is obviously the moment where we call **Conversation.StartScript("testConversation")** and so now we have all the constituent parts.<br />
<br />
== Creating the actual conversation ==<br />
<br />
You have already created your conversation script (the example being 'testConversation.lua' that you created at the start of this example) open up this file and then we are ready to get down to the creative bit. <br />
<br />
Our example conversation looks like this:<br />
<br />
<syntaxhighlight source lang="lua" line><br />
<br />
anger = 0<br />
sendData = true<br />
encrypted = true<br />
characters = {<br />
"Joe",<br />
"Smedley",<br />
"Terrence",<br />
-- "HW",<br />
}<br />
<br />
begin = function()<br />
Send( {"Smedley", "Joe..."} )<br />
Send( {"Smedley", "you there yet?"} )<br />
SendResponse( {"yes"} )<br />
Send( {"Smedley", "Ok this is Terrence, the newspaper editor I told you about"})<br />
Send( {"Terrence", --[["theapostle_obj_enterbuilding_msg_1"]] <br />
"Thanks for turning up, I know this was a strange request. Firstly you're going to need to find a way into the buildings server room in the basement"})<br />
Send( {"Smedley", <br />
function() <br />
return "Yeah, follow my cues and we'll work that out, something like " .. tostring(math.random(1, 40)) .. " young people have been vanished without a trace in the last " .. tostring(math.random(1,4)) .." months."<br />
end } )<br />
-- Send( {"HW", "Oh, it's you."} )<br />
SendResponse( { "Yes but what the hell am I doing here?!", rude }, { "But why a newspaper office?", ignore } )<br />
end<br />
<br />
rude = function ()<br />
anger = anger+1<br />
Send( {"Smedley", "Keep calm, we have alot to get through"} )<br />
continue()<br />
end<br />
<br />
ignore = function ()<br />
anger = anger-1<br />
Send( {"Terrence", "Apologies for being cryptic, I promise all will be revealed"} )<br />
continue()<br />
end<br />
<br />
continue = function()<br />
End()<br />
end<br />
<br />
<br />
</syntaxhighlight><br />
<br />
<br />
There is quite a lot of power behind the conversations system, it's open to being made in the sprawling, branching mess you have always dreamed of creating, or purely an interactive way of tailoring the humour of the player, with a few witty conversational choises and apt trite responses.<br />
<br />
Not only this but you can run functions within conversations to either draw from variables or use mathematical operators, to create complex reactions that draw on 'memory' of previous events in the game.<br />
<br />
The conversations themselves can run generate or add to variables, giving the ability to track elements of the conversation and use it to influence events later in the game for instance unlocking a mission by selecting a particular conversation path could be done by having certain choices add increment a variable with each correct selection. That variable reaching the correct value would then unlock the level. <br />
<br />
More subtly perhaps this functionality could be used to track the players temperament by choices and give varied reactions from different characters dependent on how the player chooses to talk to them.</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Conversations&diff=188Conversations2017-06-28T13:13:27Z<p>Dominic: /* How to write up a crypto chat conversation */</p>
<hr />
<div><br />
== How to write up a crypto chat conversation ==<br />
<br />
The in game conversations through cryptochat are an important way to deliver narrative context, tutorialisation of tools and mechanics, or telegraphing the goals and objectives you might need to, to a player playing your level. <br />
<br />
To start building your own conversations you only need to know the locations of two lua scripts, <br />
<br />
our old friend the 'Mission Script' which as a reminder sits in <code> Assets\StreamingAssets\Levels\*YourLevelName*\Scripts </code><br />
<br />
and then a new script, or actually scripts, you see each conversation is its own lua script found in <code> Assets\StreamingAssets\Levels\NewsPaperOffice\Conversations </code><br />
<br />
Create a new file for your new conversation and give it a name, it can be anything, it is only used a reference for starting the conversation, tieing the name to an objective or event can make it easier to keep in your head when and where the conversation will be called while editing them. The example we are using here is **testConversation.lua**<br />
<br />
[[File:ConversationsLua.png|400px|thumb|none|The file path for the conversations lua files]]<br />
<br />
Conversations can be triggered in many different ways but the most basic example is by a trigger volume such as a mission object.<br />
<br />
=Set up a trigger volume=<br />
<br />
Create a game object and give it a name, in this example "MissionObject_1_1" <br />
<br />
Give it a mission object component, set the drop down to trigger<br />
<br />
Make sure the game object has a box collider, and tick the isTrigger box. <br />
<br />
=In the mission script, create the trigger=<br />
<br />
<syntaxhighlight source lang="lua" line><br />
<br />
-- [[ Mission triggers & interactions]] --<br />
<br />
MissionObjects["MissionObject_1_1"].OnTriggerEnter = function(name)<br />
if name == Player.GetName() then<br />
Mission.StartObjective(mission.objectives.enterbuilding)<br />
end<br />
end<br />
<br />
</syntaxhighlight><br />
<br />
This will fire off the objective on player entry<br />
<br />
= Create the objective =<br />
<br />
Here we create the 'enterbuilding' (or objective name of your choosing) objective.<br />
<br />
<syntaxhighlight source lang="lua" line><br />
<br />
-- Mission objectives:<br />
objectives = {<br />
--[[ Find way into the building ]]--<br />
enterbuilding = {<br />
name = "theapostle_obj_enterbuilding_name",<br />
description = "theapostle_obj_enterbuilding_desc",<br />
hints = {<br />
"theapostle_obj_enterbuilding_hint_1",<br />
"theapostle_obj_enterbuilding_hint_2",<br />
},<br />
messages = {<br />
"theapostle_obj_enterbuilding_msg_1",<br />
},<br />
onStart = function()<br />
print("Started objective 'enterbuilding'")<br />
**Conversation.StartScript("testConversation")**<br />
end,<br />
onCompleted = function()<br />
print("Completed objective 'enterbuilding'")<br />
end,<br />
},<br />
<br />
</syntaxhighlight><br />
<br />
The operative part of the objective here is obviously the moment where we call **Conversation.StartScript("testConversation")** and so now we have all the constituent parts.<br />
<br />
= Creating the actual conversation =<br />
<br />
You have already created your conversation script (the example being 'testConversation.lua' that you created at the start of this example) open up this file and then we are ready to get down to the creative bit. <br />
<br />
Our example conversation looks like this:<br />
<br />
<syntaxhighlight source lang="lua" line><br />
<br />
anger = 0<br />
sendData = true<br />
encrypted = true<br />
characters = {<br />
"Joe",<br />
"Smedley",<br />
"Terrence",<br />
-- "HW",<br />
}<br />
<br />
begin = function()<br />
Send( {"Smedley", "Joe..."} )<br />
Send( {"Smedley", "you there yet?"} )<br />
SendResponse( {"yes"} )<br />
Send( {"Smedley", "Ok this is Terrence, the newspaper editor I told you about"})<br />
Send( {"Terrence", --[["theapostle_obj_enterbuilding_msg_1"]] <br />
"Thanks for turning up, I know this was a strange request. Firstly you're going to need to find a way into the buildings server room in the basement"})<br />
Send( {"Smedley", <br />
function() <br />
return "Yeah, follow my cues and we'll work that out, something like " .. tostring(math.random(1, 40)) .. " young people have been vanished without a trace in the last " .. tostring(math.random(1,4)) .." months."<br />
end } )<br />
-- Send( {"HW", "Oh, it's you."} )<br />
SendResponse( { "Yes but what the hell am I doing here?!", rude }, { "But why a newspaper office?", ignore } )<br />
end<br />
<br />
rude = function ()<br />
anger = anger+1<br />
Send( {"Smedley", "Keep calm, we have alot to get through"} )<br />
continue()<br />
end<br />
<br />
ignore = function ()<br />
anger = anger-1<br />
Send( {"Terrence", "Apologies for being cryptic, I promise all will be revealed"} )<br />
continue()<br />
end<br />
<br />
continue = function()<br />
End()<br />
end<br />
<br />
<br />
</syntaxhighlight><br />
<br />
<br />
There is quite a lot of power behind the conversations system, it's open to being made in the sprawling, branching mess you have always dreamed of creating, or purely an interactive way of tailoring the humour of the player, with a few witty conversational choises and apt trite responses.<br />
<br />
Not only this but you can run functions within conversations to either draw from variables or use mathematical operators, to create complex reactions that draw on 'memory' of previous events in the game.<br />
<br />
The conversations themselves can run generate or add to variables, giving the ability to track elements of the conversation and use it to influence events later in the game for instance unlocking a mission by selecting a particular conversation path could be done by having certain choices add increment a variable with each correct selection. That variable reaching the correct value would then unlock the level. <br />
<br />
More subtly perhaps this functionality could be used to track the players temperament by choices and give varied reactions from different characters dependent on how the player chooses to talk to them.</div>Dominichttp://wiki.offgridthegame.com/index.php?title=Conversations&diff=187Conversations2017-06-28T13:11:37Z<p>Dominic: /* Creating the actual conversation */</p>
<hr />
<div><br />
== How to write up a crypto chat conversation ==<br />
<br />
The in game conversations through cryptochat are an important way to deliver narrative context, tutorialisation of tools and mechanics, or telegraphing the goals and objectives you might need to, to a player playing your level. <br />
<br />
To start building your own conversations you only need to know the locations of two lua scripts, <br />
<br />
our old friend the 'Mission Script' which as a reminder sits in <code> Assets\StreamingAssets\Levels\*YourLevelName*\Scripts </code><br />
<br />
and then a new script, or actually scripts, you see each conversation is it's own lua script found in <code> Assets\StreamingAssets\Levels\NewsPaperOffice\Conversations </code><br />
<br />
Create a new file for your new conversation and give it a name, it can be anything, it is only used a reference for starting the conversation, tieing the name to an objective or event can make it easier to keep in your head when and where the conversation will be called while editing them. The example we are using here is **testConversation.lua**<br />
<br />
[[File:ConversationsLua.png|400px|thumb|none|The file path for the conversations lua files]]<br />
<br />
Conversations can be triggered in many different ways but the most basic example is by a trigger volume such as a mission object. <br />
<br />
=Set up a trigger volume=<br />
<br />
Create a game object and give it a name, in this example "MissionObject_1_1" <br />
<br />
Give it a mission object component, set the drop down to trigger<br />
<br />
Make sure the game object has a box collider, and tick the isTrigger box. <br />
<br />
=In the mission script, create the trigger=<br />
<br />
<syntaxhighlight source lang="lua" line><br />
<br />
-- [[ Mission triggers & interactions]] --<br />
<br />
MissionObjects["MissionObject_1_1"].OnTriggerEnter = function(name)<br />
if name == Player.GetName() then<br />
Mission.StartObjective(mission.objectives.enterbuilding)<br />
end<br />
end<br />
<br />
</syntaxhighlight><br />
<br />
This will fire off the objective on player entry<br />
<br />
= Create the objective =<br />
<br />
Here we create the 'enterbuilding' (or objective name of your choosing) objective.<br />
<br />
<syntaxhighlight source lang="lua" line><br />
<br />
-- Mission objectives:<br />
objectives = {<br />
--[[ Find way into the building ]]--<br />
enterbuilding = {<br />
name = "theapostle_obj_enterbuilding_name",<br />
description = "theapostle_obj_enterbuilding_desc",<br />
hints = {<br />
"theapostle_obj_enterbuilding_hint_1",<br />
"theapostle_obj_enterbuilding_hint_2",<br />
},<br />
messages = {<br />
"theapostle_obj_enterbuilding_msg_1",<br />
},<br />
onStart = function()<br />
print("Started objective 'enterbuilding'")<br />
**Conversation.StartScript("testConversation")**<br />
end,<br />
onCompleted = function()<br />
print("Completed objective 'enterbuilding'")<br />
end,<br />
},<br />
<br />
</syntaxhighlight><br />
<br />
The operative part of the objective here is obviously the moment where we call **Conversation.StartScript("testConversation")** and so now we have all the constituent parts.<br />
<br />
= Creating the actual conversation =<br />
<br />
You have already created your conversation script (the example being 'testConversation.lua' that you created at the start of this example) open up this file and then we are ready to get down to the creative bit. <br />
<br />
Our example conversation looks like this:<br />
<br />
<syntaxhighlight source lang="lua" line><br />
<br />
anger = 0<br />
sendData = true<br />
encrypted = true<br />
characters = {<br />
"Joe",<br />
"Smedley",<br />
"Terrence",<br />
-- "HW",<br />
}<br />
<br />
begin = function()<br />
Send( {"Smedley", "Joe..."} )<br />
Send( {"Smedley", "you there yet?"} )<br />
SendResponse( {"yes"} )<br />
Send( {"Smedley", "Ok this is Terrence, the newspaper editor I told you about"})<br />
Send( {"Terrence", --[["theapostle_obj_enterbuilding_msg_1"]] <br />
"Thanks for turning up, I know this was a strange request. Firstly you're going to need to find a way into the buildings server room in the basement"})<br />
Send( {"Smedley", <br />
function() <br />
return "Yeah, follow my cues and we'll work that out, something like " .. tostring(math.random(1, 40)) .. " young people have been vanished without a trace in the last " .. tostring(math.random(1,4)) .." months."<br />
end } )<br />
-- Send( {"HW", "Oh, it's you."} )<br />
SendResponse( { "Yes but what the hell am I doing here?!", rude }, { "But why a newspaper office?", ignore } )<br />
end<br />
<br />
rude = function ()<br />
anger = anger+1<br />
Send( {"Smedley", "Keep calm, we have alot to get through"} )<br />
continue()<br />
end<br />
<br />
ignore = function ()<br />
anger = anger-1<br />
Send( {"Terrence", "Apologies for being cryptic, I promise all will be revealed"} )<br />
continue()<br />
end<br />
<br />
continue = function()<br />
End()<br />
end<br />
<br />
<br />
</syntaxhighlight><br />
<br />
<br />
There is quite a lot of power behind the conversations system, it's open to being made in the sprawling, branching mess you have always dreamed of creating, or purely an interactive way of tailoring the humour of the player, with a few witty conversational choises and apt trite responses.<br />
<br />
Not only this but you can run functions within conversations to either draw from variables or use mathematical operators, to create complex reactions that draw on 'memory' of previous events in the game.<br />
<br />
The conversations themselves can run generate or add to variables, giving the ability to track elements of the conversation and use it to influence events later in the game for instance unlocking a mission by selecting a particular conversation path could be done by having certain choices add increment a variable with each correct selection. That variable reaching the correct value would then unlock the level. <br />
<br />
More subtly perhaps this functionality could be used to track the players temperament by choices and give varied reactions from different characters dependent on how the player chooses to talk to them.</div>Dominic