Last active
October 10, 2021 11:24
-
-
Save matt-dray/efb38f717fe560bb37166d31eb532255 to your computer and use it in GitHub Desktop.
Extract objects from locations in the pret/pokered disassembly (investigating base R v4.1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files <- list.files( | |
"~/Desktop/pokered-master/data/maps/objects", | |
pattern = ".asm$", | |
full.names = TRUE | |
) | |
object_names <- gsub(".asm", "", basename(files)) | |
locations <- lapply(files, function(x) readLines(x)) |> | |
setNames(object_names) | |
.get_objects <- function(lines = locations, loc = "PalletTown") { | |
warp <- lines[[loc]][grepl("\twarp", lines[[loc]])] | |
warp <- strsplit(gsub(" ", "", warp), ",") | |
warp <- unlist(lapply(warp, \(x) x[4])) | |
warp_df <- data.frame(location = loc, type = "warp", feature = warp) | |
obj <- lines[[loc]][grepl("\tobject", lines[[loc]])] | |
obj <- strsplit(gsub(",", "", obj), " ") | |
obj <- unlist(lapply(obj, \(x) x[2])) | |
obj_df <- data.frame(location = loc, type = "object", feature = obj) | |
rbind(warp_df, obj_df) | |
} | |
.get_objects() | |
.get_objects(loc = "AgathasRoom") | |
lapply(object_names[1:3], \(x) .get_objects(locations, x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment