Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Dev Tool] Simple Text Message Module
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#1
[Dev Tool] Simple Text Message Module

Enough people have been asking about a SOMA equivalent for Amnesia's SetMessage function that I went ahead and created a module for it.

[Image: AiC97mf.jpg]

Installing the script into your mod is simple - just take the "script" folder from the mod package and copy it into the root folder of your mod, then make sure you add the line "<Directory Path="/script" AddSubDirs="true" />" to your mod's resources.cfg file (if you haven't already).

You will also need to add a new file inside your config folder called "Modules.cfg", then paste this text into that file.

Using the script is simple as well. For basic functionality, it shares the syntax from Amnesia:

SetMessage(const tString &in asText);
SetMessage(const tString &in asTextCategory, const tString &in asTextEntry);
SetMessage(const tString &in asText, float afMessageDuration);
SetMessage(const tString &in asTextCategory, const tString &in asTextEntry, float afMessageDuration);

So a very simple example of using the module (the code I used for the image above in fact) would be:

SetMessage("This is a simple message.");

For people who want to add a little more control to their messages, here is the full syntax for the functions as well:

void SetMessage(const tString &in asText,
    float afMessageDuration = 3.0f,
    eMessagePosition alMessagePosition = eMessagePosition_TopCenter,
    eMessageAlignment alMessageAlignment = eMessageAlignment_Default,
    cVector2f avMessageSize = cVector2f_MinusOne,
    cVector2f avMessageOffset = cVector2f_Zero);
  • asText: The message to be displayed.
  • afMessageDuration: The time, in seconds, for the message to be displayed. (Excluding the fade in/out time.)
  • alMessagePosition: The position of the text on the screen. (Defaults to dead center).
  • alMessageAlignment: The alignment of the text body. (Defaults to dependent on the message position.)
  • avMessageSize: The size, in group space (0.0-1.0), of the text body. (Defaults to roughly two-thirds the width of the screen.)
  • alMessageOffset: The offset, in group space (0.0-1.0), of the message text. (Defaults to no offset.)


void SetMessage(const tString &in asTextCategory,
    const tString &in asTextEntry,
    float afMessageDuration = 3.0f,
    eMessagePosition alMessagePosition = eMessagePosition_TopCenter,
    eMessageAlignment alMessageAlignment = eMessageAlignment_Default,
    cVector2f avMessageSize = cVector2f_MinusOne,
    cVector2f avMessageOffset = cVector2f_Zero);
  • asTextCategory: The text category to be using for this message.
  • asTextEntry: The text entry for the message to be displayed.
  • afMessageDuration: The time, in seconds, for the message to be displayed. (Excluding the fade in/out time.)
  • alMessagePosition: The position of the text on the screen. (Defaults to dead center).
  • alMessageAlignment: The alignment of the text body. (Defaults to dependent on the message position.)
  • avMessageSize: The size, in group space (0.0-1.0), of the text body. (Defaults to roughly two-thirds the width of the screen.)
  • alMessageOffset: The offset, in group space (0.0-1.0), of the message text. (Defaults to no offset.)

To sum that up, you can use either plain text or lang categories for the message text, input your own duration time, define where you want the message box to appear, how you want the text to be aligned, and put in your own custom offset/size for the box itself.

To get the module, you can either get it from the Steam Workshop or by downloading it directly from MediaFire.
(This post was last modified: 03-10-2016, 01:53 PM by Abion47.)
03-10-2016, 01:48 AM
Find
Hypercube Offline
Member

Posts: 124
Threads: 20
Joined: Sep 2015
Reputation: 1
#2
RE: [Dev Tool] Simple Text Message Module

(03-10-2016, 01:48 AM)Abion47 Wrote: Installing the script into your mod is simple - just take the "script" folder from the mod package and copy it into the root folder of your mod, then make sure you add the line "<Directory Path="/script" AddSubDirs="true" />" to your mod's resources.cfg file (if you haven't already).

You will also need to add a new file inside your config folder called "Modules.cfg", then paste this text into that file.
I'm having a little trouble installing it or something, maybe it's a script error but I'm not sure. I put your script folder into my mod folder and added the Modules file into the config folder, but the script still won't work. Everything pops up in the script just fine, but the text won't display on the screen for some reason.

This is all I typed in:

void GlimpseEnd(const tString& in asEntityName)
{
SetMessage("What the hell was that?!");
Entity_SetActive("monster_glimpse_1",false);
}
(This post was last modified: 05-22-2016, 07:20 PM by Hypercube.)
05-22-2016, 07:20 PM
Find
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#3
RE: [Dev Tool] Simple Text Message Module

Does the script throw any errors?
05-22-2016, 07:40 PM
Find
Hypercube Offline
Member

Posts: 124
Threads: 20
Joined: Sep 2015
Reputation: 1
#4
RE: [Dev Tool] Simple Text Message Module

(05-22-2016, 07:40 PM)Abion47 Wrote: Does the script throw any errors?

Well, the script recompile screen or whatever that shows the errors pops up (because I'm in debug mode), but says nothing on it.
(This post was last modified: 05-22-2016, 08:07 PM by Hypercube.)
05-22-2016, 08:06 PM
Find
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#5
RE: [Dev Tool] Simple Text Message Module

Oh, in debug mode the module won't be loaded because it doesn't load your mod's resources or anything, just your map. If you want the module to run in debug mode, you need to replace SOMA's Modules.cfg file as well, then add your mod folder to SOMA's resources file.
05-22-2016, 09:44 PM
Find
Hypercube Offline
Member

Posts: 124
Threads: 20
Joined: Sep 2015
Reputation: 1
#6
RE: [Dev Tool] Simple Text Message Module

(05-22-2016, 09:44 PM)Abion47 Wrote: Oh, in debug mode the module won't be loaded because it doesn't load your mod's resources or anything, just your map. If you want the module to run in debug mode, you need to replace SOMA's Modules.cfg file as well, then add your mod folder to SOMA's resources file.

Oh, I keep forgetting that. Like the fact the my lang file doesn't load in debug, but I didn't think it would be a problem because I thought that if it works in the script file just fine, then it would load correctly? Ehh, well thanks anyways. Big Grin
05-23-2016, 12:37 AM
Find
Rememb Offline
Junior Member

Posts: 1
Threads: 0
Joined: Feb 2017
Reputation: 0
#7
RE: [Dev Tool] Simple Text Message Module

(03-10-2016, 01:48 AM)Abion47 Wrote: Installing the script into your mod is simple

But still I can't get it to work. Been going through the steps multiple times, but I still get "No matching signatures to 'SetMessage(tString)'"

Help would be super appreciated!

EDIT: Nevermind, I fixed it. Needed to add:
#include "helpers/helper_message.hps"
At the top of my .hps file.

Great script btw! Smile
(This post was last modified: 02-24-2017, 10:51 AM by Rememb.)
02-24-2017, 10:26 AM
Find




Users browsing this thread: 1 Guest(s)