Text Placement

Started by DCillusion, Thu 24/06/2004 05:56:36

Previous topic - Next topic

DCillusion

Is there any way to set the default position of the text window.  I'm going to get carpel tunnels if I have to write DisplayAt  for EVERY line I enter.

Ginny

#1
I don't know about setting a default, but you could create a custom function:

function DisplayAtDefault (string message, ...) {

DisplayAt (100, 50, 40, string message, ...);

}

- - - - - - - - - -
DisplayAtDefault ("This is displayed in the default place.");

However, I'm not entirely sure that the ... thing will work, it's supposed to allow you to include int and strings in your messages, something like this:

int coins_amount = 35;

DisplayAtDefault ("You have %d coins.", coins_amount);

:)
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Scorpiorus

With the Display function a text window is always centred. DisplayAt is the only way out but you can have a simple wrapper function to make it easier:

main global script:

function DisplayMy(string message) {
   DisplayAt(50, 100, 100, message);
}

script header:

import function DisplayMy(string message);


script:
DisplayMy("displaying a text at 50, 100");

Ginny

I tried something with including an integer in the text, and using an int in the room didn't work, it displayed 44704 or some value like that, instead of 16, the assigned value, and using an int in the global script didn't help. I only managed to do this this way:

function DisplayAtDefault (string message, ...) {

DisplayAt (100, 50, 40, message, coins_amount);

}
in which case it works, but only with global scope variables, or GlobalInts, and it's specific to this variable.

Also, does it matter if you use "import function DoStuff (int first, int second);" or "import function DoStuff (int, int);" ? I may have asked this before and forgotten :P.
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Scorpiorus

Quote from: Ginny on Thu 24/06/2004 13:39:18
I tried something with including an integer in the text, and using an int in the room didn't work...
That's a limitation of custom functions. You, generally, can't have them like the built-in Display function and have to fill a string and pass it to DisplayAtDefault:

string info;
StrFormat(info, "money: %d", coins_amount);
DisplayAtDefault(info);

There is a quite tricky way of doing it with (...) an ellipsis but it would be not very reliable and can crash the engine at any time.

QuoteAlso, does it matter if you use "import function DoStuff (int first, int second);" or "import function DoStuff (int, int);" ? I may have asked this before and forgotten :P.
You can do either way but without specifying of parameters names you won't see these nice calltips showing not only a type but parameters names as well.

SMF spam blocked by CleanTalk