Second item not appear in purchase menu, 2x2 template in NML, how to add more items??

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

Moderator: Graphics Moderators

Post Reply
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Second item not appear in purchase menu, 2x2 template in NML, how to add more items??

Post by temporal8 »

Hi everyone, I need a little help with NML coding.

I had started developing my Real Cars and Real House sets in Hex / NFO but I soon realized that it was the most difficult and pointless path, so I am starting from scratch in NML.

I used the 2x2 object in NML template as a base, adapting it to my own graphic template and I already have the first house running in the game, the problem occurs when I want to add a second house since it does not appear in the purchase menu. (//HOUSE 2 - GREEN inside the code..)

When I did this in NFO I simply duplicated the first house code and changed the ID, however in NML this seems to work in a way that I don't know.

Can someone give me a hand?
Thanks in advance.

Code: Select all

// define the newgrf
grf {
    grfid:                  "TEM2";
    name:                   string(STR_GRF_NAME);
    desc:                   string(STR_GRF_DESCRIPTION);
    version:                2;
    min_compatible_version: 1;
}

//template for the purchase menu
template template_realhouse_purchase(x,y,filename) {
    [x, y, 128, 200, -95, -169, filename]
    [x+133, y, 128, 200, -95, -169, filename]
    [x+266, y, 128, 200, -95, -169, filename]
    [x+399, y, 128, 200, -95, -169, filename]
	
}

//template for sprite tile.1
template template_realhouse_t1(x,y,filename) {
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]	
}

//template for sprite tile32.1
template template_realhouse_32_t1(x,y,filename) {
    [x+158, y+3, 264, 264, -130, -135, filename]
    [x+158, y+400, 264, 264, -130, -135, filename]
    [x+158, y+797, 264, 264, -130, -135, filename]
    [x+158, y+1193, 264, 264, -130, -135, filename]	
}

//template for sprite tile.2
template template_realhouse_t2(x,y,filename) {
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
}

//template for sprite tile32.2
template template_realhouse_32_t2(x,y,filename) {
    [x+287, y+65, 264, 264, -129, -137, filename]
    [x+287, y+462, 264, 264, -129, -137, filename]
    [x+287, y+859, 264, 264, -129, -137, filename]
    [x+287, y+1255, 264, 264, -129, -137, filename]	
}

//template for sprite tile.3
template template_realhouse_t3(x,y,filename) {
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
}

//template for sprite tile32.3
template template_realhouse_32_t3(x,y,filename) {
    [x+33, y+65, 264, 264, -127, -137, filename]
    [x+33, y+462, 264, 264, -127, -137, filename]
    [x+33, y+859, 264, 264, -127, -137, filename]
    [x+33, y+1255, 264, 264, -127, -137, filename]	
}

//template for sprite tile.4
template template_realhouse_t4(x,y,filename) {
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
}

//template for sprite tile32.4
template template_realhouse_32_t4(x,y,filename) {
    [x+160, y+127, 264, 264, -128, -139, filename]
    [x+160, y+524, 264, 264, -128, -139, filename]
    [x+160, y+921, 264, 264, -128, -139, filename]
    [x+160, y+1317, 264, 264, -128, -139, filename]
	
}

/* template_realhouse_001 */

//spritesets with 4 directions and the PURCHASE-menu
spriteset (spriteset_template_realhouse_001_t1) {
    template_realhouse_t1(0,0,"realhouse/gfx/template_realhouse_001.png")
}
alternative_sprites (spriteset_template_realhouse_001_t1, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) { 
    template_realhouse_32_t1(0,0,"realhouse/gfx/template_realhouse_32_001.png")
}

spriteset (spriteset_template_realhouse_001_t2) {
    template_realhouse_t2(0,0,"realhouse/gfx/template_realhouse_001.png")
}

alternative_sprites (spriteset_template_realhouse_001_t2, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) { 
    template_realhouse_32_t2(0,0,"realhouse/gfx/template_realhouse_32_001.png")
}

