How to add Road detection to this 2x1 template?

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

Moderator: Graphics Moderators

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

How to add Road detection to this 2x1 template?

Post by temporal8 »

Hi, I started testing my town set and have already included a few buildings with 2x2 and 2x1 templates, the problem of course is my little knowledge (or no knowledge) of coding.

Each of my houses has 4 views since initially it was going to be an eyecandy set and I would like to be able to take advantage of it for my town set, that the houses can detect the roads and orient themselves correctly. In another topic Eddi and Andrew helped me and I already have it working for 1x1 templates but now I want to do it for 2x1.

I know that doing it for 4 views would perhaps be a lot to ask and I honestly do not know if it is possible to have 4 different views in a House as you have in the eyecandy objects, so im thinking to do it only for 1 view and repeat that Code/house 4 times changing the graphic and the orientation, In that way a eyecandy house with 4 different views / oriented graphics would actually become inside the code in 4 different houses, one for view / detected road.

I just need to know how to add street detection to this example of my set,
I want the house to only appear if it detects a street in SW (1,0)

Thanks in advance guys.

Code: Select all

//HOUSE 6 2x1 --------------------------------------------------------------

//template for the frontsprite
template template_realhouse6_front(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 the frontsprite 32
template template_realhouse6_front_32(x,y,filename) {
    [x+15, y+77, 264, 264, -126, -118, filename]  //1f
    [x+561, y+77, 264, 264, -131, -136, filename]  //2f
    [x+848, y+77, 264, 264, -125, -136, filename]  //3f
    [x+1392, y+77, 264, 264, -123, -135, filename] //4f
	
}
//template for the backsprite
template template_realhouse6_back(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 the backsprite 32
template template_realhouse6_back_32(x,y,filename) {
    [x+141,  y+16, 264, 264, -127, -115, filename] //1b
    [x+429, y+16, 264, 264, -135, -133, filename] //2b
    [x+973, y+16, 264, 264, -128, -133, filename] //3b
    [x+1264, y+16, 264, 264, -123, -132, filename] //4b	
	
}

//template 2x1

//spritesets with 4 directions.
spriteset (spriteset_template_realhouse6_001_front) {
    template_realhouse6_front(0,0,"gfx/template_realhouse_001.png")
}
alternative_sprites (spriteset_template_realhouse6_001_front, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) { 
    template_realhouse6_front_32(0,0,"gfx/template_realhouse_32_002.png")
}
spriteset (spriteset_template_realhouse6_001_back) {
    template_realhouse6_back(0,0,"gfx/template_realhouse_001.png")
}
alternative_sprites (spriteset_template_realhouse6_001_back, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) { 
    template_realhouse6_back_32(0,0,"gfx/template_realhouse_32_002.png")
}

//Direction_1
spritelayout spritelayout_template_realhouse6_001_front_1 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse6_001_front(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_realhouse6_001_back_1 {
    ground {
      // normal ground sprite - always draw
      sprite: LOAD_TEMP(0) + LOAD_TEMP(1);
   }
    
    building {
        sprite: spriteset_template_realhouse6_001_back(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;
    }
}

item (FEAT_HOUSES, item_realhouse_006, -1, HOUSE_SIZE_2X1) {
    property {

        substitute: 74;
        name: string(STR_template_realhouse_006);

        building_flags: bitmask();
        population: 255;
        mail_multiplier: 22;
        accepted_cargos: [[PASS, 8], [MAIL, 2], [GOOD, 2]];
        local_authority_impact: 150;
        removal_cost_multiplier: 180;
        probability: 1.0 * 0.33;
        years_available: [1930, 9999];
        minimum_lifetime: 10;
//      availability_mask: [bitmask(TOWNZONE_CENTRE, TOWNZONE_INNER_SUBURB, TOWNZONE_OUTER_SUBURB), bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, ABOVE_SNOWLINE, CLIMATE_TROPICAL)];
        availability_mask:[ALL_TOWNZONES, ALL_CLIMATES | bitmask(ABOVE_SNOWLINE)];
        random_colours: [COLOUR_DARK_BLUE, COLOUR_DARK_BLUE, COLOUR_DARK_BLUE, COLOUR_DARK_BLUE];
        refresh_multiplier: 0;

        building_class: 0;
    }

    graphics {
 graphics_north: spritelayout_template_realhouse6_001_back_1;
 graphics_west: spritelayout_template_realhouse6_001_front_1;

    }
}
 
Image
Attachments
street.jpg
street.jpg (1.08 MiB) Viewed 1046 times
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 19 guests