Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Fri Oct 20, 2017 12:11 pm

All times are UTC




Post new topic  Reply to topic  [ 137 posts ]  Go to page Previous 13 4 5 6 7
Author Message
PostPosted: Tue Sep 12, 2017 4:38 pm 
Offline
Tycoon
Tycoon

Joined: Tue Feb 22, 2011 6:34 pm
Posts: 2589
You don't close your cargotable block, so the switch directly after that is considered part of that block, where it is not possible to be.

Also, the code you propose
Code:
cargo_subtype: PRAGA_N_LIVERY_SWITCH;

is not valid, there is no cargo_subtype graphics-property. If you do not want livery overrides, the default: should point to the correct switch or spriteset.

_________________
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML


Top
   
PostPosted: Wed Sep 13, 2017 5:16 am 
Offline
Engineer
Engineer
User avatar

Joined: Sun Oct 31, 2004 12:43 pm
Posts: 35
Location: Slovakia - Bratislava
On the contrary.

My aim is to have several refits for the same cargo - that is the whole point of the switch.

When I add it to the
Code:
default:
it doesnt allow any refits.

Can someone provide an advice how to create refits for the same cargo?

Two ways I tried:

1st switching through cargotable:
[+] Spoiler
Code:
cargotable {
    PASS,
    MAIL
}
switch(FEAT_ROADVEHS, SELF, PRAGA_N_LIVERY_SWITCH, cargo_subtype) {
    0:      PRAGA_N_0;
    1:      PRAGA_N_1;
    2:      PRAGA_N_2;
    3:      PRAGA_N_3;
}

switch(FEAT_ROADVEHS, SELF, sw_PRAGA_N_CARGO_SUBTYPE_TEXT, cargo_subtype) {
    0: return string(STR_NAME_PRAGA_N_0);
    1: return string(STR_NAME_PRAGA_N_1);
    2: return string(STR_NAME_PRAGA_N_2);
    3: return string(STR_NAME_PRAGA_N_3);
    return CB_RESULT_NO_TEXT;
}
 switch(FEAT_ROADVEHS, SELF, PRAGA_N_CAPACITY_SWITCH, cargo_subtype) {
       0: 35;
       1: 40;
       2: 35;
       3: 40;

item (FEAT_ROADVEHS, ITEM_PRAGA_N) {
                  property {
                             name: string(STR_NAME_PRAGA_N);
                             climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL);
                               introduction_date: date(1915,01,01);
                             model_life: 11;
                             vehicle_life: 11;
                             reliability_decay: 20;
                                              refittable_cargo_classes:    bitmask(CC_PASSENGERS);
                        cargo_allow_refit: [PASS];
                        refit_cost: 0;
                             loading_speed: 5;
                             cost_factor: 108;
                             running_cost_factor: 90;
                             sprite_id: SPRITE_ID_NEW_ROADVEH;
                             speed: 40 km/h;
                              running_cost_base: RUNNING_COST_ROADVEH;
                             power: 45 hp;
                        weight: 4.5 ton;
                             sound_effect: SOUND_BUS_START_PULL_AWAY;
                          }

                      graphics {
                             default:  PRAGA_N_0;
                        PASS: PRAGA_N_LIVERY_SWITCH;
                        cargo_subtype_text: sw_PRAGA_N_CARGO_SUBTYPE_TEXT;
                                                           cargo_capacity: PRAGA_N_CAPACITY_SWITCH;
                        purchase_cargo_capacity: 25;
                     }
                 }



2nd switching through cargo-subtype at default in graphics section:
[+] Spoiler
Code:

switch(FEAT_ROADVEHS, SELF, SKODA_505_LIVERY_SWITCH, cargo_subtype) {
    0:      SKODA_505_0;
    1:      SKODA_505_1;
    2:      SKODA_505_2;
    3:      SKODA_505_3;
    4:      SKODA_505_4;
}

