How to make BBS missions using the script engine

The place to discuss scripting and game modifications for X³: Reunion.

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

Mysterial
Posts: 645
Joined: Wed, 6. Nov 02, 20:31
x4

How to make BBS missions using the script engine

Post by Mysterial » Sat, 19. Nov 05, 05:54

After much trial and error, I've figured out much about creating BBS missions using the script engine.

It works a lot like the AL engine; you register a script as a BBS mission script and the BBS system calls your script with certain event strings that you must use to perform some action.

The register function is under General Commands: "register quest script <script name> instance multiple=<number>". Instance multiple is the maximum number of instances of this mission that may be offered/running simultaneously.

BBS mission scripts have four parameters:

1: The quest object. (this is NULL for 'init' and 'reinit' events) This is for use to pass to the various quest updating functions that take a variable of type 'Var/Quest'. Note that said type isn't selectable as a script parameter type, you must use 'Value'.
2: The event string. The event strings that I've found are described below.
3. Instance data array. This array can be filled with whatever you want and every time your quest script is called with an event, the data array that corresponds to that instance of the quest is sent. This is where you store what the player needs to do and what's happened so far, for example how many wares the player needs to buy and how many he's got so far.
4. Question choice. This contains whatever the player chose when the quest gives him a question (with [select value=whatever] in the text) using the 'set quest state with message' function.

The events that I've seen so far are:

init: sent when you register the script
reinit: sent when you load a savegame where the script is registered
prio: sent to get the priority of your mission (the likelihood of it being offered). I'm not sure what the correct range of values is here, but returning higher numbers seems to be more likely to appear.
offer: sent when the BBS system wants to offer your mission. You must set the quest state to Quest.Offered (it's in the list of constants) with the message you want to display by using the 'set quest state with message' function in General Commands. The message must have at least one [select value=whatever] or the player won't be able to actually activate it.
display: sent when the player actually looks at the mission in the BBS.
select: sent when the player picks one of the choices your offer text had. Parameter 4 holds what they chose. If the player is allowed to take the mission, you should set the quest state to Quest.Accepted, otherwise set it to Quest.Aborted.
accept: sent when the quest state is set to Accepted.
check: sent periodically once the quest has been accepted. I know for sure it's sent every time you enter a station or gate. This is where you check on the progress of the mission. You should set the quest state to Quest.Finished when the mission is over.
destruct: sent when the mission has been removed from the system (because the player didn't select it in the BBS and the timeout expired, because it was aborted, or because it was finished, it doesn't matter). This is where you do any cleanup operations.

As with AL engine plugins, you can't register quests in a startup script prefixed with 'init'. You can use a 'al.plugin' script, however. There might be a special prefix for BBS mission startup scripts, but I haven't found it yet.

You can tag an object to call your quest when certain events happen to it. To do this, use the function 'add event listener'. This function takes three parameters; 1) the quest object as passed to the first parameter to your quest script, 2) the event type you're interested in (one of the constants that starts with 'Quest.Event'), and 3) the script to call when the event occurs. The script will be given the same parameters as your quest script, except that parameter 2 will be the name of the event that you were looking for ('killed', 'captured', etc) and parameter 4 will be the object that the event happened to. The script can be your quest script; you don't have to write a seperate one. Unfortunately, objects only seem to support one event per quest at a time, so you cannot for example hook up both 'Quest.Event.Killed' and 'Quest.Event.Captured'.

Hope this is helpful! Please add anything you discover :)
Last edited by Mysterial on Sun, 20. Nov 05, 01:23, edited 1 time in total.

bendyspex
Posts: 837
Joined: Tue, 13. Apr 04, 10:39
x3

Post by bendyspex » Sat, 19. Nov 05, 10:30

Does this mean we will be seeing new BBS missions being made soon? If so thats great, hopefully the missions will be a lot more imaginaive than the ones currently available.

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Sat, 19. Nov 05, 13:21

nice one finding out :)

will have to have a play aorund with it

Mysterial
Posts: 645
Joined: Wed, 6. Nov 02, 20:31
x4

Post by Mysterial » Sun, 20. Nov 05, 01:42

Found out some more stuff about registering missions and mission events that I've added above.

User avatar
LV
Sith Lord
Posts: 8255
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by LV » Sun, 20. Nov 05, 10:24

How about uploading an example script, I've spent enough days/weeks/eons frustrating myself trying to get the BBS integrated :evil:
LV's TC Scripts
Readme's For All My Scripts


I felt a great disturbance in the forum, Like millions of voices cried out in terror, then were silenced

