Page 2 of 3

Re: trying to obtain coding skills - anyone i can ask?

Posted: 02 Oct 2007 07:59
by DaleStan
Vehicle IDs are the still the 5th byte of an action 0 or 4, and the 4th byte of an action 3, just like Pikka said.
For example

Code: Select all

  213 * 7	 03 01 01 3E 00 08 00
             1st2nd3rd^^
  214 * 19	 04 01 7F 01 41 "lstom Citadis" 00
              1st2nd3rd4th^^
  215 * 20	 00 01 07 01 3A 0E FF 00 00 00 02 16 03 1E 04 64 06 07 07 14
              1st2nd3rd4th^^
If that byte happens to be a quoted character, NFORenum's @@BEAUTIFY command will fix the problem.

Re: trying to obtain coding skills - anyone i can ask?

Posted: 04 Oct 2007 12:38
by DJ Nekkid
are there any way one can make a (passanger) wagon (un)load more then 5 per tick ? i think i did read it somewhere in the documentation, but i cannot find it again...

Re: trying to obtain coding skills - anyone i can ask?

Posted: 04 Oct 2007 13:04
by FooBar
You can set that with an Action0. In case of road vehicles it's property 07. In case of an other vehicle type it's probably also property 07, but I should check that to be sure.

Re: trying to obtain coding skills - anyone i can ask?

Posted: 04 Oct 2007 13:35
by DJ Nekkid
ahh, i did find it:
Load amount

This is the amount of cargo transferred per unit of time if using gradualloading. The default is 5 for trains and road vehicles, 10 for ships and 20 for aircraft.
would til also apply to the "improved loading algorythm" + "load vehicles gradually" in OTTD?

this is my codeline
00 00 0F 01 58 00 \w2007-01-01 03 \b30 04 \b255 05 00 06 07 17 08 01 09 \w120 0B \w2253 12 FD 13 01 14 \b165 15 00 16 \b31 19 28 27 04

Re: trying to obtain coding skills - anyone i can ask?

Posted: 04 Oct 2007 15:23
by PikkaBird
You seem to have lost a byte somewhere there. Doubtless nforenum will pick that up for you.

If you're using a recent version of grfcodec, you can have linebreaks in the action, if that makes it easier to read. You can even put comments in to remind you what each value is.

Code: Select all

00 00 0F 01 58 
00 \w2007-01-01 // introduction date
03 \b30              // vehicle life
04 \b255            // etc
05 00 
06           // <---- should be another byte here?
07 17
08 01 
09 \w120 
0B \w2253 
12 FD 
13 01 
14 \b165 
15 00 
16 \b31 
19 28 
27 04

Re: trying to obtain coding skills - anyone i can ask?

Posted: 04 Oct 2007 15:43
by DJ Nekkid
will that be dooable with nforenum as well? i use nforenum tho... and the linebreaks would just be kickass :)

btw: i added 07 behind that 06, and that seemed to fix the problem...

Re: trying to obtain coding skills - anyone i can ask?

Posted: 04 Oct 2007 23:13
by DaleStan
NFORenum will insert linebreaks like that for you, if you ask it and the sprite has no fatal errors. It'll destroy the backslash-formats in the process, though.
GRFCodec will not insert such linebreaks, no matter how much you beg and plead.

Linebreaks in pseudos have been supported since at least GRFCodec 0.9.5. Support for inline-comments was added in 0.9.6 or 0.9.7, I think.

Re: trying to obtain coding skills - anyone i can ask?

Posted: 04 Oct 2007 23:41
by PikkaBird
But nforenum will not eat your linebreaks or comments when you run it, which is how I interpreted your question. :)

Re: trying to obtain coding skills - anyone i can ask?

Posted: 06 Oct 2007 12:04
by DJ Nekkid
PikkaBird wrote:But nforenum will not eat your linebreaks or comments when you run it, which is how I interpreted your question. :)

that is what i asked :)

Re: trying to obtain coding skills - anyone i can ask?

Posted: 29 Dec 2007 11:48
by DJ Nekkid
why dont this code work?

The change (action 0) works properly, but the graphics dont change
posted with the "fatal errors" renum gave me...

Code: Select all

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
    0 * 4	 0A 00 00 00

// Initial sprite with line count. Leave it empty because NFORenum will fix it for you.
//-1 * 0 00 00 00 00

// Action 8: define GRF version (07), GRFID (46 42 79 01), Name and Description.
    1 * 62	 08 07 46 42 84 01 "Ugly Doubledecker" 00 "Drawn by DJ Nekkid\nCoded by DJ Nekkid" 00