switch(FEAT_ROADVEHS, SELF, SWITCH_SKODA_505_CARGO_SUBTYPE_TEXT, cargo_subtype) {
    0: return string(STR_NAME_SKODA_505_0);
    1: return string(STR_NAME_SKODA_505_1);
    2: return string(STR_NAME_SKODA_505_2);
    3: return string(STR_NAME_SKODA_505_3);
    4: return string(STR_NAME_SKODA_505_4);
    return CB_RESULT_NO_TEXT;
}
switch(FEAT_ROADVEHS, SELF, SKODA_505_CAPACITY_SWITCH, cargo_subtype) {
    0: 32;
    1: 32;
    2: 32;
    3: 32;
    4: 32;
}

item (FEAT_ROADVEHS, ITEM_SKODA_505) {
                  property {

                             /* Properties common to all vehicle types */
                             name: string(STR_NAME_SKODA_505);
                             climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL);
                               introduction_date: date(1923,01,01);
                             model_life: 7;
                             vehicle_life: 25;
                             reliability_decay: 20;
                             loading_speed: 5; //                    STRING***********
                             cost_factor: 108; //                 **********POZRIET*********
                             running_cost_factor: 90; //                 **********POZRIET*********
                          /* cargo_age_period is left at default */
                             /* RV-specific properties */
                             sprite_id: SPRITE_ID_NEW_ROADVEH;
                             speed: 40 km/h;
                     //        misc_flags: bitmask(ROADVEH_FLAG_2CC); //    **********POZRIET*********
                              running_cost_base: RUNNING_COST_ROADVEH;
                             power: 35 hp;
                        weight: 3.6 ton;
                          /* TE and air drag coefficient is left at default */
                                   refittable_cargo_classes:    bitmask(CC_PASSENGERS);
                             

                          sound_effect: SOUND_BUS_START_PULL_AWAY;
                          }

                      graphics {
                             default:  SKODA_505_LIVERY_SWITCH;
                        cargo_subtype_text: SWITCH_SKODA_505_CARGO_SUBTYPE_TEXT;
                        cargo_capacity: SKODA_505_CAPACITY_SWITCH;
                        purchase_cargo_capacity: 32;
                     }
                 }
                


I get NO error messages when compiling the grf, all vehicles are there and are running, but none from them has an available refit.

Do I miss anything or is there some mistake I, with my minimal experience simply do not see?

_________________
Woof !


Top
   
PostPosted: Mon Sep 18, 2017 9:55 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Mon Apr 17, 2017 4:52 pm
Posts: 287
Location: S.W. London
So the way I've done it in the past is

Code:
spriteset(spriteset_Example_Purchase, "gfx/Example.png") {
   template_purchase(237, 488)
}

spriteset(spriteset_Example_Livery2, "gfx/Example.png") {
   template_electrostar(0, 468)
}

spriteset(spriteset_Example_Livery, "gfx/Example.png") {
   template_electrostar(0, 546)
}

spriteset(spriteset_Example_Livery3, "gfx/Example.png") {
   template_electrostar(0, 0)
}


switch(FEAT_TRAINS,SELF, sw_Example,cargo_subtype){
   0:spriteset_Example_Livery;
   1:spriteset_Example_Livery2;
   2:spriteset_Example_Livery3;
   }

switch(FEAT_TRAINS,SELF,sw_Example_cargo_subtype_text,cargo_subtype){
    0:   return string(str_Livery2);
    1:   return string(str_Livery);
    2:   return string(str_Livery3);
       return CB_RESULT_NO_TEXT;
}

