Formatting message log text

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Formatting message log text

Post by Litcube »

This has changed in TC hasn't it?

<t id="1">\033B %s \033X</t>

Writing that to the log from the text file writes nothing. A big blank space, as opposed to the expected blue coloured text

EDIT, ANSWER FOUND:

Note to forume help searchers:

The old \033 codes do NOT work when writing text to the message log (though do work, oddly, with the menu system).

The correct method is to use, as -Duty- has indicated:

[yellow]Message Text[/yellow]

This works for all other colors too (red, blue, green, cyan, magenta, white).
Last edited by Litcube on Tue, 28. Oct 08, 22:00, edited 1 time in total.
ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh »

I've used \033Y and \033G and it worked fine, not tried blue though. Didn't put spaces between the colour tags and the %s though like you have there, maybe that's the problem?

<t id="200">\033Y%s\033X</t>

... A direct copy-paste from my t file that works fine.
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

Tried writing it to the message log using
write to player logbook: printf?

Doesn't work. Puts a blank message.
ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh »

Well this code definately works to highlight the word "Default" in yellow:

Code: Select all

<t id="200">\033Y%s\033X</t>
<t id="403">Default</t>

. . .

$option =  read text: page=$page.id id=403
$option = sprintf: pageid=$page.id textid=200, $option, null, null, null, null
EDIT: Actually, the word is used in a 'custom menu', not the logbook. I don't know about adding colour to logbook messages...
jlehtone
Posts: 22078
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

Several X3R scripts definitely did wrote formatted text to logbook.


PS. AFAIK, the colour codes are changes of state machine rather than "tags". Thus,

Code: Select all

\033RHello \033Bworld\033X!!\033X
prints:
Hello world!!
rather than:
Hello world!!
and therefore

Code: Select all

\033RHello \033Bworld\033X!!
is sufficient. For the red exclamations you would use:

Code: Select all

\033RHello \033Bworld\033R!!\033X
It is a difference between

Code: Select all

\colour red
Hello
\colour blue
world
\colour gray
!!
and

Code: Select all

\begin{red}
  Hello
  \begin{blue}
    world
  \end{blue}
  !!
\end{red}
And whether you need the \033X (set colour to default gray) at the end depends on what/how the printing continues. But it is good style to set it explicitly.
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

Hi, guys. Thanks for your help. I've been scripting in Reunion for two years, and I'm aware of how the codes work, but it seems as though something has changed.

@ThisIsHarsh: Yes, the colour codes work in menus. I knew that prior, and have been doing it for a while.

@jlehtone: I usually close the colour code off. You're right. It's good practice.

The essence of my original post, however, is that it writes a blank message to the message log when using a colour code.

Message log.

Blank post.

Colour codes.

Does anyone know how to post colour to the message log? Not to menus, ship names, or in a letter to your mom. Message log. Writing coloured text to the message log.

Message log.
User avatar
-Dusty-
Posts: 2301
Joined: Fri, 30. Dec 05, 20:17
x3tc

Post by -Dusty- »

For messages (including the message log), you have to format your text like this:

Code: Select all

[yellow]Message Text[/yellow]
This works for all other colors too (red, blue, green, cyan, magenta, white).

For all other texts, the old \033x format still works.
I wonder why they have changed this in Terran Conflict...
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

Thank you!

Note to forume help searchers:

The old \033 codes do NOT work when writing text to the message log (though do work, oddly, with the menu system).

The correct method is to use, as -Duty- has indicated:

[yellow]Message Text[/yellow]

This works for all other colors too (red, blue, green, cyan, magenta, white).

Thanks, -Dusty-

Updating OP for info.
jlehtone
Posts: 22078
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

-Dusty- wrote:I wonder why they have changed this in Terran Conflict...
I guess it is a more flexible method of inserting formatted strings into text. The menu entries probably use the old parser as they are frequently shown and the strings are short and more static. Efficiency.

How about the ship and station names? That is a target that somebody probably wants to reformat sooner or later.
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22336
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

-Dusty- wrote:For messages (including the message log), you have to format your text like this:

Code: Select all

[yellow]Message Text[/yellow]
This works for all other colors too (red, blue, green, cyan, magenta, white).

For all other texts, the old \033x format still works.
I wonder why they have changed this in Terran Conflict...
because the BBS was removed.

the incomming message formating was part of the BBS module ;)
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

The old formats work with ship and station names, FYI.
WarChicken
Posts: 136
Joined: Mon, 20. Mar 06, 20:19
x3tc

Post by WarChicken »

Is it possible to rename your ships to colored text (maybe even formattet like bold or italic) without using anything advanced like a script?
By just using the rename option?
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

No.
WarChicken
Posts: 136
Joined: Mon, 20. Mar 06, 20:19
x3tc

