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
}
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.load(polyfill, "@starbound.jar!/scripts/polyfill.lua")

View File

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

View File

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

View File

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

View File

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