Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Sep 26, 2018 9:50 am

All times are UTC




Post new topic  Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Tue May 23, 2017 6:29 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Mon May 25, 2015 9:09 am
Posts: 316
Location: The Netherlands
Hello,

I am currently trying to make a parameter which sets how high the train is shown, because the trains look off in the FS-maglev track set, but if I adapt the train-height to the FS-set, the train looks weird on normal rails. To achieve this, I used the following code to set the parameter:
Code:
   param {
        param_height {
            type:   int;
            name:   string(STR_PARAM_RAILHEIGHT);
            desc:   string(STR_PARAM_RAILHEIGHT_DESC);
            min_value: 0;
            max_value: 1;
            def_value: 0;
            names: {
                        0: string(STR_PARAM_RAILHEIGHT_ST);
                        1: string(STR_PARAM_RAILHEIGHT_FS);
            };
        }
    }

and then the following code to use it:
Code:
template TEMP_TRAIN_DOUBLE_8(h,d) {
   [0, 0, 8, 22+h+d, -3, -14-h-(4*param_height)]
   [9, 0, 22, 17+h+d, -14, -7-h-(4*param_height)]
   [32, 0, 32, 12+h+d, -15, -6-h-(4*param_height)]
   [65, 0, 22, 17+h+d, -8, -7-h-(4*param_height)]
   [88, 0, 8, 22+h+d, -3, -14-h-(4*param_height)]
   [97, 0, 22, 17+h+d, -14, -7-h-(4*param_height)]
   [120, 0, 32, 12+h+d, -15, -6-h-(4*param_height)]
   [153, 0, 22, 17+h+d, -8, -7-h-(4*param_height)]
}


The latter block of code causes the compiler to return this:
Code:
nmlc ERROR: "src/template.pnml", line 209: Unrecognized identifier 'param_height' encountered


and if I change the template to not use the parameter, I find that the parameter is completely missing from the list.

What am I doing wrong?

_________________
No pics no clicks. Seriously.
ImageImageImageImageImageImage


Top
   
PostPosted: Tue May 23, 2017 6:36 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9036
Location: Sol d
Why don't skip the parameter and simply include both offsets (thus the sprite two times, once with each offset) and show the appropriate one, depending on the tracktype?

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
PostPosted: Tue May 23, 2017 7:07 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Mon May 25, 2015 9:09 am
Posts: 316
Location: The Netherlands
planetmaker wrote:
Why don't skip the parameter and simply include both offsets (thus the sprite two times, once with each offset) and show the appropriate one, depending on the tracktype?

Well, there is really only 1 tracktype: Maglev, and the FS-track replaces the maglev track, thus effectively making it so that I can't change the offset depending on the tracktype, unfortunately.

_________________
No pics no clicks. Seriously.
ImageImageImageImageImageImage


Top
   
PostPosted: Tue May 23, 2017 7:10 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9036
Location: Sol d
Erato wrote:
planetmaker wrote:
Why don't skip the parameter and simply include both offsets (thus the sprite two times, once with each offset) and show the appropriate one, depending on the tracktype?

Well, there is really only 1 tracktype: Maglev, and the FS-track replaces the maglev track, thus effectively making it so that I can't change the offset depending on the tracktype, unfortunately.


That's a design error in the tracks then: if the *same* track label requires differently coded vehicles, then the error is with the track. Use different track labels, if the vehicles need to be coded differently.

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
PostPosted: Tue May 23, 2017 7:23 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Mon May 25, 2015 9:09 am
Posts: 316
Location: The Netherlands
planetmaker wrote:
Erato wrote:
planetmaker wrote:
Why don't skip the parameter and simply include both offsets (thus the sprite two times, once with each offset) and show the appropriate one, depending on the tracktype?

Well, there is really only 1 tracktype: Maglev, and the FS-track replaces the maglev track, thus effectively making it so that I can't change the offset depending on the tracktype, unfortunately.


That's a design error in the tracks then: if the *same* track label requires differently coded vehicles, then the error is with the track. Use different track labels, if the vehicles need to be coded differently.


I can unfortunately not change the way the track is coded:
Code:
   //RT labels
   -1 * 0   04 06 FF 01 00 D0 "Maglev Construction" 00 // in case you need these changed
   -1 * 0   04 06 FF 01 01 D0 "FS-Maglev Tracks" 00
   
   -1 * 0   00 10 05 01 01
      08 "MGLV"   //replace maglev tracks - RAIL for normal rail, ELRL for electrified rail and MONO for monorail
      09 00 D0   //build rail toolbar caption - see RT labels
      0A 00 D0   //rail construction dropdown text  - see RT labels
      10 02      //disable level crossings
      1B 01 D0   //railtype name  - see RT labels
Looks to me like it completely replaces the maglev track without getting a new track label.

But then remains the problem that I can't set or use the parameter. And I would like to know what I did wrong so next time I try it it won't have to make a new thread.

