Thought i would share my database object.
construct.net/en/make-games/addons/1513/data-container
I always seem to end up using invisible sprite objects to store and organise data because it's so easy to manage using Construct's picking system, but it has its issues.
So i decided to create my own database object that emulates Construct's picking behaviour, but with more options.
quick example
DataContainer → Add file "Sword"
DataContainer → Set file's "damage" to 10 for file "Sword"
DataContainer → Set file's "rarity" to "common" for file "Sword"
DataContainer → Pick highest "damage" → Sub-event: Text Set text to CurFileName & ": " & CurProperty("damage")
ACEs Overview
All ACEs are under the Container category. Here's the full list:
Conditions (Picking, Looping, Checks, Triggers)
File exists {0}: True if the file exists.
Pick file {0}: Picks a specific file by name (sets as current).
Pick file with highest {0}: Picks the file with the max value for a property.
Pick file with lowest {0}: Picks the file with the min value for a property.
Pick random file: Picks a random file.
Pick weighted random file with highest {0}: Random pick weighted by property (higher = more likely; negatives/0 = equal chance).
Pick weighted random file with lowest {0}: Random pick weighted inversely (lower/negatives = more likely).
Pick last created file: Picks the most recently added file.
Pick all files: Resets to select all files.
Pick files where {0} {1} {2}: Picks files matching a property comparison (=, >, <, >=, <=, !=).
For each file: Loops over all (or picked) files.
For each file ordered randomly: Loops in random order.
For each file ordered descending {0}: Loops highest-to-lowest by property.
For each file ordered ascending {0}: Loops lowest-to-highest by property.
For each file alphabetically ascending: Loops A-Z by filename.
For each file alphabetically descending: Loops Z-A by filename.
For each file weighted random highest {0}: Loops in weighted random order (higher prop first).
For each file weighted random lowest {0}: Loops in weighted random order (lower prop first).
On file added {0}: Triggers when a file is added.
On file deleted {0}: Triggers when a file is deleted.
On property changed {0} {1}: Triggers on single-file changes (or "all files" if file is empty).
On any change: Triggers on any data modification.
Actions (Data Manipulation)
Add file {0}: Adds a new empty file.
Add property {0}: Adds a property (with null value) to all files.
Set file's {1} to {2} for file {0}: Sets a property in a specific file (creates if missing).
Set all files' {0} to {1}: Sets a property across all files (creates if missing; triggers "all" change event).
Delete file {0}: Removes a file.
Delete property {0}: Removes a property from all files.
Clear all: Wipes all files and properties.
Load from JSON {0}: Replaces data with parsed JSON string.
Download to JSON file {0}: Downloads current data as a .json file.
Expressions (Data Access)
CountFiles: Number of files.
CurFileName: Name of the current file (in loops/picks).
CurProperty({0}): Value of a property on the current file ("" if missing).
FileProperty({0}, {1}): Value of a property on a specific file ("" if missing).
AsJSON: Entire container as a JSON string.