Where is the 'Room message editor?'

Started by madradubhcroga, Thu 03/05/2012 16:58:52

Previous topic - Next topic

madradubhcroga

Hi.
I may deserve a slap for asking this, but:


Where is the 'Room message editor?'

Context:

I want what the character says when looking at an item to appear beside a GUI in the top right corner of the screen, like this:


+++++++++++++++++++++++++++++++++++++++++
+  @@                                                                                +
+ @@@   "A sword hangs over the fireplace."                   +
+  @@                                                                                +
+                                                                                        +
+                                                                                        +
+                                                                                        +
+                                          -                                             +
+                                       P                                               +
+                                                                                        +
+                                                                                        +
+                                                                                        +
+++++++++++++++++++++++++++++++++++++++++



Manual says use DisplayMessage(x);
Where x  =  the line in the Room message editor.
But where is it?

monkey0506

DisplayMessage only exists for legacy reasons. There is no room message editor, though by default your game does have some messages that are stored. Removing or changing them can permanently break your game, so don't.

Use Character.Say, Character.SayAt, Display, a GUI, etc. for your needs.

madradubhcroga


Thanks for reply!

I thought maybe there was a drop-down menu like the 'Dialogues' one that I was missing.
That would be handy, because I could put in functional place-holder-type dialogue for now, and then just go down the list later and replace it all with bona-fide literature.

If I want good-reads in the game, I'm just going to have to get it right first time, or chase through all the room.asc windows looking for and replacing all my bad prose, eh? 

Khris

#3
You could code a substitute.
In a new script, put this in .ash:

Code: ags
import void DisplayRM(int x);


and .asc:

Code: ags
String rm[200];

void game_start() {
  rm[0] = "A sword hangs over the fireplace.";
  rm[1] = "...";
  ...
}

void DisplayRM(int x) {
  DisplayAt(20, rm[x]);
}


Then use
  DisplayRM(0);

Bonus: if you do it that way, you can customize the way the message is displayed as much as you want.

madradubhcroga

#4

That's amazing.
Wow.
Thank you.


String rm[200];

sets the number of characters per text, right?


Where are the parameters like background & font colour being selected from?

If I use a SetTimer to make the string disappear after a few seconds, does that mean I have one less SetTimer for the room?

And where can I find out what 'Void' means and does?


Khris

1. String rm[200]; reserves space for 200 Strings, or here, room messages. (If 200 stood for the number of characters, there'd be only one string.)
If you need more, just increase the number.
The number of characters per message is the usual limit of the String datatype. (500 or something).

2. DisplayAt uses the default text GUI. You can create your own by right-clicking the GUI node and selecting "New Text Window GUI". When you're done, enter its number in General settings -> Text output -> Custom text-window GUI
Alternatively, you can put inside the DisplayRM function whatever you want; you don't have to use DisplayAt.

3. You only need a timer if the game is supposed to continue while the message is displayed. You can have up to 20 simultaneous timers running. But basically yes, if your room uses timers 1-3, you shouldn't reuse them in the display script. Just use timer 20 for that.

4. void is in the same category as function. I've used void because the function only DOES something and doesn't need to return a value.
Basically, using the function (or int) keyword tells AGS: here's a block of code with name x, and at the end, it might or might not return an integer value.
Using void tells AGS (and, almost more importantly, any coder reading the source) that the function doesn't return anything.


monkey0506

Quote from: Khris on Fri 04/05/2012 11:00:58The number of characters per message is the usual limit of the String datatype. (500 or something).

To be clear on this point, AGS doesn't have a hard-coded limit on the length of a String (a string by contrast has a limit of 200 characters). The String.Format function cannot return a String that is longer than a certain length (I think CJ increased this to some absurd value like 2048 just because of me (see Stack module, etc.)). The work-around in that case would be just to have Format return shorter formatted Strings and then Append them together (Append doesn't have a hard-coded limit).

Quote from: Khris on Fri 04/05/2012 11:00:583. You only need a timer if the game is supposed to continue while the message is displayed. You can have up to 20 simultaneous timers running. But basically yes, if your room uses timers 1-3, you shouldn't reuse them in the display script. Just use timer 20 for that.

Since AGS only has 20 timers for use with the built-in timer functions, it's helpful to point out that you can just create an int variable yourself and update it in repeatedly_execute. When you get more advanced with scripting this is typically the "preferred" method just because it ensures your timers won't collide with any other code you might use (e.g. modules, plugins, etc.).

deadlockuk

Try using DisplayAt function in the function that starts after the event has happened:
DisplayAt(X, Y, Width, "string message");

Go to the Room editor and double click on the Room, hover with the mouse over the location where your message should be Displayed - the upper left corner of the message window - write down those X and Y coordinates, for example 60 for X and 70 for Y.

Go back to the script and use those X and Y values. you will need to experiment with the WIDTH as it will depend on the length of the message string.

hope that answers your question.

Khris

deadlockuk: It's nice that you want to help, but a) putting arbitrary coordinates in 100+ lines is a really bad way to do stuff, and b) madradubhcroga was also looking for a way to edit all messages in one place.

deadlockuk

Quote from: Khris on Wed 09/05/2012 12:33:12
deadlockuk: It's nice that you want to help, but a) putting arbitrary coordinates in 100+ lines is a really bad way to do stuff, and b) madradubhcroga was also looking for a way to edit all messages in one place.
my wrong :)

SpeechCenter

Quote from: Khris on Thu 03/05/2012 19:16:00
You could code a substitute.
In a new script, put this in .ash:

Code: ags
import void DisplayRM(int x);


and .asc:

Code: ags
String rm[200];

void game_start() {
  rm[0] = "A sword hangs over the fireplace.";
  rm[1] = "...";
  ...
}

void DisplayRM(int x) {
  DisplayAt(20, rm[x]);
}


Then use
  DisplayRM(0);

Bonus: if you do it that way, you can customize the way the message is displayed as much as you want.
Is this a best current practice? How would one create a voice acting script after the game is all developed? (or is there a feature for this which I missed?)

Khris

No, it's not really good practice at all. I just pointed out how to do something like that because of this statement:
Quote from: madradubhcroga on Thu 03/05/2012 19:02:16If I want good-reads in the game, I'm just going to have to get it right first time, or chase through all the room.asc windows looking for and replacing all my bad prose, eh?

I haven't looked at your plugin yet, I assume it parses the scripts for .Say lines only?

SpeechCenter

#13
Yes, it parses built-in speech functions that have a string as a parameter and I recently added custom functions, but cases like these won't give proper results.
It's not easy to implement with static analysis, I may be able to create an interpreter, but it's more effort and it will never cover all use cases. The editor has similar limitations, probably for the same reasons. So I think we need to either provide best practices with the current capabilities or establish a new, but standard way to cover speech.

EDIT: Actually, when I think about it, one of the reasons I created the plugin is for madradubhcroga's use case - so there won't be a need to chase for bad text in all the scripts  :)

SMF spam blocked by CleanTalk