_________________
No pics no clicks. Seriously.
ImageImageImageImageImageImage


Top
   
PostPosted: Tue May 23, 2017 7:45 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9036
Location: Sol d
Erato wrote:
But then remains the problem that I can't set or use the parameter. And I would like to know what I did wrong so next time I try it it won't have to make a new thread.


I would query the presence of that particular NewGRF instead and adjust template depending on the outcome ;)

Unfortunately I don't quite see what could be wrong with the code you showed and I would have guessed that it works as you think it should work. Do you have other parameters? Do they work?

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
PostPosted: Tue May 23, 2017 7:50 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Mon May 25, 2015 9:09 am
Posts: 316
Location: The Netherlands
planetmaker wrote:
Erato wrote:
But then remains the problem that I can't set or use the parameter. And I would like to know what I did wrong so next time I try it it won't have to make a new thread.


I would query the presence of that particular NewGRF instead and adjust template depending on the outcome ;)

Unfortunately I don't quite see what could be wrong with the code you showed and I would have guessed that it works as you think it should work. Do you have other parameters? Do they work?


I was thinking about that but I don't really know how to do that. Would that require a switch-case for the grf-id of the FS-maglev track set?

Why yes, I do have other parameters, and they do work, however, they are boolean, instead of drop-down.
Code:
[+] Spoiler
Code:
#define JAPAN param_japan
#define GERMANY param_germany
#define SOVIET param_soviet
#define UK param_uk
#define SK param_sk
#define CHINA param_china
#define BRAZIL param_brazil
#define US param_us
#define RAILHEIGHT param_height
//#define VENEZUELA param_venezuela

#define NOREGION 0

#define REGION(REGION1,REGION2) climates_available: (REGION1 || REGION2) ? ALL_CLIMATES : NO_CLIMATE

grf {
   grfid:   "EN\01\01";
   name:   string(STR_GRF_NAME);
   desc:   string(STR_GRF_DESC);
   version:   4;
   min_compatible_version: 4;
   param {
        param_height {
            type:   int;
            name:   string(STR_PARAM_RAILHEIGHT);
            desc:   string(STR_PARAM_RAILHEIGHT_DESC);
            min_value: 0;
            max_value: 1;
            def_value: 0;
            names: {
                        0: string(STR_PARAM_RAILHEIGHT_ST);
                        1: string(STR_PARAM_RAILHEIGHT_FS);
            };
        }
    }
   param {
      JAPAN {
         type:   bool;
         name:   string(STR_PARAM_JAPAN);
         desc:   string(STR_PARAM_JAPAN_DESC);
         def_value: 1;
      }
   }
   param {
      GERMANY {
         type:   bool;
         name:   string(STR_PARAM_GERMANY);
         desc:   string(STR_PARAM_GERMANY_DESC);
         def_value: 1;
      }
   }
   param {
      US {
         type:   bool;
         name:   string(STR_PARAM_US);
         desc:   string(STR_PARAM_US_DESC);
         def_value: 1;
      }
   }
   param {
      SK {
         type:   bool;
         name:   string(STR_PARAM_SK);
         desc:   string(STR_PARAM_SK_DESC);
         def_value: 1;
      }
   }
   param {
      CHINA {
         type:   bool;
         name:   string(STR_PARAM_CHINA);
         desc:   string(STR_PARAM_CHINA_DESC);
         def_value: 1;
      }
   }
   param {
      SOVIET {
         type:   bool;
         name:   string(STR_PARAM_SOVIET);
         desc:   string(STR_PARAM_SOVIET_DESC);
         def_value: 1;
      }
   }
   param {
      UK {
         type:   bool;
         name:   string(STR_PARAM_UK);
         desc:   string(STR_PARAM_UK_DESC);
         def_value: 1;
      }
   }
   param {
      BRAZIL {
         type:   bool;
         name:   string(STR_PARAM_BRAZIL);
         desc:   string(STR_PARAM_BRAZIL_DESC);
         def_value: 1;
      }
   }
}


Edit, interestingly enough, the parameter did show up after I removed and readded the grf to the NewGRF settings.

Still doesn't explain why I couldn't use it in the code.

_________________
No pics no clicks. Seriously.
ImageImageImageImageImageImage


Top
   
PostPosted: Thu May 25, 2017 8:08 am 
Offline
Tycoon
Tycoon

Joined: Wed Apr 27, 2005 7:09 am
Posts: 5237
Erato wrote:
[...] Still doesn't explain why I couldn't use it in the code.

I don´t think it could work that way.

What you´re trying to do boils down to change a value in an action1 (y-offset in that "template") but this can´t be done "dynamically", i.e. not even by use of a callback.

So, what you need to do is to set up two sprite blocks with different offsets and switch them depending on your parameter, as planetmaker suggested.

regards
Michael

_________________
Image


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 8 posts ] 

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-2018 phpBB Limited

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