diff --git a/Server/src/main/core/game/system/command/sets/AnimationCommandSet.kt b/Server/src/main/core/game/system/command/sets/AnimationCommandSet.kt index d3861894e..0b3de8287 100644 --- a/Server/src/main/core/game/system/command/sets/AnimationCommandSet.kt +++ b/Server/src/main/core/game/system/command/sets/AnimationCommandSet.kt @@ -1,7 +1,9 @@ package core.game.system.command.sets import core.api.animate +import core.api.animateInterface import core.api.delayScript +import core.api.openInterface import core.api.queueScript import core.api.stopExecuting import core.game.interaction.QueueStrength @@ -84,6 +86,34 @@ class AnimationCommandSet : CommandSet(Privilege.ADMIN) { } } + /** Cycles animations on an interface child. */ + define("ianims", Privilege.ADMIN, "::ianims <(opt) Duration>", "Cycles animations on an interface child.") { player, args -> + if (args.size !in 4..6) { + reject(player, "Syntax error: ::ianims <(opt) Duration>") + } + + val interfaceId = args[1].toInt() + val childId = args[2].toInt() + val animationFrom = args[3].toInt() + val animationTo = args.getOrNull(4)?.toInt() ?: animationFrom + val animationDelay = (args.getOrNull(5) ?: "3").toInt() + var animationId = animationFrom + + openInterface(player, interfaceId) + + queueScript(player, 1, QueueStrength.SOFT) { + animateInterface(player, interfaceId, childId, animationId) + notify(player, "Playing interface animation $animationId on $interfaceId:$childId") + + if (animationId == animationTo) { + return@queueScript stopExecuting(player) + } + + animationId++ + return@queueScript delayScript(player, animationDelay) + } + } + /** * Force the player to loop animation */