[Tool Script] - Stop/Start station production - with indicator

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

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

Post Reply
B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

[Tool Script] - Stop/Start station production - with indicator

Post by B-O'F » Fri, 30. Jun 06, 17:49

Hi,

Here is a useful script to start/stop factory production from the station command panel.

When a station's production has been stopped, an indicator (red asterisk) is placed in front of the station's name.

This is visible in the Properties menu as well as the sector map.

There are entries required for the t file, setup.xxx.Xml, and the xml script itself.

As I have my own file for all the commands, names etc.that I use, I am just giving the information, as it has proven useful.

If anyone wants to modify, package, or anything else with this information, they are welcome to it - it is now in the S&M scripting domain.

It is currently using COMMAND_TYPE_STATION_40 (1140)

tfile entries

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<language id="44">

<page id="2008" title="Script Object Commands" descr="0">
<t id="1140">COMMAND_ON_OFF_PRODUCTION</t>
</page>

<page id="2010" title="Commands" descr=" ">
 <t id="1140">Start/Stop Production</t>
</page>

<page id="2011" title="Commands" descr=" ">
 <t id="1140">0/1 Production</t>
</page>

<page id="2022" title="Command Info" desc="0" >
<t id="1140">\nStart or Stop Factory production.\n\n Enter 1 to Start, 0 to Stop</t>
</page>

<page id="7000" title="Production control Messages" desc="Messages to the player">
<t id="200">[author]Station Production Control[/author]%s has stopped production.</t>
<t id="201">[author]Station Production Control[/author]%s has started production.</t>
<t id="202">\033R* \033X</t>
<t id="203">[author]Station Production Control[/author]%s already stopped.</t>
<t id="204">[author]Station Production Control[/author]%s already started.</t>
</page>

</language>


Setup.control.xml

Change load text: id=XX to match the tfile number used

Code: Select all


001   * Add new commands
002   load text: id=XX

089   * Start/Stop production
090   set script command upgrade: command=COMMAND_TYPE_STATION_40  upgrade=[TRUE]
091   global script map: set: key=COMMAND_TYPE_STATION_40, class=Station, race=Player, script='control.production', prio=0

control.production - Change Page.ID and textid's to match tfile

Code: Select all

name = control.production
version = 0
engine version = 32
description = Start and stop station production

argument index = 1  name = ctrl  type = Number  desc = 1 - start, 0 - stop production


 001     * Start/Stop factory production
 002     * Shows station stopped indicator at start of station name
 003     
 004     * Set tfile page containing messages
 005     $Page.ID = 7000
 006     
 007     * $ss is station stopped indicator - red asterisk plus a space
 008     $ss =  read text: page=$Page.ID id=202
 009     * Station stopped indicator (red asterisk plus space) has length of 6
 010     * Not using a numerical length, so can change it to whatever is wanted
 011     $sslen =  get length of string $ss
 012     
 013     * 0 stops production. 1 or higher starts production
 014     
 015     if $ctrl == 0
 016     * Check if already stopped
 017          $name = [THIS] -> get name
 018          $tname =  get substring of $name offset=0 length=$sslen
 019          if $tname == $ss
 020     * Already stopped
 021               $message = sprintf: pageid=$Page.ID textid=203, [THIS], null, null, null, null
 022          else
 023     * Stop production
 024               [THIS] -> factory production task: on=[FALSE]
 025               $message = sprintf: pageid=$Page.ID textid=200, [THIS], null, null, null, null
 026               
 027     * Set station stopped indicator
 028               $name = [THIS] -> get name
 029               $name = $ss + $name
 030               [THIS] -> set name to $name
 031          end
 032     else
 033     * Check if already started
 034          $name = [THIS] -> get name
 035          $tname =  get substring of $name offset=0 length=$sslen
 036          if $tname == $ss
 037     * It is stopped, so can start it
 038               [THIS] -> factory production task: on=[TRUE]
 039     * Remove station stopped indicator
 040               $name = [THIS] -> get name
 041               $len =  get length of string $name
 042               $len1 = $len - $sslen
 043               $name =  get substring of $name offset=$sslen length=$len1
 044               [THIS] -> set name to $name
 045               $message = sprintf: pageid=$Page.ID textid=201, [THIS], null, null, null, null
 046          else
 047     * Not stopped, say so
 048               $message = sprintf: pageid=$Page.ID textid=204, [THIS], null, null, null, null
 049          end
 050          
 051     end
 052     
 053     * Send success/error mesage
 054     send incoming message $message to player: display it=[FALSE]
 055     return null

[Edit]

To stop the messages from appearing in your logbook, change line 54 to:-

Code: Select all

[THIS]-> send incoming message: text = $message temporary = [TRUE]
[/Edit]
I hope that this is useful to someone out there,

Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

Post Reply

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