Various NML related questions

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9412
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Various NML related questions

Post by planetmaker »

stefino_cz wrote:
29 Jan 2020 13:44
Hi, I have a short question about NRT in NML. When the NRT flags will be add in NML? In Wiki pages there are 4 flags like "No houses along the roadtype" but NML doesn't know it. Thanks :)
They are there. Did you forget to use their prefix ROADTYPE_FLAG?

Code: Select all

global_constants.py:    'ROADTYPE_FLAG_CATENARY'          : 0,
global_constants.py:    'ROADTYPE_FLAG_NO_LEVEL_CROSSING' : 1,
global_constants.py:    'ROADTYPE_FLAG_NO_HOUSES'         : 2,
global_constants.py:    'ROADTYPE_FLAG_HIDDEN'            : 3,
global_constants.py:    'ROADTYPE_FLAG_TOWN_BUILD'        : 4,
(Maybe please edit the wiki such that the flag description follows the example of the flags for objects etc with a separate table which might be more clear)

User avatar
stefino_cz
Traffic Manager
Traffic Manager
Posts: 244
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: Various NML related questions

Post by stefino_cz »

Planet: Yay...my bad :) Thanks for the quick answer :)
Image

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9412
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Various NML related questions

Post by planetmaker »

stefino_cz wrote:
29 Jan 2020 14:28
Planet: Yay...my bad :) Thanks for the quick answer :)
Happy to help :) I know you'll reward us with awesome NewGRFs.

User avatar
stefino_cz
Traffic Manager
Traffic Manager
Posts: 244
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: Various NML related questions

Post by stefino_cz »

planetmaker wrote:
29 Jan 2020 16:04
stefino_cz wrote:
29 Jan 2020 14:28
Planet: Yay...my bad :) Thanks for the quick answer :)
Happy to help :) I know you'll reward us with awesome NewGRFs.
I found the problem. I remembered that I have an old NML version because newer version are not for windows :| So this is the problem I think.
Image

User avatar
3iff
Tycoon
Tycoon
Posts: 1012
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Various NML related questions

Post by 3iff »

Regarding the cargo price changing, it seems there's a setting called "profit:" (in cargos/graphics) which allows for an independent profit calculation.

I can get it to do something, but not anything useful at the moment. It seems I need to replicate how the trunk code calculates cargo payment to get what I actually want. Unfortunately I can't make much sense of how the trunk code does this. I'm about to investigate further but any pointers in this area would be helpful.

I did have a look at copying across the cargo pricing from FIRS3 but unfortunately different economies mix up the cargo id numbers (and prices) so a simple reorganisation has zero change of working.

-----

I have a bit more info now so maybe I can make this work after all (famous last words!).
The profit callback returns a value to use as a multiplier for amount and price_factor...which makes it clearer than I originally understood it...

User avatar
Gadg8eer
Engineer
Engineer
Posts: 61
Joined: 14 Dec 2019 14:22

Re: Various NML related questions

Post by Gadg8eer »

I'm trying to create a small roadset, but I keep getting this error...

Code: Select all

ERROR: "src/roads/0000_road.pnml", line 9: Unrecognized identifier 'FEAT_ROADTYPES' encountered
I included my source code with this post. Can someone please explain what's going on?
Attachments
src.7z
(2.38 KiB) Downloaded 83 times

User avatar
jfs
Tycoon
Tycoon
Posts: 1208
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Various NML related questions

Post by jfs »

The version of NML you're using is probably too old.
Currently we don't have a released Windows build ready-to-run that supports NRT. You'll have to run it "manually" via Python for now.

Alon
Engineer
Engineer
Posts: 17
Joined: 22 Jul 2019 14:07

Re: Various NML related questions

Post by Alon »

Can I change the max speed of a wagon?
Example:
Wagon Sggrss 80', max speed when empty is 120 km/h , but when it reached 25 t axle load the max speed will be 100 km/h.
Is there a way to implement that in nml? Like switch block or something.

User avatar
jfs
Tycoon
Tycoon
Posts: 1208
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Various NML related questions

Post by jfs »

Alon wrote:
09 Feb 2020 13:42
Can I change the max speed of a wagon?
Example:
Wagon Sggrss 80', max speed when empty is 120 km/h , but when it reached 25 t axle load the max speed will be 100 km/h.
Is there a way to implement that in nml? Like switch block or something.
"Maybe", I'm not sure if it will work but you can make a callback for the wagon named "speed", which should return the actual max speed for it based on the various properties.
The reason it might not work is that I'm not sure if the "Change vehicle properties" callback is called when a train leaves station or loads/unloads cargo, or only in other circumstances.

User avatar
Gadg8eer
Engineer
Engineer
Posts: 61
Joined: 14 Dec 2019 14:22

Re: Various NML related questions

Post by Gadg8eer »

jfs wrote:
09 Feb 2020 08:40
The version of NML you're using is probably too old.
Currently we don't have a released Windows build ready-to-run that supports NRT. You'll have to run it "manually" via Python for now.
I'm going to need instructions on what to specifically do. Please?

User avatar
jfs
Tycoon
Tycoon
Posts: 1208
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Various NML related questions

Post by jfs »

Gadg8eer wrote:
09 Feb 2020 20:18
jfs wrote:
09 Feb 2020 08:40
The version of NML you're using is probably too old.
Currently we don't have a released Windows build ready-to-run that supports NRT. You'll have to run it "manually" via Python for now.
I'm going to need instructions on what to specifically do. Please?
The last few posts in the main NML thread has some instructions, here: viewtopic.php?p=1227960#p1227960

Alon
Engineer
Engineer
Posts: 17
Joined: 22 Jul 2019 14:07