si tacuisses, philosophus mansisses

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Sun, 20. Nov 05, 13:30

i've managed to get BBS missions working now, i will soon release the script as an example of how its done, seems pretty simple so far

the "prio" event is sent when you first check the bbs in a station, and is only sent once until you leave the sector.

So if you dock at a station and view the BBS, the prio will be sent to the script, but wont be sent again until you leave the sector and dock again.

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Sun, 20. Nov 05, 14:22

Heres an example script, its quite basic
it adds a bbs entry to overtune your ship, when accepting, it will add extra engine tunings to your ship

Download Rar Archive

User avatar
Red Spot
Posts: 3461
Joined: Fri, 4. Feb 05, 13:44
x3

Post by Red Spot » Sun, 20. Nov 05, 14:33

:thumb_up:

and
LV wrote:How about uploading an example script, I've spent enough days/weeks/eons frustrating myself trying to get the BBS integrated :evil:
Lord Vader .. the Force .. its .. I cant feel it anymore ..;):P


G

Mysterial
Posts: 645
Joined: Wed, 6. Nov 02, 20:31
x4

Post by Mysterial » Sun, 20. Nov 05, 15:23

Here's an example of the mission I'm working on that shows most of the things I've found so far. It's kind of messy and still has debug code and such but it shouldn't be too hard to understand.

Example mission

User avatar
LV
Sith Lord
Posts: 8255
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by LV » Sun, 20. Nov 05, 16:16

Red Spot wrote::thumb_up:

and

Enough to have his spleen removed with a blunt instrument
You have no idea how much I hatethe BBS already, I tried working it out more times that you've been reject by women and the last time I checked Norris McWhirter wanted to put that record in his book.

LV runs off with the above two scripts like a child with a pocket full of stolen candy.

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Sun, 20. Nov 05, 16:21

hehe, good luck adding them into ur scripts
:)

999-JAY-999
Posts: 622
Joined: Mon, 7. Apr 03, 16:29
x3tc

Post by 999-JAY-999 » Mon, 21. Nov 05, 14:22

A RAY of hope...... fledging out the bare mundane BBS system.... RIGHT ON!

:)
System Spec :-

AMD Athlon(tm) 64 Duel 6000+ (3.01GHz)
Windows XP Home Ed. SP 3
ATI Radeon HD 4850 (512)
Creative X-FI Soundard
2.00 GB of RAM
G9 RAZOR Mouse

User avatar
LV
Sith Lord
Posts: 8255
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by LV » Tue, 22. Nov 05, 20:44

Imperial respect here guys, If it wasn't for the fact my GF Card is melting currently I'd have some BBS up and running :thumb_up:
LV's TC Scripts
Readme's For All My Scripts


I felt a great disturbance in the forum, Like millions of voices cried out in terror, then were silenced

si tacuisses, philosophus mansisses

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Thu, 1. Dec 05, 00:22

Just a few things i've found out

the command

Code: Select all

set quest <Var/Quest> timeout to <Var/Number>
is used to set the timeout event, after the given time it will call the "timeout" event followed by the "destruct" and the quest is ended

the command

Code: Select all

set quest/event <Var/Quest> timer to <Var/Number>
is used to set the timer event, after the given time the "timer" event will be called, this only seems to be called once.

Both commands only work after the quest as been accepted

User avatar
DeltaWolf
Posts: 597
Joined: Tue, 6. Jul 04, 08:48
x4

Post by DeltaWolf » Mon, 5. Dec 05, 09:04

Anybody figured out how to add a BBS news article? - does it work the same as the quest ones, or is it completely different?

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Mon, 5. Dec 05, 11:22

i've been trying but not had any luck yet, theres 2 commands you have to use

one is the display news article, which sets up the message to display and returns the news object

then you use the change availabity command using the returned object, to set it in the stations within a set radius


It is possible to use the quest method to create news articles, if you dont put theanswers in, it will display it as a normal news, its not the best method, but it works until we can find out how the news articles work

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Tue, 6. Dec 05, 03:41

Let me try to give a brief explanation of how to set up randomized news articles using the newsengine. I'm going to start typing for a bout an hour and then stop, so if I don't get all the way thru, sry. :) Hopefully you'll be able to figure out the nitty gritty given the rough stuff I'll present.

I'm going to use my random economic events scripts as the example.

Basically, what the newsengine can do, is given a bunch of segments of text that can work together, it will piece together a bbs articale and then display it.