Post by WarChicken »

That's a pity. But thanks anyway for the info.
alex2069
Posts: 205
Joined: Thu, 22. Dec 05, 21:19
x3tc

send incoming message and write to player logbook problems

Post by alex2069 »

So I'm playing with scripting, but for some annoyingly stupid unknown reason, send incoming message and write to player logbook wont work for me. They just come up as blank For the log book the sender is "Unknown", and for the message it's really weird and skewed (the "ok" button is way off to the side for some reason, but no message text).

However if I do write to log file, it works perfectly - as in, I could do all three commands directly after each other with the exact same input message, but only the log file works.

Are there some sort of weird limitations or format constraints for the other two?
alex2069
Posts: 205
Joined: Thu, 22. Dec 05, 21:19
x3tc

Post by alex2069 »

Bleh, finally figured it out.
I was using the \033x type colors and the message/log didn't like them. After much searching apparently you can just use [color]text[/color], lol.


{Merged to thread listed in sticky. jlehtone}
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

to the problem this Topic started with: i have written a library, which changes the old tags (used in Ship Names or Menues) into the new Tags (uses in Incoming and Logbook Messages)

here is a Screen of the Test Run Result (write the Name of the Player Ship in the Logbook):
[ external image ]

and here the library itself

How to Use:
Input:
Argument 1: Object, which name has to be re-formatted or String to re-format

Returnvalue: Re-Formatted String, definetly free of the old Color-Tags ;)

Version Return: Put in 'VersionCheck' vor Argument 1

DO NOT MODIFY THIS LIB-SCRIPT unless you know what you do, otherwise your game will freeze when this Script is called...

i will add some modded EGOSoft-Scripts (which are creating Logbook-Entries or send Messages to the Player) that they use this soon (but there are some Hardcoded things i cann't change..), for the modification of other Scripts which are sending Messages or Logbook entries please ask the responsible Scripter to modify it...



PS This Library has not been tested under every possible and impossible condition (for example there were some problems with long Strings in the test runs which are avoided by some changes in the Code) so if there are any problems please tell me :)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
Chroniss
Posts: 155
Joined: Mon, 10. Nov 03, 21:15
x3tc

Converting Scripts - Problem with message choices

Post by Chroniss »

I've been trying to pull some scripts from Reunion over to TC, and while they work in game to some extent, regardless of the script I'm testing the initialization message that gives you setup options always shows like this:

http://img204.imageshack.us/my.php?imag ... agegk6.jpg

Anyone know why this is? I thought at first it was color codes, but removing those did nothing. The text file is setup correctly something like this:

<page id="1234" title="Temp" descr="0" voice="0">

<t id="1">Testing</t>
<t id="2">Select the Difficulty Level\n
[select value="1"]Easy[/Select]\n
[select value="2"]Medium[/Select]\n
[select value="3"]Hard[/Select]\n
</t>
<t id="3">Configuration</t>

and the script calls it with this command:
$Variable = sprintf: pageid=$page.id textid=1, null, null, null

it initializes the correct pageid to $page.id previously in the script, and I don't think thats related because I can pull data from that variable correctly, it just wont display it right.

This is just an example, I have tested 3 different scripts that work in game but their configuration message is messed up in the same manner. If I change the script to just dispay id=1 for instance, it will show Testing. If I change it back to show all page.id it shows this |< symbol.


{Merged to active relevant thread, which already contains the answer. jlehtone}
Chroniss
Posts: 155
Joined: Mon, 10. Nov 03, 21:15
x3tc

Post by Chroniss »

I have no color codes in the text file though, its just as shown and it still displays that odd symbol.

Its like this in the script (1234 is just for example)

$page.id=1234
load text: id= $page.id

$var = sprintf: pageid = $page.id textid = 2, null, null, null

send incomming question $var to player: callback al.temp.config

I know its reading from the text file because if I change textid = 2 to textid = 1 it displays Testing. If I use 2 I get this problem.

I tried changing the read input to
$var = read text: page = $page.id id=2

like I saw on page 1 but that didn't do anything different.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

it is no direct Solution for your problem, but why are you not using the new custom menus??

(dont wonder about the Line Numbers, i have copied a bit from one of my Scripts ^^)

102 $menu.arr = create custom menu array
104 add custom menu item to array $menu.arr: text='Easy' returnvalue=1
106 add custom menu item to array $menu.arr: text='Medium' returnvalue=2
108 add custom menu item to array $menu.arr: text='Hard' returnvalue=3
114 $difficulty = open custom menu: title='Select Difficulty' description='Select the Difficulty for the ***-Script' option array=$menu.arr
115 skip if not $area == -1
116 return null
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”