[OTTD]JVTrains in NML[devel]

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
zumoshieki
Engineer
Engineer
Posts: 4
Joined: 16 Sep 2018 20:32

[OTTD]JVTrains in NML[devel]

Post by zumoshieki »

Hi!

I write this topic because I need help with a newGRF I want to create with NML.
I'm following this guide: https://www.tt-wiki.net/wiki/NMLTutoria ... gle_engine
I'm using a custom png I have prepared. I already set the DOS palette in this PNG.
And It seems that the nml file compiles but only a question mark is show when I add my GRF to the game...

I attached my PNG and the NML file.
Hope someone can throw some light and tell me what I'm doing wrong.
Thank you all!

P.S: The compile output

Code: Select all

$ nmlc -l NewGRF/lang/ -c -u --grf 447.grf 447.nml 
 nmlc info: 4 sprites, 0 cached, 0 orphaned, 0 duplicates, 4 newly encoded (native)
 nmlc info: Train items: 1/65420
 nmlc info: Concurrent spritesets: 1/255 ("447.nml", line 81)
 nmlc info: Concurrent spritegroups: 1/256 ("447.nml", line 81)
 nmlc info: Railtype translation table: 4/256
 nmlc warning: "447.nml", line 19: "NewGRF/447r_nopmr_8bbp.png" at [x: 72, y: 4]: 1 of 852 pixels (0%) are animated
Attachments
447.nml
(3.53 KiB) Downloaded 90 times
447r_nopmr_8bbp.png
447r_nopmr_8bbp.png (1.93 KiB) Viewed 2033 times
english.lng
(403 Bytes) Downloaded 67 times
Arnoud
Engineer
Engineer
Posts: 78
Joined: 29 Sep 2008 05:02
Location: Amsterdam

Re: [OTTD]JVTrains in NML[devel]

Post by Arnoud »

At the top of your nml file you have defined several spritesets, however in the graphics block only 1 is referenced (only the front_lighted);

graphics {
default: cotxe447r_nopmr_front_lighted; // use a goods container for a (loaded) flatbed truck
}
This means that you've let the script know that all of the other spritesets exist, but you havent told the script to use them.
This may not be the only problem though.

I would highly recommend reading the part in the tutorial about templating allso, allthough this may seem to to be more work/more learning, it actually makes coding easier I think.

Edit: example of how to tell the script to use sprites for the buy menu:

graphics {
default: cotxe447r_nopmr_front_lighted; // I would recommend changing _front_lighted to _default, unless you want to create a lighted/unlighted state
purchase: cotxe447r_nopmr_purchase;
}
The other spritesets are only used if you want to add more parts to the train or show the train in different states and are therefore referred indirectly through callbacks, see the next pages of the documentation.
I havent tested wether the x, y coordinates you have specified are correct, the nmlc warning implies that they are not, the result of that may range from major gliches to no visible glitches at all, I think this warning is unrelated to your question mark problem.
Coder for the 2cc trams (passenger) and the 2cc cargo trams
User avatar
zumoshieki
Engineer
Engineer
Posts: 4
Joined: 16 Sep 2018 20:32

Re: [OTTD]JVTrains in NML[devel]

Post by zumoshieki »

Thank you for your help!

I still need to try things to improve my code and also find what I'm doing wrong ?( , but I'm sure that the problem comes from the definition of the sprites. :idea:
In fact I'm doing this having no much idea hehe. But I'm learning a lot, so it worth for me.

Anyway, I attach more screenshots about what I'm saying of that "question mark" that appears.

I will keep trying and reading more and more hehehe :))
Attachments
Captura_2019-12-25_17-06-06.png
Captura_2019-12-25_17-06-06.png (4.71 KiB) Viewed 1987 times
Captura_2019-12-25_17-05-23.png
Captura_2019-12-25_17-05-23.png (1.7 KiB) Viewed 1987 times
Captura_2019-12-25_17-04-54.png
Captura_2019-12-25_17-04-54.png (69.6 KiB) Viewed 1987 times
User avatar
zumoshieki
Engineer
Engineer
Posts: 4
Joined: 16 Sep 2018 20:32

Re: [OTTD]JVTrains in NML[devel]

Post by zumoshieki »

I have found that my sprites are being loaded, beside some errors, inside the game but aren't being used when I buy my new passenger coach.
You can check it on the screenshots I attached to this post.
Also I'm adding a updated version of my NML file but here in a code block because I can't attach it now

Code: Select all


grf {
	grfid: "SF\EF\01";
	name: string(STR_GRF_NAME);
	desc: string(STR_GRF_DESCRIPTION);
	version: 0;
	min_compatible_version: 1;
	}

// Definir 447 R NO PMR	
	spriteset (cotxe447r_nopmrs, "NewGRF/447r_nopmr_8bbp.png") {
	[1, 1, 9, 52, -26, -4]
	[11, 2, 56, 40, -28, -20]
	[70, 2, 69, 12, -34, -6]
	[139, 1, 52, 38, -26, -19]
	[1, 1, 9, 52, -26, -4]
	[11, 2, 56, 40, -28, -20]
	[70, 2, 69, 12, -34, -6]
	[139, 1, 52, 38, -26, -19]
	}
		
	