spriteset (spriteset_template_realhouse_001_t3) {
    template_realhouse_t3(0,0,"realhouse/gfx/template_realhouse_001.png")
}

alternative_sprites (spriteset_template_realhouse_001_t3, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) { 
    template_realhouse_32_t3(0,0,"realhouse/gfx/template_realhouse_32_001.png")
}

spriteset (spriteset_template_realhouse_001_t4) {
    template_realhouse_t4(0,0,"realhouse/gfx/template_realhouse_001.png")
}

alternative_sprites (spriteset_template_realhouse_001_t4, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) { 
    template_realhouse_32_t4(0,0,"realhouse/gfx/template_realhouse_32_001.png")
}

spriteset (spriteset_template_realhouse_001_PURCHASE) {
    template_realhouse_purchase(0,0,"realhouse/gfx/template_realhouse_001_PURCHASE.png")
}

//View_1
spritelayout spritelayout_template_realhouse_001_t1_view1 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t1(0);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_t2_view1 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t2(0);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_t3_view1 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t3(0);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_t4_view1 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t4(0);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_view1_purchase {
	ground {
        sprite: GROUNDSPRITE_NORMAL;
	}
	building {
		sprite: spriteset_template_realhouse_001_PURCHASE(0);
		xoffset: 0; //from NE edge
                yoffset: 16; //from NW edge
                zoffset: 0;
                xextent: 16;
                yextent: 16;
                zextent: 16;
	}
}

//View_2
spritelayout spritelayout_template_realhouse_001_t1_view2 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t1(1);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_t2_view2 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t2(1);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_t3_view2 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t3(1);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_t4_view2 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t4(1);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_view2_purchase {
	ground {
        sprite: GROUNDSPRITE_NORMAL;
	}
	building {
		sprite: spriteset_template_realhouse_001_PURCHASE(1);
		xoffset: 0; //from NE edge
                yoffset: 16; //from NW edge
                zoffset: 0;
                xextent: 16;
                yextent: 16;
                zextent: 16;
	}
}


//View_3
spritelayout spritelayout_template_realhouse_001_t1_view3 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t1(2);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_t2_view3 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t2(2);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_t3_view3 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t3(2);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_t4_view3 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t4(2);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }
}

spritelayout spritelayout_template_realhouse_001_view3_purchase {
	ground {
        sprite: GROUNDSPRITE_NORMAL;
	}
	building {
		sprite: spriteset_template_realhouse_001_PURCHASE(2);
		xoffset: 0; //from NE edge
                yoffset: 16; //from NW edge
                zoffset: 0;
                xextent: 16;
                yextent: 16;
                zextent: 16;
	}
}


//View_4
spritelayout spritelayout_template_realhouse_001_t1_view4 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t1(3);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }
}

spritelayout spritelayout_template_realhouse_001_t2_view4 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t2(3);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }
}

spritelayout spritelayout_template_realhouse_001_t3_view4 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t3(3);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_t4_view4 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse_001_t4(3);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse_001_view4_purchase {
	ground {
        sprite: GROUNDSPRITE_NORMAL;
	}
	building {
		sprite: spriteset_template_realhouse_001_PURCHASE(3);
		xoffset: 0; //from NE edge
                yoffset: 16; //from NW edge
                zoffset: 0;
                xextent: 16;
                yextent: 16;
                zextent: 16;
	}
}




//select correct sprites for position of the tiles for the four views
switch (FEAT_OBJECTS, SELF, switch_template_realhouse_001_position_view1, relative_pos) {
	relative_coord(0, 0): spritelayout_template_realhouse_001_t1_view1;
	relative_coord(0, 1): spritelayout_template_realhouse_001_t2_view1;
	relative_coord(1, 0): spritelayout_template_realhouse_001_t3_view1;
	relative_coord(1, 1): spritelayout_template_realhouse_001_t4_view1;
    spritelayout_template_realhouse_001_t1_view1;
    }