// Action 1: for trains define 1 set of 4 sprites for the passenger carriage
    2 * 4	 01 00 01 04
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
    3 sprites/doubledecker.pcx 2 100 01 24 8 -4 -12
    4 sprites/doubledecker.pcx 42 100 01 17 22 -11 -9
    5 sprites/doubledecker.pcx 82 100 01 11 32 -16 -6
    6 sprites/doubledecker.pcx 122 100 01 17 22 -11 -9

// Action 2: For trains define cargo ID A0, 1 moving state, 1 loading state, use first set from Action1, use first set from Action1
//!!Fatal Error (42): Length does not match nument1 and nument2 of 72 and 01. (Expected 235 bytes)
    7 * 9	 02 00 A0 72 01 00 00 00 00

// Action 3: For trains, 1 train, VehID 72, 0 cargo type definitions, default cargo ID A0.
//!!Error (62): Offset 5: ID A0 has not been defined.
    8 * 7	 03 00 01 72 00 A0 00

// Action 4: Change Vehicle name
    9 * 25	 04 00 7F 01 72 "Double Decker Wagon" 00

// Action 0:
//!!Error (63): Expected 3 more properties.
   10 * 30	 00 00 0F 01 72 03 \b30 04 \b255 05 02 06 07 07 08 08 01 0B \w0 12 FD 14 \b80 15 00 16 \b31 17 9f
something is wrong here, and tbh, i cant really see what and why :)

Re: trying to obtain coding skills - anyone i can ask?

Posted: 29 Dec 2007 20:18
by Lakie
The action2 structure appears to be wrong to me.

Code: Select all

7 * 9    02 00 A0 72 01 00 00 00 00
should be more likely, because of the 'loading' sprites
7 * 10    02 00 A0 72 01 01 00 00 00 00
Fixing that should also fix your Action3 renum error message.

The Action0 is incorrect because you've said there will be 15 (0x0F) properties defined and you only defined 112 (0x0C), the following should be more correct.

Code: Select all

10 * 30    00 00 0C 01 72 03 \b30 04 \b255 05 02 06 07 07 08 08 01 0B \w0 12 FD 14 \b80 15 00 16 \b31 17 9f
Hope that helps,
~ Lakie

Re: trying to obtain coding skills - anyone i can ask?

Posted: 30 Dec 2007 01:28
by Zephyris
Have a look at the following code and see if it helps:

Making a GRF

Code: Select all

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel

// Number of sprites in the grf; little endian dword
    0 * 4	 02 00 00 00

// Action 8: Defines DRF details; GRF ID (AA BB CC DD) and name (Simple Vehicle Demos: A GRF)
    1 * 45	 08 06 AA BB CC DD "Simple Vehicle Demos: A GRF" 00

//The rest of the grf goes here
Changing vehicle properties

Code: Select all

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel

// Number of sprites in the grf
    0 * 4	 02 00 00 00

// Action 8: Defines DRF details; GRF ID (AA BB CC DD) and name (Simple Vehicle Demos: Changing Vehicle Properties)
    1 * 56	 08 06 AA BB CC DD "Simple Vehicle Demos: Changing Vehicle Properties" 00

//  Action 0: Change vehicle properties; Train 00 speed to 100mph and make double headed
//  Sprite number
//  |   Number of bytes in this sprite
//  |   |        
//  |   |        Action 00: Change vehicle properties
//  |   |        |  Feature 00: Trains
//  |   |        |  |  02 properties: Two properties altered
//  |   |        |  |  |  01 vehicles: On one vehicle
//  |   |        |  |  |  |  Vehicle 00: Trains, so Kirby Paul Tank (Steam)
//  |   |        |  |  |  |  |  Property 09: Maximum speed
//  |   |        |  |  |  |  |  |  Value A0: 100 mph (A0 (Hexadecimal) = 160 (Decimal) = 100 mph * 1.6)
//  |   |        |  |  |  |  |  |  |  Property 13: Double headed?
//  |   |        |  |  |  |  |  |  |  |  Value 01: Double headed (00 = no, 01 = yes)
//  |   |        |  |  |  |  |  |  |  |  |
    2 * 9        00 00 02 01 00 09 A0 13 01

//Thats it!
Changing vehicle names

Code: Select all

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel

// Number of sprites in the grf
    0 * 4	 02 00 00 00

// Action 8: Defines DRF details; GRF ID (AA BB CC DD) and name (Simple Vehicle Demos: Changing Names)
    1 * 43	 08 06 AA BB CC DD "Simple Vehicle Demos: Changing Names" 00

