Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sat Jul 21, 2018 9:31 am

All times are UTC




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sun Jul 02, 2017 11:49 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sat Nov 01, 2014 5:24 am
Posts: 31
Location: São José dos Campos, Brazil
Can "is_city" town variable be accessed to be used in a if_else statement in NML?

I tried if ((is_city) == 1){ but the terminal game me a message:
Code:
←[Knmlc ERROR: "CRABS.nml", line 38: Unrecognized identifier 'is_city' encountered


Top
   
PostPosted: Mon Jul 03, 2017 12:20 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 290
Show us a sample of the code block you are working on?

The "is_city" variable is only ever defined in certain scopes:

https://newgrf-specs.tt-wiki.net/wiki/NML:Towns
Quote:
Towns aren't a NewGRF feature of their own but town variables can be accessed via the parent scope of stations, houses and industries.


Hence, you must be in one of those scopes to be able to use it.

Also, maybe a ternary operator might be what you are looking for?

Code:
property = is_city ? 1 : 0;


So where are you using it and what's the goal?


Top
   
PostPosted: Mon Jul 03, 2017 12:41 am 
Offline
Engineer
Engineer
User avatar

Joined: Sat Nov 01, 2014 5:24 am
Posts: 31
Location: São José dos Campos, Brazil
I was testing an idea of giving town one set of road sprites and cities another. Like this:
Code:
if ((is_city) == 1){
   replace dirt_road (1332, "gfx/test.png"){
      template_roads(1, 1)
      }
}else{
   replace sett_road (1332, "gfx/test.png"){
      template_roads(1, 42)
      }
}


Top
   
PostPosted: Mon Jul 03, 2017 8:47 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 290
And is that inside a FEAT_HOUSES, FEAT_STATIONS or FEAT_INDUSTRIES block?
I suspect what you are trying to achieve there isn't possible. But i don't know. Either way, the "is_city" variable is only available inside it's related feature as explained in the link i gave you.


Top
   
PostPosted: Mon Jul 03, 2017 6:38 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sat Nov 01, 2014 5:24 am
Posts: 31
Location: São José dos Campos, Brazil
Thanks for your answer, definitively it is not possible to use is_city the way I thought. Will have to change plans :) Thanks


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 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.