Take On Mars

Take On Mars

26 ratings
Scenario creating IV: Datapad
By dariusz1983
Scenario Creating Part 4

Well hello there dear friends. Glad to see you stick around, but enough with the formalities. We're here to talk about the datapad. The datapad is a little "toy" we have in the game. It's use is being demonstrated in a prototype scenario. It is great to display mission relevant information to the player and the best thing is, we can use it for our own purposes.

This modding guide is the fourth in a series of guides trying to show you guys and gals how to make cool scenarios. I have spent some quality time going through the code and the config files, experimenting etc. and have found some really fun stuff for everyone to try out.

The guide series:
  1. Starting in a landing vehicle
  2. Triggers and Events
  3. Displaying messages to the player
  4. Data Pad guide (this guide)
  5. Supply Drop with custom goodies.
  6. Mission Objectives

If there's anything you guys would like to see, let me know in the comments. I am going to create a scenario that actually uses all of the mentioned "features" and upload it as a reference.
   
Award
Favorite
Favorited
Unfavorite
Introduction
The datapad's gui offers three main features, a customizable information page, a camera and a map:



The camera allows you to take screenshots. The screenshots will be saved under:
C:\Program Files (x86)\Steam\userdata\PLAYERID\244030\local\PLAYER\screenshots

The map shows the current scenario map and the players current position on it, nothing else.

The information page contains three sub pages. Text, images and audio. All of those can be filled with your own data, and it's almost easy, all you need to do is provide the content you'd like to display to the player and do some little numeric magic. But not to worry, I'll show you how.

The datapad, or rather, every datapad in a scenario looks for three config files that are located in following subfolder:
\scripts\entities\configs\datapad

The three files are:
  • text.cfg
  • images.cfg
  • audio.cfg

Those files all contain the data to display, texts, images and audio files respectively. Each piece of data (a text, single image, and audio file) is represented by a single line. Each line consists of two string entries, the title and the actual data.

One important thing to remember is that those specify all the available data and each and every datapad (described in the scenario file) defines which of those entries it will use.

I will demonstrate that for the texts. It works in the same manner for the other types of data.
Texts



The datapad can display up to 32 (text) items. Clicking on one and hitting "READ" displays the actual text. All the available text data is stored in the text.cfg file using the following format:
"TITLE" "TEXT"

You can type the text directly like this:
"Objective #1" "In order to survive, you have to locate the emergency beacon..."

Of course you can use a reference to the strings.xml file like this:
"#tkom_SP_DataTXT_1_title" "#tkom_SP_DataTXT_1"

Now the important theoretical part. You can populate your config file with texts and everything. Then, you create a scenario with a datapad. You fire up the game and...well, nothing. The datapad shows none of your texts.

The reason is that you have to tell each and every datapad which of the text entries from the text.cfg file you want it to use. This is accomplished by means of the generic vector value of said datapad. But first, this is how the line in the scenario file looks like, that defines a single datapad:
BB_INV_STORED 0 "#tkom_SP_DataPad_title" "#tkom_SP_DataPad" "gui/textures/printer3dhud/characters/tools/datapad" "Scripts/Entities/Controllers/TakeMeToMars/InventoryItems/Items/DataPad.h" "Scripts/Entities/Configs/InventoryItems/Items/DataPad.cfg" "obj/misc/items/datapad.xob" "" "scripts/entities/configs/fx/part_small.cfg" 5 "Tool Small Medium Large" 0 0 "0 0 0" "DATAPAD"

Now this is the code the scenario editor inserts for a datapad already stored in the players inventory. Just for your interest, the last six entries in this long lines have following meaning:
5
"Tool Small Medium Large"
0
0
"0 0 0"
"DATAPAD"
Stored Item Mass
Valid Slots
Generic Integer
Generic Float
Generic Vector
Generic String

What we are interested in is the generic vector, which, in 3D space, is defined by three numbers. Now usually a vector is used to define a place in the world, or the direction of a force, velocity, etc. In this case it has a different meaning.
"0 0 0"

It defines three numeric values. Each value defines which entries to display. The first number defines which text entries to display. The second defines the images to display and the third the audio files.

