Page 2 of 2

Re: NML House with check road position complete example??

Posted: 15 Nov 2020 20:47
by Eddi
ok, let's try a longer explanation

Code: Select all

switch (FEAT_HOUSES, SELF, switch_combined,
    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
) 
the "|" operator adds up all the values of the above 4 lines. the summary of these lines will be checked below

Code: Select all

{
	0: <insert target jump here, i'll omit those in the next lines> // this jump will be taken if none of the checks were true
	1: // this jump will be taken if the first check was the only one that is true
	2: // this jump will be taken if the second check was the only one that is true
	4: // this jump will be taken if the third check was the only one that is true
	8: // this jump will be taken if the fourth check was the only one that is true
	3:  // 3=1+2,  this jump will be taken if the first and second check were true
	5:  // 5=1+4,  this jump will be taken if the first and third check were true
	6:  // 6=2+4,  this jump will be taken if the second and third check were true
	9:  // 9=1+8,  this jump will be taken if the first and fourth check were true
	10: // 10=2+8, this jump will be taken if the second and fourth check were true
	12: // 12=4+8, this jump will be taken if the third and fourth check were true
	7:  // 7=1+2+4,  this jump will be taken if the first, second and third check were true
	11: // 11=1+2+8, this jump will be taken if the first, second and fourth check were true
	13: // 13=1+4+8, this jump will be taken if the first, third and fourth check were true
	14: // 14=2+4+8, this jump will be taken if the second, third and fourth check were true
	15: // 15=1+2+4+8,  this jump will be taken if all the checks were true
}

Re: NML House with check road position complete example??

Posted: 16 Nov 2020 01:47
by temporal8
There is no case, we can spend more days on this same path and it will be the same. I can understand a code doing reverse engineering, I can understand certain things, but this is beyond me. I want to spend my time doing 3d things for the game, not fighting against code. :D

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_combined, animation_frame,
    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
) 

{
	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; 
}