switch (FEAT_OBJECTS, SELF, switch_template_realhouse_001_position_view2, relative_pos) {
	relative_coord(0, 0): spritelayout_template_realhouse_001_t1_view2;
	relative_coord(0, 1): spritelayout_template_realhouse_001_t2_view2;
	relative_coord(1, 0): spritelayout_template_realhouse_001_t3_view2;
	relative_coord(1, 1): spritelayout_template_realhouse_001_t4_view2;
    spritelayout_template_realhouse_001_t1_view2;
    }

switch (FEAT_OBJECTS, SELF, switch_template_realhouse_001_position_view3, relative_pos) {
	relative_coord(0, 0): spritelayout_template_realhouse_001_t1_view3;
	relative_coord(0, 1): spritelayout_template_realhouse_001_t2_view3;
	relative_coord(1, 0): spritelayout_template_realhouse_001_t3_view3;
	relative_coord(1, 1): spritelayout_template_realhouse_001_t4_view3;
    spritelayout_template_realhouse_001_t1_view3;
    }

switch (FEAT_OBJECTS, SELF, switch_template_realhouse_001_position_view4, relative_pos) {
	relative_coord(0, 0) : spritelayout_template_realhouse_001_t1_view4;
	relative_coord(0, 1) : spritelayout_template_realhouse_001_t2_view4;
	relative_coord(1, 0) : spritelayout_template_realhouse_001_t3_view4;
	relative_coord(1, 1) : spritelayout_template_realhouse_001_t4_view4;
    spritelayout_template_realhouse_001_t1_view4;
    }
 
//decide spritelayout for each of the 4 directions
switch (FEAT_OBJECTS, SELF, switch_template_realhouse_001_view, view) {
    1:  switch_template_realhouse_001_position_view2;
    2:  switch_template_realhouse_001_position_view3;
    3:  switch_template_realhouse_001_position_view4;
    switch_template_realhouse_001_position_view1;
}


//calculate ground sprite for object
switch (FEAT_OBJECTS, SELF, switch_template_realhouse_001_object, [
    STORE_TEMP(GROUNDSPRITE_NORMAL, 1),
    STORE_TEMP( (nearby_tile_terrain_type(0,0) == TILETYPE_DESERT) * GROUNDSPRITE_DESERT, 1),
    STORE_TEMP( LOAD_TEMP(1) + (LOAD_TEMP(1) == 0) * 4512 * (nearby_tile_terrain_type( 1, 0) == TILETYPE_DESERT), 1),
    STORE_TEMP( LOAD_TEMP(1) + (LOAD_TEMP(1) == 0) * 4512 * (nearby_tile_terrain_type(-1, 0) == TILETYPE_DESERT), 1),
    STORE_TEMP( LOAD_TEMP(1) + (LOAD_TEMP(1) == 0) * 4512 * (nearby_tile_terrain_type( 0, 1) == TILETYPE_DESERT), 1),
    STORE_TEMP( LOAD_TEMP(1) + (LOAD_TEMP(1) == 0) * 4512 * (nearby_tile_terrain_type( 0,-1) == TILETYPE_DESERT), 1),
    STORE_TEMP( LOAD_TEMP(1) + (LOAD_TEMP(1) == 0) * GROUNDSPRITE_NORMAL, 1),
    STORE_TEMP(terrain_type == TILETYPE_SNOW   ? GROUNDSPRITE_SNOW : LOAD_TEMP(1), 1),
    STORE_TEMP(snowline_height == 0xFF ? 0xFF : nearby_tile_height(0,0) - snowline_height, 255),
    STORE_TEMP((LOAD_TEMP(255) == -1) ? GROUNDSPRITE_SNOW_1_4 : LOAD_TEMP(1), 1),
    STORE_TEMP((LOAD_TEMP(255) ==  0) ? GROUNDSPRITE_SNOW_2_4 : LOAD_TEMP(1), 1),
    STORE_TEMP((LOAD_TEMP(255) ==  1) ? GROUNDSPRITE_SNOW_3_4 : LOAD_TEMP(1), 1)
        ]) {
    switch_template_realhouse_001_view;
}

