mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 11:34:05 +09:00
trying to load a world
This commit is contained in:
@@ -37,22 +37,26 @@ object ExportMeta : ConsoleCommand {
|
||||
|
||||
object ExportWorld : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
try {
|
||||
val world = Terrarum.ingame!!.world
|
||||
val str = WriteWorld(Terrarum.ingame!! as TerrarumIngame).invoke()
|
||||
val writer = java.io.FileWriter(AppLoader.defaultDir + "/Exports/world${world.worldIndex}.json", false)
|
||||
writer.write(str)
|
||||
writer.close()
|
||||
Echo("Exportworld: exported to world${world.worldIndex}.json")
|
||||
if (args.size == 2) {
|
||||
try {
|
||||
val str = WriteWorld(Terrarum.ingame!! as TerrarumIngame).invoke()
|
||||
val writer = java.io.FileWriter(AppLoader.defaultDir + "/Exports/${args[1]}", false)
|
||||
writer.write(str)
|
||||
writer.close()
|
||||
Echo("Exportworld: exported to ${args[1]}")
|
||||
}
|
||||
catch (e: IOException) {
|
||||
Echo("Exportworld: IOException raised.")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
catch (e: IOException) {
|
||||
Echo("Exportworld: IOException raised.")
|
||||
e.printStackTrace()
|
||||
else {
|
||||
ImportWorld.printUsage()
|
||||
}
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo("Usage: Exportworld")
|
||||
Echo("Usage: Exportworld filename.json")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.torvald.terrarum.modulebasegame.console
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-20.
|
||||
@@ -11,7 +10,7 @@ import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
internal object GetTime : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
|
||||
val worldTime = (Terrarum.ingame!!.world as GameWorldExtension).worldTime
|
||||
val worldTime = (Terrarum.ingame!!.world).worldTime
|
||||
Echo(worldTime.getFormattedTime())
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package net.torvald.terrarum.modulebasegame.console
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package net.torvald.terrarum.modulebasegame.console
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.serialise.ReadWorld
|
||||
import net.torvald.terrarum.serialise.WriteMeta
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2021-08-25.
|
||||
*/
|
||||
object ImportWorld : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
try {
|
||||
val reader = java.io.FileReader(AppLoader.defaultDir + "/Exports/${args[1]}")
|
||||
ReadWorld(Terrarum.ingame!! as TerrarumIngame).invoke(reader)
|
||||
Echo("Importworld: imported a world from ${args[1]}")
|
||||
}
|
||||
catch (e: IOException) {
|
||||
Echo("Importworld: IOException raised.")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
else {
|
||||
printUsage()
|
||||
}
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo("Usage: Importworld filename.json")
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
*/
|
||||
internal object SetTime : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val world = (Terrarum.ingame!! as TerrarumIngame).gameworld
|
||||
val world = (Terrarum.ingame!! as TerrarumIngame).world
|
||||
|
||||
|
||||
if (args.size == 2) {
|
||||
|
||||
@@ -13,7 +13,7 @@ internal object SetTimeDelta : ConsoleCommand {
|
||||
val HARD_LIMIT = 60
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
val world = (Terrarum.ingame!! as TerrarumIngame).gameworld
|
||||
val world = (Terrarum.ingame!! as TerrarumIngame).world
|
||||
|
||||
|
||||
if (args.size == 2) {
|
||||
|
||||
Reference in New Issue
Block a user