A library that makes automating events in ADOFAI levels more convenient.
Project description
This is a library that makes automating events in ADOFAI levels more convenient.
List of Classes:
LevelDict
-
Initalize with
LevelDict.filename : str
- The filename of the file from which the
LevelDict
was obtained. LevelDict.encoding : str
- The encoding of the file from which the
LevelDict
was obtained. LevelDict.nonFloorDecos : list[Decoration]
- A list of all decorations in the level that are not tied to any particular tile.
LevelDict.settings : Settings
- The level settings, as a Settings object.
LevelDict.tiles : list[Tile]
- A list of all tiles in the level. (See
Tile
class) LevelDict.appendTile(angle : float) -> None:
- Adds a single tile to the end of the level.
LevelDict.appendTiles(angles : list[float]) -> None:
- Adds a list of tiles to the end of the level.
LevelDict.insertTile(angle : float, index : int) -> None:
- Adds a single tile to the level before the specified index.
LevelDict.insertTiles(angles : list[float], index : int) -> None:
- Adds a list of tiles to the level before the specified index.
LevelDict.getAngles() -> list[float]:
- Returns a list of angles for each tile.
LevelDict.setAngles(angles: list[float]) -> None:
- Writes a list of angles to angleData. The list is truncated if it's too big, and the track is truncated if the list is too small.
LevelDict.getAnglesRelative(ignoretwirls: bool=False) -> list[float]
- Gets a list of relative angles (degrees between each pair of tiles.) Twirls are taken into account by default. To disable this, set ignoretwirls to True. Midspins are always taken into account.
LevelDict.setAnglesRelative(angles: list[float]) -> None
- Sets a list of relative angles (degrees between each pair of tiles.)
LevelDict.addAction(event : Action) -> int:
- Adds the given action to the level. Returns the index of the event within the tile.
LevelDict.addAction(event : Action) -> int:
- Adds the given action to the level. Returns the index of the event within the tile.
LevelDict.addDecoration(event : Decoration) -> int:
- Adds the given decoration to the level. Returns the index of the event within the tile / within the list of non-floor decorations.
LevelDict.getActions(condition : Callable) -> list[Action]:
- Returns a list of actions in the level that meet the given condition. Returns a list of all actions if condition is not specified.
LevelDict.getDecorations(condition : Callable) -> list[Decoration]:
- Returns a list of decorations in the level that meet the given condition. Returns a list of all decorations if condition is not specified.
LevelDict.removeActions(condition : Callable) -> list[Action]:
- Removes all actions in the level that meet the given condition. Returns a list of removed actions.
LevelDict.removeDecorations(condition : Callable) -> list[Decoration]:
- Removes all decorations in the level that meet the given condition. Returns a list of removed decorations.
LevelDict.popAction(tile, index) -> Action:
- Removes the action at the specified tile at the specified index. Returns the event.
LevelDict.popDecoration(tile, index) -> Decoration:
- Removes the decoration at the specified tile at the specified index. Returns the event.
LevelDict.replaceFieldAction(condition : Callable, field : str, new) -> None:
- Changes the value of "field" to "new" in all actions that meet the given condition.
LevelDict.replaceFieldDecoration(condition : Callable, field : str, new) -> None:
- Changes the value of "field" to "new" in all decorations that meet the given condition.
LevelDict.writeDictToFile(leveldict : dict, filename : str):
- Writes the given dictionary to the specified file. Overwrites the original file if filename is not specified.
Use this if you are working withLevelDict.leveldict
. LevelDict.writeToFile(filename : str=None) -> None:
- Writes the level to the specified file. Overwrites the original file if filename is not specified.
LevelDict(filename, encoding)
(encoding is optional, default is utf-8-sig)Settings
Part of a LevelDict object. The properties of this class are equivalent to the parameters in the
settings
field of a .adofai file.
Tile
A list of Tiles is contained within a LevelDict object.
Tile.angle : float
- The angle that the tile points towards (0 degrees is facing right, 90 degrees is facing upwards)
Tile.actions : list[Action]
- A list of actions which are present on that particular tile.
Tile.decorations : list[Decoration]
- A list of decorations which are present on that particular tile.
Action
An event that goes on a tile (one with a purple icon). An
Action
object behaves like a dict
. The keys depend on the event type. Check any entry in the actions
field of a .adofai file for more information on the fields used by that event type.
Action objects are found in a list of actions in a
Tile
object.
Decoration
A decoration, object decoration, or text decoration (anything found in the decorations menu on the left sidebar). A
Decoration
object behaves like a dict
. The keys depend on the event type. Check any entry in the decorations
field of a .adofai file for more information on the fields used by that event type.
Decoration objects are found in a list of decorations in a
Tile
object. If the decoration is not tied to any tile, it is found in the list of non-floor decos.
Changelog
3.1.0 (2024/05/20)
- Major update and bugfixes
- Added
getAngles()
andsetAngles()
- Added
getAnglesRelative()
andsetAnglesRelative()
, with options to take twirls/midspins into account tiles
list is now type-check friendly- Updated
Settings
class - Added support for levels that use
pathData
- Fixed
writeToFile()
no longer working (again) - Fixed typos in
_getFileString()
and_getFileDict()
- Cleaned up some errors in README.md
- Version number is no longer out of sync
3.0.3 (2024/03/18)
- Minor bugfixes
- Fixed
writeToFile()
no longer working - Replaced
json.dumps()
with fasterjson.dump()
inwriteToFile()
- Known issue: version number is out of sync
3.0.1 (2023/12/02)
- Minor bugfix
- Fixed markdown bug on README and CHANGELOG
- Removed unnessecary files
3.0.0 (2023/12/01)
- Major update
- Completely overhauled file structure to use a class-based system
- Too much to list! Read the docs for more info
2.0.3 (2023/09/23)
- Minor bugfixes
- Fixed
addEvent()
not detectingaddObject
andaddText
events - Fixed
removeEvents()
not modifyingleveldict
- Fixed typo in
replaceField()
- Added logo to README
2.0.2 (2023/09/03)
- Minor bugfix
- Fixed markdown bug on README and CHANGELOG for real this time
2.0.1 (2023/09/03)
- Minor bugfix
- Fixed markdown bug on README and CHANGELOG (hopefully)
2.0.0 (2023/09/03)
- Major update
- Completely overhauled file reading to use dictionaries instead of strings
- Added
getFileDict()
- Added 3 new utility functions:
searchEvents()
,removeEvents()
andreplaceField()
getAngles()
,setAngles()
and all event functions are now deprecated- Updated documentation
- README and CHANGELOG now uses markdown
0.1.1 (2023/07/17)
- Minor bugfixes
- Fixed encoding incompatibility
- Fixed output string for
moveDecorations()
0.1.0 (2023/06/15)
- Minor update
- Added dynamic pivot offset, parallax offset, masking and blending fields to
addDecoration()
andmoveDecorations()
- Added angleOffset to
setSpeed()
0.0.3 (2023/06/14)
- Minor bugfix: fixed filename
__init__.py
0.0.2 (2023/06/13)
- Minor bugfix:
're'
is no longer a dependency
0.0.1 (2023/05/28)
- First Release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
adofaipy-3.1.0.tar.gz
(9.2 kB
view details)
File details
Details for the file adofaipy-3.1.0.tar.gz
.
File metadata
- Download URL: adofaipy-3.1.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd93c9a372372b302c3b84195c61c00abd2e236898a1074816748f39b07b74b0 |
|
MD5 | f2e4d183b0455a7d62581e38b675050c |
|
BLAKE2b-256 | f254c5a1e284cdb3a4f33ba653f1a029413b5cdc8ec7ab57d7432d582208b6fd |