Bug #2785

problem with spritelayout parameters

Added by yexo about 8 years ago. Updated almost 5 years ago.

Status:NewStart date:2011-06-22
Priority:NormalDue date:
Assignee:-% Done:

50%

Category:-
Target version:-

Description

Given the following code, what should the output be? Should the groundsprite and building sprite both use sprite 10 or should the groundsprite use sprite 10 and the building sprite 20 or even something else?

param[0] = 10;
param[1] = 10;
spritelayout my_layout(a) {
ground { sprite: param[0]; }
building { sprite: a; }
}
param[0] = 20;
param[1] = 20;
item(FEAT_AIRPORTTILES, small_airport_tiles) {
graphics { my_layout(param[1]; }
}

History

#1 Updated by Hirundo about 8 years ago

I'd say 20.
For non-stations, I fear this gets really hairy, though....

Edit: To clarify, as I didn't read it quite properly
ground should (IMO) be 10, building 20.

#2 Updated by planetmaker about 8 years ago

I'd probably expect to see ground { sprite: 10; } and building {sprite: 20; }

I'm not sure... should NML get a command line option to warn or notify about this possible bear trap? Maybe as part of the debug command line option?

#3 Updated by Hirundo about 8 years ago

  • Target version set to 0.2.0

A note in the documentation should suffice

#4 Updated by yexo about 8 years ago

A note in the documentation is enough only if NML currently behaves in this way. It needs checking for various items than can be moved around by nml so see if it works correctly in all cases.

#5 Updated by yexo almost 8 years ago

  • % Done changed from 0 to 50

Just checked the behavior and NML works like expected (ground: 10, building: 20). Not sure what the best place in the documentation is to mention this.

#6 Updated by yexo almost 8 years ago

  • Target version deleted (0.2.0)

#7 Updated by frosch almost 5 years ago

Another weird example by rubidium:

    param[0] = 1;
    param[1] = 2;
    spritelayout my_layout(a) {
        ground { sprite: param[a]; }
        building { sprite: a; }
    }
    param[0] = 3;
    param[1] = 4;
    item(FEAT_AIRPORTTILES, small_airport_tiles) {
        graphics { my_layout(1); }
    }

Tricky to document and trick to check.

Also available in: Atom PDF