DJ Nekkids & Bennythen00b's NFO lessons

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

Moderator: Graphics Moderators

Post Reply
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

DJ Nekkids & Bennythen00b's NFO lessons

Post by DJ Nekkid »

EDIT:

see this post
clicky the linky

--------


hi guys.

I am trying to enable this, so the MU's in the 2cc set only can use the special MU-wagon (VehID 70) , and also the Express wagon (for mail/valuables:) (VehID 5F))

This is my code, but it dont seem to work properly

Code: Select all


3x8 real sprites
-1 * 0  02 00 AA 01 01 00 00 00 00 // <-- direction
-1 * 0  02 00 AB 01 01 01 00 01 00 // --> direction 
-1 * 0  02 00 A1 01 01 02 00 02 00 // Purchase sprite
// VarAction2: Red lights at the back
-1 * 0  02 00 AC 81 40 00 FF 01 AA 00 00 00 AB 00

And then too the problem:
-1 * 0	02 00 AD 81 C6 00 FF 01 FF 80 70 70 AC 00
-1 * 0	02 00 AE 81 0C 00 FF 01 85 00 1D 1D AD 00 // 85 is the textmessage to have if it cant attach

// Action 3
-1 * 0  03 00 01 47 01 FF A1 00 AE 00
There might be more then one problem here, but i cant really see what or why. Help me please! ;)
Last edited by Hyronymus on 13 Apr 2009 08:44, edited 7 times in total.
Reason: Merge two NFO topics
Member of the
ImageImage
User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1799
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Re: VarAction2 Type 81 CF and callback 1D - problem

Post by Lakie »

Your structure looks way out, it didn't look like this when you talked to me on irc about it.
Try the following code, I've changed where the callback sorter and Action2 AD lines to something more reasonable.

Code: Select all

-1 * 0  02 00 AA 01 01 00 00 00 00
-1 * 0  02 00 AB 01 01 01 00 01 00
-1 * 0  02 00 A1 01 01 02 00 02 00
// VarAction2: Red lights at the back
-1 * 0  02 00 AC 81 40 00 FF 01 AA 00 00 00 AB 00

-1 * 0   02 00 AD 81 C6 00 FF 02 # We have 2 vehicle types we want to attach
          FF 80 70 70 # The MU wagon
          FF 80 5F 5F # And the Express Mail Van
          FD 80 # We don't want anything else to be attached (maybe 0x8000+0xD0xx id instead)?

-1 * 0   02 00 AE 81 0C 00 FF 01 # We only hook one callback
          AD 00 1D 1D # action2 chain for returning a result for callback 1D
          AC 00 # Graphic action2 chain starting point

// Action 3
-1 * 0  03 00 01 47 01 FF A1 00 AE 00
[edit] Expanded with comments to explain the changes...

Hope that helps,
~ Lakie
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: VarAction2 Type 81 CF and callback 1D - problem

Post by Eddi »

DJ Nekkid wrote: [from IRC log]
[2008-07-25 19:24] <DJNekkid> -1 * 0 02 00 AD 81 C6 00 FF 01 FF 80 70 70 AC 00
[2008-07-25 19:24] <DJNekkid> -1 * 0 02 00 AE 81 0C 00 FF 01 AC 00 1D 1D AD 00
[2008-07-25 19:25] <DJNekkid> that is my code, and the AE is used in the Action3
i urgently advise you to make more comments
rule of thumb: about every two hex-bytes make a linebreak and a comment
like this action:

Code: Select all

-1 * 0 02 00 AE 81 0C 00 FF 01 AC 00 1D 1D AD 00
write as:

Code: Select all

 -1 * 0 02 00 AE // AE: Varaction 2 for Trains
        81 0C // Check Callback
        00 FF // Varadjust shift/mask
        01 // 1 Case
        AC 00 1D 1D // Callback 1D: goto AC
        AD 00       // Otherwise:   goto AD
at that point it should be very obvious that you mixed up AC and AD
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: VarAction2 Type 81 CF and callback 1D - problem

Post by DaleStan »

There's no such thing as "CF", unless you're referring to that particular byte, which has no special meaning, and appears nowhere in your code.

Don't invent terminology.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1799
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Re: VarAction2 Type 81 CF and callback 1D - problem

Post by Lakie »

I believe that was just a typo DaleStan, as his code itself uses variable C6 ("veh.vehtype"), and technically CF would be the high byte of "veh.reliability".
Anyway I sorted it out with him on IRC, seemed he forgot I updated the last 2 action2's and not just the callback return one.

~ Lakie
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: VarAction2 Type 81 CF and callback 1D - problem