item (FEAT_TRAINS, item_Example, xxx) {
   property {
      name:                      string(STR_NAME_Example);
      climates_available:          ALL_CLIMATES;
      introduction_date:            date(1987,4,21);
      model_life:                  15;
      retire_early:               1;
      vehicle_life:               50;
      reliability_decay:            7;
      refittable_cargo_classes:      0;
      cargo_allow_refit:            [PASS];
      loading_speed:               25;
      cost_factor:               61;
      running_cost_factor:         37;
      sprite_id:                  SPRITE_ID_NEW_TRAIN;
      speed:                     161 km/h;
      misc_flags:                  TRAIN_FLAG_MU;
      refit_cost:                  0;
      track_type:                  BR_3RDC;
      ai_special_flag:            AI_FLAG_CARGO;
      power:                     1438 hp;
      running_cost_base:            RUNNING_COST_ELECTRIC;
      dual_headed:               0;
      default_cargo_type:            PASS;
      cargo_capacity:               82;
      weight:                     168 ton;
      engine_class:               ENGINE_CLASS_ELECTRIC;
      tractive_effort_coefficient:   0.03;
      air_drag_coefficient:         0.05;
      length:                     8;
      effect_spawn_model_and_powered:   EFFECT_SPAWN_MODEL_ELECTRIC;
      extra_weight_per_wagon:         0;
      bitmask_vehicle_info:         0;
   }
   graphics {
   additional_text:               return(str_purchase_text);
   can_attach_wagon:               CB_RESULT_ATTACH_ALLOW;
   cargo_subtype_text:               sw_Example_cargo_subtype_text;
   articulated_part:                 switch_articulated_Example;
   default:                      sw_Example;
   purchase:                     spriteset_Example_Purchase;
}
}

_________________
Image

https://www.tt-forums.net/viewtopic.php?f=47&t=76619&p=1188249#p1188249


Top
   
PostPosted: Thu Sep 21, 2017 7:54 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Mon Apr 17, 2017 4:52 pm
Posts: 287
Location: S.W. London
Just to let y'all know I updated my previous post

_________________
Image

https://www.tt-forums.net/viewtopic.php?f=47&t=76619&p=1188249#p1188249


Top
   
PostPosted: Sun Sep 24, 2017 2:13 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sun Oct 31, 2004 12:43 pm
Posts: 35
Location: Slovakia - Bratislava
Thank you!

I was able to make it work. However I was not able to set any other properties of the refitted vehicle - is it possible to have cargo capacity, speed, runing costs or others changed for the refitted vehicle, when the refit is based on cargo subtype?

_________________
Woof !


Top
   
PostPosted: Sun Sep 24, 2017 6:52 pm 
Offline
Engineer
Engineer
User avatar

Joined: Wed Jul 01, 2015 3:03 pm
Posts: 62
Can you get spritesets and liveries from different graphics files? I'm working on basically an extremely large livery set, which basically includes the liveries of the major Class I railroads of North America and I would like to use the 2cc template. I would not want to make hundreds of different purchase files for each individual railroad, I would just want someone to be able to refit for the desired livery.


Top
   
PostPosted: Mon Sep 25, 2017 5:47 pm 
Offline
Tycoon
Tycoon

Joined: Tue Feb 22, 2011 6:34 pm
Posts: 2589
Greyfur wrote:
Thank you!

I was able to make it work. However I was not able to set any other properties of the refitted vehicle - is it possible to have cargo capacity, speed, runing costs or others changed for the refitted vehicle, when the refit is based on cargo subtype?

I expect that will be possible, for each property you would have one switch based on the cargo_type_in_veh variable, and that switch then points to additional switches that set the value based on the cargo_subtype.

Question is, how playable that will be, if you have too many changes it might get confusing.

TrainLover wrote:
Can you get spritesets and liveries from different graphics files? I'm working on basically an extremely large livery set, which basically includes the liveries of the major Class I railroads of North America and I would like to use the 2cc template. I would not want to make hundreds of different purchase files for each individual railroad, I would just want someone to be able to refit for the desired livery.

Each sprite can be in a separate file if you want to, but you can also put all sprites in 1 file, and everything in between.

_________________
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML


Top
   
