-
Notifications
You must be signed in to change notification settings - Fork 10
CustomTaskEvent
youyihj edited this page Jan 19, 2021
·
8 revisions
The event is used to define the checker and other logic of custom tasks.
It might be required to import the class to avoid errors.
import mods.zenutils.ftbq.CustomTaskEvent;
ChapterCompletedEvent extends IEventCancelable. That means all Methods and ZenGetters that are available for IEventCancelable are also available for ChapterCompletedEvent!
ZenGetter | ZenSetter | Type | Description |
---|---|---|---|
task | Task | ||
checker | ITaskChecker | ||
checkTimer | checkTimer | int | how many ticks is the checker function is called |
maxProgress | maxProgress | int | Max progress of this task |
enableButton | enableButton | bool | Enable checking on button click |
mods.zenutils.ftbq.ITaskChecker
This is a function with the following parameters (in this order).
- IPlayer player
- int currentProgress -> the current progress of the task
the function needs return an int representing the new progress of the task. If the new progress is equal to or bigger than maxProgress of task, the task is complete.
Besides the script, you need to add a custom task with a tag named test
.
import mods.zenutils.ftbq.CustomTaskEvent;
import crafttweaker.event.PlayerLoggedInEvent;
import crafttweaker.player.IPlayer;
events.onPlayerLoggedIn(function(event as PlayerLoggedInEvent) {
val player as IPlayer = event.player;
if (player.world.remote) return;
var n as int = 0;
if (player.data has "PlayerPersisted" && player.data.PlayerPersisted has "LoggedInCount") {
n = player.data.PlayerPersisted.LoggedInCount.asInt();
}
player.update({PlayerPersisted: {LoggedInCount: n + 1}});
});
events.onCustomTask(function(event as CustomTaskEvent) {
if (event.task.hasTag("test")) {
event.maxProgress = 10;
event.checkTimer = 100;
event.enableButton = false;
event.checker = function(player, currentProgress) {
if (player.data has "PlayerPersisted" && player.data.PlayerPersisted has "LoggedInCount") {
return player.data.PlayerPersisted.LoggedInCount.asInt();
} else {
return 0;
}
};
}
});
- GlobalFunctions
- ScriptReloading
- SuppressErrorPreprocessor
- HardFailPreprocessor
- OrderlyMap
- IData Deep Update
- Template String
- Native Method Access
- Mixin
- CrTI18n
- CrTUUID
- CrTItemHandler
- CrTLiquidHandler
- ILiquidTankProperties
- StringList
- HexHelper
- StaticString
- Catenation
- PersistedCatenation
- PlayerStat
- IStatFormatter
- GameRuleHelper
- ZenCommand
- ZenCommandTree
- ZenUtilsCommandSender
- IGetCommandUsage
- ICommandExecute
- IGetTabCompletion
- CommandUtils