// Action 3: Changing in-game text; Train 00 name to "Hello World!"
//  Sprite number
//  |   Number of bytes in this sprite
//  |   |        
//  |   |        Action 04: Change in-game text
//  |   |        |  Feature 00: Train names
//  |   |        |  |  Language 7F: All languages
//  |   |        |  |  |  01 strings: 1 name to be altered
//  |   |        |  |  |  |  Vehicle 00: Kirby Paul Tank (Steam)
//  |   |        |  |  |  |  |  Text string "Hello world!": New name is Hello World!
//  |   |        |  |  |  |  |  |              00: Ends text string
//  |   |        |  |  |  |  |  |              |
    2 * 18       04 00 7F 01 00 "Hello World!" 00

//Thats it!
Changing vehicle graphics

Code: Select all

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel

// Number of sprites in the grf
    0 * 4	 0D 00 00 00

// Action 8: Defines DRF details; GRF ID (AA BB CC DD) and name (Simple Vehicle Demos: Changing Vehicle Graphics)
    1 * 58	 08 06 AA BB CC DD "Simple Vehicle Demos: Changing Vehicle Graphics" 00

// Tell train to use new graphics
//
//  Action 0: Change vehicle properties; Make train use new graphics
//  Sprite number
//  |   Number of bytes in this sprite
//  |   |        
//  |   |        Action 00: Change vehicle properties
//  |   |        |  Feature 00: Trains
//  |   |        |  |  01 properties: One property
//  |   |        |  |  |  01 vehicles: On one vehicle
//  |   |        |  |  |  |  Vehicle ID 00: Trains, so Kirby Paul Tank (Steam)
//  |   |        |  |  |  |  |  Property 12: Sprite ID for vehicle
//  |   |        |  |  |  |  |  |  Value FD: New graphics
//  |   |        |  |  |  |  |  |  |
    2 * 7        00 00 01 01 00 12 FD

//  Definition of graphics
//
//                  Vehicle type (00 = rail, 01 = road, etc.)
//                  |  Number of vehicles
//                  |  |  Number of views (4 = symmetric, 8 = non-symmetric)
//                  |  |  |
    3 * 4	 01 00 01 08
    4 c:\*****\vehicledemotrain.pcx 98 8 01 18 8 -3 -10
    5 c:\*****\vehicledemotrain.pcx 114 8 09 16 20 -14 -7
    6 c:\*****\vehicledemotrain.pcx 146 8 01 12 28 -14 -6
    7 c:\*****\vehicledemotrain.pcx 194 8 09 16 20 -6 -7
    8 c:\*****\vehicledemotrain.pcx 226 8 01 18 8 -3 -10
    9 c:\*****\vehicledemotrain.pcx 242 8 09 16 20 -14 -7
   10 c:\*****\vehicledemotrain.pcx 274 8 01 12 28 -14 -6
   11 c:\*****\vehicledemotrain.pcx 322 8 09 16 20 -6 -7

//  Definition of use of graphics
//
//                  Vehicle type (00 = rail, 01 = road, etc.)
//                  |  Cargo/action2 ID
//                  |  |  Number loaded types
//                  |  |  |  Number of loading types
//                  |  |  |  |  Sprite set (action 00 number)
//                  |  |  |  |  |     Sprite set (action 00 number)
//                  |  |  |  |  |     |
   12 * 9 	 02 00 AA 01 01 00 00 00 00
//
//  Associates defined graphics to vehicles
//
//                  Feature 00: Trains
//                  |  01 vehicles: One vehicle
//                  |  |  Vehicle ID 00: Trains, so Kirby Paul Tank (Steam)
//                  |  |  |  00 cargo specific graphics: No cargo specific graphics
//                  |  |  |  |  AA 00 for default graphics: Cargo/action2 ID of default graphics (AA expressed as a word "AA 00")
//                  |  |  |  |  |
   13 * 7 	 03 00 01 00 00 AA 00

//Thats it!
I think this is all correct, made it all ages ago when I was first learning nfo...

Re: trying to obtain coding skills - anyone i can ask?

Posted: 30 Dec 2007 04:39
by DaleStan
Lakie wrote:The action2 structure appears to be wrong to me.

Code: Select all

7 * 9    02 00 A0 72 01 00 00 00 00
should be more likely, because of the 'loading' sprites
7 * 10    02 00 A0 72 01 01 00 00 00 00
Fixing that should also fix your Action3 renum error message.
That's not really an improvement. nument1 and nument2 are still 72 and 01, respectively. 7of9, did you really want 72h (114 decimal) different sprite sets to display the quantity of cargo loaded? (But only while moving. While loading, there's only 1 set available.)
When there's an error location given (by "Offset ###:") or implied (in this case, near the bytes "72" and "01") the changes must be made at or before the mentioned bytes; changes after them won't fix anything.