PostPosted: Mon Sep 25, 2017 7:22 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Mon Apr 17, 2017 4:52 pm
Posts: 287
Location: S.W. London
Switches relating to livery are done through
Code:
 switch(FEATURE, [SELF|PARENT], sw_switchname, cargo_subtype){

Not sure if it helps, but there you go

_________________
Image

https://www.tt-forums.net/viewtopic.php?f=47&t=76619&p=1188249#p1188249


Top
   
PostPosted: Tue Sep 26, 2017 12:40 am 
Offline
Engineer
Engineer
User avatar

Joined: Sun Oct 31, 2004 12:43 pm
Posts: 35
Location: Slovakia - Bratislava
So, the property switch overrides will be located in the item graphics section after the text and graphics switches?

_________________
Woof !


Top
   
PostPosted: Tue Sep 26, 2017 12:52 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Mar 19, 2009 7:25 pm
Posts: 2514
Location: Kent
The switch itself comes above the item block, but you then reference it in the graphics block

_________________
Image


Top
   
PostPosted: Wed Oct 04, 2017 12:12 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sun Oct 31, 2004 12:43 pm
Posts: 35
Location: Slovakia - Bratislava
I seem to have a huge issue with the callbacks.

Every time I am doing a callback I receive an error.

Currently with this one:

Code:
switch(FEAT_ROADVEHS, SELF, power_B731yob_switch, build_year) {
    1982..1985:   202;
   1986..1996:     211;
 }   
 
 
item (FEAT_ROADVEHS, ITEM_B731) {
                  property {
...
                             power: 211 hp;      
...
}

                      graphics {
                           cargo_subtype_text: sw_B731_CARGO_SUBTYPE_TEXT;
                                     sw_B731_LIVERY_SWITCH;
                           power: power_B731yob_switch hp;
                     }
                 }


The Error I am receiving:
nmlc ERROR: "CS_BusSetw05lc735.nml", line 288: Syntax error, unexpected token "power"

The same issue appears even if the "hp" is removed and if I put hp to the switch value, I get an error for that.

I got the same duplicate error with cargo_capacity, when trying to do a callback through a switch based on cargo_subtype.

Anybody having a suggestion what am I doing wrong?

_________________
Woof !


Top
   
PostPosted: Wed Oct 04, 2017 3:30 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Mar 19, 2009 7:25 pm
Posts: 2514
Location: Kent
You dont need to put the hp at all, just a numerical value.

The units are auto imported from the item block

_________________
Image


Top
   
PostPosted: Wed Oct 04, 2017 3:44 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sun Oct 31, 2004 12:43 pm
Posts: 35
Location: Slovakia - Bratislava
Ok, good to know!

Any idea on the error?

_________________
Woof !


Top
   
PostPosted: Wed Oct 04, 2017 5:10 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4486
Location: home
Greyfur wrote:
Ok, good to know!

Any idea on the error?
What does "sw_B731_LIVERY_SWITCH;" do there? I am guessing it needs a callback name prefix?

_________________
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.


Top
   
PostPosted: Thu Oct 05, 2017 3:05 pm 
Offline
Tycoon
Tycoon

Joined: Tue Feb 22, 2011 6:34 pm
Posts: 2589
Alberth wrote:
Greyfur wrote:
Ok, good to know!

Any idea on the error?
What does "sw_B731_LIVERY_SWITCH;" do there? I am guessing it needs a callback name prefix?

I guess it is the default callback, so I expect that the error happens because the default callback is before the final callback. @Greyfur: Can you move the callback in the graphics-block up, so that the sw_B731_LIVERY_SWITCH is the last one?

_________________
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML


Top
   
PostPosted: Fri Oct 06, 2017 4:03 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4486
Location: home
Preferably also label it as default, as in https://newgrf-specs.tt-wiki.net/wiki/N ... hics_block

The switch could also use some additional 'return' keywords for clarity, as in https://newgrf-specs.tt-wiki.net/wiki/NML:Switch

_________________
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.


Top
   
PostPosted: Tue Oct 10, 2017 1:31 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sun Oct 31, 2004 12:43 pm
Posts: 35
Location: Slovakia - Bratislava
I didn't reply as adding the default: callback name did work and I was working on my code! Thank you so much!

There are two more things.

There are two subversions of a type built in the same year. I was able to create a switch that randomly gives you a subtype when buying the bus. One subtype is called C734.00, the other C734.03.

Now I would like to keep that subtype name after a livery refit. Is there a way to load the name into some variable and somehow reuse it after refit?

The other is - is there a way to add two different texts from two different switches one after another?

_________________
Woof !


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 137 posts ]  Go to page Previous 13 4 5 6 7

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.