CCG/Modelling: Tenders
(New page: Tenders Locomotives with tenders normally operate as a unit. However, if you use the runaround command in Driver the locomotive leaves the tender behind. For steam tender config.txt file...) |
|||
| (3 intermediate revisions by one user not shown) | |||
| Line 1: | Line 1: | ||
| − | Tenders | + | ==Tenders== |
Locomotives with tenders normally operate as a unit. | Locomotives with tenders normally operate as a unit. | ||
However, if you use the runaround command in Driver the locomotive leaves the tender behind. For steam tender config.txt files, add the following line: | However, if you use the runaround command in Driver the locomotive leaves the tender behind. For steam tender config.txt files, add the following line: | ||
| − | + | tender 1 | |
| − | tender 1 | + | |
| − | + | ||
| − | + | ||
This ensures the tender stays with the locomotive. | This ensures the tender stays with the locomotive. | ||
| − | Tenders Dump Coal | + | ===Tenders Dump Coal=== |
| − | + | ||
To prevent steam tenders or the coal bunker of a steamer being robbed at the Power station or any Multi industry | To prevent steam tenders or the coal bunker of a steamer being robbed at the Power station or any Multi industry | ||
track that is coal unload enabled, you should use the "No Dump" Script by Wulf_9, reproduced with permission. | track that is coal unload enabled, you should use the "No Dump" Script by Wulf_9, reproduced with permission. | ||
| + | |||
You may find the scripts useful. | You may find the scripts useful. | ||
| − | + | ====Stop steam locos and tenders dumping coal.==== | |
| + | This is a complete class - save to the filename and use as-is by copying all the text in the code box below | ||
| − | + | '''Tender version''' | |
| + | // steamtender.gs | ||
| + | // prevents unloading of coal at industries | ||
| + | // ©Wulf_9, Sept `04 | ||
| + | include "vehicle.gs" | ||
| + | class Steam_Tender isclass Vehicle { | ||
| + | bool UnloadProduct(LoadingReport report) { | ||
| + | bool UnloadFlag = false; | ||
| + | return UnloadFlag; | ||
| + | } | ||
| + | }; | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Include the script with the asset and add these lines to a tender config.txt file and it stops the tender dumping coal incorrectly. | Include the script with the asset and add these lines to a tender config.txt file and it stops the tender dumping coal incorrectly. | ||
| − | Config.txt entries:- | + | ''Config.txt entries:-'' |
| − | + | script "steamtender" | |
| − | script "steamtender" | + | class "Steam_Tender" |
| − | class "Steam_Tender" | + | |
A second script is available for tank engines. | A second script is available for tank engines. | ||
| − | Tank engine version | + | '''Tank engine version''' |
| + | // steamtank.gs | ||
| + | // prevents unloading of coal at industries | ||
| + | // ©Wulf_9, Sept `04 | ||
| + | |||
| + | include "vehicle.gs" | ||
| + | |||
| + | class Steam_Tank isclass Locomotive { | ||
| + | bool UnloadProduct(LoadingReport report) { | ||
| + | bool UnloadFlag = false; | ||
| + | return UnloadFlag; | ||
| + | } | ||
| + | }; | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | The following lines should be included in the config.txt file for the engine: | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | The following lines should be included in the config.txt file | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| + | ''Config.txt entries:-'' | ||
script "steamtank" | script "steamtank" | ||
class "Steam_Tank" | class "Steam_Tank" | ||
| − | + | ====Auxiliary Tender or Water Gin for Steam Locos==== | |
| − | + | Script by Wulf_9 | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | |||
| − | // slw_auxtender.gs | + | This is a complete class - save to the filename and use as-is by copying all the text in the code box. |
| + | |||
| + | // slw_auxtender.gs | ||
// | // | ||
// Auxiliary tender (or water gin) distributor and feeder script | // Auxiliary tender (or water gin) distributor and feeder script | ||
| Line 99: | Line 81: | ||
// all support obligations and other liabilities shall reside | // all support obligations and other liabilities shall reside | ||
// with the author of the asset to which this script belongs. | // with the author of the asset to which this script belongs. | ||
| − | + | ||
| − | include "vehicle.gs" | + | include "vehicle.gs" |
| − | class SLW_ATWG isclass Vehicle { | + | class SLW_ATWG isclass Vehicle { |
| − | + | Asset waterAsset; | |
| − | + | Train thisTrain; | |
| − | + | float rsd; | |
| − | + | bool active = 0, update = 0; | |
| − | + | float EndLoad(LoadingReport report) { | |
| − | + | if (active) PostMessage(me, "SLW_ATWG","ReBalance", 5.0); | |
| − | + | return 1.0; | |
| − | + | } | |
| − | + | bool UnloadProduct(LoadingReport report) { | |
if (active) return false; | if (active) return false; | ||
return true; | return true; | ||
| − | + | } | |
| − | + | Productqueue GetVehicleProductqueue(Vehicle v,Asset prodAsset) { | |
string vq, prodKuid, catKuid; | string vq, prodKuid, catKuid; | ||
bool found = 0; | bool found = 0; | ||
| Line 124: | Line 106: | ||
prodKuid = pSoup.GetNamedTag("kuid"); | prodKuid = pSoup.GetNamedTag("kuid"); | ||
catKuid = pSoup.GetNamedTag("product-category"); | catKuid = pSoup.GetNamedTag("product-category"); | ||
| − | + | ||
for (s = 0; s < vqSoup.CountTags(); s++ ) { | for (s = 0; s < vqSoup.CountTags(); s++ ) { | ||
Soup load = vqSoup.GetNamedSoup(vqSoup.GetIndexedTagName(s)); | Soup load = vqSoup.GetNamedSoup(vqSoup.GetIndexedTagName(s)); | ||
| Line 148: | Line 130: | ||
Soup prod = load.GetNamedSoup("allowed-products"); | Soup prod = load.GetNamedSoup("allowed-products"); | ||
for (p = 0; p < prod.CountTags(); p++) { | for (p = 0; p < prod.CountTags(); p++) { | ||
| − | + | ||
if (prod.GetNamedTag(prod.GetIndexedTagName(p)) == prodKuid) { | if (prod.GetNamedTag(prod.GetIndexedTagName(p)) == prodKuid) { | ||
found = 1; | found = 1; | ||
| Line 159: | Line 141: | ||
return (v.Getqueue(vq)); | return (v.Getqueue(vq)); | ||
} | } | ||
| − | + | ||
void UpdateTrain(Message msg) { | void UpdateTrain(Message msg) { | ||
if (((msg.src == me) or TrainUtil.IsInTrain(thisTrain, | if (((msg.src == me) or TrainUtil.IsInTrain(thisTrain, | ||
msg.src)) and !update) { | msg.src)) and !update) { | ||
| − | + | ||
update = 1; | update = 1; | ||
ClearMessages("SLW_ATWG", "ReBalance"); | ClearMessages("SLW_ATWG", "ReBalance"); | ||
| Line 172: | Line 154: | ||
active = 0; | active = 0; | ||
for (i = 0; i < cars.size(); i++) { | for (i = 0; i < cars.size(); i++) { | ||
| − | + | ||
| − | Productqueue pq = GetVehicleProductqueue(cars[ | + | Productqueue pq = GetVehicleProductqueue(cars[i], waterAsset); |
| − | + | ||
bool isST = (cars[i].GetVehicleTypeFlags() == Vehicle.TYPE_TENDER); | bool isST = (cars[i].GetVehicleTypeFlags() == Vehicle.TYPE_TENDER); | ||
bool facing = cars[i].GetDirectionRelativeToTrain(); | bool facing = cars[i].GetDirectionRelativeToTrain(); | ||
| Line 181: | Line 162: | ||
else inc = i + 1; | else inc = i + 1; | ||
bool count = 0; | bool count = 0; | ||
| − | + | if (pq and isST and !isAT) { | |
if ((i > 0 and facing) or (i < cars.size() - 1 and !facing)) { | if ((i > 0 and facing) or (i < cars.size() - 1 and !facing)) { | ||
if (cars[inc].GetEngineType() != Vehicle.ENGINE_STEAM) continue; | if (cars[inc].GetEngineType() != Vehicle.ENGINE_STEAM) continue; | ||
| Line 191: | Line 172: | ||
++atc; | ++atc; | ||
} | } | ||
| − | + | ||
if (pq and isAT and (i == avp + 1)) { | if (pq and isAT and (i == avp + 1)) { | ||
count = 1; | count = 1; | ||
| Line 200: | Line 181: | ||
(float)pQ.GetQueueSize()); | (float)pQ.GetQueueSize()); | ||
} | } | ||
| − | + | ||
avlf = avlf / (float)atc; | avlf = avlf / (float)atc; | ||
| − | + | ||
if (active) { | if (active) { | ||
for (i = tvp; i < (tvp + atc); i++) { | for (i = tvp; i < (tvp + atc); i++) { | ||
| − | Productqueue pq = GetVehicleProductqueue(cars | + | Productqueue pq = GetVehicleProductqueue(cars[i], waterAsset); |
| − | [i], waterAsset); | + | |
bool isAT = cars[i].isclass(SLW_ATWG); | bool isAT = cars[i].isclass(SLW_ATWG); | ||
| − | + | ||
if (pq and ((i == tvp) or isAT)) { | if (pq and ((i == tvp) or isAT)) { | ||
| − | + | ||
int vQc = (int)(avlf * (float)pQ.GetQueueSize()); | int vQc = (int)(avlf * (float)pQ.GetQueueSize()); | ||
| − | cars[i].SetqueueInitialCount(pq, waterAsset, | + | cars[i].SetqueueInitialCount(pq, waterAsset,vQc); |
| − | + | ||
} | } | ||
} | } | ||
PostMessage(me, "SLW_ATWG", "ReBalance", rsd); | PostMessage(me, "SLW_ATWG", "ReBalance", rsd); | ||
} | } | ||
| − | + | } | |
update = 0; | update = 0; | ||
| − | } | + | } |
| + | |||
| + | void InitStart(Message msg) { | ||
| + | |||
| + | thisTrain = me.GetMyTrain(); | ||
| + | } | ||
| + | public void Init(void) { | ||
| + | inherited(); | ||
| + | if (GetAsset().LookupKUIDTable("water")) waterAsset = GetAsset().FindAsset("water"); | ||
| + | rsd = (float)GetAsset().GetConfigSoup().GetNamedTagAsInt("update_delay", 300); | ||
| + | AddHandler(me, "Vehicle", "Coupled", "UpdateTrain"); | ||
| + | AddHandler(me, "Vehicle", "BadCouple","UpdateTrain"); | ||
| + | AddHandler(me, "Vehicle", "Decoupled","UpdateTrain"); | ||
| + | AddHandler(me, "SLW_ATWG", "ReBalance","UpdateTrain"); | ||
| + | AddHandler(me, "World", "ModuleInit", "InitStart"); | ||
| + | } | ||
| + | }; | ||
| − | |||
| − | + | ''Config.txt entries:-'' | |
| − | + | script "slw_auxtender" | |
| − | + | class "SLW_ATWG" | |
| − | + | ||
| − | + | update_delay "180" | |
| − | + | ||
| − | + | kuid-table | |
| − | + | { | |
| − | + | water <kuid:-3:10004> | |
| − | + | } | |
| − | + | ||
| − | + | ''update_delay is a value is in seconds'' | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | |||
| − | |||
| − | |||
| − | + | [[CCG/Modelling: Researching Data and Testing a Steam Locomotive|Previous Page]] . . . . [[CCG/Modelling: Animation Events|Next Page]] | |
| − | + | ||
| − | + | ==Return to CCG Index== | |
| − | + | [[Content Creator's Guide]] | |
| − | + | ||
Latest revision as of 23:50, 18 June 2011
Contents |
[edit] Tenders
Locomotives with tenders normally operate as a unit.
However, if you use the runaround command in Driver the locomotive leaves the tender behind. For steam tender config.txt files, add the following line:
tender 1
This ensures the tender stays with the locomotive.
[edit] Tenders Dump Coal
To prevent steam tenders or the coal bunker of a steamer being robbed at the Power station or any Multi industry track that is coal unload enabled, you should use the "No Dump" Script by Wulf_9, reproduced with permission.
You may find the scripts useful.
[edit] Stop steam locos and tenders dumping coal.
This is a complete class - save to the filename and use as-is by copying all the text in the code box below
Tender version
// steamtender.gs
// prevents unloading of coal at industries
// ©Wulf_9, Sept `04
include "vehicle.gs"
class Steam_Tender isclass Vehicle {
bool UnloadProduct(LoadingReport report) {
bool UnloadFlag = false;
return UnloadFlag;
}
};
Include the script with the asset and add these lines to a tender config.txt file and it stops the tender dumping coal incorrectly.
Config.txt entries:-
script "steamtender" class "Steam_Tender"
A second script is available for tank engines.
Tank engine version
// steamtank.gs
// prevents unloading of coal at industries
// ©Wulf_9, Sept `04
include "vehicle.gs"
class Steam_Tank isclass Locomotive {
bool UnloadProduct(LoadingReport report) {
bool UnloadFlag = false;
return UnloadFlag;
}
};
The following lines should be included in the config.txt file for the engine:
Config.txt entries:-
script "steamtank" class "Steam_Tank"
[edit] Auxiliary Tender or Water Gin for Steam Locos
Script by Wulf_9
This is a complete class - save to the filename and use as-is by copying all the text in the code box.
// slw_auxtender.gs
//
// Auxiliary tender (or water gin) distributor and feeder script
//
// Will run automatically when directly coupled, in single or multiple,
// to an active steam loco and tender combination. Not for tank locos.
//
// GetVehicleProductqueue() is a specially-customised adaptation of
// GetVehiclequeue() by Mike Carter, (c)TrainzProRoutes.com, 2004
//
// This code is (c)Wulf_9, Saxon Locomotive Works, March 2005.
// NOT to be used in payware without prior written agreement.
//
// Freeware creators are encouraged to use and share this script,
// provided the code is distributed in UNMODIFIED form. Any and
// all support obligations and other liabilities shall reside
// with the author of the asset to which this script belongs.
include "vehicle.gs"
class SLW_ATWG isclass Vehicle {
Asset waterAsset;
Train thisTrain;
float rsd;
bool active = 0, update = 0;
float EndLoad(LoadingReport report) {
if (active) PostMessage(me, "SLW_ATWG","ReBalance", 5.0);
return 1.0;
}
bool UnloadProduct(LoadingReport report) {
if (active) return false;
return true;
}
Productqueue GetVehicleProductqueue(Vehicle v,Asset prodAsset) {
string vq, prodKuid, catKuid;
bool found = 0;
int s, l, p;
vq = "";
Soup vSoup = v.GetAsset().GetConfigSoup();
Soup pSoup = prodAsset.GetConfigSoup();
Soup vqSoup = vSoup.GetNamedSoup("queues");
prodKuid = pSoup.GetNamedTag("kuid");
catKuid = pSoup.GetNamedTag("product-category");
for (s = 0; s < vqSoup.CountTags(); s++ ) {
Soup load = vqSoup.GetNamedSoup(vqSoup.GetIndexedTagName(s));
if (load.GetNamedTag("product-kuid") == prodKuid) {
found = 1;
vq = vqSoup.GetIndexedTagName(s);
break;
}
for (l = 0; l < load.CountTags(); l++ ) {
if (load.GetIndexedTagName(l) == "allowed-categories") {
Soup prod = load.GetNamedSoup("allowed-categories");
for (p = 0; p < prod.CountTags(); p++) {
if (prod.GetNamedTag(prod.GetIndexedTagName(p)) == catKuid) {
found = 1;
vq = vqSoup.GetIndexedTagName(s);
break;
}
}
}
if (found) break;
}
if (found) break;
Soup prod = load.GetNamedSoup("allowed-products");
for (p = 0; p < prod.CountTags(); p++) {
if (prod.GetNamedTag(prod.GetIndexedTagName(p)) == prodKuid) {
found = 1;
vq = vqSoup.GetIndexedTagName(s);
break;
}
}
if (found) break;
}
return (v.Getqueue(vq));
}
void UpdateTrain(Message msg) {
if (((msg.src == me) or TrainUtil.IsInTrain(thisTrain,
msg.src)) and !update) {
update = 1;
ClearMessages("SLW_ATWG", "ReBalance");
thisTrain = me.GetMyTrain();
Vehicle[] cars = thisTrain.GetVehicles();
float avlf = 0.0;
int i = 0, inc = 0, tvp = 0, avp = 0, atc = 1;
active = 0;
for (i = 0; i < cars.size(); i++) {
Productqueue pq = GetVehicleProductqueue(cars[i], waterAsset);
bool isST = (cars[i].GetVehicleTypeFlags() == Vehicle.TYPE_TENDER);
bool facing = cars[i].GetDirectionRelativeToTrain();
bool isAT = cars[i].isclass(SLW_ATWG);
if (facing) inc = i - 1;
else inc = i + 1;
bool count = 0;
if (pq and isST and !isAT) {
if ((i > 0 and facing) or (i < cars.size() - 1 and !facing)) {
if (cars[inc].GetEngineType() != Vehicle.ENGINE_STEAM) continue;
}
active = 1;
count = 1;
tvp = i;
avp = tvp;
++atc;
}
if (pq and isAT and (i == avp + 1)) {
count = 1;
avp = i;
if (cars[i] != me) ++atc;
}
if (count) avlf = avlf + ((float)pQ.GetQueueCount() /
(float)pQ.GetQueueSize());
}
avlf = avlf / (float)atc;
if (active) {
for (i = tvp; i < (tvp + atc); i++) {
Productqueue pq = GetVehicleProductqueue(cars[i], waterAsset);
bool isAT = cars[i].isclass(SLW_ATWG);
if (pq and ((i == tvp) or isAT)) {
int vQc = (int)(avlf * (float)pQ.GetQueueSize());
cars[i].SetqueueInitialCount(pq, waterAsset,vQc);
}
}
PostMessage(me, "SLW_ATWG", "ReBalance", rsd);
}
}
update = 0;
}
void InitStart(Message msg) {
thisTrain = me.GetMyTrain();
}
public void Init(void) {
inherited();
if (GetAsset().LookupKUIDTable("water")) waterAsset = GetAsset().FindAsset("water");
rsd = (float)GetAsset().GetConfigSoup().GetNamedTagAsInt("update_delay", 300);
AddHandler(me, "Vehicle", "Coupled", "UpdateTrain");
AddHandler(me, "Vehicle", "BadCouple","UpdateTrain");
AddHandler(me, "Vehicle", "Decoupled","UpdateTrain");
AddHandler(me, "SLW_ATWG", "ReBalance","UpdateTrain");
AddHandler(me, "World", "ModuleInit", "InitStart");
}
};
Config.txt entries:-
script "slw_auxtender"
class "SLW_ATWG"
update_delay "180"
kuid-table
{
water <kuid:-3:10004>
}
update_delay is a value is in seconds
Previous Page . . . . Next Page