There seems to be a bug there, though; that line should still mark cargo ID A0 as defined. Must investigate.
EDIT: You need to upgrade NFORenum; 3.4.6 accepts the action 3 without comment.

Re: trying to obtain coding skills - anyone i can ask?

Posted: 30 Dec 2007 04:58
by Lakie
Indeed, it should actually be:

Code: Select all

7 * 9    02 00 A0 01 01 00 00 00 00
My mistake, I haven't actually wrote anything in nfo for quite sometime...

Sorry,
~ Lakie

Re: trying to obtain coding skills - anyone i can ask?

Posted: 30 Dec 2007 14:30
by DJ Nekkid
well, thanx there lakie, i thought i had to add the vehicleID to that action 2 thingy, but not it works... atleast code wise, the sprite is butt ugly, but it works :)

btw dalestan; that 72 is the vehicle ID (normaly cola wagon or something), witch i thought i had to add there, dunno why really :)

Re: trying to obtain coding skills - anyone i can ask?

Posted: 10 Jan 2008 20:12
by DJ Nekkid
a new quick question;

is it possible to make a livery override with a action A'ed engine?
example;

a new TVG (T.I.M) is drawn, and is action A'ed into the game.

New wagons are drawn as well, but i dont want to use that particular wagon for all engines, so action A is out of the question, action 3 is the normal way to go, but it seems like it need an enitire new engine for that (action 0+1+2+3). Or is there anything i've missed?

Re: trying to obtain coding skills - anyone i can ask?

Posted: 10 Jan 2008 20:19
by DaleStan
Just 1/2/3 for the engine, I think. I've never tried, but I think you could leave prop 12 unset for the engine, and attach it to some dummy sprite in the GRF, and follow that 3 with override 3s for its wagons.

Re: trying to obtain coding skills - anyone i can ask?

Posted: 10 Jan 2008 20:34
by DJ Nekkid
not sure if thats what you ment, but i action 0'ed the engine with only prop 12 FD set, followed by full 1 and 2's, and the same for the wagons, and then the action 3 sets, and it worked like a charm :)

thanx mister :) (again)

Re: trying to obtain coding skills - anyone i can ask?

Posted: 05 Feb 2008 07:36
by DJ Nekkid
hi all...
i've come a good way if i can say so myself, but i need some slight help sometimes, and i've come across a problem;

I'm makeing a TVG with it's first and last wagon to have different graphics. Both Mail and PAX. Theese are made and declaired. But the problem are, when i have the engines, plus 5 wagons it work as it should, with less then 5 wagons only the first, and middle ones get the proper grapics, but the last one get the middle grapic.
Also, when it's more then 5 wagons, the first, the 3 next, and the 5th wagon get it's proper grapics. See attachment for what i mean.

Code: Select all

eight real sprite Action 1's plus one for the purchase list
nine action 2's;
AA = Engine forward direction
A0 = Purchase list sprite
AB = Engine reverse direction
B0 = Middle PAX wagon
B1 = First PAX Wagon
B2 = Last PAX Wagon
C0 = Middle Mail Wagon
C1 = First Mail Wagon
C2 = Last Mail Wagon

// VarAction2: MAIL
-1 * 0 02 00 C3 81 40 00 BB 01 C2 00 01 01 C0 00
-1 * 0 02 00 C4 81 40 00 FF 01 C1 00 01 01 C3 00

// VarAction2: Pax
-1 * 0 02 00 B3 81 40 00 BB 01 B2 00 01 01 B0 00
-1 * 0 02 00 B4 81 40 00 FF 01 B1 00 01 01 B3 00

// VarAction2: Panto at the Back
-1 * 0 02 00 AC 81 40 00 FF 01 AA 00 00 00 AB 00

// Action 3:
-1 * 0 03 00 01 46 01 FF A0 00 AC 00
-1 * 0 03 00 81 5B 00 B4 00
-1 * 0 03 00 81 5F 00 C4 00
Why is this? I've tried to change the 01's to other numbers, but i cant really get it... Help plx!

Re: trying to obtain coding skills - anyone i can ask?

Posted: 05 Feb 2008 07:54
by michael blunck
-1 * 0 02 00 B3 81 40 00 BB 01 B2 00 01 01 B0 00
BB isn´t a valid AND-mask in your case. Remember, you´re refering to the first vehicle from behind (counting backwards).

In addition,
-1 * 0 03 00 01 46 01 FF A0 00 AC 00
here you seem to always reference your purchase sprite (AC).

regards
Michael