//calculate ground sprite for purchase menu
switch (FEAT_OBJECTS, SELF, switch_template_realhouse_001_purchase, view) {
    1:  spritelayout_template_realhouse_001_view2_purchase;
    2:  spritelayout_template_realhouse_001_view3_purchase;
    3:  spritelayout_template_realhouse_001_view4_purchase;
    spritelayout_template_realhouse_001_view1_purchase;
}

switch (FEAT_OBJECTS, SELF, switch_add_text_template_realhouse_001, view) {
1: string(STR_template_realhouse_001_purchase_view2);
2: string(STR_template_realhouse_001_purchase_view3);
3: string(STR_template_realhouse_001_purchase_view4);
default: string(STR_template_realhouse_001_purchase_view1);
}

item (FEAT_OBJECTS, template_realhouse_001, 000) {
    property {
        class: "TEM2";
        classname: string(STR_TEM2);
        name: string(STR_template_realhouse_001);
        climates_available: ALL_CLIMATES;
        size: [2,2];
        build_cost_multiplier: 0;
        remove_cost_multiplier: 0;
        introduction_date: date(1700,1,1);
        end_of_life_date: 0xFFFFFFFF;
        object_flags: bitmask(OBJ_FLAG_ALLOW_BRIDGE, OBJ_FLAG_ON_WATER, OBJ_FLAG_DRAW_WATER, OBJ_FLAG_ANYTHING_REMOVE, OBJ_FLAG_REMOVE_IS_INCOME);
        height: 0;
        num_views: 4;
     }
    graphics {
        default: switch_template_realhouse_001_object;
        purchase: switch_template_realhouse_001_purchase;
        additional_text: switch_add_text_template_realhouse_001;
      }
}





//HOUSE 2 - GREEN.


//template for the purchase menu
template template_realhouse2_purchase(x,y,filename) {
    [x, y, 128, 200, -95, -169, filename]
    [x+133, y, 128, 200, -95, -169, filename]
    [x+266, y, 128, 200, -95, -169, filename]
    [x+399, y, 128, 200, -95, -169, filename]
	
}

//template for sprite tile.1
template template_realhouse2_t1(x,y,filename) {
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]	
}

//template for sprite tile32.1
template template_realhouse2_32_t1(x,y,filename) {
    [x+158, y+1601, 264, 264, -130, -116, filename]
    [x+158, y+1996, 264, 264, -130, -135, filename]
    [x+158, y+2393, 264, 264, -130, -135, filename]
    [x+158, y+2789, 264, 264, -112, -199, filename]		
}

//template for sprite tile.2
template template_realhouse2_t2(x,y,filename) {
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
}

//template for sprite tile32.2
template template_realhouse2_32_t2(x,y,filename) {

    [x+287, y+1662, 264, 264, -129, -119, filename]
    [x+287, y+2059, 264, 264, -129, -137, filename]
    [x+287, y+2454, 264, 264, -129, -138, filename]
    [x+287, y+2850, 264, 264, -129, -103, filename]	
}

//template for sprite tile.3
template template_realhouse2_t3(x,y,filename) {
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
}

//template for sprite tile32.3
template template_realhouse2_32_t3(x,y,filename) {
    [x+33, y+1662, 264, 264, -127, -118, filename]
    [x+33, y+2059, 264, 264, -127, -136, filename]
    [x+33, y+2454, 264, 264, -127, -138, filename]
    [x+33, y+2851, 264, 264, -127, -102, filename]	
}

//template for sprite tile.4
template template_realhouse2_t4(x,y,filename) {
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
    [x+2, y+2, 64, 64, -1, -1, filename]
}

