com.lop.devtools.monstera.files.animcontroller.AnimControllerVariables.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of monstera Show documentation
Show all versions of monstera Show documentation
A library and environment designed to streamline the development of Minecraft addons.
package com.lop.devtools.monstera.files.animcontroller
import com.lop.devtools.monstera.addon.api.MonsteraFile
import com.lop.devtools.monstera.addon.api.MonsteraUnsafeMap
import com.lop.devtools.monstera.addon.molang.Molang
import com.lop.devtools.monstera.addon.molang.Variable
class AnimControllerVariables: MonsteraFile {
override val unsafe = Unsafe()
inner class Unsafe: MonsteraUnsafeMap {
val general = mutableMapOf()
override fun getData() = general
fun getAsList(): List {
return general.map { (k, v) -> "$k=$v;" }
}
}
fun set(name: String, value: String) {
val variable = if (name.startsWith("variable.") || name.startsWith("temp.") || name.startsWith("v.")) {
name
} else {
"variable.$name"
}
unsafe.general[variable] = value
}
fun set(name: String, exp: Molang) {
set(name, exp.toString())
}
fun set(value: Variable) {
val (k, v) = value.data.dropLastWhile { it == ';' }.split("=")
unsafe.general[k] = v
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy