Package: avulto
AvultoAvultois a Python library for working in the BYOND environment. Its goal is
to provide a straightforward Python API which leverages theSpacemanDMMand
potentially other community libraries.Its primary use cases are to easilyread and modify map filesparse and read icon filesread the source tree and provide reflection data.UsageAvulto is available as areleaseon PyPI. See theDevelopmentsection
below for directions on using the library locally.Avulto's API is documented in full in itsstub file, but the
most important parts of its API are below.PathPathwraps type paths and providesparent_of(other, strict=False)andchild_of(other, strict=False)for comparing paths. Whenstrict, the current
path does not count as a parent or child of itself.It also supports the division
operator for easy path suffixing.fromavultoimportPathasp>>>p('/obj/machinery').parent_of('/obj/machinery/oven')True>>>p('/turf').child_of('/turf',strict=True)False>>>p('/obj/machinery')/'microwave'/obj/machinery/microwaveDMMTheDMMclass allows parsing and manipulation of map files.MethodDescriptionfrom_file(filename)Creates aDMMfrom the givenfilename.save_to(filename)Saves theDMMto the givenfilename.coords()Return an iterator over all possible 3D coordinates.tiles()Return an iterator over all uniqueTiles on the map.tiledef(x, y, z)Returns theTileat the given coordinates.extentsThe maximum size of the map's dimensions.Tileobjects returned fromDMM.tiles()andDMM.tiledef(x, y, z)have the
following API:MethodDescriptionarea_path()Returns the tile's area.turf_path()Returns the tile's turf.convert()Provide a Python representation of all tile prefabs.Inspecting and manipulating prefabs on a tile is performed on the prefab's index:MethodDescriptionfind(prefix)Return the indexes of all the prefabs on the tile with the givenprefix.prefab_path(index)Return the path of the prefab atindex.prefab_vars(index)Return the list of var names atindex.prefab_var(index, name)Return the value of the varnameatindex.set_prefab_var(index, name, val)Set the value of the varnameatindextoval.set_path(index, path)Set the path of the prefab atindextopath.add_path(index, path)Add a prefab with the givenpathatindex.del_prefab(index)Deletes the prefab atindex.del_prefab_var(index, name)Deletes the varnamefrom the prefab atindex.Note that the mutative functions above currently apply to the preset, not the
individual tile. Future releases will hopefully provide a way to do both.DMETheDMEclass allows parsing DM object code:MethodDescriptionfrom_file(filename)Creates aDMEfrom the given.dmefile.paths_prefixed(prefix)Returns a list of paths with the givenprefix, includingprefixif it exists.typedecl(path)Returns aTypeDeclof the objectpath.TypeDeclobjects allow variable inspection:MethodDescriptionprocnames()Returns a list of proc names for the type declaration.varnames()Returns a list of variable names for the type declaration.value(name)Return a Python representation of the variablename.DMITheDMIclass allows parsing icon files.MethodDescriptionfrom_file(filename)Creates aDMEfrom the given.dmefile.state_names()Return a list of strings containing all state names in the file.state(name)Returns theIconStatewith the givenname.data_rgba8(rect)Returns the image data for the given rect in RGBA8 bytes.IconStateobjects allow icon state inspection:MethodDescriptionname()The icon state name.delays()The delay per frame, in ticks.dirs()The directions available in the icon state.frames()The number of frames in the state.movement()Whether the icon state is a movement state.rewind()Whether the state rewinds on animation.rect(dir, frame)The Rect of the given frame and direction in the file.UsingPillow, the image data for a given icon can quickly be turned into anImageobject and easily manipulated:>>>fromavultoimportDMI,Dir>>>fromPILimportImage>>>dmi=DMI.from_file("/SS13/icons/objects/weapons.dmi")>>>pistol=dmi.state("pistol")>>>pistol_rect=pistol.rect(Dir.SOUTH,frame=0)>>>pistol_data=dmi.data_rgba8(pistol_rect)>>>image=Image.frombytes("RGBA",size=(pistol_rect.width,pistol_rect.height),data=pistol_data)DevelopmentAvulto is written in Rust and implemented usingPyO3, and usesmaturinfor development. To build and install
locally:$python-mmaturinbuild;python-mpipinstall.
$python-mpytestPlanned DevelopmentMore DMI icon data.Getting image data directly through SpacemanDMM.Better errors and consistent API surface area.More reflection data, including method names.LicenseAvulto is licensed under the GPL. SeeLICENSEfor more information.AcknowledgementsPortions of Avulto are originally based onSpacemanDMM, copyright Tad
Hardesty and licensed under the GPL.Portions of Avulto are originally based onStrongDMM, copyright SpaiR and licensed
under the GPL.