root.npcConfig
This commit is contained in:
parent
22c39ba497
commit
046698ddc5
@ -30,6 +30,7 @@ import ru.dbotthepony.kstarbound.defs.item.ItemPrototype
|
||||
import ru.dbotthepony.kstarbound.defs.item.LegsArmorItemPrototype
|
||||
import ru.dbotthepony.kstarbound.defs.item.LiquidItemPrototype
|
||||
import ru.dbotthepony.kstarbound.defs.item.MaterialItemPrototype
|
||||
import ru.dbotthepony.kstarbound.defs.npc.NpcTypeDefinition
|
||||
import ru.dbotthepony.kstarbound.defs.tile.LiquidDefinition
|
||||
import ru.dbotthepony.kstarbound.defs.particle.ParticleDefinition
|
||||
import ru.dbotthepony.kstarbound.defs.player.BlueprintLearnList
|
||||
@ -119,6 +120,9 @@ class Starbound : ISBFileLocator {
|
||||
private val _json2Functions = ObjectRegistry<Json2Function>("json 2functions")
|
||||
val json2Functions = _json2Functions.view
|
||||
|
||||
private val _npcTypes = ObjectRegistry<NpcTypeDefinition>("npc types")
|
||||
val npcTypes = _npcTypes.view
|
||||
|
||||
val gson: Gson = with(GsonBuilder()) {
|
||||
serializeNulls()
|
||||
setDateFormat(DateFormat.LONG)
|
||||
@ -381,7 +385,7 @@ class Starbound : ISBFileLocator {
|
||||
val table = args.lua.stackTop
|
||||
|
||||
for ((i, value) in values.withIndex()) {
|
||||
args.lua.push(i)
|
||||
args.lua.push(i + 1)
|
||||
args.lua.push(value)
|
||||
args.lua.setTableValue(table)
|
||||
}
|
||||
@ -394,6 +398,18 @@ class Starbound : ISBFileLocator {
|
||||
1
|
||||
}
|
||||
|
||||
state.setTableFunction("npcConfig", this) { args ->
|
||||
// Json root.npcConfig(String npcType)
|
||||
val name = args.getString()
|
||||
args.lua.push(npcTypes[name]?.copy() ?: throw NoSuchElementException("No such NPC type $name"))
|
||||
1
|
||||
}
|
||||
|
||||
state.setTableFunction("npcVariant", this) { args ->
|
||||
// Json root.npcVariant(String species, String npcType, float level, [unsigned seed], [Json parameters])
|
||||
TODO()
|
||||
}
|
||||
|
||||
state.pop()
|
||||
|
||||
state.load(polyfill, "@starbound.jar!/scripts/polyfill.lua")
|
||||
@ -599,6 +615,7 @@ class Starbound : ISBFileLocator {
|
||||
loadStage(callback, _particles, ext2files["particle"] ?: listOf())
|
||||
loadStage(callback, _questTemplates, ext2files["questtemplate"] ?: listOf())
|
||||
loadStage(callback, _techs, ext2files["tech"] ?: listOf())
|
||||
loadStage(callback, _npcTypes, ext2files["npctype"] ?: listOf())
|
||||
|
||||
pathStack.block("/") {
|
||||
//playerDefinition = gson.fromJson(locate("/player.config").reader(), PlayerDefinition::class.java)
|
||||
|
@ -0,0 +1,9 @@
|
||||
package ru.dbotthepony.kstarbound.defs.npc
|
||||
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory
|
||||
|
||||
@JsonFactory
|
||||
data class NpcTypeDefinition(
|
||||
val type: String,
|
||||
val baseType: String? = null,
|
||||
)
|
Loading…
Reference in New Issue
Block a user