Here's the piece of the script that calls for the display of the bbs article:
(don't worry, I'll try to explain it all in a little bit)

Code: Select all

177   * define variables for news article
178    $news.array =  array alloc: size=2
179    $news.array[0] = $ware
180    $news.array[1] = $sector
181    $occurences = random value from 3 to 6 - 1
182    
183   * add bbs news articles to relevant stations
184    $key =  display news article: page=$text.page.id newsid=$news.id occurences=$occurences maxoffertime=null maxtime=null placeholder:race1=$race race2=null customarray=$news.array
185    
186    if $key 
187      change event news availability: $key race=$race sector=null jumps=null
Ok, let's work through the script code first.

You can pass arguments to your bbs article to be displayed as part of the text. You pass them as an array of any size. They'll be referenced in the t file. I needed two variables for my news events, the ware to be affected, and the sector in which the event took place. So I construct an array with two elements, called news array, and I load these values in. Note that $ware and $sector would've been defined earlier in the script.

Occurences defines something like the maximum number of times you'll see the bbs article, to be honest, I'm not precisely sure.

Ok, now there are two main steps to actually creating the news article and then placing it in stations. The first command you see which begins with $key handles the creation. Basically what that line does is go to the t file and look at the text that it has to choose from . Then the newsengine pieces together the text subject to the rules that you set up and creates the article. We're not talking about static articles here, those are extremely easy, I'm giving you the full blown example of how to create dynamic articles.
You'll see the first argument after page.id (which just references the correct page in the t file), is news.id. I'll refer to this periodically as news.id or event number or event in this tutorial. It just means, if you've defined like 8 different types of bbs articles that could be displayed (player wins lottery, player blows up station, player gains race recognition, whatever you want your articles to be about). Anyway, if you've defined several types of articles, those will be different event numbers, so you can use the newsengine to call the one you like referenced by number.
Let me define the t file before I get into what the other individual arguments in this line of code does ok?

the next line that says change event news ... is what actually tells the game to put the newly created article into the stations bbs.

