-
Notifications
You must be signed in to change notification settings - Fork 11
Create a program
-
fr.B4D.program
contains the program API, you don't need to change the files to create a program. -
fr.B4D.programs.tutorials
contains all the tutorials. -
fr.B4D.programs.[category]
contains all the programs related to a specific category.
Here is a starter code for your first program :
package fr.B4D.programs;
public final class MyProgram extends Program{
public MyProgram(){
super(Place.Astrub, Category.Quete, "Sub-category", "Name", new Channel[] {Channel.PRIVATE, Channel.GENERAL}, Status.AVAILABLE);
}
@Override
public void intro(Person person) {
//Run once at the beginning
}
@Override
public void cycle(Person person) throws FullInventoryException, StopProgramException, CancelProgramException, B4DException {
//Run n times
}
@Override
public void outro(Person person) {
//Run once at the end
}
}
-
public final class MyProgram extends Program
: Inheritage from the super classProgram
which contains all the base for a working program. -
public MyProgram(...)
: Call the super class builder to create the object. Here are the parameters :-
Place.Astrub
: The program starts in Astrub. -
Category.Quete
: Categorised as a Quest. -
Sub-category
: Program sub-category name. -
Name
: Program name. -
new Channel[] {Channel.PRIVATE, Channel.GENERAL}
: Only private and general channels will be displayed. -
Status.AVAILABLE
: The available status will be enabled.
-
-
public void intro(Person person){...}
: Run once at the beginning. -
public void cycle(Person person){...}
: Run n times. -
public void outro(Person person){...}
: Run once at the end.
When the program is running, 4 types of Exceptions can occur:
-
FullInventoryException
: When the inventory of the player is full. The super class will automatically manage it regarding the defined settings. -
StopProgramException
: To stop the program cycle. Theoutro
method will be called. -
CancelProgramException
: To cancel the program. Theoutro
method will not be called. -
B4DException
: When an unknown error occurs.
For more details, refer to the JavaDoc or go check programs source codes.
In the Program.java
file under the fr.B4D.program
package. You have to add your program to the list by adding programs.add(new MyProgram())
.
You can check the to do programs list if you don't have any idea. Some programs cannot be done since the corresponding API doesn't exists yet.
In your program, you will probably have to use the APIs to interact, exchange, move...
B4D
Utilisation
Contribution