Ok, the next lines in the t file are:
Code: Select all
<t id="200000">[Author][Byline][Report][Melodrama A][Melodrama B][Quote]</t>
<t id="200001">[Event Comment]</t>
<t id="200002">[Headline][Intro]</t>
We've already talked about those above, although note that we've only defined the generic segments so far, we haven't done 'event specific' or 'event specific linked' yet.
Moving onward:
Code: Select all
<t id="210000">$WARE$</t>
<t id="210001">$SECTOR$</t>
This section defines the variables that were passed to the newsengine using the Customarray argument in the script. Remember I constructed a two element array where the first element was the $ware and the second was the $sector? This section defines those entries in that array so the newsengine can make use of them in the text. You can have as many elements to your array as you like, just start with:
- 2100000 - first element
2100001 - second element
2100002 - third element
and so on. Have as many entries as you need to fully describe the array you are passing.
Once you define them in this way, you can use them in the text. And you can probably see places in the generic text we've already looked at where I've included the variables $WARE$ and $SECTOR$. Anywhere the newsengine sees those variables it's going to replace them with the values from the array.
Moving right along, the next section is very important. It's where we define the templates to use in constructing the article:
Code: Select all
<t id="1000000">[Author][title][Headline][/title][justify][Intro][br/][br/][Melodrama A][Quote][br/][br/][Report][/justify][br/][br/][Byline]</t>
<t id="1000001">[Author][title][Headline][/title][justify][Intro][Melodrama A][br/][br/][Quote][Melodrama B][br/][br/][Report][/justify][br/][br/][Byline]</t>
<t id="1000002">[Author][title][Headline][/title][justify][Intro][Melodrama B][Quote][br/][br/][Report][/justify][br/][br/][Byline]</t>
Ok, let me try to remember here:
Every template t id is going to have 7 digits. They always start with 1.
1
000000 - The first two numbers define the events that the templates are used for. If you use 00, then they are generic templates that could be used for all of your articles. (I kept mine simple and did not have event specific template types)
100
0000 - these numbers don't do anything (I don't think), keep them zeros
10000
00 - The last two numbers are the unique ids, just like they were for the generic text segments.
So you can see that I've defined three different template types for all of my events. I'll get into how the newsengine constructs the article using these templates after we've defined the rest of our segments.
Next in the t file is:
Code: Select all
<t id="2010000">example of event 1 specific text</t>
Ok, event specific text ids have 7 digits and always start with the number 2.
2
010000 - The first two numbers define the event that the text is used for. You would never have 00 here since there are no generic entries for event specific texts. (that wouldn't make sense)
201
0000 - These numbers denote the first segment, which was defined above in the line <t id="200001">[Event Comment]</t>. If I had two segments in there, I'd need to define at least one entry for both.
20100
00 - The last two numbers are the unique ids, just like they always have been.
So it's easier than it sounds. For the generic ids we had five digits. They defined both the segment number and the unique id. For event specific, we just need to add a couple of numbers to denote the event right? Other than that, it's just the same. So the event numbers are the first two. The segment numbers are the next two. The unique id is the last two.
So for example, t id: 2020402 means:
The 3rd unique id for the fifth segment for the second event type.
Remember that unique ids and segments start with 00, event types always start with 01. (and then go sequentially, 02, 03, 04, etc.) You can't start event types with 00 since 00 means generic. (In the templates at least)
Read that until it makes sense
Notice that I only have one example event specific text in there just to show you how it's done. I don't actually use it anywhere inthe text. (you can see that since you don't see the [Event Comment] segment in any of my templates.
Moving onward in the t file:
Code: Select all
<t id="3010000">Solar Flares Spark Energy Boom in $SECTOR$</t>
<t id="3020000">Discovery in $SECTOR$</t>
<t id="3010100">A sudden rise in solar activity has enabled Solar Power Plants to substantially accelerate their production rate. Station managers across the sector have reported in record yields with prices dropping to an all-time low. This has in turn created a chain-reaction with other stations throughout the sector recording a surge in production.</t>
<t id="3020100">Scientists have recently discovered another location for what may possibly be the first new resource to be of value in several Jazuras. Since the news was first published, $SECTOR$ has been flooded with requests for further information. While still unknown, it is believed the refinement of the resource yields massive amounts of energy cells, which has consequently sparked a rise in the production for all factories given the sudden abundance of energy now available for consumption in $SECTOR$.</t>
Ok, these texts define the entries for the segments of the 'event specific linked' type. Remember those were the ones defined in the previous line:
Code: Select all
<t id="200002">[Headline][Intro]</t>
These are just like the event specific ones defined above, but instead of starting with a 2, they start with a 3.
From what we've learned I hope you can deduce what is going on.
We have four entries here, as follows in order:
3010000 - The first entry for the [Headline] to be used for event type 1
3020000 - The first entry for the [Headline] to be used for event type 2
3010100 - The first entry for the [Intro] to be used for event type 1
3020100 - The first entry for the [Intro] to be used for event type 2
Do you see why?
The second two numbers specify the event, the next two the segment number, 00 is the first [Headline], 01 is the second [Intro]. I only have one entry to choose from for each type.
Now let me try to define linked as opposed to the simple event specific.
Linked means that if I had more than one possible entry for each event, linked always pairs up unique ids.
Let me explain this way. Let's say I've defined four [Headline] and four [Intro] segments for event 1 as follows:
My [Headline] segments:
- 3010000
3010001
3010002
3010003
and my [Intro] segments:
- 3010100
3010101
3010102
3010103
Ok?
Linked means if the code randomly selects to use the second [Headline]: 3010001, it will also use the 'linked' second [Intro]: 3010101 since they have the same unique id.
So if 3010003 is selected as the [Headline], the code must also use 3010103 for the [Intro] if the template also calls for an [Intro].
Does that make sense?
If I had defined the [Headline] and [Intro] blocks as event specific (as opposed to linked) I'd have the following [Headline] and [Intro] segments:
My [Headline] segments:
- 2010000
2010001
2010002
2010003
and my [Intro] segments:
- 2010100
2010101
2010102
2010103
In this case, they aren't linked, so let's say the code decides to use 2010002 as the [Headline]. It doesn't have to use 2010102 for the [Intro] it can use any of the four, and it will select one at random.
I hope that makes sense.
To be honest, in this exsample t file, since I only have one unique entry for each headline and intro, I could've defined them as event specific or linked. I didn't need to link them since there's nothing random about choosing the only entry defined for an event. But oh well, I hope it makes sense anyway.
So now we have everything defined. let's look at how the code builds the article using those templates defined above.
Constructing the Article:
The first thing the newsengine does is read in the $news.id or event number from the code. Then it looks at possible templates. Since I don't have any event specific templates, it's going to pick one of the generic ones at random. It will then piece together the article using the selected template. So, let's say when it's called, it selects the second one, 1000001. (look back at the templates for reference)
Reading from left to right, it will start to construct the article.
First it will put the [Author] segment in, so it goes to look at my defined [Author] segments, sees only one, 10000, and grabs it. It puts the text in the author segment of the bbs screen (top left) since I put the [author] [/author] tags around my text. (Please don't confuse the [author][/author] tags which appear in the line of text with the [Author] text segment (which is the whole line. I probably should've named that something else, it's kind of confusing.
Anyway, ok, so it's stuck in the [Author] segment, it moves on. It says, ok, I need a [Headline] (which I've placed between the [title][/title] tags to center it at the top of the article. [Headline] it finds in the event specific linked section, so it says, 'ok, I'm looking for event 1, so I need to pick one from that defined list'.
I only have one [Headline] defined for event 1, 3010000. So it grabs that and puts it in.
Next it moves to the next segment to place. [justify] is a text formatting command, not a segment type. you'll see that closing [/justify] after the bosy of the article has been defined later on in the template. The next segment it finds is [Intro]. It finds [Intro] in the linked section so it says, 'ok, for linked stuff, I've already chosen the unique id of 00 for linked segements when I grabbed the [Headline], so I have to use this for all future linked segments as well, so I need to find 3010100 (the first unique entry of the second segment type defined in the linked section). So it looks and finds it and grabs it and puts it in. It is not a random selection since it was a linked segment. It is specifically looking for that text id. (for reasons discussed above)
It moves on and says, 'ok I need a [Melodrama A]'. That's in the generic section so it's not event specific. It grabs one of the segments in between 10300 - 10302 at random and puts it in. (remember, [Melodrama A] is the fourth segment type, so the second two numbers in the id should be 03)
Next it looks for a
, so it grabs one of 10500 - 10502 at random (
is the 6th defined segment)
Next it looks for a [Melodrama B], so it grabs one of 10400 - 10402 at random.
Ignoring the formatting tags, it finishes off with a [Report] and a [Byline], so it grabs 10200 for the [Report] and then either 10100 or 10101 for the [Byline] and places them in there. Hopefully at this point you see why.
At this point it's done constructing the article using the template.
You'll get something like this:
Code: Select all
Solar Flares Spark Energy Boom in $SECTOR$
A sudden rise in solar activity has enabled Solar Power Plants to substantially accelerate their production rate. Station managers across the sector have reported in record yields with prices dropping to an all-time low. This has in turn created a chain-reaction with other stations throughout the sector recording a surge in production. These events have given cause for many to believe that this may herald a new era for trade relations between $SECTOR$ and its neighbours. Those who believed otherwise appear to be in a now silent minority.
"It's been incredible! I've never known anything like this to have happened before. Certainly my shipmates don't recall such an event in near history either!" claimed $PERSON1$ who had just arrived at the station while we were investigating this story. Jumpgates remain in constant use as the sector works hard to process the traders working to cut a higher margin of profit on trades that are now becoming known across even more outlying regions.
Check back regularly for all the latest business news concerning $SECTOR$ and surrounding areas.
$AUTHOR$, Editor in Chief, GalNet Economic News
Can you point out each segment?
, [Melodrama A] etc.?
You see where the line breaks [br/] tags come in and seperate the text according to the template?
You can see that by varying the template styles and using different segments in different orders subject to different formatting, (and the fact that every time it's pulling in different text at random to construct the article) you can have just a couple of text entries and templates and you'll get a huge variety of articles to be displayed.
Ok, I've now been typing for over 2 1/2 hours. That's all I can say for now.
If someone doesn't use this now, I'll go postal, just letting you know.
Cheers.
"Nature's first green is gold" . . . stay golden.