Ok, I wrote up a solution myself after looking at the post from
http://forums.rpgmakerweb.com/index.php?/topic/2829-autotile-tile-ids/ I must say a big thank you to PK8 for doing all that homework!
This is a class for coders, it doesn't do anything visual, or anything with tiles themselves for that matter. It just took me all afternoon to write so I figured I'd share it in the interest of maybe saving others the effort. It's also probably really inefficient, since I was more concerned with making it work instead of making it fast.
Pass this class a tile id, and the id of all the 8 tiles around it, and it will return the auto-tile offset to add to the base id.
You can also get the base id of the tile in question by calling the second function(which it also uses internally for the first function).
Put the script above any code you white that needs to call on it, the object needs to exist for you to be able to call it.
Use permissions:
Use for any commercial or non-commercial RPG maker VX ace projects only. I'd appreciate credit to darkgriffin if you use this class, and please share a link to your game with me too!
Spoiler
=begin ####################################################### # $autotile_functions # by Dark Griffin ########################################################## # This object is referenced in any scripts after it by the # global object $autotile_functions ########################################################## Call the following to get this to return useful info: ############################################################### $autotile_functions.get_auto_offset(tile_id,n,ne,e,se,s,sw,w,nw) --- Passes back a calculated auto-tile offset for a passed in tile. Takes tile ids straight from the map, and can figure out a base auto tile from any autotile given to it. If the asked tile is an auto tile, returns 0 to 47. If the tile is not an auto tile, then the function simply returns 0, so tile formulas using the result as an addition in math don't need to worry about checking the type of tile. -------- tile_id - a tile passed in that needs to figure out it's autotile, the format is the same ids that the map system uses internally (the long ids, not the editor spacing) n,ne,e,se,s,sw,w,nw - the long ids of the tiles around the tile_id tile. ################################ $autotile_functions.find_index_from_tile(old_tile) --- Finds the original tile id of an auto tile(any tile from the game map, or unrounded tile numbers such as editor placed autotiles) Returns the original base autotile. If the tile is not an auto tile, the function passes back the original number that was handed to it. ------------ old_tile - an offset auto tile that we are trying to find the original for.=end################################### Class start##################################class DG_autotile_functions ################################## # get_auto_offset # Get correct offset for the tile based on the tile ID and the edges # tile_id = the id number of the original 00 autotile. # edges = ids of the four surrounding tiles. # This function should return a value between 0 and 47, which will offset # the tile to the correct autotile for the situation. ################################## def get_auto_offset(tile_id,north,northeast,east,southeast,south,southwest,west,northwest) # NOTE: for now, this doesn't support waterfalls. Those don't make good # walls anyway. #get the original tile id of the tile auto_tile = find_index_from_tile(tile_id) #get original for each direction, and if it matches or not onorth = find_index_from_tile(north) onortheast = find_index_from_tile(northeast) oeast = find_index_from_tile(east) osoutheast = find_index_from_tile(southeast) osouth = find_index_from_tile(south) osouthwest = find_index_from_tile(southwest) owest = find_index_from_tile(west) onorthwest = find_index_from_tile(northwest) #matching flags @n = false @ne = false @e = false @se = false @s = false @sw = false @w = false @nw = false #check if any match if(onorth == auto_tile) @n = true end if(onortheast == auto_tile) @ne = true end if(oeast == auto_tile) @e = true end if(osoutheast == auto_tile) @se = true end if(osouth == auto_tile) @s = true end if(osouthwest == auto_tile) @sw = true end if(owest == auto_tile) @w = true end if(onorthwest == auto_tile) @nw = true end #figure out the offset value of a tile, given the surrounding tiles. @ao = 0 #value for offset, by setting this to 0 we also make sure that # in the case of a non-auto tile, we pass back a 0. ################################################### #if tile is a normal autotile, set the directions if(auto_tile >= 2048) if(@n && @ne && @e && @se && @s && @sw && @w && @nw) #if center @ao = 0 end if(@n && @ne && @e && @se && @s && @sw && @w && !@nw) @ao = 1 end if(@n && !@ne && @e && @se && @s && @sw && @w && @nw) @ao = 2 end if(@n && !@ne && @e && @se && @s && @sw && @w && !@nw) @ao = 3 end if(@n && @ne && @e && !@se && @s && @sw && @w && @nw) @ao = 4 end if(@n && @ne && @e && !@se && @s && @sw && @w && !@nw) @ao = 5 end if(@n && !@ne && @e && !@se && @s && @sw && @w && @nw) @ao = 6 end if(@n && !@ne && @e && !@se && @s && @sw && @w && !@nw) @ao = 7 end if(@n && @ne && @e && @se && @s && !@sw && @w && @nw) @ao = 8 end if(@n && @ne && @e && @se && @s && !@sw && @w && !@nw) @ao = 9 end if(@n && !@ne && @e && @se && @s && !@sw && @w && @nw) @ao = 10 end if(@n && !@ne && @e && @se && @s && !@sw && @w && !@nw) @ao = 11 end if(@n && @ne && @e && !@se && @s && !@sw && @w && @nw) @ao = 12 end if(@n && @ne && @e && !@se && @s && !@sw && @w && !@nw) @ao = 13 end if(@n && !@ne && @e && !@se && @s && !@sw && @w && @nw) @ao = 14 end if(@n && !@ne && @e && !@se && @s && !@sw && @w && !@nw) @ao = 15 end if(@n && @ne && @e && @se && @s && !@sw && !@w && !@nw) @ao = 16 end if(@n && !@ne && @e && @se && @s && !@sw && !@w && !@nw) @ao = 17 end if(@n && @ne && @e && !@se && @s && !@sw && !@w && !@nw) @ao = 18 end if(@n && !@ne && @e && !@se && @s && !@sw && !@w && !@nw) @ao = 19 end if(!@n && !@ne && @e && @se && @s && @sw && @w && !@nw) @ao = 20 end if(!@n && !@ne && @e && !@se && @s && @sw && @w && !@nw) @ao = 21 end if(!@n && !@ne && @e && @se && @s && !@sw && @w && !@nw) @ao = 22 end if(!@n && !@ne && @e && !@se && @s && !@sw && @w && !@nw) @ao = 23 end if(@n && !@ne && !@e && !@se && @s && @sw && @w && @nw) @ao = 24 end if(@n && !@ne && !@e && !@se && @s && !@sw && @w && @nw) @ao = 25 end if(@n && !@ne && !@e && !@se && @s && @sw && @w && !@nw) @ao = 26 end if(@n && !@ne && !@e && !@se && @s && !@sw && @w && !@nw) @ao = 27 end if(@n && @ne && @e && !@se && !@s && !@sw && @w && @nw) @ao = 28 end if(@n && @ne && @e && !@se && !@s && !@sw && @w && !@nw) @ao = 29 end if(@n && !@ne && @e && !@se && !@s && !@sw && @w && @nw) @ao = 30 end if(@n && !@ne && @e && !@se && !@s && !@sw && @w && !@nw) @ao = 31 end if(@n && !@ne && !@e && !@se && @s && !@sw && !@w && !@nw) @ao = 32 end if(!@n && !@ne && @e && !@se && !@s && !@sw && @w && !@nw) @ao = 33 end if(!@n && !@ne && @e && @se && @s && !@sw && !@w && !@nw) @ao = 34 end if(!@n && !@ne && @e && !@se && @s && !@sw && !@w && !@nw) @ao = 35 end if(!@n && !@ne && !@e && !@se && @s && @sw && @w && !@nw) @ao = 36 end if(!@n && !@ne && !@e && !@se && @s && !@sw && @w && !@nw) @ao = 37 end if(@n && !@ne && !@e && !@se && !@s && !@sw && @w && @nw) @ao = 38 end if(@n && !@ne && !@e && !@se && !@s && !@sw && @w && !@nw) @ao = 39 end if(@n && @ne && @e && !@se && !@s && !@sw && !@w && !@nw) @ao = 40 end if(@n && !@ne && @e && !@se && !@s && !@sw && !@w && !@nw) @ao = 41 end if(!@n && !@ne && !@e && !@se && @s && !@sw && !@w && !@nw) @ao = 42 end if(!@n && !@ne && @e && !@se && !@s && !@sw && !@w && !@nw) @ao = 43 end if(@n && !@ne && !@e && !@se && !@s && !@sw && !@w && !@nw) @ao = 44 end if(!@n && !@ne && !@e && !@se && !@s && !@sw && @w && !@nw) @ao = 45 end if(!@n && !@ne && !@e && !@se && !@s && !@sw && !@w && !@nw) @ao = 46 end end ### end of normal autotile logic ### ####################################################################### ### If the tile is a wall or roof, overwrite what the normal autotiling # says to do with roof/wall logic instead. if(auto_tile >= 4352 && auto_tile < 8191) @ao = 0 if(@n && @e && @s && @w) @ao = 0 end if(@n && @e && @s && !@w) @ao = 1 end if(!@n && @e && @s && @w) @ao = 2 end if(!@n && @e && @s && !@w) @ao = 3 end if(@n && !@e && @s && @w) @ao = 4 end if(@n && !@e && @s && !@w) @ao = 5 end if(!@n && !@e && @s && @w) @ao = 6 end if(!@n && !@e && @s && !@w) @ao = 7 end if(@n && @e && !@s && @w) @ao = 8 end if(@n && @e && !@s && !@w) @ao = 9 end if(!@n && @e && !@s && @w) @ao = 10 end if(!@n && @e && !@s && !@w) @ao = 11 end if(@n && @e && !@s && !@w) @ao = 12 end if(@n && !@e && !@s && !@w) @ao = 13 end if(!@n && !@e && !@s && @w) @ao = 14 end if(!@n && !@e && !@s && !@w) @ao = 15 end end # end of wall/roof tile logic ############################################### #pass back offset to caller return @ao end # end of get_auto_offset ################################ find an original index of a tile based on the tile id############################### def find_index_from_tile(old_tile) # if the tile id is greater then 2048, then the tile is an autotile. if(old_tile >= 2048) # tile is an autotile # subtract to get just the tile id number new_tile_base_id = old_tile - 2048 #divmod to get the original autotile number new_tile_divmod = new_tile_base_id.divmod(48) base_tile = new_tile_divmod[0] # the original auto id is equal to 2048 + (48 * base_tile) org_auto = 2048 + (base_tile * 48) #auto_offset = new_tile_divmod[1] return org_auto else #tile is a normal tile, so it's id is also normal. new_tile = old_tile return new_tile end #end if old tile over 2048 end # end of find_index_from_tile ############################################# ##############################end # end of class################################################################################# spawn an instance of the class in memory on launch, so everything can call# on it later with $autotile_functions##################################################$autotile_functions = DG_autotile_functions.new()######## End of Script ##################
My question on a faster way to handle the directional solving of auto tiles still stands. As you can see, my method is quite slow. I'm sure there is some logic to how the auto tile offset ids work, but I haven't been able to solve it yet. It doesn't appear to be a simple offset to get the auto tile id of a given direction/pattern of tiles. Perhaps there simply isn't any logic and the only solution is to tediously check every possibility.