DJ Nekkids & Bennythen00b's NFO lessons

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

Moderator: Graphics Moderators

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

Re: DJ Nekkids & Bennythen00b's NFO lessons

Post by DJ Nekkid »

As I have my own sticky topic i guess this is the appropiate place to post :D Its been a while since i've had a problem, but parameters and stuff isnt my best field, yet :D

Im currently working on the NuTracks set, and trying to get it to a 0.9.0 state (1.0 will come when I dont need the track enabler engines, and i can sort the list, see flyspray #4393 and #4394)

But to the problem. The set will featureseveral subsets, selectable by parameter0:

Code: Select all

Value | Meaning
    0 | Autoslect if suitable trainsets is loaded
    1 | Default
    2 | With metrotracks
    3 | With 3rd rails


Anyone have any ideas or solutions?

The auto-thingy is ment to autoselct the metrotracks or the 3rd rails (or even more in the future). I've tried a few approaches, but nothing seems to work yet.

Here is the code i've tried with:

Code: Select all

// Set parameter20 to something if parameter0 is 0 :D (i.e. the autoselect)
-1 * 6  09 PARAM0  01 \7! 00 F0           // Skip to F0 if parameter0 isnt 0. I.e. execute if it is
    // METRO TRACKS
    // Check 2cc trainset
    -1 * 6  07 88 04 0A                   // Jump to, 4 byes range, grfID is not nor will be active - i.e. execute if 2cc set is loaded
            GRFID_2CCSET                  // GRF-ID
            01                            // skip 1 sprite
    -1 * 0  0D PARAM20   80 FF FF \d2     // Sets Parameter 0 to 2 (select metro trackset)
    -1 * 6  09 PARAM20   01 \7= 02 F0     // Skip to F0 if one of the above sets' set parameter0 to 02

    // 3rd RAIL TRACKS
    // Check UKRS2
    -1 * 6  07 88 04 0A                   // Jump to, 4 byes range, grfID is not nor will be active - i.e. execute if UKRS2 set is loaded
            GRFID_UKRS2                   // GRF-ID
            01                            // skip 1 sprite
    -1 * 0  0D PARAM20   80 FF FF \d3     // Sets Parameter 0 to 3 (select 3rd rail trackset)
    // Check BROS
    -1 * 6  07 88 04 0A                   // Jump to, 4 byes range, grfID is not nor will be active - i.e. execute if BROS set is loaded
            GRFID_BROS                    // GRF-ID
            01                            // skip 1 sprite
    -1 * 0  0D PARAM20   80 FF FF \d3     // Sets Parameter 0 to 3 (select 3rd rail trackset)
    -1 * 6  09 PARAM20   01 \7= 03 F0     // Skip to F0 if one of the above sets' sets parameter0 to 03 (might not be neccesary, but in case there is more subsets in the future)    

    -1 * 0  0D PARAM20   80 FF FF \d1     // Sets Parameter 0 to 1 (select default trackset)

-1 * 2	 10 F0                            // Target of skip
What happens is, the metro trackset is loaded no matter what. No trainsets get metro trackset, bros and ukrs2 gets metro tracks.

When PARAM20 is set to this or that it selects different sets of Action0s (and when I get so far, different action1-2-3's)

Code: Select all

-1 * 6  09 PARAM20  01 \7! 01 11
<default trackset Action0s>
-1 * 2  10 11 // Target of skip

-1 * 6  09 PARAM20  01 \7! 02 11
<metro trackset Action0s>
-1 * 2  10 11 // Target of skip

-1 * 6  09 PARAM20  01 \7! 03 11
<3rd rail trackset Action0s>
-1 * 2  10 11 // Target of skip
Member of the
ImageImage
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 991
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: DJ Nekkids & Bennythen00b's NFO lessons

Post by frosch »

You are doing weird stuff with PARAM20. No idea what you intend with that, but I think your problem relates from:
Action 7/9 Spec wrote:If ["variable"] is a GRF parameter that wasn't specified in the newgrf(w).cfg file (...), the action 7 or 9 is ignored and no sprites are skipped (...)
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5631
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: DJ Nekkids & Bennythen00b's NFO lessons

Post by PikkaBird »

frosch, he's (attempting to) set the value of parameter 20 in the first part of the code.

I believe part of the problem may be your very first line there...

Code: Select all

-1 * 6  09 PARAM0  01 \7! 00 F0           // Skip to F0 if parameter0 isnt 0. I.e. execute if it is
A parameter being undefined is not the same thing as = 0. You might want something like this in there;

Code: Select all

   -1 * 9	 0D 00 80 FF 00 00 00 00 00 // set para 0 to 0 if it is not defined
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: DJ Nekkids & Bennythen00b's NFO lessons

Post by DJ Nekkid »

pikka:
that was set by an action14 :)

However, after some chatting on IRC it solved itself :)
Member of the
ImageImage
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 0 guests