root.itemType

This commit is contained in:
DBotThePony 2023-03-29 12:21:16 +07:00
parent 9e6d54cea7
commit 59fd54499b
Signed by: DBot
GPG Key ID: DCC23B5715498507
6 changed files with 44 additions and 11 deletions

View File

@ -463,6 +463,12 @@ class Starbound : ISBFileLocator {
1 1
} }
state.setTableFunction("itemType", this) { args ->
val name = args.getString()
args.lua.push(items[name]?.value?.itemType ?: throw NoSuchElementException("No such item $name"))
1
}
state.pop() state.pop()
state.load(polyfill, "@starbound.jar!/scripts/polyfill.lua") state.load(polyfill, "@starbound.jar!/scripts/polyfill.lua")

View File

@ -7,14 +7,14 @@ import ru.dbotthepony.kstarbound.io.json.builder.JsonIgnoreProperty
@JsonBuilder @JsonBuilder
abstract class ArmorItemPrototype : ItemPrototype(), IArmorItemDefinition { abstract class ArmorItemPrototype : ItemPrototype(), IArmorItemDefinition {
override var colorOptions: ImmutableList<Map<String, String>> by NotNull(ImmutableList.of()) final override var colorOptions: ImmutableList<Map<String, String>> by NotNull(ImmutableList.of())
override var maleFrames: IArmorItemDefinition.Frames by NotNull() final override var maleFrames: IArmorItemDefinition.Frames by NotNull()
override var femaleFrames: IArmorItemDefinition.Frames by NotNull() final override var femaleFrames: IArmorItemDefinition.Frames by NotNull()
override var level: Double by NotNull(1.0) final override var level: Double by NotNull(1.0)
override var leveledStatusEffects: ImmutableList<LeveledStatusEffect> by NotNull(ImmutableList.of()) final override var leveledStatusEffects: ImmutableList<LeveledStatusEffect> by NotNull(ImmutableList.of())
override var scripts: ImmutableList<DirectAssetReference> by NotNull(ImmutableList.of()) final override var scripts: ImmutableList<DirectAssetReference> by NotNull(ImmutableList.of())
override var scriptDelta: Int by NotNull(1) final override var scriptDelta: Int by NotNull(1)
init { init {
maxStack = 1L maxStack = 1L
@ -22,13 +22,25 @@ abstract class ArmorItemPrototype : ItemPrototype(), IArmorItemDefinition {
} }
@JsonBuilder @JsonBuilder
class HeadArmorItemPrototype : ArmorItemPrototype() class HeadArmorItemPrototype : ArmorItemPrototype() {
override val itemType: String
get() = "headarmor"
}
@JsonBuilder @JsonBuilder
class ChestArmorItemPrototype : ArmorItemPrototype() class ChestArmorItemPrototype : ArmorItemPrototype() {
override val itemType: String
get() = "chestarmor"
}
@JsonBuilder @JsonBuilder
class LegsArmorItemPrototype : ArmorItemPrototype() class LegsArmorItemPrototype : ArmorItemPrototype() {
override val itemType: String
get() = "legsarmor"
}
@JsonBuilder @JsonBuilder
class BackArmorItemPrototype : ArmorItemPrototype() class BackArmorItemPrototype : ArmorItemPrototype() {
override val itemType: String
get() = "backarmor"
}

View File

@ -10,4 +10,7 @@ interface ICurrencyItemDefinition : IItemDefinition {
* Ценность одного предмета в [currency] * Ценность одного предмета в [currency]
*/ */
val value: Long val value: Long
override val itemType: String
get() = "currency"
} }

View File

@ -109,4 +109,10 @@ interface IItemDefinition : IThingWithDescription {
* Количество предметов ниже или равному данному значению (но не меньше [smallStackLimit]) проиграет звук [pickupSoundsMedium] * Количество предметов ниже или равному данному значению (но не меньше [smallStackLimit]) проиграет звук [pickupSoundsMedium]
*/ */
val mediumStackLimit: Long? val mediumStackLimit: Long?
/**
* Тип предмета, используется Lua скриптами
*/
val itemType: String
get() = "item"
} }

View File

@ -7,4 +7,7 @@ interface ILiquidItem : IItemDefinition {
* То, какую жидкость из себя представляет данный предмет * То, какую жидкость из себя представляет данный предмет
*/ */
val liquid: Either<Int, String> val liquid: Either<Int, String>
override val itemType: String
get() = "liquid"
} }

View File

@ -7,4 +7,7 @@ interface IMaterialItem : IItemDefinition {
* То, какой материал (блок) из себя представляет данный предмет * То, какой материал (блок) из себя представляет данный предмет
*/ */
val material: Either<Int, String> val material: Either<Int, String>
override val itemType: String
get() = "material"
} }