Post by DJ Nekkid »

Hi again guys :)

I've rearranged the vehicle ID's of the engines in the set to other ranges. And this did ofcourse let the cannot-connect lines go wierd :) The wierdest thing however, is that the converted code works with the engines, but not with the MU's, and it is basicly JUST the same, only different ranges :)

The clue with the engines is to dissalow attaching vehicle ID 5F and 70, and allow all others, and that works perfectly with the current code, plus it can ofcourse attach more of the same engine (or others for that matter)

Code: Select all

-1 * 0	02 00 AD 81 C6 00 FF 02 // 2 ranges
                     F9 80 5F 5F // Dissalow 5F to 5F. I.E. the express muwagon with message F9 
                     F9 80 70 70 // Dissalow 70 to 70. I.E. the PAX muwagon with message F9
                     FE 80       // Allow everything else
-1 * 0	02 00 AC 81 0C 00 FF 01 AD 00 1D 1D AA 00 // Callback 1D
To me this reads:
Allow all vehicle IDs from 0 to 255, exept 5F and 70, plus 256 and higher is also allowed

On the MU's the other hand, it can attach the proper (two) wagons as they are not in the dissallowed range, but it cant attach more of the same engine, and i have no clue why. The engines are not in the 0-FF range either, they are on vehicle ID 2000 or higher, and the same is also true for the engines.

Code: Select all

-1 * 0	02 00 AD 81 C6 00 FF 03 // 3 ranges 
                     FB 80 00 5E // from 00 to 5E dissalow with message FB
                     FB 80 60 6F // from 60 to 6E dissalow with message FB
                     FB 80 71 FF // from 71 to FF dissalow with message FB
                     FE 80       // allow everything else  
-1 * 0	02 00 AC 81 0C 00 FF 01 AD 00 1D 1D AA 00 // Callback 1D
To me this reads:
All vehicled ID's from 0 to FF (0 to 255decimal) is dissallowed, exept 5F and 70. And since the engines are vehicleID 2000 or higher, it should be in the default range, just as the normal engines is.

Why isnt this working?

If some1 needs to see the .grf it can be downloaded in my signature. All engines are working, and the EMU2200 (comes out in 2005 or something) wont work as intended with the above code :(
Member of the
ImageImage
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: VarAction2 Type 81 CF and callback 1D - problem

Post by Eddi »

the "type" (81) is your problem, you mask out any bits higher than 8, so any IDs > 255 will be checked incorrectly. change the type to 85 (and adjust the mask accordingly), that should solve your problem
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: VarAction2 Type 81 CF and callback 1D - problem

Post by DJ Nekkid »

thanx a lot eddie for pointing that out, and thanx to lakie for helping me sort it out :)
Member of the
ImageImage
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: VarAction2 Type 81 CF and callback 1D - problem

Post by DJ Nekkid »

Hi guys again.

I'm trying to code some airplanes, and im trying to get the code for more liveries via refitting, and i just dont seem to get it. I'm looking in some other sets that have done this, but im not getting tooo wise.

What i've understood:

I need VarAction2Vehicles Variable F2 to tell how many sets there are.
Callback 19 for the Text in the refit window, as well as an action4 with the name in it.
Callback 15 for the actuall refit

but this is about as far as i've come.
Member of the
ImageImage
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: DJ Nekkids random NFO-problems - New issue: Refitting/Livery

Post by michael blunck »

DJ Nekkid wrote:im trying to get the code for more liveries via refitting [...]
Something like this?

Code: Select all

// load amounts
   -1 * 14      02 00 05 81 F2 00 FF 01
                        06 FF 00 00     // 6 per tick
                        08 FF           // 8 per tick
                        
// refitted capacity
   -1 * 14      02 00 06 81 F2 00 FF 01
                        30 FF 00 00     // 48 pass
                        20 FF           // 32 pass

// text suffixes
  -1 * 18       02 00 07 81 F2 00 FF 02
                        1A FF 00 00     // "2nd class"
                        1B FF 01 01     // "3rd class"
                        FF FF

// refittable: green | brown
  -1 * 14       02 00 08 81 F2 00 FF 01
                        3E 00 00 00     // "petrol" (2nd class)
                        40 00           // "wood1" (3rd class)

  -1 * 14       02 00 09 81 01 00 FF 01
                        08 00 00 07     // 1920 - 1927 brown|green
                        3E 00           // 1928- green

// callbacks 
   -1 * 26      02 00 78 81 0C 00 FF 04
                        05 00 12 12     // tick load
                        06 00 15 15     // refit capacity
                        07 00 19 19     // text suffix
                        09 00 2D 2D     // refit colour
                        00 00
regards
Michael
Image
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: DJ Nekkids random NFO-problems - New issue: Refitting/Livery

Post by DJ Nekkid »

not unlikely... i'll have a look :)
Member of the
ImageImage
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: DJ Nekkids random NFO-problems - New issue: Refitting/Livery

Post by DJ Nekkid »

what i fail to see is where i put the actual sprites?
Member of the
ImageImage
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: DJ Nekkids random NFO-problems - New issue: Refitting/Livery

Post by michael blunck »

DJ Nekkid wrote:what i fail to see is where i put the actual sprites?
Ah yes. That example did only have one sprite set.

You´d simply add another var2 statement referencing F2:

Code: Select all

// choose sprite sets
   -1 * 18      02 00 nn 81 F2 00 FF 02
                        xx 00 00 00     // #1
                        yy 00 01 01     // #2
                        zz 00           // #3
etc., pp.

HTH
regards
Michael
Image
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: DJ Nekkids random NFO-problems - New issue: Refitting/Livery

Post by DJ Nekkid »

oki...

that makes sense i think :)
Member of the
ImageImage
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: DJ Nekkids random NFO-problems - New issue: Refitting/Livery

Post by DJ Nekkid »

another followup question.

the spritesets i'm createing is going to use some "normal" var2's, but it's the same (obviously?) for each spriteset. Can i now "F2" the spritesets, and then apply the var2's to the "F2'ed" sprites? if that was clear enough

kinda example

Code: Select all

Livery1 spriteset1
Livery1 spriteset2
Livery2 spriteset1
Livery2 spriteset2

F2#1 L1S1
    L2S1

F2#2 L1S2
    L2S2

Var2 <do something> F2#1 F2#2 <default>
did that make sense?
Member of the
ImageImage
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: DJ Nekkids random NFO-problems - New issue: Refitting/Livery

Post by DaleStan »

Var2s that access var F2 are no different from var2s that access any other variable. You can mix and match them to your heart's content.

Also, please consider using the try-it-and-see method. If you think it might work, it probably will.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: DJ Nekkids random NFO-problems - New issue: Refitting/Livery

Post by DJ Nekkid »

Hehe, good point... I'm getting somewhat adept at newgrf, atleast vehicles by now i guess. I've made some framework now tho, it just lack to see if it actually do work, but it make sense to me...
(it lacks action 1 and sprites)

Code: Select all

// 1st type
// Grayscale/2cc

// BA-landor

// AB-airways

-1 * 9	 02 03 30 01 01 \w0 \w0
-1 * 9	 02 03 31 01 01 \w1 \w1
-1 * 9	 02 03 32 01 01 \w2 \w2

// Attach Grapics
-1 * 0  02 03 00 81 F2 00 FF 03
                             30 00 00 00 // Grayscale
                             31 00 01 01 // BA-Landor
                             32 00 02 02 // AB-airliens
                             FF FF
                             
// 2nd type
// Grayscale/2cc

// BA-landor

// AB-airways

-1 * 9	 02 03 30 01 01 \w0 \w0
-1 * 9	 02 03 31 01 01 \w1 \w1
-1 * 9	 02 03 32 01 01 \w2 \w2

// Attach Grapics
-1 * 0  02 03 01 81 F2 00 FF 03
                             30 00 00 00 // Grayscale
                             31 00 01 01 // BA-Landor
                             32 00 02 02 // AB-airliens
                             FF FF
 
// 3rd type
// Grayscale/2cc

// BA-landor

// AB-airways

-1 * 9	 02 03 30 01 01 \w0 \w0
-1 * 9	 02 03 31 01 01 \w1 \w1
-1 * 9	 02 03 32 01 01 \w2 \w2

// Attach Grapics
-1 * 0  02 03 03 81 F2 00 FF 03
                             30 00 00 00 // Grayscale
                             31 00 01 01 // BA-Landor
                             32 00 02 02 // AB-airliens
                             FF FF
 
// 2nd type
// Grayscale/2cc

// BA-landor

// AB-airways

-1 * 9	 02 03 30 01 01 \w0 \w0
-1 * 9	 02 03 31 01 01 \w1 \w1
-1 * 9	 02 03 32 01 01 \w2 \w2

// Attach Grapics
-1 * 0  02 03 02 81 F2 00 FF 03
                             30 00 00 00 // Grayscale
                             31 00 01 01 // BA-Landor
                             32 00 02 02 // AB-airliens
                             FF FF
 
// 2nd type
// Grayscale/2cc

// BA-landor

// AB-airways

