CCG/Example: Industry (Multiple Industry)
From TrainzOnline
Contents |
Industry (Multiple Industry)
Directory Structure
A typical asset of this kind has the following File\Directory Structure:
Required Files
config.txt - The config file for the asset.
thumb.jpg - The thumbnail image for this asset. A 240x180 jpeg.
concrete.texture.txt, concrete.tga, recess.texture.txt, recess.tga - The texture files used for the industry asset. See the section on Texture.txt files on Page 96 for more information.
icon_multiple.tga - The image files used as an icon for the industry.
multiple_industry.im - The indexed mesh used for the Industry asset.
multiple_industry.gs - The script file used to control the behavior of the industry.
Config.txt File Listing
kuid <kuid:56113:1001> trainz-build 2.5 category-class "BIN" category-region "00" category-era "1810s" username "testIndustry" kind "industry" light 1 nightmode "lamp" script "multipleindustry.gs" class "MultipleIndustry" preview-mesh-kuid <kuid:-3:10154> icon0 <kuid:-3:10164> description "Test Industry asset. Based on the Mulitple Industry New." kuid-table { coal <kuid:44179:60013> diesel <kuid:-3:10011> cont20ft <kuid:-3:10014> gengoods <kuid:-3:10013> logs <kuid:-3:10001> lumber <kuid:-3:10003> water <kuid:-3:10004> } mesh-table { default { mesh "Multiple_Industry.im" auto-create 1 effects { arrow0 { att "a.track0a" default-mesh <kuid:-3:10092> surveyor-only 1 kind "attachment" } arrow1 { att "a.track0f" default-mesh <kuid:-3:10092> surveyor-only 1 kind "attachment" } } } } attached-track { out_track0 { track <kuid:-1:15> vertices { 0 "a.track0a" 1 "a.track0b" 2 "a.track0c" 3 "a.track0d" 4 "a.track0e" 5 "a.track0f" } } } attached-trigger { trig0 { att "a.track0b" radius 10 } trig1 { att "a.track0c" radius 10 } trig2 { att "a.track0d" radius 10 } trig3 { att "a.track0e" radius 10 } } queues { 20ft_cont_q { size 100 initial-count 50 product-kuid <kuid:-3:10014> allowed-products { 0 <kuid:-3:10014> } } gen_goods_q { size 100 initial-count 50 product-kuid <kuid:-3:10013> allowed-products { 0 <kuid:-3:10013> } } logs_q { size 90 initial-count 45 product-kuid <kuid:-3:10001> allowed-products { 0 <kuid:-3:10001> } } lumber_q { size 51 initial-count 25 product-kuid <kuid:-3:10003> allowed-products { 0 <kuid:-3:10003> } } coal_q { size 1086000 initial-count 543000 product-kuid <kuid:44179:60013> allowed-products { 0 <kuid:44179:60013> } } diesel_q { size 1164000 initial-count 582000 product-kuid <kuid:-3:10011> allowed-products { 0 <kuid:-3:10011> } } water_q { size 15000 initial-count 10000 animated-mesh "default" product-kuid <kuid:-3:10004> allowed-products { 0 <kuid:-3:10004> } } } processes { multi_consumer_producer { start-enabled 1 duration 30 } } inputs { 0 { amount 1 queue "20ft_cont_q" } 1 { amount 1 queue "gen_goods_q" } 3 { amount 1 queue "logs_q" } 4 { amount 100000 queue "coal_q" } 5 { amount 100000 queue "diesel_q" } 6 { amount 100 queue "water_q" } } outputs { 0 { amount 1 queue "20ft_cont_q" } 1 { amount 1 queue "gen_goods_q" } 2 { amount 1 queue "logs_q" } 3 { amount 100000 queue "coal_q" } 4 { amount 100000 queue "diesel_q" } 5 { amount 100 queue "water_q" } } string-table { multi_pickupdropoff "Multiple Pickup/Drop off" } thumbnails { 0 { image "icon_multiple.tga" width 64 height 64 } 1 { image "thumb.jpg" width 240 height 180 } }
Script Listing
multipleindustry.gs
include "BaseIndustry.gs" // // MultipleIndustry industry // class MultipleIndustry isclass BaseIndustry { ProductQueue crudeOilQueue, dieselQueue, petrolQueue, coalQueue, cont20ftQueue, cont0ftQueue; ProductQueue gengoodsQueue, logsQueue, lumberQueue, woodchipsQueue, waterQueue, avgasQueue; Asset crudeOilAsset, dieselAsset, petrolAsset, coalAsset, cont20ftAsset, cont0ftAsset, gengoodsAsset; Asset logsAsset, lumberAsset, woodchipsAsset, waterAsset, avgasAsset; bool animating = false; bool processing = false; bool scriptletEnabled = true; // Track if they only supply some of the logs that were requested in the waybill. int avWBRemain = 0; int cont20WBRemain = 0; int cont0WBRemain = 0; int goodsWBRemain = 0; int logWBRemain = 0; int lumberWBRemain = 0; int coalWBRemain = 0; int woodchipWBRemain = 0; int oilWBRemain = 0; int dieselWBRemain = 0; int petrolWBRemain = 0; int waterWBRemain = 0; // // // bool TriggerSupportsStoppedLoad(Vehicle vehicle, string triggerName) { bool vehicleToTrain = vehicle.GetFacingRelativeToTrain(); int direction = vehicle.GetRelationToTrack(me, "out_track0"); if (!vehicleToTrain) direction = -direction; // Are we up to the furthest trigger away from the side we entered for diesel? if (direction == Vehicle.DIRECTION_BACKWARD and triggerName == "trig3") return true; if (direction == Vehicle.DIRECTION_FORWARD and triggerName == "trig0") return true; // If the train has already stopped, then fall thru and allow this load as well if (triggerName == "trig0" or triggerName == "trig" or triggerName == "trig2" or triggerName == "trig3") { if (vehicle.GetMyTrain().IsStopped()) return true; } return false; } void PerformStoppedLoad(Vehicle vehicle, string triggerName) { if (triggerName == "trig0" or triggerName == "trig" or triggerName == "trig2" or triggerName == "trig3") { bool avWBModified = false; bool cont20WBModified = false; bool cont40WBModified = false; bool goodsWBModified = false; bool logWBModified = false; bool lumberWBModified = false; bool coalWBModified = false; bool woodchipWBModified = false; bool oilWBModified = false; bool dieselWBModified = false; bool petrolWBModified = false; bool waterWBModified = false; int spaceAvailable; LoadingReport report; int direction; if (itc.IsTrainCommand(vehicle.GetMyTrain(), Industry.LOAD_COMMAND)) { // Attempt to load everything! ;) // // Load the crudeoil // if (GetProcessOutput("multi_consumer_producer",crudeOilQueue, crudeOilAsset) > 0) { spaceAvailable = crudeOilQueue.GetQueueCount(); report = CreateLoadingReport(crudeOilQueue,spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.LoadProduct(report); // Already done something to the queue? if so, set flag so that we don't unload it again. (just for this multi ind) if (report.amount > 0) oilWBModified = true; } // // Load the diesel // if (GetProcessOutput("multi_consumer_producer",dieselQueue, dieselAsset) > 0) { spaceAvailable = dieselQueue.GetQueueCount(); report = CreateLoadingReport(dieselQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.LoadProduct(report); // Already done something to the queue? if so, set flag so that we don't unload it again. (just for this multi ind) if (report.amount > 0) dieselWBModified = true; } // // Load the petrol // if (GetProcessOutput("multi_consumer_producer",petrolQueue, petrolAsset) > 0) { spaceAvailable = petrolQueue.GetQueueCount(); report = CreateLoadingReport(petrolQueue,spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.LoadProduct(report); // Already done something to the queue? if so, set flag so that we don't unload it again. (just for this multi ind) if (report.amount > 0) petrolWBModified = true; } // // Load the coal // if (GetProcessOutput("multi_consumer_producer",coalQueue, coalAsset) > 0) { spaceAvailable = coalQueue.GetQueueCount(); report = CreateLoadingReport(coalQueue,spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.LoadProduct(report); // Already done something to the queue? if so, set flag so that we don't unload it again. (just for this multi ind) if (report.amount > 0) coalWBModified = true; } // // Load the cont20 // if (GetProcessOutput("multi_consumer_producer",cont20ftQueue, cont20ftAsset) > 0) { spaceAvailable = cont20ftQueue.GetQueueCount(); report = CreateLoadingReport(cont20ftQueue,spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.LoadProduct(report); // Already done something to the queue? if so, set flag so that we don't unload it again. (just for this multi ind) if (report.amount > 0) cont20WBModified = true; } // // Load the cont0 // if (GetProcessOutput("multi_consumer_producer", cont0ftQueue, cont0ftAsset) > 0) { spaceAvailable = cont0ftQueue.GetQueueCount(); report = CreateLoadingReport(cont0ftQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.LoadProduct(report); // Already done something to the queue? if so, set flag so that we don't unload it again. (just for this multi ind) if (report.amount > 0) cont40WBModified = true; } // Load the gengoods // if (GetProcessOutput("multi_consumer_producer", gengoodsQueue, gengoodsAsset) > 0) { spaceAvailable = gengoodsQueue.GetQueueCount(); report = CreateLoadingReport(gengoodsQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_ track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.LoadProduct(report); // Already done something to the queue? if so, set flag so that we don't unload it again. (just for this multi ind) if (report.amount > 0) goodsWBModified = true; } // // Load the logs // if (GetProcessOutput("multi_consumer_producer", logsQueue, logsAsset) > 0) { spaceAvailable = logsQueue.GetQueueCount(); report = CreateLoadingReport(logsQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.LoadProduct(report); // Already done something to the queue? if so, set flag so that we don't unload it again. (just for this multi ind) if (report.amount > 0) logWBModified = true; } // // Load the lumber // if (GetProcessOutput("multi_consumer_producer", lumberQueue, lumberAsset) > 0) { spaceAvailable = lumberQueue.GetQueueCount(); report = CreateLoadingReport(lumberQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.LoadProduct(report); // Already done something to the queue? if so, set flag so that we don't unload it again. (just for this multi ind) if (report.amount > 0) lumberWBModified = true; } // // Load the woodchips // if (GetProcessOutput("multi_consumer_producer", woodchipsQueue, woodchipsAsset) > 0) { spaceAvailable = woodchipsQueue.GetQueueCount(); report = CreateLoadingReport(woodchipsQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.LoadProduct(report); // Already done something to the queue? if so, set flag so that we don't unload it again. (just for this multi ind) if (report.amount > 0) woodchipWBModified = true; } // // Load the water // if (GetProcessOutput("multi_consumer_producer", waterQueue, waterAsset) > 0) { spaceAvailable = waterQueue.GetQueueCount(); report = CreateLoadingReport(waterQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.LoadProduct(report); // Already done something to the queue? if so, set flag so that we don't unload it again. (just for this multi ind) if (report.amount > 0) waterWBModified = true; } // // Load the avgas // if (GetProcessOutput("multi_consumer_producer",avgasQueue, avgasAsset) > 0) { spaceAvailable = avgasQueue.GetQueueCount(); report = CreateLoadingReport(avgasQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.LoadProduct(report); // Already done something to the queue? if so, set flag so that we don't unload it again. (just for this multi ind) if (report.amount > 0) avWBModified = true; } } if (itc.IsTrainCommand(vehicle.GetMyTrain(), Industry. UNLOAD_COMMAND)) { // Attemp to unload everything! ;) // // Unload the crudeoil // if (GetProcessInput("multi_consumer_producer", crudeOilQueue, crudeOilAsset) > 0) { if (!oilWBModified) { spaceAvailable = crudeOilQueue.GetQueueSpace(); report = CreateUnloadingReport(crudeOilQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.UnloadProduct(report); // Ensure we are tracking this if we are waiting for a way bill to complete in its entirety if (oilWBRemain > 0) oilWBRemain = oilWBRemain - report.amount; } } // // Unload the diesel // if (GetProcessInput("multi_consumer_producer", dieselQueue, dieselAsset) > 0) { if (!dieselWBModified) { spaceAvailable = dieselQueue.GetQueueSpace(); report = CreateUnloadingReport(dieselQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.UnloadProduct(report); // Ensure we are tracking this if we are waiting for a way bill to complete in its entirety if (dieselWBRemain > 0) dieselWBRemain = dieselWBRemain - report.amount; } } // // Unload the petrol // if (GetProcessInput("multi_consumer_producer",petrolQueue, petrolAsset) > 0) { if (!petrolWBModified) { spaceAvailable = petrolQueue.GetQueueSpace(); report = CreateUnloadingReport(petrolQueue,spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.UnloadProduct(report); // Ensure we are tracking this if we are waiting for a way bill to complete in its entirety if (petrolWBRemain > 0) petrolWBRemain = petrolWBRemain - report.amount; } } // // Unload the coal // if (GetProcessInput("multi_consumer_producer",coalQueue, coalAsset) > 0) { if (!coalWBModified) { spaceAvailable = coalQueue.GetQueueSpace(); report = CreateUnloadingReport(coalQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.UnloadProduct(report); // Ensure we are tracking this if we are waiting for a way bill to complete in its entirety if (coalWBRemain > 0) coalWBRemain = coalWBRemain - report.amount; } } // // Unload the cont20 // if (GetProcessInput("multi_consumer_producer",cont20ftQueue, cont20ftAsset) > 0) { if (!cont20WBModified) { spaceAvailable = cont20ftQueue.GetQueueSpace(); report = CreateUnloadingReport(cont20ftQueue,spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.UnloadProduct(report); // Ensure we are tracking this if we are waiting for a way bill to complete in its entirety if (cont20WBRemain > 0) cont20WBRemain = cont20WBRemain - report.amount; } } // // Unload the cont0 // if (GetProcessInput("multi_consumer_producer",cont0ftQueue, cont0ftAsset) > 0) { if (!cont40WBModified) { spaceAvailable = cont0ftQueue.GetQueueSpace(); report = CreateUnloadingReport(cont0ftQueue,spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.UnloadProduct(report); // Ensure we are tracking this if we are waiting for a way bill to complete in its entirety if (cont0WBRemain > 0) cont0WBRemain = cont0WBRemain - report.amount; } } // // Unload the gengoods // if (GetProcessInput("multi_consumer_producer", gengoodsQueue, gengoodsAsset) > 0) { if (!goodsWBModified) { spaceAvailable = gengoodsQueue.GetQueueSpace(); report = CreateUnloadingReport(gengoodsQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.UnloadProduct(report); // Ensure we are tracking this if we are waiting for a way bill to complete in its entirety if (goodsWBRemain > 0) goodsWBRemain = goodsWBRemain - report.amount; } } // // Unload the logs // if (GetProcessInput("multi_consumer_producer", logsQueue, logsAsset) > 0) { if (!logWBModified) { spaceAvailable = logsQueue.GetQueueSpace(); report = CreateUnloadingReport(logsQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.UnloadProduct(report); // Ensure we are tracking this if we are waiting for a way bill to complete in its entirety if (logWBRemain > 0) logWBRemain = logWBRemain - report.amount; } } // // Unload the lumber // if (GetProcessInput("multi_consumer_producer", lumberQueue, lumberAsset) > 0) { if (!lumberWBModified) { spaceAvailable = lumberQueue.GetQueueSpace(); report = CreateUnloadingReport(lumberQueue,spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.UnloadProduct(report); // Ensure we are tracking this if we are waiting for a way bill to complete in its entirety if (lumberWBRemain > 0) lumberWBRemain = lumberWBRemain - report.amount; } } // // Unload the woodchips // if (GetProcessInput("multi_consumer_producer", woodchipsQueue, woodchipsAsset) > 0) { if (!woodchipWBModified) { spaceAvailable = woodchipsQueue.GetQueueSpace(); report = CreateUnloadingReport(woodchipsQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.UnloadProduct(report); // Ensure we are tracking this if we are waiting for a way bill to complete in its entirety if (woodchipWBRemain > 0) woodchipWBRemain = woodchipWBRemain - report.amount; } } // // Unload the water // if (GetProcessInput("multi_consumer_producer",waterQueue, waterAsset) > 0) { if (!waterWBModified) { spaceAvailable = waterQueue.GetQueueSpace(); report = CreateUnloadingReport(waterQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.UnloadProduct(report); // Ensure we are tracking this if we are waiting for a way bill to complete in its entirety if (waterWBRemain > 0) waterWBRemain = waterWBRemain - report.amount; } } // // Unload the avgas // if (GetProcessInput("multi_consumer_producer",avgasQueue, avgasAsset) > 0) { if (!avWBModified) { spaceAvailable = avgasQueue.GetQueueSpace(); report = CreateUnloadingReport(avgasQueue, spaceAvailable); direction = vehicle.GetRelationToTrack(me, "out_track0"); if (direction == Vehicle.DIRECTION_FORWARD) report.sideFlags = LoadingReport.LEFT_SIDE; else if (direction == Vehicle.DIRECTION_BACKWARD) report.sideFlags = LoadingReport.RIGHT_SIDE; vehicle.UnloadProduct(report); // Ensure we are tracking this if we are waiting for a way bill to complete in its entirety if (avWBRemain > 0) avWBRemain = avWBRemain - report.amount; } } } } } // // // thread void MultipleMain(void) { Message msg; Vehicle vehicle; string triggerName; wait() { // ? on "Scriptlet-Enabled", "": { if (!scriptletEnabled) { scriptletEnabled = true; SetProcessEnabled("multi_consumer_producer", true); } continue; } // ? on "Scriptlet-Enabled", "0": { if (scriptletEnabled) { scriptletEnabled = false; SetProcessEnabled("multi_consumer_producer", false); } continue; } } } // called by the game once when a process is ready to start (see Industry.gs) void NotifyProcessStarted(string processName) { //Interface.Print("A process in the oil refinery has started."); if (PerformProcessInput(processName)) { // we are making the assumption that there is only one process, "multi_consumer_producer" PerformProcessStarted(processName); } else PerformProcessCancelled(processName); } // // Called by the game once when a process is ready to stop (see Industry.gs) // void NotifyProcessFinished(string processName) { //Interface.Print("A process in the oil refinery has finished."); processing = false; if (!animating) { PerformProcessOutput(processName); PerformProcessFinished(processName); PostMessage(me,"GenericIndustry", "ProcessComplete", 0.0f); } } // // // public void Init(void) { inherited(); usePipeAnimation = false; useGenericViewDetails = true; // initialize queues crudeOilQueue = GetQueue("crude_oil_q"); dieselQueue = GetQueue("diesel_q"); petrolQueue = GetQueue("petrol_q"); coalQueue = GetQueue("coal_q"); cont20ftQueue = GetQueue("20ft_cont_q"); cont0ftQueue = GetQueue("0ft_cont_q"); gengoodsQueue = GetQueue("gen_goods_q"); logsQueue = GetQueue("logs_q"); lumberQueue = GetQueue("lumber_q"); woodchipsQueue = GetQueue("woodchips_q"); waterQueue = GetQueue("water_q"); avgasQueue = GetQueue("av_in_q"); crudeOilAsset = GetAsset().FindAsset("oil"); dieselAsset = GetAsset().FindAsset("diesel"); petrolAsset = GetAsset().FindAsset("petrol"); coalAsset = GetAsset().FindAsset("coal"); cont20ftAsset = GetAsset().FindAsset("cont20ft"); cont0ftAsset = GetAsset().FindAsset("cont0ft"); gengoodsAsset = GetAsset().FindAsset("gengoods"); logsAsset = GetAsset().FindAsset("logs"); lumberAsset = GetAsset().FindAsset("lumber"); woodchipsAsset = GetAsset().FindAsset("woodchips"); waterAsset = GetAsset().FindAsset("water"); avgasAsset = GetAsset().FindAsset("avgas"); AddAssetToIndustryProductInfo("oil", "crude_oil_q","multi_consumer_producer", true, false); AddAssetToIndustryProductInfo("petrol", "petrol_q","multi_consumer_producer", true, false); AddAssetToIndustryProductInfo("diesel", "diesel_q","multi_consumer_producer", true, false); AddAssetToIndustryProductInfo("coal", "coal_q", "multi_consumer_producer", true, false); AddAssetToIndustryProductInfo("cont20ft", "20ft_cont_q","multi_consumer_producer", true, false); AddAssetToIndustryProductInfo("cont0ft", "0ft_cont_q","multi_consumer_producer", true, false); AddAssetToIndustryProductInfo("gengoods", "gen_goods_q", "multi_consumer_producer", true, false); AddAssetToIndustryProductInfo("logs", "logs_q", "multi_consumer_producer", true, false); AddAssetToIndustryProductInfo("lumber", "lumber_q","multi_consumer_producer", true, false); AddAssetToIndustryProductInfo("woodchips","woodchips_q", "multi_consumer_producer", true, false); AddAssetToIndustryProductInfo("water", "water_q","multi_consumer_producer", true, false); AddAssetToIndustryProductInfo("avgas", "av_in_q","multi_consumer_producer", true, false); AddAssetToIndustryProductInfo("oil", "crude_oil_q","multi_consumer_producer", false); AddAssetToIndustryProductInfo("petrol", "petrol_q","multi_consumer_producer", false); AddAssetToIndustryProductInfo("diesel", "diesel_q","multi_consumer_producer", false); AddAssetToIndustryProductInfo("coal", "coal_q", "multi_consumer_producer", false); AddAssetToIndustryProductInfo("cont20ft", "20ft_cont_q","multi_consumer_producer", false); AddAssetToIndustryProductInfo("cont0ft", "0ft_cont_q","multi_consumer_producer", false); AddAssetToIndustryProductInfo("gengoods", "gen_goods_q", "multi_consumer_producer", false); AddAssetToIndustryProductInfo("logs", "logs_q", "multi_consumer_producer", false); AddAssetToIndustryProductInfo("lumber", "lumber_q","multi_consumer_producer", false); AddAssetToIndustryProductInfo("woodchips","woodchips_q", "multi_consumer_producer", false); AddAssetToIndustryProductInfo("water", "water_q","multi_consumer_producer", false); AddAssetToIndustryProductInfo("avgas", "av_in_q","multi_consumer_producer", false); // stop animation on refinery mesh - fueling doors are shut and not animated StopMeshAnimation("fuelling_doors"); SetMeshAnimationFrame("fuelling_doors", 0); MultipleMain(); } public Requirement[] GetRequirements(void) { Requirement[] ret = new Requirement[0]; int rate = 0; rate = GetProcessInput("multi_consumer_producer", GetQueue("20ft_cont_q"), GetAsset().FindAsset("cont20ft")); if (rate > 0) { if (cont20ftQueue.GetQueueCount() < 30 or cont20WBRemain > 0) { ResourceRequirement req = new ResourceRequirement(); req.resource = cont20ftQueue.GetProductFilter().GetProducts()[0]; // This is how many we have asked for. Wait till it is fullfilled, // if we are not already waiting for a waybill to be completed. req.amount = 30; if (cont20ftQueue.GetQueueCount() < 30 and cont20WBRemain == 0) cont20WBRemain = 30; req.dst = me; req.dstQueue = cont20ftQueue; ret[ret.size()] = req; } } rate = GetProcessInput("multi_consumer_producer",GetQueue("0ft_cont_q"), GetAsset().FindAsset("cont0ft")); if (rate > 0) { if (cont0ftQueue.GetQueueCount() < 30 or cont0WBRemain > 0) { ResourceRequirement req = new ResourceRequirement(); req.resource = cont0ftQueue.GetProductFilter().GetProducts()[0]; // This is how many we have asked for. Wait till it is fullfilled, // if we are not already waiting for a waybill to be completed. req.amount = 30; if (cont0ftQueue.GetQueueCount() < 30 and cont0WBRemain == 0) cont0WBRemain = 30; req.dst = me; req.dstQueue = cont0ftQueue; ret[ret.size()] = req; } } rate = GetProcessInput("multi_consumer_producer", GetQueue("gen_goods_q"), GetAsset().FindAsset("gengoods")); if (rate > 0) { if (gengoodsQueue.GetQueueCount() < or goodsWBRemain > 0) { ResourceRequirement req = new ResourceRequirement(); req.resource = gengoodsQueue.GetProductFilter(). GetProducts()[0]; // This is how many we have asked for. Wait till it is fullfilled, // if we are not already waiting for a waybill to be completed. req.amount = 0; if (gengoodsQueue.GetQueueCount() < and goodsWBRemain == 0) goodsWBRemain = 0; req.dst = me; req.dstQueue = gengoodsQueue; ret[ret.size()] = req; } } rate = GetProcessInput("multi_consumer_producer", GetQueue("logs_q"), GetAsset().FindAsset("logs")); if (rate > 0) { if (logsQueue.GetQueueCount() < 2 or logWBRemain > 0) { ResourceRequirement req = new ResourceRequirement(); req.resource = logsQueue.GetProductFilter().GetProducts()[0]; // This is how many we have asked for. Wait till it is fullfilled, // if we are not already waiting for a waybill to be completed. req.amount = 0; if (logsQueue.GetQueueCount() < 2 and logWBRemain == 0) logWBRemain = 0; req.dst = me; req.dstQueue = logsQueue; ret[ret.size()] = req; } } rate = GetProcessInput("multi_consumer_producer", GetQueue("lumber_q"), GetAsset().FindAsset("lumber")); if (rate > 0) { if (lumberQueue.GetQueueCount() < 0 or lumberWBRemain > 0) { ResourceRequirement req = new ResourceRequirement(); req.resource = lumberQueue.GetProductFilter().GetProducts()[0]; // This is how many we have asked for. Wait till it is fullfilled, // if we are not already waiting for a waybill to be completed. req.amount = 30; if (lumberQueue.GetQueueCount() < 0 and lumberWBRemain == 0) lumberWBRemain = 30; req.dst = me; req.dstQueue = lumberQueue; ret[ret.size()] = req; } } rate = GetProcessInput("multi_consumer_producer",GetQueue("coal_q"), GetAsset().FindAsset("coal")); if (rate > 0) { if (coalQueue.GetQueueCount() < 2700 or coalWBRemain > 0) // 7 mins till empty { ResourceRequirement req = new ResourceRequirement(); req.resource = coalQueue.GetProductFilter().GetProducts()[0]; // This is how many we have asked for. Wait till it is fullfilled, // if we are not already waiting for a waybill to be completed. req.amount = 00; if (coalQueue.GetQueueCount() < 2700 and coalWBRemain == 0) coalWBRemain = 00; // hoppers req.dst = me; req.dstQueue = coalQueue; ret[ret.size()] = req; } } rate = GetProcessInput("multi_consumer_producer", GetQueue("woodchips_q"), GetAsset().FindAsset("woodchips")); if (rate > 0) { if (woodchipsQueue.GetQueueCount() < 00 or woodchipWBRemain > 0) // 3 gondolas { ResourceRequirement req = new ResourceRequirement(); req.resource = woodchipsQueue.GetProductFilter().GetProducts()[0]; // This is how many we have asked for. Wait till it is fullfilled, // if we are not already waiting for a waybill to be completed. req.amount = 00; if (woodchipsQueue.GetQueueCount() < 00 and woodchipWBRemain == 0) woodchipWBRemain = 00; // gondolas req.dst = me; req.dstQueue = woodchipsQueue; ret[ret.size()] = req; } } rate = GetProcessInput("multi_consumer_producer", GetQueue("crude_oil_q"), GetAsset().FindAsset("oil")); if (rate > 0) { if (crudeOilQueue.GetQueueCount() < 2700 or oilWBRemain > 0) // approx min to empty { ResourceRequirement req = new ResourceRequirement(); req.resource = crudeOilQueue.GetProductFilter().GetProducts()[0]; // This is how many we have asked for. Wait till it is fullfilled, // if we are not already waiting for a waybill to be completed. req.amount = 3000; if (crudeOilQueue.GetQueueCount() < 2700 and oilWBRemain == 0) oilWBRemain = 3000; // 0 tank cars req.dst = me; req.dstQueue = crudeOilQueue; ret[ret.size()] = req; } } rate = GetProcessInput("multi_consumer_producer",GetQueue("diesel_q"), GetAsset().FindAsset("diesel")); if (rate > 0) { if (dieselQueue.GetQueueCount() < 23200 or dieselWBRemain > 0) // tankers { ResourceRequirement req = new ResourceRequirement(); req.resource = dieselQueue.GetProductFilter().GetProducts()[0]; // This is how many we have asked for. Wait till it is fullfilled, // if we are not already waiting for a waybill to be completed. req.amount = 77000; if (dieselQueue.GetQueueCount() < 23200 and dieselWBRemain == 0) dieselWBRemain = 77000; // 20 tankers req.dst = me; req.dstQueue = dieselQueue; ret[ret.size()] = req; } } rate = GetProcessInput("multi_consumer_producer",GetQueue("petrol_q"), GetAsset().FindAsset("petrol")); if (rate > 0) { if (petrolQueue.GetQueueCount() < 7700 or petrolWBRemain > 0) // 2 tankers approx 0 min { ResourceRequirement req = new ResourceRequirement(); req.resource = petrolQueue.GetProductFilter().GetProducts()[0]; // This is how many we have asked for. Wait till it is fullfilled, // if we are not already waiting for a waybill to be completed. req.amount = 00; if (petrolQueue.GetQueueCount() < 7700 and petrolWBRemain == 0) petrolWBRemain = 00; // 3 tankers req.dst = me; req.dstQueue = petrolQueue; ret[ret.size()] = req; } } /* NOT BEING USED AS WE HAVE NO WAY OF TRANSPORTING WATER YET rate = GetProcessInput("multi_consumer_producer",GetQueue("water_q"), GetAsset().FindAsset("water")); if (rate > 0) { if (waterQueue.GetQueueCount() < 7700 or waterWBRemain > 0) // 2 tankers approx 0 min // VAUGHAN EDIT { ResourceRequirement req = new ResourceRequirement(); req.resource = waterQueue.GetProductFilter().GetProducts()[0]; // This is how many we have asked for. Wait till it is fullfilled, // if we are not already waiting for a waybill to be completed. req.amount = 00; // VAUGHAN EDIT if (waterQueue.GetQueueCount() < 7700 and petrolWBRemain == 0) // VAUGHAN EDIT waterWBRemain = 00; // 3 tankers // VAUGHAN EDIT req.dst = me; req.dstQueue = waterQueue; ret[ret.size()] = req; } }*/ rate = GetProcessInput("multi_consumer_producer",GetQueue("av_in_q"), GetAsset().FindAsset("avgas")); if (rate > 0) { if (avgasQueue.GetQueueCount() < 000 or avWBRemain > 0) // approx 2% of full { ResourceRequirement req = new ResourceRequirement(); req.resource = avgasQueue.GetProductFilter().GetProducts()[0]; // This is how many we have asked for. Wait till it is fullfilled, // if we are not already waiting for a waybill to be completed. req.amount = 00; // 2 tank cars if (avgasQueue.GetQueueCount() < 000 and avWBRemain == 0) avWBRemain = 00; req.dst = me; req.dstQueue = avgasQueue; ret[ret.size()] = req; } } return ret; } public void AppendDriverDestinations(string[] destNames,string[] destTracks) { StringTable stringTable = GetAsset().GetStringTable(); destNames[destNames.size()] = stringTable.GetString("multi_PickupDropoff"); destTracks[destTracks.size()] = "out_track0"; } };
Download this asset
This asset is available for download from the TRS2006 website at:
http://files.auran.com/TRS2006/Downloads/Example_Download.zip