Sorry man, maybe it's my little understanding of coding (im not a coder) and language.
(1): The == operator compares the values of two objects, in this code it compares the coord with the Tile_Class (Road) so
its a Road in 0,-1 coord, other tiles classes can be used as well: TILE_CLASS_GROUND, TILE_CLASS_RAIL,TILE_CLASS_ROAD, TILE_CLASS_HOUSE... etc. (sorry for my poor english)
(2): The “&” and “&&” both are the operators, used to evaluate the conditional statements. The & operator is a logical as well as, a bitwise operator. The && operator is purely a Logical operator. The basic difference between the & and && operator is that the & operator evaluate both sides of the expression whereas, the && operator evaluates only the left-hand side of the expression to obtain the final result.
Here I am lost because and in theory i evaluated both sides, the coord and the tile class because it last one can be diferent. (eg: TILE_CLASS_RAIL)
I Returned to your original help and I got this code, it detects the streets well but apparently there is a problem with the animation code that does not work, I checked it several times and I did not find the error.
Code: Select all
grf {
grfid: "NML\44";
name: string(STR_REALHOUSETOWN_NAME);
desc: string(STR_REALHOUSETOWN_DESC);
version: 0;
min_compatible_version: 0;
}
cargotable {
PASS, MAIL, GOOD, FOOD , RCYC
}
/*Road North East*/
spriteset (spriteset_realhousetown_northeast, "realhousetown.png") {
[98, 8, 44, 36, -22, 0, NOCROP]
}
alternative_sprites (spriteset_realhousetown_northeast, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "realhousetown_32.png") {
[0, 0, 256, 256, -109, -154, NOCROP]
}
spritelayout spritelayout_realhousetown_northeast {
ground {
sprite: GROUNDSPRITE_NORMAL;
}
building {
sprite: spriteset_realhousetown_northeast;
recolour_mode: RECOLOUR_REMAP;
palette: PALETTE_USE_DEFAULT;
xextent: 8;
yextent: 16;
zextent: 27;
xoffset: 4;
yoffset: 2;
zoffset: 0;
hide_sprite: 0;
}
}
/*Road South East*/
spriteset (spriteset_realhousetown_southeast, "realhousetown.png") {
[98, 8, 44, 36, -22, 0, NOCROP]
}
alternative_sprites (spriteset_realhousetown_southeast, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "realhousetown_32.png") {
[259, 0, 256, 256, -109, -154, NOCROP]
}
spritelayout spritelayout_realhousetown_southeast {
ground {
sprite: GROUNDSPRITE_NORMAL;
}
building {
sprite: spriteset_realhousetown_southeast;
recolour_mode: RECOLOUR_REMAP;
palette: PALETTE_USE_DEFAULT;
xextent: 8;
yextent: 16;
zextent: 27;
xoffset: 4;
yoffset: 2;
zoffset: 0;
hide_sprite: 0;
}
}
/*Road South West*/
spriteset (spriteset_realhousetown_southwest, "realhousetown.png") {
[98, 8, 44, 36, -22, 0, NOCROP]
}
alternative_sprites (spriteset_realhousetown_southwest, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "realhousetown_32.png") {
[518, 0, 256, 256, -109, -154, NOCROP]
}
spritelayout spritelayout_realhousetown_southwest{
ground {
sprite: GROUNDSPRITE_NORMAL;
}
building {
sprite: spriteset_realhousetown_southwest;
recolour_mode: RECOLOUR_REMAP;
palette: PALETTE_USE_DEFAULT;
xextent: 8;
yextent: 16;
zextent: 27;
xoffset: 4;
yoffset: 2;
zoffset: 0;
hide_sprite: 0;
}
}
/*Road North West*/
spriteset (spriteset_realhousetown_northwest, "realhousetown.png") {
[98, 8, 44, 36, -22, 0, NOCROP]
}
alternative_sprites (spriteset_realhousetown_northwest, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "realhousetown_32.png") {
[777, 0, 256, 256, -109, -154, NOCROP]
}
spritelayout spritelayout_realhousetown_northwest {
ground {
sprite: GROUNDSPRITE_NORMAL;
}
building {
sprite: spriteset_realhousetown_northwest;
recolour_mode: RECOLOUR_REMAP;
palette: PALETTE_USE_DEFAULT;
xextent: 8;
yextent: 16;
zextent: 27;
xoffset: 4;
yoffset: 2;
zoffset: 0;
hide_sprite: 0;
}
}
/* North, South... */
/* North Corner */
spriteset (spriteset_realhousetown_northcorner, "realhousetown.png") {
[98, 8, 44, 36, -22, 0, NOCROP]
}
alternative_sprites (spriteset_realhousetown_northcorner, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "realhousetown_32.png") {
[0, 259, 256, 256, -109, -154, NOCROP]
}
spritelayout spritelayout_realhousetown_northcorner {
ground {
sprite: GROUNDSPRITE_NORMAL;
}
building {
sprite: spriteset_realhousetown_northcorner;
recolour_mode: RECOLOUR_REMAP;
palette: PALETTE_USE_DEFAULT;
xextent: 8;
yextent: 16;
zextent: 27;
xoffset: 4;
yoffset: 2;
zoffset: 0;
hide_sprite: 0;
}
}
/* East Corner */
spriteset (spriteset_realhousetown_eastcorner, "realhousetown.png") {
[98, 8, 44, 36, -22, 0, NOCROP]
}
alternative_sprites (spriteset_realhousetown_eastcorner, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "realhousetown_32.png") {
[259, 259, 256, 256, -109, -154, NOCROP]
}
spritelayout spritelayout_realhousetown_eastcorner {
ground {
sprite: GROUNDSPRITE_NORMAL;
}
building {
sprite: spriteset_realhousetown_eastcorner;
recolour_mode: RECOLOUR_REMAP;
palette: PALETTE_USE_DEFAULT;
xextent: 8;
yextent: 16;
zextent: 27;
xoffset: 4;
yoffset: 2;
zoffset: 0;
hide_sprite: 0;
}
}
/* South Corner */
spriteset (spriteset_realhousetown_southcorner, "realhousetown.png") {
[98, 8, 44, 36, -22, 0, NOCROP]
}
alternative_sprites (spriteset_realhousetown_southcorner, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "realhousetown_32.png") {
[518, 259, 256, 256, -109, -154, NOCROP]
}
spritelayout spritelayout_realhousetown_southcorner{
ground {
sprite: GROUNDSPRITE_NORMAL;
}
building {
sprite: spriteset_realhousetown_southcorner;
recolour_mode: RECOLOUR_REMAP;
palette: PALETTE_USE_DEFAULT;
xextent: 8;
yextent: 16;
zextent: 27;
xoffset: 4;
yoffset: 2;
zoffset: 0;
hide_sprite: 0;
}
}
/* West Corner */
spriteset (spriteset_realhousetown_westcorner, "realhousetown.png") {
[98, 8, 44, 36, -22, 0, NOCROP]
}
alternative_sprites (spriteset_realhousetown_westcorner, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "realhousetown_32.png") {
[777, 259, 256, 256, -109, -154, NOCROP]
}
spritelayout spritelayout_realhousetown_westcorner {
ground {
sprite: GROUNDSPRITE_NORMAL;
}
building {
sprite: spriteset_realhousetown_westcorner;
recolour_mode: RECOLOUR_REMAP;
palette: PALETTE_USE_DEFAULT;
xextent: 8;
yextent: 16;
zextent: 27;
xoffset: 4;
yoffset: 2;
zoffset: 0;
hide_sprite: 0;
}
}
/* Switches */
switch (FEAT_HOUSES, SELF, switch_southeast4,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 15;
CB_RESULT_DO_NOTHING;
}
switch (FEAT_HOUSES, SELF, switch_southeast3,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 14;
switch_southeast4;
}
switch (FEAT_HOUSES, SELF, switch_southwest3,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 13;
switch_southeast3;
}
switch (FEAT_HOUSES, SELF, switch_northwest2,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 11;
switch_southwest3;
}
switch (FEAT_HOUSES, SELF, switch_norteast2,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 7;
switch_northwest2;
}
switch (FEAT_HOUSES, SELF, switch_southcorner,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 12;
switch_norteast2;
}
switch (FEAT_HOUSES, SELF, switch_southwest2,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 10;
switch_southcorner;
}
switch (FEAT_HOUSES, SELF, switch_westcorner,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 9;
switch_southwest2;
}
switch (FEAT_HOUSES, SELF, switch_eastcorner,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 6;
switch_westcorner;
}
switch (FEAT_HOUSES, SELF, switch_southeast2,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 5;
switch_eastcorner;
}
switch (FEAT_HOUSES, SELF, switch_northcorner2,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 3;
switch_southeast2;
}
switch (FEAT_HOUSES, SELF, switch_southwest,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 8;
switch_northcorner2;
}
switch (FEAT_HOUSES, SELF, switch_southeast,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 4;
switch_southwest;
}
switch (FEAT_HOUSES, SELF, switch_northeast,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 2;
switch_southeast;
}
switch (FEAT_HOUSES, SELF, switch_northwest,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD |
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 |
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 |
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3
) {
TILE_CLASS_ROAD: 1;
switch_northeast;
}
switch (FEAT_HOUSES, SELF, switch_northcorner,
nearby_tile_class( 0, -1) == TILE_CLASS_ROAD | // this line has value 1 if true, 0 if false
nearby_tile_class(-1, 0) == TILE_CLASS_ROAD << 1 | // this line has value 2 if true, 0 if false
nearby_tile_class( 0, 1) == TILE_CLASS_ROAD << 2 | // this line has value 4 if true, 0 if false
nearby_tile_class( 1, 0) == TILE_CLASS_ROAD << 3 // this line has value 8 if true, 0 if false
) {
TILE_CLASS_ROAD: 0;
switch_northwest;
}
switch (FEAT_HOUSES, SELF, switch_check_road_final, animation_frame) {
0: spritelayout_realhousetown_northcorner;
1: spritelayout_realhousetown_northwest;
2: spritelayout_realhousetown_northeast;
4: spritelayout_realhousetown_southeast;
8: spritelayout_realhousetown_southwest;
3: spritelayout_realhousetown_northcorner;
5: spritelayout_realhousetown_southeast;
6: spritelayout_realhousetown_eastcorner;
9: spritelayout_realhousetown_westcorner;
10: spritelayout_realhousetown_southwest;
12: spritelayout_realhousetown_southcorner;
7: spritelayout_realhousetown_northeast;
11: spritelayout_realhousetown_northwest;
13: spritelayout_realhousetown_southwest;
14: spritelayout_realhousetown_southeast;
15: spritelayout_realhousetown_southeast;
spritelayout_realhousetown_southeast;
}
/* Switches End */
item (FEAT_HOUSES, item_realhousetown, -1, HOUSE_SIZE_1X1) {
property {
substitute: 2;
override: 2;
population: 90;
mail_multiplier: 30;
accepted_cargos: [[PASS, 4], [MAIL, 3], [GOOD, 3]];
probability: 10;
years_available: [1855, 2050];
name: string(STR_REALHOUSETOWN_HOUSE);
availability_mask: [ALL_TOWNZONES, ALL_CLIMATES];
building_flags : bitmask(HOUSE_FLAG_ANIMATE);
animation_info : [ANIMATION_LOOPING, 1];
}
graphics {
default: switch_check_road_final;
anim_control: switch_northcorner;
}
}
I read all your help again and I couldn't figure it out either, I'm obviously doing something wrong, thanks too Andrew.
I made a simple test, i modified the 0: and the 9: frames and it show a correct detection, so its a animation problem, i made something wrong, where its my error? Thanks in advance.