в общем, когда-то давно (точнее этим летом) я это правило себе чинил. Примерно так...
1) открыл куид Driver command на редактрование
2) скрипт там шифрованный, поэтому скопировал скрипт какого-то локомотива с переименованием на DriverCommandRule.gs
3) вставил скрипт этого правила из АПИ 2006
как я помню, заработало
Код HTML:
//
// DriverCommandRule.gs
//
// Copyright (C) 2002 Auran Developments Pty Ltd
// All Rights Reserved.
//
include "ScenarioBehavior.gs"
include "World.gs"
include "Browser.gs"
include "KUID.gs"
//
// This rule allows the scenario-designer to edit the driver commands available in a profile.
//
class DriverCommandRule isclass ScenarioBehavior
{
KUID[] driverCommands; // array of KUIDs of the driver commands currently in this rule
bool isDefault = true; // set to true if this rule's properties have not been customised
//
// Resets the commands in the Trainz world to the ones this rule has. Called by Pause()
// when this behavior is unpaused to reset driver commands.
//
void CreateCommandsNow(void);
void FillDefaults(void);
//
// ScenarioBehavior methods
//
//
// Initialization method that sets the driver command array to being empty.
//
public void Init(Asset p_self)
{
inherited(p_self);
driverCommands = new KUID[0];
}
//
// Pause/unpause this behavior. When unpaused, CreateCommandsNow() is called to reset
// driver commands.
//
public void Pause(bool paused)
{
if (paused == IsPaused())
return;
SetStateFlags(PAUSED, paused);
if (!paused)
CreateCommandsNow();
}
//
// PropertyObject methods
//
//
// Initializes the driver commands list of this rule from the given database.
//
public void SetProperties(Soup soup)
{
inherited(soup);
//
// Clear any existing data
//
driverCommands = new KUID[0];
//
// Reload from the specified soup
//
Soup commands = soup.GetNamedSoup("commands");
int i, count = commands.CountTags();
for (i = 0; i < count; i++)
{
Soup commandInfo = commands.GetNamedSoup((string)i);
driverCommands[i] = commandInfo.GetNamedTagAsKUID("kuid");
}
Interface.Log("DriverCommandRule.SetProperties> " + driverCommands.size() + " commands loaded");
isDefault = !count and !soup.GetNamedTagAsInt("DriverCommandRule.modified");
// this is a helper in case someone needs to know what commands are available
// it may cause inconsistancies if multiple DriverCommandRules are present!
// THIS IS A HACK - DONT RELY ON THIS IF AT ALL POSSIBLE
if (World.GetCurrentModule() == World.SURVEYOR_MODULE)
CreateCommandsNow();
}
//
// Saves the KUIDs of the driver commands in this rule to a database and returns it.
//
public Soup GetProperties(void)
{
Soup soup = inherited();
Soup commands = Constructors.NewSoup();
int i, count = driverCommands.size();
for (i = 0; i < count; i++)
{
Soup commandInfo = Constructors.NewSoup();
commandInfo.SetNamedTag("kuid", driverCommands[i]);
commands.SetNamedSoup((string)i, commandInfo);
}
soup.SetNamedSoup("commands", commands);
soup.SetNamedTag("DriverCommandRule.modified", !isDefault);
Interface.Log("DriverCommandRule.GetProperties> " + driverCommands.size() + " commands saved");
return soup;
}
public bool ListContainsKUID(KUID[] list, KUID it)
{
int i;
for (i = 0; i < list.size(); i++)
if (list[i] == it)
return true;
return false;
}
public bool ListRemoveKUID(KUID[] list, KUID it)
{
int i;
for (i = 0; i < list.size(); i++)
if (list[i] == it)
{
list[i, i+1] = null;
return true;
}
return false;
}
public void ListAddKUID(KUID[] list, KUID it)
{
list[list.size()] = it;
}
//
// Returns HTML code with hyperlinks that allows commands in this rule to be added/deleted.
//
public string GetDescriptionHTML(void)
{
if (isDefault)
FillDefaults();
StringTable strTable = GetAsset().GetStringTable();
string list = "";
int i;
list = list + "<table>";
Asset[] commandAssets = World.GetAssetList("DriverCommand");
for (i = 0; i < commandAssets.size(); i++)
{
Asset commandAsset = commandAssets[i];
KUID commandKUID = commandAsset.GetKUID();
string commandName = commandAsset.GetName();
string commandIcon = commandKUID.GetHTMLString();
string description = commandAsset.GetStringTable().GetString("description");
string url = "live://property/" + (string)i;
string link = "<a href='" + url + "'>";
if (description.size())
description = BrowserInterface.Quote(description);
else
description = strTable.GetString("no-description");
list = list + "<tr>";
list = list + "<td>" + link;
list = list + HTMLWindow.CheckBox( url, ListContainsKUID(driverCommands, commandKUID) );
/*if (ListContainsKUID(driverCommands, commandKUID))
list = list + "<img src='checkbox-on.tga'>";
else
list = list + "<img src='checkbox-off.tga'>";*/
list = list + "</td>";
list = list + "<td>" + link;
list = list + "<img kuid='" + commandIcon + "' width=48 height=48>";
list = list + "</a></td>";
list = list + "<td>" + link;
list = list + "<font color=#000000>" + BrowserInterface.Quote(commandName) + "</font></a><br>";
list = list + "<font color=#000000 size=-4>" + description + "</font>";
list = list + "</td>";
list = list + "</tr>";
}
/*
for (i = 0; i < driverCommands.size(); i++)
{
Asset commandAsset = World.FindAsset(driverCommands[i]);
KUID kuid = commandAsset.GetKUID();
string icon = kuid.GetHTMLString();
string commandName;
if (commandAsset)
commandName = commandAsset.GetName();
else
commandName = "<not installed>";
list = list + "<tr><td width=5></td><td>";
list = list + "<img kuid='" + icon + "' width=32 height=32> </td><td width=5></td><td><font color=#000000>" + BrowserInterface.Quote(commandName) + "</font>";
list = list + "</td>";
list = list + "<td width=5></td><td>";
list = list + "<font color=#000000><a href=live://property/" + ((string)i) + ">" + strTable.GetString("html_description3") + "</a></font>";
list = list + "</td></tr>";
}
*/
list = list + "</table>";
//if (driverCommands.size() < 20)
// list = list + strTable.GetString("html_description1");
return "<html><body><font color=#000000>" + strTable.GetString("html_description2") + list + "</font></body></html>";
}
//
// Gets user-friendly readable name for the named property.
//
string GetPropertyName(string p_propertyID)
{
StringTable strTable = GetAsset().GetStringTable();
//if (p_propertyID == "add-object")
// return strTable.GetString("property_name_add");
return "<null>";
}
//
// Gets user-friendly readable description of named property.
//
string GetPropertyDescription(string p_propertyID)
{
StringTable strTable = GetAsset().GetStringTable();
//if (p_propertyID == "add-object")
// return strTable.GetString("property_desc_add");
return "<null>";
}
//
// Gets the type for the named property.
//
string GetPropertyType(string p_propertyID)
{
//if (p_propertyID == "add-object")
// return "list";
return "link";
}
//
// Called by SetPropertValue and GetPropertyElementList to get the names of all of the
// commands in the array.
//
/*void GetCommandNameKUIDList(string[] names, KUID[] kuids)
{
Asset[] commandAssets = World.GetAssetList("DriverCommand");
int i, out = 0;
for (i = 0; i < commandAssets.size(); i++)
{
KUID kuid = commandAssets[i].GetKUID();
int n;
for (n = 0; n < driverCommands.size(); n++)
if (driverCommands[n] == kuid or driverCommands[n].GetName() == commandAssets[i].GetName() )
{
kuid = null;
break;
}
if (kuid)
{
if (names)
names[out] = commandAssets[i].GetName();
if (kuids)
kuids[out] = kuid;
out++;
}
}
}*/
//
// Sets the value of the named property.
//
/*void SetPropertyValue(string p_propertyID, string p_value)
{
if (p_propertyID == "add-object")
{
string[] names = new string[0];
KUID[] kuids = new KUID[0];
GetCommandNameKUIDList(names, kuids);
int i;
for (i = 0; i < names.size(); i++)
if (names[i] == p_value)
{
driverCommands[driverCommands.size()] = kuids[i];
return;
}
}
}*/
//
// Respond to a hyper-link click on the named property.
//
void LinkPropertyValue(string p_propertyID)
{
isDefault = false;
int index = Str.ToInt(p_propertyID);
//driverCommands[index, index + 1] = null;
Asset[] commandAssets = World.GetAssetList("DriverCommand");
KUID commandKUID = commandAssets[index].GetKUID();
if (ListRemoveKUID(driverCommands, commandKUID))
{
// an item was removed
}
else
{
// add an item
ListAddKUID(driverCommands, commandKUID);
}
// this is a helper in case someone needs to know what commands are available
// it may cause inconsistancies if multiple DriverCommandRules are present!
// THIS IS A HACK - DONT RELY ON THIS IF AT ALL POSSIBLE
CreateCommandsNow();
}
//
// Gets a list of elements the user can select for the named property.
//
public string[] GetPropertyElementList(string p_propertyID)
{
string[] ret = new string[0];
//if (p_propertyID == "add-object")
// GetCommandNameKUIDList(ret, null);
return ret;
}
//
// Resets the commands in the Trainz world to the ones this rule has. Called by Pause()
// when this behavior is unpaused to reset driver commands.
//
void CreateCommandsNow(void)
{
if (isDefault)
FillDefaults();
//
// Reset the driver commands list
//
int i, count = driverCommands.size();
DriverCommand[] dcs = World.GetDriverCommandList();
for (i = 0; i < dcs.size(); i++)
World.RemoveDriverCommand(dcs[i]);
Interface.Log("DriverCommandRule.CreateCommandsNow> " + dcs.size() + " commands removed");
for (i = 0; i < count; i++)
{
Asset commandAsset = World.FindAsset(driverCommands[i]);
if (commandAsset)
World.AddDriverCommand(commandAsset);
}
Interface.Log("DriverCommandRule.CreateCommandsNow> " + driverCommands.size() + " commands added");
}
void FillDefaults(void)
{
Asset asset = GetAsset();
driverCommands = new KUID[11];
driverCommands[0] = asset.LookupKUIDTable("drive-to-command");
driverCommands[1] = asset.LookupKUIDTable("drive-to-trackmark-command");
driverCommands[2] = asset.LookupKUIDTable("drive-via-trackmark-command");
driverCommands[3] = asset.LookupKUIDTable("drive-schedule-command");
driverCommands[4] = asset.LookupKUIDTable("load-command");
driverCommands[5] = asset.LookupKUIDTable("unload-command");
driverCommands[6] = asset.LookupKUIDTable("couple-command");
driverCommands[7] = asset.LookupKUIDTable("decouple-command");
driverCommands[8] = asset.LookupKUIDTable("runaround-command");
driverCommands[9] = asset.LookupKUIDTable("wait-for-command");
driverCommands[10] = asset.LookupKUIDTable("notify-command");
isDefault = true;
}
public void AppendDependencies(KUIDList io_dependencies)
{
inherited(io_dependencies);
int i;
for (i = 0; i < driverCommands.size(); i++)
io_dependencies.AddKUID(driverCommands[i]);
}
};