-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Dandelion uses JSON to read custom particles. The only files that will be read are data/dandelion/particles.json and data/dandelion/emitters.json. Add to these to implement new particles.
Particles and emitters can be spawned by running dandelion.<particle_name>, where particle name is identical to the one you provide in JSON. Particle names are lowercase. Names will be converted to lowercase from JSON.
Caution
Writing invalid JSON will cause Usagi to crash on startup. Make sure your IDE supports JSON!
Dandelion allows some values to be replaced with chunks (i.e. an expression which must be evaluated). Fields that allow chunks will be labeled in cheat sheets. Fields that do not allow chunks cannot receive chunks, and will throw an error if one is provided. A chunk must return the same value as the one the field expects.
Chunks run in the global environment; they only have access to global variables, not local ones. This means that libraries like math and util are available to use, but variables initialized using the local keyword will not be.
An additional table is passed to expressions, self, which is a reference to the table that represents the particle or emitter. For example, self.age will evaluate to the number of seconds since the particle was created. Particles may also have a second reference passed to them, emit, which is a reference to the emitter that created that particle. Particles do not have to created by an emitter, so always include an alternative when checking an emit field (ex. emit.age or 1).
Note
This DOES mean that you can call functions from ANY object available from the global environment. Putting usagi.quit() in one of your chunks will quit the game when that particle is rendered.