Need help about script

Hi,
I need someone help me about the script. It's about the speed of wagon traincar.
The part of script is :

if (speed < 3.0 and speed > -3.0)

As far I know, if traincar's speed is more than 3 (reverse also), there's no loading activity.
But iin driver running, the industry only stop if the speed no more than 10.
Did I mistake a script ?

2. Thank you in advance.
 
show more of the script. How do your derive the velocity of a traincar?
Oh, here is ...

class CoalLoader isclass BaseIndustry
{
ProductQueue coalOutQueue;
thread void PerformLoad(Vehicle vehicle)
{
float speed = vehicle.GetVelocity();
if (speed < 3.0 and speed > -3.0)
{
int coalAvailable = coalOutQueue.GetQueueCount();
LoadingReport report = CreateLoadingReport(coalOutQueue, coalAvailable);
vehicle.LoadProduct(report);
}
}
 
@aprinto_joss, fyi, if you wrap your code in [CODE] [/CODE] tags, the forum will preserve the indentation and make the script easier to read.

Like so:
Code:
class CoalLoader isclass BaseIndustry
{
  ProductQueue coalOutQueue;
  thread void PerformLoad(Vehicle vehicle)
  {
    float speed = vehicle.GetVelocity();
    if (speed < 3.0 and speed > -3.0)
    {
      int coalAvailable = coalOutQueue.GetQueueCount();
      LoadingReport report = CreateLoadingReport(coalOutQueue, coalAvailable);
      vehicle.LoadProduct(report);
    }
  }
}
 
@aprinto_joss, fyi, if you wrap your code in [CODE] [/CODE] tags, the forum will preserve the indentation and make the script easier to read.

Like so:
Code:
class CoalLoader isclass BaseIndustry
{
  ProductQueue coalOutQueue;
  thread void PerformLoad(Vehicle vehicle)
  {
    float speed = vehicle.GetVelocity();
    if (speed < 3.0 and speed > -3.0)
    {
      int coalAvailable = coalOutQueue.GetQueueCount();
      LoadingReport report = CreateLoadingReport(coalOutQueue, coalAvailable);
      vehicle.LoadProduct(report);
    }
  }
}
Thank you for you advise....
I am not quite familiar with this forum....
You should probably check that the passed vehicle parameter is not void.
So, I should use this ?
Code:
  thread PerformLoad(Vehicle vehicle)
.....
 
Thank you for you advise....
You`re welcome.

So, I should use this ?
If you`re referring to the use of the [CODE] [/CODE] tags, then you got it perfect.

If, however, you were referring to checking for vehicle being null, then more like this:
Code:
class CoalLoader isclass BaseIndustry
{
  ProductQueue coalOutQueue;
  thread void PerformLoad(Vehicle vehicle)
  {
    if (vehicle)
    {
      float speed = vehicle.GetVelocity();
      if (speed < 3.0 and speed > -3.0)
      {
        int coalAvailable = coalOutQueue.GetQueueCount();
        LoadingReport report = CreateLoadingReport(coalOutQueue, coalAvailable);
        vehicle.LoadProduct(report);
      }
    }
  }
}
 
In Trainz the speed is measured in mps (meters per second). For kph (kilometers per hour) you have to multiply the value by 3.6 (3.0 mps = 10.8 kph), for mph (miles per hour) the multiplier is 2.237 (3.0 mps = 6.71 mph).

Peter
 
In Trainz the speed is measured in mps (meters per second). For kph (kilometers per hour) you have to multiply the value by 3.6 (3.0 mps = 10.8 kph), for mph (miles per hour) the multiplier is 2.237 (3.0 mps = 6.71 mph).

Peter
Yeah, you're right ....
I had changed to 1 and -1, so now the loader will only load if train speed max is 3 .... I don't know it's 3.6 kph or 2.2 mph. But I set to metric in the route.
Thank you.
 
Back
Top