ActualMusic API

From Embassy Wiki
Jump to: navigation, search

Though not yet completed, the API for ActualMusic is nearly finished and in a state that it can be released for mod authors to include in their projects. The API is very simple, but it will be fully described in this section. As it's not finished yet it is completely untested, so don't panic if you can't get it to work.


Download the API and extract it to the source folder of your project. It's that simple!


The Basics

At any time BEFORE post-init of your mod create an instance of net.fokson.actualmusic.api.API, passing a friendly version of your mod's name as its parameter. You can then call the method registerTrigger(...) from the API instance for each of the triggers you want to add to ActualMusic. Once all your triggers are registered, call net.fokson.actualmusic.api.API.registerAPI(...), passing your API instance as the parameter. That's all there is to it!

Register Trigger


apiInstance.registerTrigger( <triggerName>, <field>, <object>, <priority> );

TriggerName: This is the name of the trigger you're registering, and as such will be ( along with the mod name you passed the API instance ) what a songpack author names the song file for your trigger. For example, for a mod named Rescue and a trigger named Injured, the song's filename would be RescueInjured. This can be left as an empty string, but it isn't recommended unless you're only planning on having a single trigger in your mod that should simply be named after your mod.

Field: This is a boolean field that stores the state of your trigger. If the field is true, the trigger is set. If false, the trigger is unset. You acquire the field like this:

SomeClassName.class.getField( "booleanFieldName" )

Object: This is the object instance that stores the boolean field. This can't be null, and the field can't be static.

Priority: This is one of the following: HIGHEST, HIGHER, HIGH, NORMAL, LOW, LOWER, LOWEST. Refer to the trigger priority list in the ActualMusic Reference Guide to see where they fall in.