//template for sprite tile32.4
template template_realhouse2_32_t4(x,y,filename) {
    [x+160, y+1725, 264, 264, -128, -120, filename]
    [x+160, y+2120, 264, 264, -128, -139, filename]
    [x+160, y+2517, 264, 264, -128, -139, filename]
    [x+160, y+2913, 264, 264, -110, -104, filename]	
}

/* template_realhouse2_001 */

//spritesets with 4 directions and the PURCHASE-menu
spriteset (spriteset_template_realhouse2_001_t1) {
    template_realhouse2_t1(0,0,"realhouse/gfx/template_realhouse_001.png")
}
alternative_sprites (spriteset_template_realhouse2_001_t1, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) { 
    template_realhouse2_32_t1(0,0,"realhouse/gfx/template_realhouse_32_001.png")
}

spriteset (spriteset_template_realhouse2_001_t2) {
    template_realhouse2_t2(0,0,"realhouse/gfx/template_realhouse_001.png")
}

alternative_sprites (spriteset_template_realhouse2_001_t2, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) { 
    template_realhouse2_32_t2(0,0,"realhouse/gfx/template_realhouse_32_001.png")
}

spriteset (spriteset_template_realhouse2_001_t3) {
    template_realhouse2_t3(0,0,"realhouse/gfx/template_realhouse_001.png")
}

alternative_sprites (spriteset_template_realhouse2_001_t3, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) { 
    template_realhouse2_32_t3(0,0,"realhouse/gfx/template_realhouse_32_001.png")
}

spriteset (spriteset_template_realhouse2_001_t4) {
    template_realhouse2_t4(0,0,"realhouse/gfx/template_realhouse_001.png")
}

alternative_sprites (spriteset_template_realhouse2_001_t4, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) { 
    template_realhouse2_32_t4(0,0,"realhouse/gfx/template_realhouse_32_001.png")
}

spriteset (spriteset_template_realhouse2_001_PURCHASE) {
    template_realhouse2_purchase(0,0,"realhouse/gfx/template_realhouse2_001_PURCHASE.png")
}

//View_1
spritelayout spritelayout_template_realhouse2_001_t1_view1 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t1(0);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_t2_view1 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t2(0);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_t3_view1 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t3(0);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_t4_view1 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t4(0);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_view1_purchase {
	ground {
        sprite: GROUNDSPRITE_NORMAL;
	}
	building {
		sprite: spriteset_template_realhouse2_001_PURCHASE(0);
		xoffset: 0; //from NE edge
                yoffset: 16; //from NW edge
                zoffset: 0;
                xextent: 16;
                yextent: 16;
                zextent: 16;
	}
}

//View_2
spritelayout spritelayout_template_realhouse2_001_t1_view2 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t1(1);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_t2_view2 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t2(1);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_t3_view2 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t3(1);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_t4_view2 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t4(1);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_view2_purchase {
	ground {
        sprite: GROUNDSPRITE_NORMAL;
	}
	building {
		sprite: spriteset_template_realhouse2_001_PURCHASE(1);
		xoffset: 0; //from NE edge
                yoffset: 16; //from NW edge
                zoffset: 0;
                xextent: 16;
                yextent: 16;
                zextent: 16;
	}
}


//View_3
spritelayout spritelayout_template_realhouse2_001_t1_view3 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t1(2);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_t2_view3 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t2(2);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_t3_view3 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t3(2);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_t4_view3 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t4(2);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }
}

spritelayout spritelayout_template_realhouse2_001_view3_purchase {
	ground {
        sprite: GROUNDSPRITE_NORMAL;
	}
	building {
		sprite: spriteset_template_realhouse2_001_PURCHASE(2);
		xoffset: 0; //from NE edge
                yoffset: 16; //from NW edge
                zoffset: 0;
                xextent: 16;
                yextent: 16;
                zextent: 16;
	}
}


//View_4
spritelayout spritelayout_template_realhouse2_001_t1_view4 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t1(3);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }
}

spritelayout spritelayout_template_realhouse2_001_t2_view4 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t2(3);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }
}

spritelayout spritelayout_template_realhouse2_001_t3_view4 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t3(3);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_t4_view4 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse2_001_t4(3);
        hide_sprite: nearby_tile_height(0, 0) >= snowline_height;
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }

}

spritelayout spritelayout_template_realhouse2_001_view4_purchase {
	ground {
        sprite: GROUNDSPRITE_NORMAL;
	}
	building {
		sprite: spriteset_template_realhouse2_001_PURCHASE(3);
		xoffset: 0; //from NE edge
                yoffset: 16; //from NW edge
                zoffset: 0;
                xextent: 16;
                yextent: 16;
                zextent: 16;
	}
}




//select correct sprites for position of the tiles for the four views
switch (FEAT_OBJECTS, SELF, switch_template_realhouse2_001_position_view1, relative_pos) {
	relative_coord(0, 0): spritelayout_template_realhouse2_001_t1_view1;
	relative_coord(0, 1): spritelayout_template_realhouse2_001_t2_view1;
	relative_coord(1, 0): spritelayout_template_realhouse2_001_t3_view1;
	relative_coord(1, 1): spritelayout_template_realhouse2_001_t4_view1;
    spritelayout_template_realhouse2_001_t1_view1;
    }

switch (FEAT_OBJECTS, SELF, switch_template_realhouse2_001_position_view2, relative_pos) {
	relative_coord(0, 0): spritelayout_template_realhouse2_001_t1_view2;
	relative_coord(0, 1): spritelayout_template_realhouse2_001_t2_view2;
	relative_coord(1, 0): spritelayout_template_realhouse2_001_t3_view2;
	relative_coord(1, 1): spritelayout_template_realhouse2_001_t4_view2;
    spritelayout_template_realhouse2_001_t1_view2;
    }

switch (FEAT_OBJECTS, SELF, switch_template_realhouse2_001_position_view3, relative_pos) {
	relative_coord(0, 0): spritelayout_template_realhouse2_001_t1_view3;
	relative_coord(0, 1): spritelayout_template_realhouse2_001_t2_view3;
	relative_coord(1, 0): spritelayout_template_realhouse2_001_t3_view3;
	relative_coord(1, 1): spritelayout_template_realhouse2_001_t4_view3;
    spritelayout_template_realhouse2_001_t1_view3;
    }

switch (FEAT_OBJECTS, SELF, switch_template_realhouse2_001_position_view4, relative_pos) {
	relative_coord(0, 0) : spritelayout_template_realhouse2_001_t1_view4;
	relative_coord(0, 1) : spritelayout_template_realhouse2_001_t2_view4;
	relative_coord(1, 0) : spritelayout_template_realhouse2_001_t3_view4;
	relative_coord(1, 1) : spritelayout_template_realhouse2_001_t4_view4;
    spritelayout_template_realhouse2_001_t1_view4;
    }
 
//decide spritelayout for each of the 4 directions
switch (FEAT_OBJECTS, SELF, switch_template_realhouse2_001_view, view) {
    1:  switch_template_realhouse2_001_position_view2;
    2:  switch_template_realhouse2_001_position_view3;
    3:  switch_template_realhouse2_001_position_view4;
    switch_template_realhouse2_001_position_view1;
}


//calculate ground sprite for object
switch (FEAT_OBJECTS, SELF, switch_template_realhouse2_001_object, [
    STORE_TEMP(GROUNDSPRITE_NORMAL, 1),
    STORE_TEMP( (nearby_tile_terrain_type(0,0) == TILETYPE_DESERT) * GROUNDSPRITE_DESERT, 1),
    STORE_TEMP( LOAD_TEMP(1) + (LOAD_TEMP(1) == 0) * 4512 * (nearby_tile_terrain_type( 1, 0) == TILETYPE_DESERT), 1),
    STORE_TEMP( LOAD_TEMP(1) + (LOAD_TEMP(1) == 0) * 4512 * (nearby_tile_terrain_type(-1, 0) == TILETYPE_DESERT), 1),
    STORE_TEMP( LOAD_TEMP(1) + (LOAD_TEMP(1) == 0) * 4512 * (nearby_tile_terrain_type( 0, 1) == TILETYPE_DESERT), 1),
    STORE_TEMP( LOAD_TEMP(1) + (LOAD_TEMP(1) == 0) * 4512 * (nearby_tile_terrain_type( 0,-1) == TILETYPE_DESERT), 1),
    STORE_TEMP( LOAD_TEMP(1) + (LOAD_TEMP(1) == 0) * GROUNDSPRITE_NORMAL, 1),
    STORE_TEMP(terrain_type == TILETYPE_SNOW   ? GROUNDSPRITE_SNOW : LOAD_TEMP(1), 1),
    STORE_TEMP(snowline_height == 0xFF ? 0xFF : nearby_tile_height(0,0) - snowline_height, 255),
    STORE_TEMP((LOAD_TEMP(255) == -1) ? GROUNDSPRITE_SNOW_1_4 : LOAD_TEMP(1), 1),
    STORE_TEMP((LOAD_TEMP(255) ==  0) ? GROUNDSPRITE_SNOW_2_4 : LOAD_TEMP(1), 1),
    STORE_TEMP((LOAD_TEMP(255) ==  1) ? GROUNDSPRITE_SNOW_3_4 : LOAD_TEMP(1), 1)
        ]) {
    switch_template_realhouse2_001_view;
}

//calculate ground sprite for purchase menu
switch (FEAT_OBJECTS, SELF, switch_template_realhouse2_001_purchase, view) {
    1:  spritelayout_template_realhouse2_001_view2_purchase;
    2:  spritelayout_template_realhouse2_001_view3_purchase;
    3:  spritelayout_template_realhouse2_001_view4_purchase;
        spritelayout_template_realhouse2_001_view1_purchase;
}

switch (FEAT_OBJECTS, SELF, switch_add_text_template_realhouse2_001, view) {
1: string(STR_template_realhouse2_001_purchase_view2);
2: string(STR_template_realhouse2_001_purchase_view3);
3: string(STR_template_realhouse2_001_purchase_view4);
default: string(STR_template_realhouse2_001_purchase_view1);
}

item (FEAT_OBJECTS, template_realhouse2_001, 000) {
    property {
        class: "TEM2";
        classname: string(STR_TEM2);
        name: string(STR_template_realhouse2_001);
        climates_available: ALL_CLIMATES;
        size: [2,2];
        build_cost_multiplier: 0;
        remove_cost_multiplier: 0;
        introduction_date: date(1700,1,1);
        end_of_life_date: 0xFFFFFFFF;
        object_flags: bitmask(OBJ_FLAG_ALLOW_BRIDGE, OBJ_FLAG_ON_WATER, OBJ_FLAG_DRAW_WATER, OBJ_FLAG_ANYTHING_REMOVE, OBJ_FLAG_REMOVE_IS_INCOME);
        height: 0;
        num_views: 4;
     }
    graphics {
        default: switch_template_realhouse2_001_object;
        purchase: switch_template_realhouse2_001_purchase;
        additional_text: switch_add_text_template_realhouse2_001;
      }
}

Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
User avatar
2TallTyler
Route Supervisor
Route Supervisor
Posts: 502
Joined: 11 Aug 2019 18:15
Contact:

Re: Second item not appear in purchase menu, 2x2 template in NML, how to add more items??

Post by 2TallTyler »

You've chosen both a name (required) and a numeric ID (optional but recommended). The two objects have different names but share the ID 000. Changing this on the second object should fix the problem. :)
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: Second item not appear in purchase menu, 2x2 template in NML, how to add more items??

Post by temporal8 »

I have it! thank you very much! :D
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 17 guests