Page 11 of 14

Re: Various NML related questions

Posted: 12 Dec 2020 13:02
by Andrew350
McZapkie wrote: 12 Dec 2020 10:06 Is it possible to define default track type in menu (not the first one)?
Let say I have 3 tracktype, Slow, Medium, Fast, they appear in menu in such order,
any means to force Medium to be first choice when track menu is opened?
No. Which rail type gets selected first depends on the user's settings, and NewGRF can't influence that.

Re: Various NML related questions

Posted: 12 Dec 2020 18:13
by paritcl3s
Am currently trying to make a town name .grf.
I'm fresh to the task and have never made an attempt at a graphics pack.
So far I've tried deriving an .nfo from the elder scrolls name .grf.
nmlc --nfo=<file>

It returned a copy

Code: Select all

// 2 * 98	 08 07 "JS" 0F 01 "The Elder Scrolls Town Names" 00
	 8A "Coded Together by Jan Skoch" 0D 93 "GNU "
	 "GPL v2" 0D 91 "Version # 2013.04.26" 00
    3 * 1630	 0F 00 01 90 00 08 01 "Alftand" 00 01 "Arkngthamz" 00 01 "Avanchnzel" 00
	 01 "Blackreach" 00 01 "Bthalft" 00 01 "Bthardamz" 00
	 01 "Fahlbtharz" 00 01 "Irkngthand" 00 01 "Kagrenzel" 00
	 01 "Kagrumez" 00 01 "Mzinchaleft" 00 01 "Mzulft" 00 01
	 "Nchardak" 00 01 "Nchuand-Zel" 00 01 "Raldbthar" 00
It goes on like that basically.

The --nml output states lang/english.lng doesn't exit so not sure where to turn. Is there any template to follow for folder hierarchy for proper compilation?

Re: Various NML related questions

Posted: 13 Dec 2020 15:05
by 2TallTyler
Here’s a link to my town names repository. Each state is a separate NewGRF and NML project and there’s a makefile to compile them all using nmlc. Using NML is much easier than NFO.

https://github.com/2TallTyler/town_names

Re: Various NML related questions

Posted: 05 Jan 2021 08:30
by Greyfur
IHi guys,

is this because I am using old nmlc?

Code: Select all

