diff --git a/tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/lua/MapLib.kt b/tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/lua/MapLib.kt index fdcfe715..89de582a 100644 --- a/tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/lua/MapLib.kt +++ b/tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/lua/MapLib.kt @@ -57,14 +57,21 @@ class MapLib(private val resourceAccess: GameResourceAccess, private val spriteS @TinyFunction("Set the current level to use.") inner class level : OneArgFunction() { + @TinyCall("Return the index of the current level.") + override fun call(): LuaValue { + return super.call() + } + @TinyCall( "Set the current level to use. " + "The level can be an index or the id defined by LDTK. " + "Return the previous index level.", ) override fun call(@TinyArg("level") arg: LuaValue): LuaValue { + if (arg.isnil()) return valueOf(currentLevel) + val prec = currentLevel - currentLevel = if (arg.isstring()) { + currentLevel = if (!arg.isnumber()) { var index = 0 var found = false var level = resourceAccess.level(index)