NML - a Newgrf Meta Language
Moderator: Graphics Moderators
Re: NML - a Newgrf Meta Language
in the context of cargodist, there is more to worry about than station rating. if passengers pile up at intermediate stations, they already used up some part of the ressources, but they have not paid you any money, which reduces your overall income significantly.
if you want to adjust capacities, you can decompile a GRF into NFO, and change the values there. you can't decompile it into NML.
also, there are several passenger-reducing patches in the development forum.
if you want to adjust capacities, you can decompile a GRF into NFO, and change the values there. you can't decompile it into NML.
also, there are several passenger-reducing patches in the development forum.
Re: NML - a Newgrf Meta Language
Thanks guys for answers. I just managed to alter the grf(s) with grfcodec. It worked like a charm
I didn't know that you can decode/encode grfs written in nml. thank you
I didn't know that you can decode/encode grfs written in nml. thank you
The rest is confetti!
-
- Tycoon
- Posts: 2781
- Joined: 22 Feb 2011 18:34
Re: NML - a Newgrf Meta Language
I have a question regarding Dual-headed vehicles. Which properties are shared between the front head and the back head and which properties are only set for the front head (and need a switch-block to also be set for the back head)? It seems to me that power and costs are not set for the back head, but the other properties are.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Re: NML - a Newgrf Meta Language
what about the "available for articulated part" column in this table?
http://newgrf-specs.tt-wiki.net/wiki/NM ... icle_types
http://newgrf-specs.tt-wiki.net/wiki/NM ... icle_types
-
- Tycoon
- Posts: 2781
- Joined: 22 Feb 2011 18:34
Re: NML - a Newgrf Meta Language
It follows the list mostly, but for example weight and TE coefficient are not set to 0 for dual-headed vehicles, while they are set to 0 for articulated parts.Eddi wrote:what about the "available for articulated part" column in this table?
http://newgrf-specs.tt-wiki.net/wiki/NM ... icle_types
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Re: NML - a Newgrf Meta Language
I want to implement finite resources of mines by using permanent storage:
however seems that it is not working (I'm checking storage levels by means of industry extra text switch).
Should I push permanent storage to the temporary one during substraction, or there is my another mistake?
Code: Select all
switch(FEAT_INDUSTRIES, SELF, core_mine_resources_on_build, STORE_PERM(initial_resource,1)) {
return 16;
}
switch(FEAT_INDUSTRIES, SELF, core_mine_monthly_prod_change,
(STORE_PERM(LOAD_PERM(1)-produced_this_month_1,1))) {
return CB_RESULT_IND_PROD_NO_CHANGE;
}
Should I push permanent storage to the temporary one during substraction, or there is my another mistake?
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: NML - a Newgrf Meta Language
You don't seem to actually check for the variable. You only assign a new value. Additionally you always return 'no production change', whatever your variable value.McZapkie wrote:I want to implement finite resources of mines by using permanent storage:however seems that it is not working (I'm checking storage levels by means of industry extra text switch).Code: Select all
switch(FEAT_INDUSTRIES, SELF, core_mine_resources_on_build, STORE_PERM(initial_resource,1)) { return 16; } switch(FEAT_INDUSTRIES, SELF, core_mine_monthly_prod_change, (STORE_PERM(LOAD_PERM(1)-produced_this_month_1,1))) { return CB_RESULT_IND_PROD_NO_CHANGE; }
Should I push permanent storage to the temporary one during substraction, or there is my another mistake?
Try
Code: Select all
switch(FEAT_INDUSTRIES, SELF, core_mine_monthly_prod_change,
[STORE_PERM(MAX(LOAD_PERM(1)-produced_this_month_1,0),1), LOAD_PERM(1)]
) {
0: return CB_RESULT_IND_PROD_CLOSE; // close when no ressource left anymore)
return CB_RESULT_IND_PROD_NO_CHANGE;
}
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
Re: NML - a Newgrf Meta Language
I'm testing via:planetmaker wrote:
You don't seem to actually check for the variable. You only assign a new value. Additionally you always return 'no production change', whatever your variable value.
Code: Select all
switch(FEAT_INDUSTRIES, SELF, core_mine_extra_text, (LOAD_PERM(1) > 0 ? (LOAD_PERM(1)>initial_resource-1 ? 2 : 1 ): 0) ) {
0: return string(STR_MINE_EXHAUSTED);
1: return string(STR_MINE_1);
2: return string(STR_MINE_2);
return string(STR_NUMBER_UNDEF);
}
I removed all production change procedures to simplify code.
EDIT: there was funny mistake, I used produced_this_month in monthly_prod_change switch, wich is called at the beginning of each month - obviously this variable is equal zero.
With produced_last_month everything works OK.
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Re: NML - a Newgrf Meta Language
How to change type of cargo produced?
There is cargo_output callback, but it is unclear for me how it works.
I want to have one cargo produced permanently and the second one switched from one type to another and back, repeatedly.
There is cargo_output callback, but it is unclear for me how it works.
I want to have one cargo produced permanently and the second one switched from one type to another and back, repeatedly.
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: NML - a Newgrf Meta Language
There are the cargo_input and cargo_output callbacks.
But think twice, better three times before you start making use of those. People generally expect that an industry always accepts the same cargo types and also produces the same cargo types. it also doesn't work well with the industry chain view which also assumes constant cargo chains. And it will possibly also break AIs.
Code: Select all
switch (FEAT_INDUSTRIES, SELF, decide_output_cargo, extra_callback_info1) {
0: return cargotype("WATR");
1: return cargotype("OIL_");
return 0xFF;
}
...
item (FEAT_INDUSTRIES, well) {
graphics {
cargo_output: decide_output_cargo;
}
}
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
-
- Tycoon
- Posts: 2781
- Joined: 22 Feb 2011 18:34
Re: NML - a Newgrf Meta Language
Sounds like you are trying to work around a game limitation, and I'm not sure if this is the right way to do that.McZapkie wrote:How to change type of cargo produced?
There is cargo_output callback, but it is unclear for me how it works.
I want to have one cargo produced permanently and the second one switched from one type to another and back, repeatedly.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Re: NML - a Newgrf Meta Language
I need it to accept and produce passengers in case of farms, however let me redirect eventual discussion to another thread:planetmaker wrote:There are the cargo_input and cargo_output callbacks.
...
But think twice, better three times before you start making use of those. People generally expect that an industry always accepts the same cargo types and also produces the same cargo types. it also doesn't work well with the industry chain view which also assumes constant cargo chains. And it will possibly also break AIs.
http://www.tt-forums.net/viewtopic.php?f=67&t=71105
I have another question related to parsing NML files and using variable substitution within #define sttement -
sometimes there is variable_name ## something, sometimes variable_name ##something_without_space - what is a difference?
Is it possible to make #define template for switches names within graphic statement or only explicit names can be used?
Re: NML - a Newgrf Meta Language
space after ## does not make a difference.
you can make a #define containing a switch or any other text sequence, it will be replaced textually before nmlc processing. use \ at the end of line to make a define cover multiple lines (for easier overview)
for more information about #define see https://gcc.gnu.org/onlinedocs/cpp/
you can make a #define containing a switch or any other text sequence, it will be replaced textually before nmlc processing. use \ at the end of line to make a define cover multiple lines (for easier overview)
for more information about #define see https://gcc.gnu.org/onlinedocs/cpp/
-
- Tycoon
- Posts: 2781
- Joined: 22 Feb 2011 18:34
Re: NML - a Newgrf Meta Language
For an example of the use of \, see this codeEddi wrote:you can make a #define containing a switch or any other text sequence, it will be replaced textually before nmlc processing. use \ at the end of line to make a define cover multiple lines (for easier overview)
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
-
- Tycoon
- Posts: 2781
- Joined: 22 Feb 2011 18:34
Re: NML - a Newgrf Meta Language
I have a question regarding running_cost_base. Is it for train vehicles fine to set it to RUNNING_COST_ROADVEH? According to the specifications it is, but are there side-effects I should be aware of?
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Re: NML - a Newgrf Meta Language
It's "fine", but has exactly the drawbacks you've already identified in the 2cc thread.Transportman wrote:I have a question regarding running_cost_base. Is it for train vehicles fine to set it to RUNNING_COST_ROADVEH? According to the specifications it is, but are there side-effects I should be aware of?
If you want different cost bases with slightly less potential for other grfs buggering things up, you could do what I do in 10CC: use RUNNING_COST_STEAM for all locomotives, and RUNNING_COST_DIESEL for all wagons.
Re: NML - a Newgrf Meta Language
the side effect of using RUNNING_COST_ROADVEH is that changes to it are going to be global, if you don't actually define a road vehicle (you can easily define a dummy road vehicle that never becomes available to avoid this)
-
- Tycoon
- Posts: 2781
- Joined: 22 Feb 2011 18:34
Re: NML - a Newgrf Meta Language
Okay, that is a bit of a downside, also because of the potential that base cost NewGRFs have to accidentally influence them as RVs. I'll stick to PikkaBirds suggestion to use one base for engines and stuff and one base for wagons/coaches. That still gives me the control I need, without the pesky side-effects.Eddi wrote:the side effect of using RUNNING_COST_ROADVEH is that changes to it are going to be global, if you don't actually define a road vehicle (you can easily define a dummy road vehicle that never becomes available to avoid this)
Thanks for the information, saved me from a less handy decision.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Re: NML - a Newgrf Meta Language
Is it possible to create industry tile callback dependent on industry variables?
For example, I want to set industry tile anim_control callback dependent on industry production level.
For example, I want to set industry tile anim_control callback dependent on industry production level.
Re: NML - a Newgrf Meta Language
Certainly. Industry tiles can use the PARENT scope in switches to test the variables of the industry.
Who is online
Users browsing this forum: No registered users and 19 guests