Let's take a look at a small piece of the t file now.
(I've trimmed out most of the non unique type of entries, you can see the full thing somewhere in the t file for the game)

Code: Select all

- <page id="2200" title="good econ event news page" descr="Text for Good Economic Events News">
  <t id="101">Argon</t> 
  <t id="102">Boron</t> 
  <t id="103">Split</t> 
  <t id="104">Paranid</t> 
  <t id="105">Teladi</t> 
  <t id="108">Pirates</t> 
  <t id="151">Argon</t> 
  <t id="152">Boron</t> 
  <t id="153">Split</t> 
  <t id="154">Paranid</t> 
  <t id="155">Teladi</t> 
  <t id="158">Pirates</t> 
  <t id="10000">[author]Galaxy Network - GalNet[/author]</t> 
  <t id="10100">$AUTHOR$, Editor in Chief, GalNet Economic News</t> 
  <t id="10101">$AUTHOR$, Assoc. Editor, GalNet Economic News</t> 
  <t id="10200">Check back regularly for all the latest business news concerning $SECTOR$ and surrounding areas.</t> 
  <t id="10300">Surrounding sectors have reported a frenzied increase in traffic as ships struggle to reach $SECTOR$ to take advantage of the great prices.</t> 
  <t id="10301">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.</t> 
  <t id="10302">Freighters are arriving at steadily increasing rates in the sector, loading up with as much stock as they can hold, with destinations as of yet unknown. Prices in neighbouring sectors remain steady despite the incredible offers currently available in $SECTOR$.</t> 
  <t id="10400">There does not seem to be an end to the sector's good fortune, and while many may think that the profits made by those who trade in this area may be less than legal, nothing has been proven bar honest work and long stazuras spent in hangar bays and cockpits.</t> 
  <t id="10401">We have seen countless traders spread across the sector who are clearly delighted at the turn of events to befall them. While many agree with us that these times will eventually come to an end, no one is willing to place a bet on when that time may come.</t> 
  <t id="10402">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.</t> 
  <t id="10500">"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.</t> 
  <t id="10501">"I didn't think I would see something like this in my lifetime. I remember our elders talking of times like these when I was very young. That they are upon us now, this surprises me," said $PERSON1$, a station manager still apparently in shock at being in the middle of such happenings.</t> 
  <t id="10502">"We have seen so many workers who were clearly short of sleep and in need of replacement that we have stopped counting. The stress of the situation is indeed beginning to show, but one thing's for sure, profits have never been so good. We're selling like hellfire!" said $PERSON1$, a station manager clearly excited to be seeing such incredible business.</t> 
  <t id="200000">[Author][Byline][Report][Melodrama A][Melodrama B][Quote]</t> 
  <t id="200001">[Event Comment]</t> 
  <t id="200002">[Headline][Intro]</t> 
  <t id="210000">$WARE$</t> 
  <t id="210001">$SECTOR$</t> 
  <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> 
  <t id="2010000">example of event 1 specific text</t> 
  <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>  
  </page>
Ok, that's only a little piece of it, but I think it demonstrates everything you'd need to know.

Ok, let's go line by line and talk about what each line in the t file does, and I'll reference back to the arguments in the script code as well (as needed). The first thing to remember is that we're piecing together a unique article from a lot of possibilities given a template ok? So you basically need to define the template, and all of the possible choices and then tell the newsengine how to piece it together. Then it does all the work. i know that doesn't make sense yet, read on.

There are certain variables that are always available in every news article and don't need to be passed as arguments in that special array we talked about creating earlier. They are:
  • $THISSTATION$ - the station the player is docked at
    $THISPEOPLE$ - the race (people) of the station the player is docked at
    $THISRACEGOVERNMENT$ - the race (govt) of the station the player is docked at
    $THISPERSON$ - random name of a person belonging to the race of the station the player is docked at
    $AUTHOR$ - a different random name as above
    $PEOPLE1$ - the race (people) defined in the code in slot 1
    $PERSON1$ - random name of a person belonging to the race defined in the code in slot 1
    $GOVERNMENT1$ - the race (govt) defined in the code in slot 1
    $PEOPLE2$ - same as above for slot 2 (I don't use slot 2 in the econ code)
    $PERSON2$ - same as above for slot 2 (I don't use slot 2 in the econ code)
    $GOVERNMENT2$ - same as above for slot 2 (I don't use slot 2 in the econ code)
you see back in the line of script code the stuff after the placeholder? it takes an argument for race1, race2, and then customarray? Race1&2 are used to define the above variables that can be used in the article. Customarray lets you define other variables you want to have available that aren't contained above. Ok? That should be it for getting variables into the article. You'll see how they're referenced in the text as I continue to explain the t file.

Ok, line by line. The first few lines of the t file should contain the lines:

Code: Select all

  <t id="101">Argon</t> 
  <t id="102">Boron</t> 
  <t id="103">Split</t> 
  <t id="104">Paranid</t> 
  <t id="105">Teladi</t> 
  <t id="108">Pirates</t> 
  <t id="151">Argon</t> 
  <t id="152">Boron</t> 
  <t id="153">Split</t> 
  <t id="154">Paranid</t> 
  <t id="155">Teladi</t> 
  <t id="158">Pirates</t> 
What this does is define the text to use for the variables $PEOPLE1$, and $GOVERNMENT1$. The reason those are different variables is because in other languages the words are not necessariliy the same. So just put these lines in the beginning of your text page. You'll notice in the script editor that like, Argon correspond to the number 1, etc. The same convention is here, that's why they are listed in the order given. If you put, for example:
<t id="101">Argon Citizens</t>
Then what would happen is when the script code took the race1 argument of Argon and passed the number 1 to the t file, it would look at entry 101 (because of the 1 - argon) and come up with the above text for $PEOPLE1$.
So 101 - 105, 108 defines what will be used for $PEOPLE1$ for the 6 races (I'd assume it will extend to other races as well, just figure out the numbers.
151 - 155, 158 defines what will be used for $GOVERNMENT1$

Ok so far?

Let's skip a bit until we come to the following lines:

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>  
These lines define all of the segments that can be used to construct the article. You'll see that I've defined 6 segments in the first line, one in the second, and two in the last, you can read them above. You can define up to 100 segment types in each line. (God help you if you have that many :p).
This is what the individual lines mean:
200000 - this text id is used to define all of the 'generic' text for your articles. This means that these segments are available to any article to use.
200001 - this text id is used to define all of the 'event specific' text for your articles. The text for these segments will only be available to the defined events. (you'll define which text goes with which events below)
200002 - this text id is used to define all of the 'event specific linked' segments. I know this doesn't make much sense yet, but bear with me. Here you define all of the segments that are specific to events and must go together. You can look at my example for [Headline] and [Intro]. Meaning that every event has a unique Headline that must be displayed and then a linked Intro segment that must correspond to the headline.

Now that I've told the news engine what types of segments I'm going to have, now I want to populate the choices. Each segment must have at least one entry associated with it. let's go back up to where we were in the t file:

The first thing that is defined are the generic segments (the ones defined in t id 200000)

Code: Select all

  <t id="10000">[author]Galaxy Network - GalNet[/author]</t> 
This is where I define my only entry for the [Author] segment type.

Generic segment definition t ids always have 5 digits and begin with the number 1.

10000 - these two numbers define the segment type. 00 is the first segment, and therefore corresponds to the first entry in the segment definition line '[Author]'. (Don't worry this will make more sense as I go through a couple)

10000 - these two numbers are the unique id. 00 is the first entry for the author segment type.

so 10000 means the first entry of the first segment type
10304 means the fifth entry of the fourth segment type (don't forget to start counting from 0 :)) etc.

Let's look at the next two lines:

Code: Select all

  <t id="10100">$AUTHOR$, Editor in Chief, GalNet Economic News</t> 
  <t id="10101">$AUTHOR$, Assoc. Editor, GalNet Economic News</t> 
Ok, using the above rules, we can see that 10100 means the first entry of the second segment type. 10101 means the second entry of the second segment type. The second segment type, as defined by that first line we looked at, is [Byline]. So these are my two entries for the [Byline] segment type.

Moving on:

Code: Select all

  <t id="10200">Check back regularly for all the latest business news concerning $SECTOR$ and surrounding areas.</t>
This is my first and only entry for the [Report] segment type. Can you see why?

Code: Select all

  <t id="10300">Surrounding sectors have reported a frenzied increase in traffic as ships struggle to reach $SECTOR$ to take advantage of the great prices.</t> 
  <t id="10301">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.</t> 
  <t id="10302">Freighters are arriving at steadily increasing rates in the sector, loading up with as much stock as they can hold, with destinations as of yet unknown. Prices in neighbouring sectors remain steady despite the incredible offers currently available in $SECTOR$.</t>
These are my three entries for [Melodrama A].

You should be able to see the entries that follow for [Melodrama B] and
which follow underneath.

Ok so now the news engine knows all of the generic segment types we have, and it knows all the possible choices it has to choose from if it's told to use a certain segment.

I'll continue in the next post.
Last edited by Burianek on Thu, 8. Dec 05, 03:22, edited 2 times in total.
"Nature's first green is gold" . . . stay golden.

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Tue, 6. Dec 05, 03:42

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.

1000000 - 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)
1000000 - these numbers don't do anything (I don't think), keep them zeros
1000000 - 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.
2010000 - 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)
2010000 - 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.
2010000 - 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.
Last edited by Burianek on Tue, 6. Dec 05, 05:08, edited 1 time in total.
"Nature's first green is gold" . . . stay golden.

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Tue, 6. Dec 05, 04:48

Oh, by the way, if you just wanted simple static articles, you could simply define 1 event specific segment for each event.
Call it [Article] or something.

Code: Select all

  <t id="200001">[Article]</t>
Then you'd just have one template like:

Code: Select all

  <t id="1000000">[Article]</t>
It can be generic since you're going to use an [Article] segment regardless of the event type.

Then when you call the event, it's going to look for [Article] segments defined as the following ids:

Code: Select all

  <t id="2010000">article for event 1</t>
  <t id="2020000">article for event 2</t>
  <t id="2030000">article for event 3</t>
  <t id="2040000">article for event 4</t>
  <t id="2050000">article for event 5</t>
Make sense? Easy as pie. ;)
"Nature's first green is gold" . . . stay golden.

User avatar
Burianek
Posts: 2981
Joined: Mon, 29. Dec 03, 03:29
x3tc

Post by Burianek » Tue, 6. Dec 05, 04:52

Oh, I forgot to define:

Code: Select all

187      change event news availability: $key race=$race sector=null jumps=null
$key was built using the previous command
race sets which stations to display the article in (station owned by, not setor owned by)
sector sets the central sector
jumps displays the jump radius from the central sector in which it will be displayed

null values for sector and jumps specify all (or that it's not filtered)

so my news article displays in all stations across the galaxy owned by $race.

If you want to set it to display in multiple race stations, you may call the command more than once. Once for every race you want to include.
However, note that the sector and jump values will be overwritten for the article every time you call the command. So you can't define a different sector and jumprange for each race. If you're defining multiple races, only the last defined sector and jumprange will be used (for all of them).

Cheers.
Last edited by Burianek on Thu, 8. Dec 05, 03:30, edited 2 times in total.
"Nature's first green is gold" . . . stay golden.

Post Reply

Return to “X³: Reunion - Scripts and Modding”