What is the right way to get cargoID?

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
User avatar
George
Tycoon
Tycoon
Posts: 4362
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

What is the right way to get cargoID?

Post by George »

Then coding a train set, I want to be sure, that the cargo with known label is heavy or light, and fix it in case it is not.

Code: Select all

if (cargotype_available("LVST")) {
  item(FEAT_CARGOS, cargo_lvst, cargotype("LVST")) 
  { property { weight: 12.0/16; } }
}
I try to fix the weigth this way, but I get the error

Code: Select all

nmlc ERROR: "xussr.nml", line 1652: Parameter for cargotype() must be a string literal that is also in your cargo table [ERR]
But cargotable has that label

Code: Select all

// cargotable
cargotable {
  PASS, TOUR,
  YETI, YETY,
  LVST, GOOD, 
  ...
}
What am I doing wrong and how to fix it?
Image Image Image Image
User avatar
GarryG
Tycoon
Tycoon
Posts: 5850
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: What is the right way to get cargoID?

Post by GarryG »

George wrote: 02 Dec 2022 14:28 But cargotable has that label
I still using NML 5.3 for coding so might be a bit different to what I doing.
But check your last entry in your cargotable and remove the comma if there.
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
User avatar
George
Tycoon
Tycoon
Posts: 4362
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Re: What is the right way to get cargoID?

Post by George »

GarryG wrote: 02 Dec 2022 22:25
George wrote: 02 Dec 2022 14:28 But cargotable has that label
But check your last entry in your cargotable and remove the comma if there.
There is no comma there
Image Image Image Image
User avatar
warp
Engineer
Engineer
Posts: 6
Joined: 22 Nov 2021 07:07
Contact:

Re: What is the right way to get cargoID?

Post by warp »

George wrote: 02 Dec 2022 14:28 Then coding a train set, I want to be sure, that the cargo with known label is heavy or light, and fix it in case it is not.

Code: Select all

if (cargotype_available("LVST")) {
  item(FEAT_CARGOS, cargo_lvst, cargotype("LVST")) 
  { property { weight: 12.0/16; } }
}
I try to fix the weigth this way, but I get the error

Code: Select all

nmlc ERROR: "xussr.nml", line 1652: Parameter for cargotype() must be a string literal that is also in your cargo table [ERR]
But cargotable has that label

Code: Select all

// cargotable
cargotable {
  PASS, TOUR,
  YETI, YETY,
  LVST, GOOD, 
  ...
}
What am I doing wrong and how to fix it?
Hi George,

I have the same nmlc error when I try to use the cargotype() function in my code.
Have you found a solution for this error in the meantime?
Or maybe someone else can help how to use the function in question?

Code: Select all

$ nmlc --version
0.7.4
Cheers
(~) warp
User avatar
George
Tycoon
Tycoon
Posts: 4362
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Re: What is the right way to get cargoID?

Post by George »

Hi
warp wrote: 15 Jul 2023 16:51I have the same nmlc error when I try to use the cargotype() function in my code.
Have you found a solution for this error in the meantime?
Unfortunately no.
Image Image Image Image
User avatar
warp
Engineer
Engineer
Posts: 6
Joined: 22 Nov 2021 07:07
Contact:

Re: What is the right way to get cargoID?

Post by warp »

Hi George,

Regarding our problem - just couple hours ego there is an issue report made on Github (by Stormcone) https://github.com/OpenTTD/nml/issues/299 It includes also the issue with cargotype().

Lets hope the devs will fix it in next release of nml.

Cheers
(~) warp
User avatar
George
Tycoon
Tycoon
Posts: 4362
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Re: What is the right way to get cargoID?

Post by George »

warp wrote: 19 Jul 2023 07:21Regarding our problem - just couple hours ego there is an issue report made on Github (by Stormcone) https://github.com/OpenTTD/nml/issues/299 It includes also the issue with cargotype().
Lets hope the devs will fix it in next release of nml.
Thank you
Image Image Image Image
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: No registered users and 18 guests