mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
Former-commit-id: 851e141fc91b170190d6027f42f59906dda0f31f Former-commit-id: 03dbb9da1788e1c50e84ae33d95f76194ad9a08d
31 lines
896 B
Kotlin
31 lines
896 B
Kotlin
package net.torvald.terrarum.console
|
|
|
|
import net.torvald.terrarum.gameworld.WorldTime
|
|
import net.torvald.terrarum.Terrarum
|
|
|
|
/**
|
|
* Created by minjaesong on 16-03-20.
|
|
*/
|
|
internal object SetTime : ConsoleCommand {
|
|
override fun execute(args: Array<String>) {
|
|
if (args.size == 2) {
|
|
val timeToSet = WorldTime.parseTime(args[1])
|
|
|
|
Terrarum.ingame.world.time.setTime(timeToSet)
|
|
|
|
Echo("Set time to ${Terrarum.ingame.world.time.elapsedSeconds} " +
|
|
"(${Terrarum.ingame.world.time.hours}h${formatMin(Terrarum.ingame.world.time.minutes)})")
|
|
}
|
|
else {
|
|
printUsage()
|
|
}
|
|
}
|
|
|
|
private fun formatMin(min: Int): String {
|
|
return if (min < 10) "0${min.toString()}" else min.toString()
|
|
}
|
|
|
|
override fun printUsage() {
|
|
Echo("usage: settime <39201-in sec or 13h32-in hour>")
|
|
}
|
|
} |