I'm really sorry, but we have to dipp our toes in computer science. Those three numbers contain so called flags. This is a design pattern (technique) to store versatile information in a single number. It basically allows you to store boolean values (true/false) and retrieve them. The trick is powers of 2. Here's an example:
Flag
Value
Mashed potatoes
1
Steak
2
Peas
4
Coke
8

Now, in order to store a "meal order" in a single numeric value all you have to do is add the flag values. If we want a steak with a coke and no extras we add 2 and 8, the result is 10. A 10 uniquely identifies the flag values for a coke and a steak, nothing else.
The flag values are powers of 2, so the first is 1, then 2, 4, 8, 16, 32, 64, 128 and so on. Simply multiplay each number with 2 to get the next.

Now back to our datapad. Imagine each entry representing a text in the text.cfg is numerated like a list, but with powers of 2. Here's an example:
1 "Objective 1" "Get some food for the others" 2 "Objective 2" "Find some oxygen" 4 "Objective 3" "Find the rover keys" 8 "Secret 1" "Find the obelisk"

If you want your datapad to display all of those you have to add all the flag values and put them in the first generic string. Here, all summed up would be 1+2+4+8=15.

The generic vector is therefor:
"15 0 0"

Or as a complete entry:
BB_INV_STORED 0 "#tkom_SP_DataPad_title" "#tkom_SP_DataPad" "gui/textures/printer3dhud/characters/tools/datapad" "Scripts/Entities/Controllers/TakeMeToMars/InventoryItems/Items/DataPad.h" "Scripts/Entities/Configs/InventoryItems/Items/DataPad.cfg" "obj/misc/items/datapad.xob" "" "scripts/entities/configs/fx/part_small.cfg" 5 "Tool Small Medium Large" 0 0 "15 0 0" "DATAPAD"

And that's it. The reason the devs chose this aproach is to allow one text.cfg file that can supply several datapds with different information.

P.S.: The reason why the max number of text (or any other) items is 32 is that 2 power 32 is the highest number that a (32-bit) computer can store. I tell you that only to assure you the devs didn't chose the limitation out of a bad mood or something.

I hope this helps you. Have fun experimenting.
26 Comments
JoeThePunisher Apr 5 @ 9:10am 
As Sir Cobalt stated there is no entities, configs or datapad files. I too never located the files even when i did a search. those file folders seem to be missing do we just add them ourselves and if so where?
DeltaforceAKAwalker Feb 16, 2023 @ 11:40am 
hello is there any update on the tutorial i mean i am also not finding this files even did a full search on SSD's and nothing
Silver Fox Jun 20, 2020 @ 7:57pm 
Hi there! I can't find the subfolders "\scripts\entities\configs\datapad"... I have the scripts folder, but that's about it. There's no subfolders there. Anyone?
indeepj Dec 8, 2019 @ 2:59pm 
And So, This Is Very Important Information
Thanks!
Harbingerman May 22, 2018 @ 9:21pm 
I do not see this subfolder or if I do it is empty: \scripts\entities\configs\datapad why or where is it?
Sir Cobalt Aug 6, 2017 @ 2:54pm 
There is no entities, configs or datapad files.

Of course this would happen to me, never anyone else, just me. Typical.
Myst Leissa Feb 9, 2017 @ 2:13am 
Just FYI you should list this info in the main guide: The Best Proporitions for Image Size are 1024x768 - Which is the same as the datapad's external screenshot size. I had to fool around quite a bit to find out what was wrong with my images. JPG are usable even though the default game uses TGA.
dariusz1983  [author] Jan 30, 2017 @ 2:11pm 
@Mr. Monochrome [Hood Certified]
Sure thing!
Mr. Monochrome [Hood Certified] Jan 30, 2017 @ 9:59am 
@dariusz1983

Could you add information on how to code the images and audio section? I'm trying to add audio to a datapad that isn't part of a scenario but is printed out and the audio just ends up blank.
dariusz1983  [author] Jan 13, 2017 @ 7:41am 
@The Ghost: Thanks! You too.