-1 * 9	 02 03 30 01 01 \w0 \w0
-1 * 9	 02 03 31 01 01 \w1 \w1
-1 * 9	 02 03 32 01 01 \w2 \w2

// Attach Grapics
-1 * 0  02 03 04 81 F2 00 FF 03
                             30 00 00 00 // Grayscale
                             31 00 01 01 // BA-Landor
                             32 00 02 02 // AB-airliens
                             FF FF

// #############################################################################
// ######################## G E N E R A L   V A R 2'S ##########################
// #############################################################################

// ###################
// ## Purchase list ##
// ###################
sprites/boeing/sprites/737/400/gray.pcx	267	2	9	23	44	-22	-12
-1 * 9	 02 03 0F 01 01 00 00 00 00

// ########################
// ## Speeds+dif sprites ##
// ################### ####

// 08 - 09 = just landed, 00 - 0E = on the ground, 0D = taking off, 0F = climb out, 12 - cruising,
// 10 - 14 = approach(?), 15 = decending, 16 = braking on the runway

-1 * 0  02 03 25 81 44 08 FF 01 02 00 38 FF 03 00 // Different sprites when decending
-1 * 0	02 03 20 81 E2 00 FF 05 
                             02 00 08 09 // Just landed
                             04 00 0F 0F // Climbing
                             00 00 12 12 // Cruising
                             25 00 15 15 // Decending
                             02 00 16 16 // Breaking on the runway
                             01 00
 
-1 * 0  02 03 09 81 E2 00 FF 04 
                             20 80 0D 0F // Takeoff + Climb speed (20h) 
                             AF 80 12 12 // 
                             20 80 10 14 // 
                             18 80 15 16 // 
                             AF 80
 
-1 * 18	 02 03 08 81 0C 00 FF 01 09 00 36 36 20 00

// ############
// ## Refits ##
// ############

// Refitted capacity
-1 * 0  02 03 C0 81 F2 00 FF 01
                                  \b168 FF 00 00 // Same capacity everywhere
                                  \b168 FF
// Refit texts
-1 * 0  02 03 C1 81 F2 00 FF 03
                            00 FF 00 00 // Grayscale
                            01 FF 01 01 // BA-Landor
                            02 FF 02 02 // AB-airlines
                            FF FF
                                  
// Attach Grapics
-1 * 0  02 03 C2 81 F2 00 FF 03
                            A0 00 00 00 // Grayscale
                            A1 00 01 01 // BA-Landor
                            A2 00 02 02 // AB-airliens
                            A0 00
                                  
// CB's
-1 * 0  02 03 CB 81 0C 00 FF 02
                             C0 00 15 15 // Capacity
                             C1 00 19 19 // Refit text
                             C2 00


-1 * 0  03 03 01 00 02 FF 0F 00 00 CB 00 A0 00
Member of the
ImageImage
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: DJ Nekkids random NFO-problems - New issue: Refitting/Livery

Post by DJ Nekkid »

New question:

Is it possible to vary the price of a wagon depending on what engine it attaches itself to? CB36 _can_ change the purchase cost, i cannot however see when it could be usefull, as that callback is called after a wagon is purchased.
Member of the
ImageImage
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5631
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: DJ Nekkids random NFO-problems - New issue: Refitting/Livery

Post by PikkaBird »

DJ Nekkid wrote:Is it possible to vary the price of a wagon depending on what engine it attaches itself to?
No. "What engine it attaches itself to" is a fairly nonsensical criterion in any case. If there is not exactly one train in the depot when the wagon is bought, it won't attach itself immediately to any engine.
i cannot however see when it could be usefull, as that callback is called after a wagon is purchased.
CB36 is available in the buy list. Purchase price can be adjusted in the buy list action 2 chain.
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: DJ Nekkids random NFO-problems - New issue: Wagon prices

Post by DJ Nekkid »

PikkaBird wrote: No. "What engine it attaches itself to" is a fairly nonsensical criterion in any case. If there is not exactly one train in the depot when the wagon is bought, it won't attach itself immediately to any engine.
Well, my point were...

IF there is exactly one engine in the depot when the wagon is baught, can the price of the purchased wagon be alterted in any way?

PikkaBird wrote: CB36 is available in the buy list. Purchase price can be adjusted in the buy list action 2 chain.
is there any posibilty that i can use it in a "if engine is X, price is Y" else "if engine is Z, price is A" chain?

i _could_ do a locomotion-variant, where each engine have it's own wagon, or as someone (i cant remember his name) suggested in the 2cc-thread, to have one cheap, one medium and one expensive wagon, but that is not particulary elegant...
Member of the
ImageImage
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 3 guests