/* Define the spritesets, these allow referring to these sprites later on */
/*spriteset (cotxe447r_nopmr, "NewGRF/447r_nopmr_8bbp.png") { [2, 2, 10, 54, 0, 0]
	[13, 6, 58, 45, 0, 0]
	[72, 4, 71, 12, 0, 0]
	[142, 4, 54, 41, 0, 0]
	[2, 2, 10, 54, 0, 0]
	[13, 6, 58, 45, 0, 0]
	[72, 4, 71, 12, 0, 0]
	[142, 4, 54, 41, 0, 0]}*/
spriteset (cotxe447r_nopmr_purchase,      "NewGRF/3_8bbp.png") 
{ 
[70, 2, 69, 12, -34, -6]
}

	
	item (FEAT_TRAINS, cotxe447r_no_pmr) {
	property {
		name:                         string(STR_NAME_COTXE447R_NOPMR);
        // not available in toyland:
        climates_available:           ALL_CLIMATES; 
		introduction_date:  date(1989,1,1);
		model_life: VEHICLE_NEVER_EXPIRES;
        vehicle_life:                 30;
        reliability_decay:            20;
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);
        non_refittable_cargo_classes: bitmask();
        // refitting is done via cargo classes only, no cargo types need explicit enabling/disabling
        // It's an intercity train, loading is relatively slow:
        loading_speed:                6; 
        cost_factor:                  45;
        running_cost_factor:          0; // Changed by callback
        sprite_id:                    cotxe447r_no_pmr;
        speed:                        141 km/h; // actually 140, but there are rounding errors
        
        refit_cost:                   0; //refit costs don't apply to subcargo display 
        // callback flags are not set manually
        track_type:                   ELRL; // from rail type table
        power:                        0; // Changed by CB
        running_cost_base:            0;
        dual_headed:                  0;
        cargo_capacity:               80; // per part, changed by callback
        weight:                       144 ton; // Total, changed by callback
        ai_engine_rank:               0; // not intended to be used by the ai
        extra_power_per_wagon:        0 kW;
        // 4/12 of weight on driving wheels, with a default friction coefficient of 0.3:
        tractive_effort_coefficient:  0.3 / 3; // changed by callback
        air_drag_coefficient:         0.06;
        // Overridden by callback to disable for non-powered wagons:
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);
        extra_weight_per_wagon:       0 ton;
        bitmask_vehicle_info:         0;
	}
	
		 /* Define graphics */
    graphics {
        default: cotxe447r_nopmrs; 
        purchase: cotxe447r_nopmr_purchase;
    }

	}

	railtypetable {
		RAIL, ELRL, MONO, MGLV
	}
	
	

I hope someone can help.
Thank you in advance!
Attachments
Captura_2019-12-25_19-34-55.png
Captura_2019-12-25_19-34-55.png (7.85 KiB) Viewed 1961 times
Captura_2019-12-25_19-33-50.png
Captura_2019-12-25_19-33-50.png (7.01 KiB) Viewed 1961 times
Captura_2019-12-25_19-33-03.png
Captura_2019-12-25_19-33-03.png (7.38 KiB) Viewed 1961 times
Arnoud
Engineer
Engineer
Posts: 78
Joined: 29 Sep 2008 05:02
Location: Amsterdam

Re: [OTTD]JVTrains in NML[devel]

Post by Arnoud »

You have told the script to load 3 spritesets; the engine, the carriage and the purchase.

You are only using 2 of them (the engine and purchase), this most likely causes the question mark.

If you want to create a train with a fixed number of carriages like an EMU or DMU you can add code to the existing train to tell it to use the carriage sprites, however what I think you want to do is allow the player to buy the carriages separately from the engine.

In that case you need to code the carriage as a separate train from the engine; give it it's own item block and graphics block.
Coder for the 2cc trams (passenger) and the 2cc cargo trams
User avatar
zumoshieki
Engineer
Engineer
Posts: 4
Joined: 16 Sep 2018 20:32

Re: [OTTD]JVTrains in NML[devel]

Post by zumoshieki »

Arnoud, you're right! I only want to create a passenger wagon.
I still trying things and now I successfully created a "tram" with my sprites hehehe.

Due the fact that are originally created for be a train are too big for be a tram but at least I can see what I have to improve (the perspective for example).
In a future I have plans of creating several trams so every I learn will be worth.

Today I will be away so I won't post updates.

Merry xmas by the way. :D
Attachments
Captura_2019-12-26_08-11-49.png
Captura_2019-12-26_08-11-49.png (4.72 KiB) Viewed 1898 times
Captura_2019-12-26_08-10-24.png
Captura_2019-12-26_08-10-24.png (18.59 KiB) Viewed 1898 times
Captura_2019-12-26_08-09-51.png
Captura_2019-12-26_08-09-51.png (43.11 KiB) Viewed 346 times
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: No registered users and 56 guests