Feature #1174

Action 14 support

Added by Hirundo over 9 years ago. Updated over 9 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:yexo% Done:

100%

Category:-
Target version:0.1.0

Description

Although OpenTTD source code will be the most reliable source available, some information about this new feature can be found here:
http://devs.openttd.org/~frosch/texts/StaticGRFInfo.txt

Extension to the grf block seems a logical start.


Related issues

Blocked by NewGRF Meta Language - Bug #1350: double GRF name and description Closed 2010-08-29

History

#1 Updated by yexo over 9 years ago

name/description are already a string code, so the action14 for them can already be written from the current information

#2 Updated by planetmaker over 9 years ago

I concur with Hirundo. As a proposal:

grf {
    grfid : "SER0";
    name : string(STR_GRF_NAME);
    desc : string(STR_GRF_DESCRIPTION);
    version : 0815-beta1
    palette : windows;
    parameters {
//        [min,max,description]
        [0,7,string(STR_PARAM_COMPATIBILITY)]
        [0,5000000,string(STR_PARAM_DEPOT_INTRODUCTION)]
        [0,1,string(STR_PARAM_USE_FENCES)]
//        or maybe [number,min,max,description]
    }
}

#3 Updated by yexo over 9 years ago

Alternative proposal:

grf {
    grfid : "SER0";
    name : string(STR_GRF_NAME);
    desc : string(STR_GRF_DESCRIPTION);
    version : 3; // must be numeric
    // palette is automatically detected by nml
    settings : [
        param {
            setting_num {
                name: string(STR_SETTING0_NAME);
                first_bit: 0;
                num_bits: 3;
                max_value: 5;
                names : {
                    0: string(STR_PARAM0_VAL0);
                    1: string(STR_PARAM0_VAL1);
                    2: string(STR_PARAM0_VAL2);
                };
            }
            setting_bool {
                name: string(STR_SETTING1_NAME);
                desc: string(STR_SETTING1_DESC);
                bit: 3;
            }
            setting_bool {
                name: string(STR_SETTING2_NAME);
                bit: 7;
            }
            setting_num {
                name: string(STR_SETTING0_NAME);
                first_bit: 16;
                num_bits: 8;
                max_value: 200;
            }
        }
        param {
            // data for parameter 1
        }
    ];
}

#4 Updated by Hirundo over 9 years ago

  • Start date deleted (2010-07-31)

Only bool settings should be packed into a single parameter, IMO. Packing multiple numbers in a single uint is nigh impossible for 1.0.x / TTDP users.
It would be nice to be able refer to parameters in an easy way, possibly using referencing by name.
This requires implementing named parameters first, though.

#5 Updated by Ammler over 9 years ago

what about:

grf {
    grfid : "SER0";
    name : string(STR_GRF_NAME);
    desc : string(STR_GRF_DESCRIPTION);
    version : 3; // must be numeric
    // palette is automatically detected by nml
    settings : [
        param {
            name_xy {
                type: int;
                name: string(STR_SETTING0_NAME);
                first_bit: 0;
                num_bits: 3;
                max_value: 5;
                names : {
                    0: string(STR_PARAM0_VAL0);
                    1: string(STR_PARAM0_VAL1);
                    2: string(STR_PARAM0_VAL2);
                };
            }
            old_depots {
                type: bool;
                name: string(STR_SETTING1_NAME);
                desc: string(STR_SETTING1_DESC);
                bit: 3;
            }
            whatever {
                type. bool;
                name: string(STR_SETTING2_NAME);
                bit: 7;
            }
            yet_another_number {
                type: num;
                name: string(STR_SETTING0_NAME);
                first_bit: 16;
                num_bits: 8;
                max_value: 200;
            }
        }
        param {
            // data for parameter 1
            setting1 {
              // data for setting
            }
        }
    ];
}

#6 Updated by Rubidium over 9 years ago

Maybe those parameter names should be "available" later when you're doing calculations with the parameter values or is that already implemented / stupid?

#7 Updated by Hirundo over 9 years ago

That is not yet implemented, but buried somewhere in the todo list. I'm planning some changes to the code that reduces expressions / resolves identifiers first, though.

New suggestion:

grf {
    grfid : "SER0";
    name : string(STR_GRF_NAME);
    desc : string(STR_GRF_DESCRIPTION);
    version : 3; // must be numeric
    // palette is automatically detected by nml
    param [num] { //num is optional, if not set last+1 is used.
        old_depots {
            type: bool; //when using multiple settings in one param, only bool is allowed.
            name: string(STR_SETTING1_NAME);
            desc: string(STR_SETTING1_DESC);
            bit: 3; //booleans only have one bit, so num_bits is not needed anywhere.
        }
        whatever {
            type: bool;
            name: string(STR_SETTING2_NAME);
            bit: 7;
        }
    }
    param 2 {
        // data for parameter 1
        name_xy {
            type: int; //int is default
            name: string(STR_SETTING0_NAME);
            min_value: 0;
            max_value: 5;
            names : {
                0: string(STR_PARAM0_VAL0);
                1: string(STR_PARAM0_VAL1);
                2: string(STR_PARAM0_VAL2);
            };
        }
    }
}

#8 Updated by planetmaker over 9 years ago

I like Hirundo's latest proposal. Re-using the names later in the newgrf makes IMHO perfect sense. At least from a user's POV.

#9 Updated by yexo over 9 years ago

  • Status changed from New to Assigned
  • Assignee set to yexo

Working on an implementation of Hirundo's latest proposal.

#10 Updated by yexo over 9 years ago

  • Status changed from Assigned to New
  • Assignee deleted (yexo)
  • % Done changed from 0 to 70

Most of the work is done. The names for the settings are parsed but then ignored, and it's not yet possible to specify names for setting values.

#11 Updated by yexo over 9 years ago

I should add that I have no plans to fix either of these in the short-term, other issues are more important.

#12 Updated by yexo over 9 years ago

  • Assignee set to yexo
  • Target version set to 0.1.0

#13 Updated by yexo over 9 years ago

  • Status changed from New to Closed
  • % Done changed from 70 to 100

#14 Updated by planetmaker over 9 years ago

  • Status changed from Closed to Reopened

Probably I'm just missing out on it, but to me it seems that setting and use of a default value seems to be missing:

The following code does not result in OpenTTD to reset the parameter to 1975, if "reset parameters" is pressed.
param {
param_depot_year {
type: int;
name: string(STR_PARAM_DEPOTYEAR);
desc: string(STR_PARAM_DEPOTYEAR_DESC);
min_value: 0;
max_value: 5000000;
default_value: 1975;
}
}

#15 Updated by yexo over 9 years ago

It should be def_value, not default_value

#16 Updated by planetmaker over 9 years ago

  • Status changed from Reopened to Closed

Thanks, that works. I even missed that then when browsing NML source :S

Also available in: Atom PDF