root.liquidStatusEffects
This commit is contained in:
parent
6a39ed7f56
commit
c67c2095a0
@ -71,6 +71,7 @@ import ru.dbotthepony.kstarbound.util.ItemStack
|
|||||||
import ru.dbotthepony.kstarbound.util.PathStack
|
import ru.dbotthepony.kstarbound.util.PathStack
|
||||||
import ru.dbotthepony.kstarbound.util.SBPattern
|
import ru.dbotthepony.kstarbound.util.SBPattern
|
||||||
import ru.dbotthepony.kstarbound.util.WriteOnce
|
import ru.dbotthepony.kstarbound.util.WriteOnce
|
||||||
|
import ru.dbotthepony.kstarbound.util.filterNotNull
|
||||||
import ru.dbotthepony.kstarbound.util.set
|
import ru.dbotthepony.kstarbound.util.set
|
||||||
import ru.dbotthepony.kstarbound.util.traverseJsonPath
|
import ru.dbotthepony.kstarbound.util.traverseJsonPath
|
||||||
import ru.dbotthepony.kvector.vector.nint.Vector2i
|
import ru.dbotthepony.kvector.vector.nint.Vector2i
|
||||||
@ -224,6 +225,13 @@ class Starbound : ISBFileLocator {
|
|||||||
add(species::get)
|
add(species::get)
|
||||||
add(statusEffects::get)
|
add(statusEffects::get)
|
||||||
add(particles::get)
|
add(particles::get)
|
||||||
|
add(questTemplates::get)
|
||||||
|
add(techs::get)
|
||||||
|
add(jsonFunctions::get)
|
||||||
|
add(json2Functions::get)
|
||||||
|
add(npcTypes::get)
|
||||||
|
add(projectiles::get)
|
||||||
|
add(tenants::get)
|
||||||
})
|
})
|
||||||
|
|
||||||
registerTypeAdapter(LongRangeAdapter)
|
registerTypeAdapter(LongRangeAdapter)
|
||||||
@ -539,6 +547,22 @@ class Starbound : ISBFileLocator {
|
|||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.setTableFunction("liquidStatusEffects", this) { args ->
|
||||||
|
val liquid: LiquidDefinition
|
||||||
|
|
||||||
|
if (args.isStringAt()) {
|
||||||
|
val name = args.getString()
|
||||||
|
liquid = this.liquid[name]?.value ?: throw NoSuchElementException("No such liquid with name $name")
|
||||||
|
} else {
|
||||||
|
val id = args.getInt()
|
||||||
|
liquid = this.liquidByID[id]?.value ?: throw NoSuchElementException("No such liquid with ID $id")
|
||||||
|
}
|
||||||
|
|
||||||
|
args.lua.pushStrings(liquid.statusEffects.stream().map { it.value?.value?.name }.filterNotNull().toList())
|
||||||
|
|
||||||
|
1
|
||||||
|
}
|
||||||
|
|
||||||
state.pop()
|
state.pop()
|
||||||
|
|
||||||
state.load(polyfill, "@starbound.jar!/scripts/polyfill.lua")
|
state.load(polyfill, "@starbound.jar!/scripts/polyfill.lua")
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.tile
|
package ru.dbotthepony.kstarbound.defs.tile
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
|
import ru.dbotthepony.kstarbound.defs.RegistryReference
|
||||||
|
import ru.dbotthepony.kstarbound.defs.StatusEffectDefinition
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory
|
import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory
|
||||||
import ru.dbotthepony.kvector.vector.Color
|
import ru.dbotthepony.kvector.vector.Color
|
||||||
|
|
||||||
@ -12,7 +14,7 @@ data class LiquidDefinition(
|
|||||||
val tickDelta: Int = 1,
|
val tickDelta: Int = 1,
|
||||||
val color: Color,
|
val color: Color,
|
||||||
val itemDrop: String? = null,
|
val itemDrop: String? = null,
|
||||||
val statusEffects: ImmutableList<String> = ImmutableList.of(),
|
val statusEffects: ImmutableList<RegistryReference<StatusEffectDefinition>> = ImmutableList.of(),
|
||||||
val interactions: ImmutableList<Interaction> = ImmutableList.of(),
|
val interactions: ImmutableList<Interaction> = ImmutableList.of(),
|
||||||
val texture: String,
|
val texture: String,
|
||||||
val bottomLightMix: Color,
|
val bottomLightMix: Color,
|
||||||
|
@ -463,7 +463,7 @@ class LuaState private constructor(private val pointer: Pointer, val stringInter
|
|||||||
|
|
||||||
fun hasSomethingAt(position: Int): Boolean {
|
fun hasSomethingAt(position: Int): Boolean {
|
||||||
check(position in 1 ..this.top) { "JVM code error: Invalid argument position: $position" }
|
check(position in 1 ..this.top) { "JVM code error: Invalid argument position: $position" }
|
||||||
return this@LuaState.typeAt() != LuaType.NONE
|
return this@LuaState.typeAt(position) != LuaType.NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasSomethingAt(): Boolean {
|
fun hasSomethingAt(): Boolean {
|
||||||
@ -475,6 +475,14 @@ class LuaState private constructor(private val pointer: Pointer, val stringInter
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isStringAt(position: Int = this.position): Boolean {
|
||||||
|
return this@LuaState.typeAt(position) == LuaType.STRING
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isNumberAt(position: Int = this.position): Boolean {
|
||||||
|
return this@LuaState.typeAt(position) == LuaType.NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
fun getString(position: Int = this.position++, limit: Long = DEFAULT_STRING_LIMIT): String {
|
fun getString(position: Int = this.position++, limit: Long = DEFAULT_STRING_LIMIT): String {
|
||||||
check(position in 1 ..this.top) { "JVM code error: Invalid argument position: $position" }
|
check(position in 1 ..this.top) { "JVM code error: Invalid argument position: $position" }
|
||||||
return this@LuaState.getString(position, limit = limit)
|
return this@LuaState.getString(position, limit = limit)
|
||||||
|
@ -9,6 +9,7 @@ import com.google.gson.JsonObject
|
|||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
|
import java.util.stream.Stream
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
fun String.sbIntern(): String {
|
fun String.sbIntern(): String {
|
||||||
@ -87,3 +88,8 @@ fun UUID.toStarboundString(): String {
|
|||||||
|
|
||||||
return builder.toString()
|
return builder.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("unchecked_cast")
|
||||||
|
fun <T> Stream<T?>.filterNotNull(): Stream<T> {
|
||||||
|
return filter { it != null } as Stream<T>
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user