H:\CSBusSet\!!!!!!!!!!!!!!!!!!!!>nmlc CSBusSetN4.5.5.nml
[Knmlc ERROR: nmlc: An internal error has occurred:
nmlc-version: v6379:afad0c76c40b from 2017-06-19
Error:    (IndexError) "pop from empty list".
Command:  ['nmlc', 'CSBusSetN4.5.5.nml']
Location: File "nml\actions\action4.py", line 170, in get_string_action4s 

Re: Various NML related questions

Posted: 05 Jan 2021 23:36
by Eddi
in any case, NML shouldn't be crashing with an "internal error" like that, but return a proper error message about what is actually wrong with your code, so you should probably update, and report it with the code that triggers it if the problem persists

the typical cause for this kind of error is that some kind of ID-pool ran out, which may be fixable by rearranging some code

Re: Various NML related questions

Posted: 06 Jan 2021 00:47
by Greyfur
I am getting the same with the newest stable windows one I could find.

Code: Select all

C:\NML>nmlc CSBusSetN4.5.5.nml
 nmlc ERROR: nmlc: An internal error has occurred:
nmlc-version: 0.5.0
Error:    (IndexError) "pop from empty list".
Command:  ['nmlc', 'CSBusSetN4.5.5.nml']
Location: File "nml\actions\action4.py", line 170, in get_string_action4s
the only difference is the text is now in red.

Are there any limits on how many vehicles, lines of code, switches, text lines in language file, etc there could be?

Re: Various NML related questions

Posted: 06 Jan 2021 08:25
by Eddi
there are many such limits, and nmlc usually outputs a statistics of how close you are to any of these limits. (if it doesn't crash, that is)

if it crashes with action4, you're probably running out of StringIDs (any string that's not a vehicle name, and there's like 1024 IDs available)

Re: Various NML related questions

Posted: 06 Jan 2021 12:01
by Greyfur
Eddi wrote: 06 Jan 2021 08:25 there are many such limits, and nmlc usually outputs a statistics of how close you are to any of these limits. (if it doesn't crash, that is)

if it crashes with action4, you're probably running out of StringIDs (any string that's not a vehicle name, and there's like 1024 IDs available)
Thank you! :bow:

I didn't know there was such a limit. I will most likely have to split my grf in two or three parts I guess. I plan to do a reduction of duplicates, but with how much I will still have to add, it would definitely not fit into a 1024 limit.

Re: Various NML related questions

Posted: 04 Feb 2021 02:59
by supermop
I'm having trouble figuring out how to set the size and position of bounding boxes in NML, particularly for catenary sprites. While the spritelayout page of the specs mentions x, y and z extents and offsets, road and railtypes do not use sprite layouts, and the other spec pages make no mention of how to set the size or position of the bounding box, and only mention the 2d height and width of pixels in the png.

In the below image, trolleywire from my GRF has a bounding box the size of the entire tile, while rails from Termite have a bounding box the size of the wire itself - just a few px wide and tall.
BOUNDING BOXES.PNG
BOUNDING BOXES.PNG (48.9 KiB) Viewed 8979 times
The template I use for my wires is as such:

Code: Select all

template tmpl_wire_normal() {           //regular catenary sprites 
    [ 10, 10, 64, 31, -31, 0]            // '\''
    [ 80, 10, 64, 31, -31, 0]            // '/'
    
For Unspooled this works ok, but for another GRF I am working on now, I really need to set the box to a smaller size, approx 6px wide and 5px tall. I have no idea how to do this...

Re: Various NML related questions

Posted: 05 Feb 2021 07:17
by isaacrdc
Afaik you can't make it smaller except in buildings, objects and vehicles. Bounding boxes are only used as a guide to avoid graphical glitches and for deciding the position of the sprite(s). It is independent of template and cannot be moved.

Railway and Tramway bounding boxes acts different, tramways have two wires a front and back while railways only have one.

I think there is no issue regarding how small you're drawing the wire, unless you're making very large sprite that overlaps bounding boxes that make graphical glitches.

Re: Various NML related questions

Posted: 28 May 2021 10:05
by Michpi
I wish to prevent players from building several industries of the same type in one city.
For this purpose I use callback location_check.
Is there any way to show the default error "only one allowed per town"?

If I return CB_RESULT_LOCATION_DISALLOW I got an error "site unsuitable"

Re: Various NML related questions

Posted: 28 May 2021 10:30
by Eddi
as far as i can see on first glance, this is currently not possible, but it should be fairly straightforward to add to the specs and implement

Re: Various NML related questions

Posted: 28 May 2021 10:42
by Wahazar
Michpi wrote: 28 May 2021 10:05 I wish to prevent players from building several industries of the same type in one city.
For this purpose I use callback location_check.
Is there any way to show the default error "only one allowed per town"?
Just use string(STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN) as check location result, or add own string to the lang file.

Re: Various NML related questions

Posted: 28 May 2021 14:12
by Michpi
McZapkie wrote: 28 May 2021 10:42 string(STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN)
It looks like it's also a string in the lang file

Code: Select all

nmlc ERROR: "src/lifesupport.pnml", line 231: Unknown string "STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN"
Of course I can and will use the lang file, but I would prefer the default error message (if it's possible) because it is already translated into many languages.

Re: Various NML related questions

Posted: 31 May 2021 00:30
by paritcl3s
Can Nmlc extract a .grf file to it's original folder hierarchy? As in reverse compiling?

Re: Various NML related questions

Posted: 31 May 2021 07:49
by Wahazar
paritcl3s wrote: 31 May 2021 00:30 Can Nmlc extract a .grf file to it's original folder hierarchy? As in reverse compiling?
Don't think so, nmlc is a higher level programming.
You can decompile newgrf to nfo+gfx using grfcodec -d

Re: Various NML related questions

Posted: 31 May 2021 09:38
by paritcl3s
Okay, In that case what I'm attempting to get at is that I'd like to have a base folder with everything ready for compiling through Nmlc. As in a template say for train sets or town set. The only thing that would need dynamic variation is the sprites for each tile.

Someone (2TallTyler) above was nice enough to provide Town-Name Set Template, which works great.

I have minimal coding know-how.
McZapkie wrote: 31 May 2021 07:49 You can decompile newgrf to nfo+gfx using grfcodec -d
What is the benefit of getting nfo/gfx data in relation to Nmlc?

Re: Various NML related questions

Posted: 31 May 2021 10:10
by Wahazar
paritcl3s wrote: 31 May 2021 09:38 What is the benefit of getting nfo/gfx data in relation to Nmlc?
The only benefit is to retrieve images (if original source is not available).
But if you need some nml examples, most newgrfs are public domain and their source code is published.
See for example https://dev.openttdcoop.org/projects - rather obsolete city but there is lot of simple projects,
some might be helpful to understand nml for beginners.

Re: Various NML related questions

Posted: 02 Jun 2021 16:03
by LaDoncella
as i mentioned in this thread viewtopic.php?f=68&t=88956

Have vehicle animations been changed at some point, or they are broken in 0.5.3?

Re: Various NML related questions

Posted: 02 Jun 2021 20:32
by Andrew350
LaDoncella wrote: 02 Jun 2021 16:03 as i mentioned in this thread viewtopic.php?f=68&t=88956

Have vehicle animations been changed at some point, or they are broken in 0.5.3?
I'm quite sure animations are not broken in NML, and I don't think anything has changed recently in that department. It is likely the animation code in eGRVTS2 is wrong somehow and NML simply became more strict since whatever version it used before, I guess that might depend how ancient the NML version was which was used previously. I can't seem to find the NML source of eGRVTS2 anywhere with a quick search so I can't speculate what the actual issue may be. But unless a bug was introduced to NML somewhere and no one noticed yet, it's almost certainly an issue with the code in the set, not NML itself.