Re: Various NML related questions

Post by Alon »

jfs wrote:
09 Feb 2020 14:52

"Maybe", I'm not sure if it will work but you can make a callback for the wagon named "speed", which should return the actual max speed for it based on the various properties.
The reason it might not work is that I'm not sure if the "Change vehicle properties" callback is called when a train leaves station or loads/unloads cargo, or only in other circumstances.
An experiment should be made for this.

Another Question:

Can I use different spriteset for loading and unloading? I only see loading and loaded spriteset.
I wan't to create different animation when unloading ( wagon is tilted to side, like a dump truck), when loading( no changes just getting filled with cargo).

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5472
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: Various NML related questions

Post by PikkaBird »

Alon wrote:
25 Feb 2020 05:57
Can I use different spriteset for loading and unloading? I only see loading and loaded spriteset.
Yes. Use the vehicle_is_unloading variable.

michael blunck
Tycoon
Tycoon
Posts: 5877
Joined: 27 Apr 2005 07:09
Contact:

Re: Various NML related questions

Post by michael blunck »

Alon wrote:
09 Feb 2020 13:42
Can I change the max speed of a wagon?
Depends on what you're trying to achieve.
Alon wrote: Example:
Wagon Sggrss 80', max speed when empty is 120 km/h , but when it reached 25 t axle load the max speed will be 100 km/h.
You can't set vehicle speed on "axle load", i.e. as a feature of a certain track set. However, you can set it on the current load of a vehicle.

In TTDPatch times this was easy, since its "wagonspeedlimits" switch in the config file allowed for a parameter specifying how much faster empty train wagons are allowed to go.
Since OTTD lacks this feature you'll have to do it yourself by querying var 0xBC (current_load,  resp its nml variant).

This works as intended. I do it for most of the freight wagons in DBXL.

regards
Michael
Image

Alon
Engineer
Engineer
Posts: 17
Joined: 22 Jul 2019 14:07

Re: Various NML related questions

Post by Alon »

PikkaBird wrote:
25 Feb 2020 07:12

Yes. Use the vehicle_is_unloading variable.
I didn't realize that variable exist in wiki, maybe I'm having a poor eyesight.
michael blunck wrote:
25 Feb 2020 08:07

You can't set vehicle speed on "axle load", i.e. as a feature of a certain track set. However, you can set it on the current load of a vehicle.
That is what I'm trying to achieve. To modify/change the maximum speed of wagons depending on load, I just used the axle load as an example.
michael blunck wrote:
25 Feb 2020 08:07
In TTDPatch times this was easy, since its "wagonspeedlimits" switch in the config file allowed for a parameter specifying how much faster empty train wagons are allowed to go.
Since OTTD lacks this feature you'll have to do it yourself by querying var 0xBC (current_load,  resp its nml variant).
I think in nml "cargo_count" functions like "current_load" in TTDPatch/m4nfo. This might be the answer for the question.


Thanks for the answers from both of you. This made some things clear to me, and unlocked some ideas.
I really appreciate your help/s.

User avatar
3iff
Tycoon
Tycoon
Posts: 1012
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Various NML related questions

Post by 3iff »

I'm trying to make an industry that cuts local trees to provide wood (exactly as a lumber mill does). It works but apparently produces 45t per 'cut'. This generates 180-225t per month which unfortunately is about twice what I actually want. It seems the trunk code produces a hardcoded 45t per time.

Other than modifying the trunk code (currently impossible) is there any way to reduce the wood produced by about 50% ?? (I'm guessing not - but...)

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9412
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Various NML related questions

Post by planetmaker »

It's a bit ago that I tinkered with it: I wonder whether it wouldn't work out to set it to behave like lumbermill but define the custom production callback such that it runs every 256 ticks and returns whatever amount you want.

User avatar
3iff
Tycoon
Tycoon
Posts: 1012
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Various NML related questions

Post by 3iff »

Yes, that might do it. It'll chop trees regardless but maybe a custom production cycle might act independently.

Although when I had a look at a (very old) trunk source I'm fairly sure it added 45 to the waiting_cargo_1 every production cycle (maybe only if it chopped trees).

Anyway, I can give it a try. Thanks for the suggestion.

User avatar
jfs
Tycoon
Tycoon
Posts: 1208
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Various NML related questions

Post by jfs »

Yes the "cuts trees" behaviour is still magically adding some production of the industry's first produced cargo type, regardless of any production callbacks or other rules.
I agree that this behaviour should allow more customisation, the big question is how ambitious to be.

There's previously been discussions about industries "planting" NewObject tiles during creation or regularly, but that hasn't been implemented (fully?) yet. The opposite would also make sense, having industries that consume (or modify) NewObjects as part of their production cycle.

Another possibility is to have a new flag for the industry, making it cut down trees but instead of adding the trees to produced_cargo_waiting, it adds the trees to incoming_cargo_waiting and calls the cargo delivered callback, so the tree cutting is handled as if it was a delivery of cargo. However this could cause some other issues with needing to reserve a cargo slot in the industry for the cut trees, possibly needing a cargo type label for the cut trees, and how to handle things in the UI.

A third idea is to have (again) a new flag, which signals that one of the industry's permanent storage slots is used for "cut trees needing processing". That's slightly more clean, but still not a good solution.

From a technical viewpoint, doing something general-ish that (also) supports newobjects in addition to trees seems like the smartest and less hacky. It also requires much more up-front design.

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9412
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Various NML related questions

Post by planetmaker »

Wow, just wow. I didn't expect such special behaviour hidden in the code directly at this place :) Thanks for digging it out.

From my POV, the preferred solution is to generalize this to some kind of field or surrounding object placement / removal behaviour.

Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 1 guest