root.materialHealth

This commit is contained in:
DBotThePony 2023-04-10 19:10:05 +07:00
parent b311c8516b
commit 11d73a6fd5
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 17 additions and 2 deletions
src/main/kotlin/ru/dbotthepony/kstarbound

View File

@ -672,6 +672,21 @@ class Starbound : ISBFileLocator {
1 1
} }
state.setTableFunction("materialHealth", this) { args ->
val name = args.getString()
val mod = if (args.hasSomethingAt()) args.getString() else null
val mat = tiles[name] ?: throw NoSuchElementException("No such material $name")
if (mod == null) {
args.push(mat.value.health)
} else {
val getMod = tileModifiers[mod] ?: throw NoSuchElementException("No such material modifier $mod")
args.push(getMod.value.health + mat.value.health)
}
1
}
state.pop() state.pop()
state.load(polyfill, "@starbound.jar!/scripts/polyfill.lua") state.load(polyfill, "@starbound.jar!/scripts/polyfill.lua")

View File

@ -14,8 +14,8 @@ data class MaterialModifier(
val modId: Int, val modId: Int,
val modName: String, val modName: String,
val itemDrop: String? = null, val itemDrop: String? = null,
val health: Int = 0, val health: Double = 0.0,
val harvestLevel: Int = 0, val harvestLevel: Double = 0.0,
val breaksWithTile: Boolean = true, val breaksWithTile: Boolean = true,
val grass: Boolean = false, val grass: Boolean = false,
val miningParticle: String? = null, val miningParticle: String? = null,