/* 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_combined;
    anim_control: switch_combined;
	}
}

Re: NML House with check road position complete example??

Posted: 16 Mar 2021 21:40
by super_dan
Hey there, I am currently also experimenting with road detection in order to create a typical Central European town landscape (my planned set: viewtopic.php?t=73137).

As mentioned before in this topic, I use the construction_check-callback for 8 different house items for all directions. My question is: apart from having a slightly longer list of sprite layouts and items, is there any other disadvantage to this method?

Re: NML House with check road position complete example??

Posted: 16 Mar 2021 23:30
by Andrew350
It means you will use 8x the number of house IDs than you really need, and since you can only have 255, that may be a problem depending on how many houses you want.

If you are comfortable using a not-yet-official version of NML, there is a pull request open on GitHub which would allow you to access town storage and do this properly without houses flipping around: https://github.com/OpenTTD/nml/pull/173

Re: NML House with check road position complete example??

Posted: 15 May 2021 10:05
by super_dan
Thanks for the hint. I'll try figure that out.

Summing up the information in this thread, I now understand that I can use that not-yet-official version of NML to bind the graphics to the anim_next_frame-callback rather than using anim_control which would not allow for non-flipping buildings. Right? :?:

There is another reason I want to bind my graphics not to the default-callback: As my mission is to save as many item slots as possible I want to get rid of the availability-years property as a way of introducing different graphics for different historical eras. I've already successfully implemented a function to govern which set of spritelayouts should be used for different time slots. However, binding them to the anim_control callback (the way shown in this thread) makes them still change when the predefined starting years for the respective historical eras are reached.

Would using the version of NML you pointed me to allow for solving this problem?

Re: NML House with check road position complete example??

Posted: 15 May 2021 21:12
by Andrew350
super_dan wrote: 15 May 2021 10:05 Summing up the information in this thread, I now understand that I can use that not-yet-official version of NML to bind the graphics to the anim_next_frame-callback rather than using anim_control which would not allow for non-flipping buildings. Right? :?:
Actually no, I was very wrong with that statement. I overlooked a very simple solution and jumped to an erroneous conclusion which wouldn't in fact solve anything. Apologies :oops:

The easy way to make this work, or at least the way I solved it, is by simply checking for a "dummy" frame before the switch which checks for road position:

Code: Select all

switch (FEAT_HOUSES, SELF, switch_check_road_final, animation_frame) {
	1:  spritelayout_house_1;
	2:  spritelayout_house_2;
	3:  spritelayout_house_3;
	4:  spritelayout_house_4;
	spritelayout_house_0;
}
switch (FEAT_HOUSES, SELF, switch_check_road_northeast, nearby_tile_class(-1, 0)) {
	TILE_CLASS_ROAD:  4;
	CB_RESULT_DO_NOTHING;
}
switch (FEAT_HOUSES, SELF, switch_check_road_southeast, nearby_tile_class(0, 1)) {
	TILE_CLASS_ROAD:  3;
	switch_check_road_northeast;
}
switch (FEAT_HOUSES, SELF, switch_check_road_southwest, nearby_tile_class(1, 0)) {
	TILE_CLASS_ROAD:  2;
	switch_check_road_southeast;
}
switch (FEAT_HOUSES, SELF, switch_check_road_northwest, nearby_tile_class(0, -1)) {
	TILE_CLASS_ROAD:  1;
	switch_check_road_southwest;
}
switch (FEAT_HOUSES, SELF, switch_check_road_initial, animation_frame) {
	0:  switch_check_road_northwest;
	CB_RESULT_DO_NOTHING;
}
switch_check_road_initial is called by the "anim_control" callback, and switch_check_road_final is called by the "default" callback.

In this simplified example I'm only checking in four directions, so frames 1..4 are my actual rotated house sprites. Frame 0 in this case should never be used as long as I cover all cases in the following switch(es). So the first switch in this chain only allows the callback to continue if currently on frame 0 and simply does nothing further if it encounters a different frame (which indicates it has been called before). This simple change will successfully prevent houses from flipping directions when the road changes, and the same tactic should work for your other issue as well :)


Again, apologies for my misdirection here, but hopefully this should finally give a (basic) answer to the original question. There are probably other ways to solve it as well, but this has worked for me :)

Re: NML House with check road position complete example??

Posted: 07 Aug 2021 23:31
by temporal8
Hi, it's been 8 months since the last time and I want to see if I can get this to work to finally release it.

The last time I reached a point where I could not continue anymore since I am not a coder and there are things that I do not understand.

I need help so that the code shows the corners correctly, the last time I tried the code it detected the 4 directions correctly but not the corners.

Andrew350 or Eddi can you give me a hand with this? your names will be present in the newgrf credits of course.

Thanks in advance.

Re: NML House with check road position complete example??

Posted: 14 Oct 2021 00:04
by temporal8
Finally I was able to advance in the code and I managed to detect the corners and some different situations, I still need to fix a few things but I am closer.

Thanks Eddi, I re-read the explanations you gave me in 2020 and finally understood the Pseudo code.

Re: NML House with check road position complete example??

Posted: 26 Oct 2021 10:17
by temporal8
Hello, I have the code working detecting streets and corners, to place corners I am detecting the adyacent roads, for example: Northcorner detects NW (0, -1), N (-1, -1) and NE (-1,0).

switch (FEAT_HOUSES, SELF, switch_combined_northcorner,
nearby_tile_class (0, -1) &
nearby_tile_class (-1, -1) &
nearby_tile_class (-1, 0)
) {
TILE_CLASS_ROAD: 7;
switch_combined_eastcorner;
}

Image

BUT there is some kind of error since it detects any adjacent object and not just the streets:
By adding one more module (number 2) North corner is added instead of NorthEast simple module, it seems that it detects the existing Northcorner (number 1) at NW (0, -1) as if it were a piece of street ?? or it´s something with animation looping order... or both...?? because it could also have detected SE (0,1) and add a EastCorner.

Image

Complete:
The original ones in white.
Image

This it´s the complete code (SOURCE FILES for test ingame will be attached to next message/reply dued to 3 attachments forum limits x message):

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_check_road_northeast, 
    nearby_tile_class (-1, 0)  
) {
	TILE_CLASS_ROAD:  0;
	CB_RESULT_DO_NOTHING;
}

switch (FEAT_HOUSES, SELF, switch_check_road_southeast, 
    nearby_tile_class (0, 1) 
) {
	TILE_CLASS_ROAD:  1;
	switch_check_road_northeast;
}

switch (FEAT_HOUSES, SELF, switch_check_road_southwest, 
    nearby_tile_class (1, 0) 
) {
	TILE_CLASS_ROAD:  2;
	switch_check_road_southeast;
}

switch (FEAT_HOUSES, SELF, switch_check_road_northwest, 
    nearby_tile_class (0,-1)
) {
	TILE_CLASS_ROAD:  3;
	switch_check_road_southwest;
}

switch (FEAT_HOUSES, SELF, switch_combined_westcorner, 
    nearby_tile_class(0, -1) &
    nearby_tile_class(1, 1) &
    nearby_tile_class(1, 0)
) {
	TILE_CLASS_ROAD:  4;
	switch_check_road_northwest;
}

switch (FEAT_HOUSES, SELF, switch_combined_southcorner, 
    nearby_tile_class(1, 0) &
    nearby_tile_class(1, 1) &
    nearby_tile_class(0, 1) 
) {
	TILE_CLASS_ROAD: 5;
	switch_combined_westcorner;
}

switch (FEAT_HOUSES, SELF, switch_combined_eastcorner, 
    nearby_tile_class(-1, 0) &
    nearby_tile_class(-1, 1) &
    nearby_tile_class(0, 1) 
) {
	TILE_CLASS_ROAD: 6;
	switch_combined_southcorner;
}

switch (FEAT_HOUSES, SELF, switch_combined_northcorner, 
   nearby_tile_class (0, -1) &
   nearby_tile_class (-1, -1) &
   nearby_tile_class (-1, 0) 
) {
	TILE_CLASS_ROAD: 7;
	switch_combined_eastcorner;
}

switch (FEAT_HOUSES, SELF, switch_check_road_initial, animation_frame) {
	0:  switch_combined_northcorner;
	CB_RESULT_DO_NOTHING;
}

switch (FEAT_HOUSES, SELF, switch_check_road_final, animation_frame) {
	7:  spritelayout_realhousetown_northcorner;
	6:  spritelayout_realhousetown_eastcorner;
	5:  spritelayout_realhousetown_southcorner;
	4:  spritelayout_realhousetown_westcorner;
	3:  spritelayout_realhousetown_northwest;
	2:  spritelayout_realhousetown_southwest;
	1:  spritelayout_realhousetown_southeast;
	0:  spritelayout_realhousetown_northeast;
	spritelayout_realhousetown_northcorner;
}

/* 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_check_road_initial;
	}
}

Re: NML House with check road position complete example??

Posted: 26 Oct 2021 10:25
by temporal8
This are the full files, nml and png if anyone wants to check the error ingame:
detect-error.zip
(1009.84 KiB) Downloaded 90 times

Re: NML House with check road position complete example??

Posted: 26 Oct 2021 18:05
by Eddi
temporal8 wrote: 26 Oct 2021 10:17 nearby_tile_class (0, -1) &
nearby_tile_class (-1, -1) &
nearby_tile_class (-1, 0)
this logic is flawed. you're performing bitwise logic, when you should do 3 individual checks.

Code: Select all

   nearby_tile_class (0, -1) == TILE_CLASS_ROAD &&
   nearby_tile_class (-1, -1) == TILE_CLASS_ROAD &&
   nearby_tile_class (-1, 0) == TILE_CLASS_ROAD
additionally, you seem to reuse animation_frame == 0 both as "not checked yet" and "northeast", this is not the cause of your current issue, but also flawed.

Re: NML House with check road position complete example??

Posted: 26 Oct 2021 21:01
by temporal8
Eddi wrote: 26 Oct 2021 18:05
temporal8 wrote: 26 Oct 2021 10:17 nearby_tile_class (0, -1) &
nearby_tile_class (-1, -1) &
nearby_tile_class (-1, 0)
this logic is flawed. you're performing bitwise logic, when you should do 3 individual checks.

Code: Select all

   nearby_tile_class (0, -1) == TILE_CLASS_ROAD &&
   nearby_tile_class (-1, -1) == TILE_CLASS_ROAD &&
   nearby_tile_class (-1, 0) == TILE_CLASS_ROAD
additionally, you seem to reuse animation_frame == 0 both as "not checked yet" and "northeast", this is not the cause of your current issue, but also flawed.
Ok, so it's like you told me above, so could you give me an example of just one line and not a pesudocode? this would be done with logical operators?

Example pseudocode (from above):
6: // 6=2+4, this jump will be taken if the second and third check were true

How would it be to write that in code? Let's see if I understand and can do the rest.

Thanks.

Re: NML House with check road position complete example??

Posted: 27 Oct 2021 04:19
by Eddi
temporal8 wrote: 26 Oct 2021 21:01could you give me an example of just one line and not a pesudocode?
what do you mean? that's exactly what i just did.

Homework:
1) What does the "==" operator do?
2) What is the difference between "&" and "&&"?

Re: NML House with check road position complete example??

Posted: 27 Oct 2021 13:47
by temporal8
Eddi wrote: 27 Oct 2021 04:19
temporal8 wrote: 26 Oct 2021 21:01could you give me an example of just one line and not a pesudocode?
what do you mean? that's exactly what i just did.

Homework:
1) What does the "==" operator do?
2) What is the difference between "&" and "&&"?
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 nearby_tile_class( 0, -1) == TILE_CLASS_ROAD 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;
	}
}
--------------------------------
Andrew350 wrote: 09 Nov 2020 02:45 Option 1 will work following Eddi's suggestion to use "anim_control" instead of "next_animation_frame". Instead of returning a spritelayout though, it must return an animation frame (or other callback result):
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.

Image

Re: NML House with check road position complete example??

Posted: 27 Oct 2021 15:16
by Eddi
temporal8 wrote: 27 Oct 2021 13:47(1): The == operator compares the values of two objects, in this code it compares the coord with the Tile_Class (Road) so nearby_tile_class( 0, -1) == TILE_CLASS_ROAD 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)
yes, but you're missing an important point here: what is the result of this comparison.
(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.
no, that is not the "important" difference. again, same as before: what are the possible result values.

Re: NML House with check road position complete example??

Posted: 27 Oct 2021 15:50
by temporal8
Eddi wrote: 27 Oct 2021 15:16
temporal8 wrote: 27 Oct 2021 13:47(1): The == operator compares the values of two objects, in this code it compares the coord with the Tile_Class (Road) so nearby_tile_class( 0, -1) == TILE_CLASS_ROAD 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)
yes, but you're missing an important point here: what is the result of this comparison.
(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.
no, that is not the "important" difference. again, same as before: what are the possible result values.
Perfect, i got it, thanks a lot for teaching me.