Awesome Arrays - Container Arrays
I thought I'd make a more user friendly breakdown on what the additional plugin AwesomeArrays let's you do since the info in the plugin text itself is rather technical. I'll breakdown what each object type is & the important functions/methods you need to know to use them correctly. This time it's ContainerArrays.
ContainerArrays:
These are basically pyramid-style arrays. They allow you to create arrays within an array while maintaining the ability to access each asset like normal arrays. It utilizes key/value relationships like normal objects & hashes in other languages. Everything added to a sub-array also gets added to the base array for basic record keeping.
For example, if you make an array for cars, but also want to be able to group them further into different categories such as brands and/or colors, then you would likely have to create a base object instead or just multiple different arrays for the same objects. This allows you to instead keep everything together within a single array that still retains all of the benefits of being a JS Array type object. Let's see how.
Syntax: new ContainerArray(keyStrings)
The way I came up with to solve this problems is basically by piggybacking the nature of JS Arrays as JS Objects & assigning keys to them in the form of text options on the fly & using those to make additional arrays. The important thing to know is just that it works tbh so I won't go deeper than that in the explanation.
var cars = new ContainerArray('red', 'blue', 'green');
This basically gives you an object in which "cars" itself is an array, meanwhile, "cars.red" is an array as well as "cars.blue" & "cars.green".
var cars = new ContainerArray(); //This is also valid
You can then define work with each value as an individual array as well as using my built in functions which I'll break down a bit now. We'll continue using the "cars" ContainerArray in most of the examples.
Initialize Function
If you need to suddenly redefine the internal arrays it's as easy as... ContainerArray.initialize('key1', 'key2', 'key3')
cars.initialize('honda', 'ford'); //cars, cars.honda, & cars.ford are now valid array objects
cars.initialize(); //cars is an array but has no sub/child arrays at first
Both of the above functions are valid.
AddKey(s) Function
You're not limited to only adding keys at object creation. I provide 2 methods for defining new ones later.
To add a single key... ContainerArray.addKey(string)
cars.addKey('white');
To add multiple keys... ContainerArray.addKeys(keyStrings)
car.addKeys('white', 'black', 'brown')
Add Function
This function lets you add objects/value to certain keys/categories while also adding them to the base array for overall management. Syntax: ContainerArray.add(keyString, values)
var car1 = new Car();
var car2 = new Car();
var car3= new Car();
cars.add('red', car1, car2); //cars.red => [car1, car2]
cars.add('green', car3); //cars.green => [car3]
The thing to note is the the key must already exist within the ContainerArray or it won't work. Also, keep in mind that anything added to a sub-array is also added to the base array at the same time so "console.log(cars)" would yield "[car1, car2, & car3]". Adding or assigning values with using the add function such as by using "cars.red.push(car1)" would not allow 'car1' to be automatically added to "cars" as well so it's better to use the "add" function unless you don't want that to happen for whatever reason.
Remove Function
This function lets you remove objects/values from certain keys/categories while also removing them from the base array. Syntax: ContainerArray.remove(keyString, values)
cars.remove('red', car1); //cars.red => [car2]
This also means... console.log(cars) => [car2, car3].
Search Function
This function lets you search for either an entire sub-array/category or a specific object within one. Syntax: ContainerArray.search(keyString, index)
Providing just the keyString value will return an array is the key already exists.
cars.search('red') => red cars
This is the same as... cars.red
Providing an index as will let you specify a specific object.
cars.search('red', 0) => first red car //same as cars.red[0]
cars.search('green', 2) => third green car //same as cars.green[2]
The search & add functions are mainly ascetic & for those who wouldn't know other ways to do those things.
Get Hover Display Plugin for RPG Maker MV
Hover Display Plugin for RPG Maker MV
Display formatted text on hover
Status | Released |
Category | Assets |
Author | Kingpin RBD |
Tags | hover, hover-display, hover-text, plugin, rmmv, RPG Maker, RPG Maker MV |
More posts
- Updated Hover Display v1.1.3Dec 16, 2022
- Updated Awesome Arrays v1.3.3Dec 16, 2022
- Awesome Arrays - TextBuffersAug 08, 2022
- Updated Awesome Arrays v1.3.2Aug 08, 2022
- Awesome Arrays - Deep ArraysJul 31, 2022
Leave a comment
Log in with itch.io to leave a comment.