-
Notifications
You must be signed in to change notification settings - Fork 124
Using code in modules
Code modules are relatively new and the API is still subject to change. Any details specified here may change at any time, so use this as a broad reference only.
Placeholder page to fill out now that https://github.com/MovingBlocks/DestinationSol/pull/381 has been merged! The PR itself is sufficiently well documented to point out a lot of the involved details, partly we need to take some of that and place it here :-)
See also https://github.com/DestinationSol/Warp as the first code-bearing DS module.
Modules in Destination Sol are sandboxed. Their code is limited to using a small list of approved classes. Additional classes can be marked as accessible using the @API
annotation. The full list used is here but essentially this means:
- No network communication
- No direct filesystem access
- No object serialisation
- Very limited reflection
- No runtime class loading
- No
java.date
classes
If a class you need is missing from the list, feel free to request its addition.
The main entry point to code modules right now is UpdateAwareSystem
. Classes that implement UpdateAwareSystem
and are annotated with @RegisterUpdateSystem
will have their update(SolGame, float)
method invoked once per game loop. The classes must have a parameterless constructor.
By using the SolGame
object provided, you can access most of the functionality of the game.
package org.destinationsol.codeModuleTest;
import org.destinationsol.game.SolGame;
import org.destinationsol.game.UpdateAwareSystem;
import org.destinationsol.game.attributes.RegisterUpdateSystem;
@RegisterUpdateSystem
public class PlayTimeUpdateSystem implements UpdateAwareSystem {
private float totalPlayTime;
public PlayTimeUpdateSystem() {
}
@Override
public void update(SolGame game, float timeStep) {
// Implement game logic here...
totalPlayTime += timeStep;
}
}
- Warp
- @BenjaminAmos's codeModuleTest
See Creating Commands for more information.
See [Creating Abilities)(Creating-Abilities) for more information.
See Creating NUI Screens for more information.
See the following sections: