diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt index 13d1c140..ac5e6569 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt @@ -672,6 +672,21 @@ class Starbound : ISBFileLocator { 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.load(polyfill, "@starbound.jar!/scripts/polyfill.lua") diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/MaterialModifier.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/MaterialModifier.kt index af8a030d..2746e84a 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/MaterialModifier.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/MaterialModifier.kt @@ -14,8 +14,8 @@ data class MaterialModifier( val modId: Int, val modName: String, val itemDrop: String? = null, - val health: Int = 0, - val harvestLevel: Int = 0, + val health: Double = 0.0, + val harvestLevel: Double = 0.0, val breaksWithTile: Boolean = true, val grass: Boolean = false, val miningParticle: String? = null,