Update some pieces of code to make it compile again

This commit is contained in:
DBotThePony 2024-12-22 21:58:47 +07:00
parent 311c6a4e47
commit d6ef396257
Signed by: DBot
GPG Key ID: DCC23B5715498507
6 changed files with 16 additions and 23 deletions

View File

@ -4,10 +4,8 @@ import com.google.gson.JsonNull
import com.google.gson.JsonObject import com.google.gson.JsonObject
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import org.classdump.luna.ByteString
import org.classdump.luna.LuaRuntimeException import org.classdump.luna.LuaRuntimeException
import ru.dbotthepony.kstarbound.Globals import ru.dbotthepony.kstarbound.Globals
import ru.dbotthepony.kstarbound.item.RecipeRegistry
import ru.dbotthepony.kstarbound.Registries import ru.dbotthepony.kstarbound.Registries
import ru.dbotthepony.kstarbound.Registry import ru.dbotthepony.kstarbound.Registry
import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.Starbound
@ -16,22 +14,13 @@ import ru.dbotthepony.kstarbound.defs.image.Image
import ru.dbotthepony.kstarbound.defs.image.SpriteReference import ru.dbotthepony.kstarbound.defs.image.SpriteReference
import ru.dbotthepony.kstarbound.defs.item.ItemDescriptor import ru.dbotthepony.kstarbound.defs.item.ItemDescriptor
import ru.dbotthepony.kstarbound.item.ItemRegistry import ru.dbotthepony.kstarbound.item.ItemRegistry
import ru.dbotthepony.kstarbound.lua.LuaEnvironment import ru.dbotthepony.kstarbound.item.RecipeRegistry
import ru.dbotthepony.kstarbound.lua.LuaThread import ru.dbotthepony.kstarbound.lua.LuaThread
import ru.dbotthepony.kstarbound.lua.LuaType import ru.dbotthepony.kstarbound.lua.LuaType
import ru.dbotthepony.kstarbound.lua.from
import ru.dbotthepony.kstarbound.lua.nextVector2i import ru.dbotthepony.kstarbound.lua.nextVector2i
import ru.dbotthepony.kstarbound.lua.luaFunction
import ru.dbotthepony.kstarbound.lua.luaFunctionN
import ru.dbotthepony.kstarbound.lua.luaStub
import ru.dbotthepony.kstarbound.lua.nextInt
import ru.dbotthepony.kstarbound.lua.push import ru.dbotthepony.kstarbound.lua.push
import ru.dbotthepony.kstarbound.lua.set
import ru.dbotthepony.kstarbound.lua.tableOf
import ru.dbotthepony.kstarbound.util.random.random import ru.dbotthepony.kstarbound.util.random.random
import kotlin.collections.isNotEmpty
import kotlin.collections.set import kotlin.collections.set
import kotlin.collections.withIndex
private val LOGGER = LogManager.getLogger() private val LOGGER = LogManager.getLogger()

View File

@ -8,11 +8,9 @@ import ru.dbotthepony.kstarbound.defs.EntityType
import ru.dbotthepony.kstarbound.defs.item.ItemDescriptor import ru.dbotthepony.kstarbound.defs.item.ItemDescriptor
import ru.dbotthepony.kstarbound.defs.`object`.LoungeOrientation import ru.dbotthepony.kstarbound.defs.`object`.LoungeOrientation
import ru.dbotthepony.kstarbound.item.ItemStack import ru.dbotthepony.kstarbound.item.ItemStack
import ru.dbotthepony.kstarbound.json.builder.IStringSerializable
import ru.dbotthepony.kstarbound.lua.LuaThread import ru.dbotthepony.kstarbound.lua.LuaThread
import ru.dbotthepony.kstarbound.lua.LuaType import ru.dbotthepony.kstarbound.lua.LuaType
import ru.dbotthepony.kstarbound.lua.nextAABB import ru.dbotthepony.kstarbound.lua.nextAABB
import ru.dbotthepony.kstarbound.lua.nextInt
import ru.dbotthepony.kstarbound.lua.nextPoly import ru.dbotthepony.kstarbound.lua.nextPoly
import ru.dbotthepony.kstarbound.lua.nextVector2d import ru.dbotthepony.kstarbound.lua.nextVector2d
import ru.dbotthepony.kstarbound.lua.nextVector2i import ru.dbotthepony.kstarbound.lua.nextVector2i

View File

@ -1,5 +1,7 @@
package ru.dbotthepony.kstarbound.world.entities package ru.dbotthepony.kstarbound.world.entities
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import org.classdump.luna.ByteString import org.classdump.luna.ByteString
import org.classdump.luna.Table import org.classdump.luna.Table
import ru.dbotthepony.kommons.util.IStruct2d import ru.dbotthepony.kommons.util.IStruct2d
@ -111,9 +113,10 @@ abstract class ActorEntity : DynamicEntity(), InteractiveEntity, ScriptedEntity
return emptyList() return emptyList()
} }
override fun callScript(fnName: String, vararg arguments: Any?): Array<Any?> { override fun callScript(fnName: String, arguments: JsonArray): JsonElement {
require(isLocal) { "Calling script on remote entity" } //require(isLocal) { "Calling script on remote entity" }
return lua.invokeGlobal(fnName, *arguments) //return lua.invokeGlobal(fnName, *arguments)
TODO()
} }
override fun evalScript(code: String): Array<Any?> { override fun evalScript(code: String): Array<Any?> {

View File

@ -1,9 +1,11 @@
package ru.dbotthepony.kstarbound.world.entities package ru.dbotthepony.kstarbound.world.entities
import com.google.gson.JsonArray import com.google.gson.JsonArray
import com.google.gson.JsonPrimitive
import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.Starbound
import ru.dbotthepony.kstarbound.defs.actor.ActorMovementModifiers import ru.dbotthepony.kstarbound.defs.actor.ActorMovementModifiers
import ru.dbotthepony.kstarbound.defs.ActorMovementParameters import ru.dbotthepony.kstarbound.defs.ActorMovementParameters
import ru.dbotthepony.kstarbound.json.jsonArrayOf
import ru.dbotthepony.kstarbound.math.AABB import ru.dbotthepony.kstarbound.math.AABB
import ru.dbotthepony.kstarbound.math.vector.Vector2d import ru.dbotthepony.kstarbound.math.vector.Vector2d
import ru.dbotthepony.kstarbound.util.supplyAsync import ru.dbotthepony.kstarbound.util.supplyAsync
@ -189,9 +191,9 @@ class PathController(val controller: ActorMovementController, var edgeTimer: Dou
for (it in entities) { for (it in entities) {
val scripted = it as ScriptedEntity val scripted = it as ScriptedEntity
val result = scripted.callScript("hasCapability", "closedDoor") val result = scripted.callScript("hasCapability", jsonArrayOf(JsonPrimitive("closedDoor")))
if (result.isNotEmpty() && result[0] is Boolean && result[0] as Boolean) { if (result is JsonPrimitive && result.isBoolean && result.asBoolean) {
it.dispatchMessage(world.connectionID, "openDoor", JsonArray()) it.dispatchMessage(world.connectionID, "openDoor", JsonArray())
any = true any = true
} }

View File

@ -145,8 +145,8 @@ class StagehandEntity(isRemote: Boolean = false) : AbstractEntity(), ScriptedEnt
override val description: String override val description: String
get() = "Technical entity responsible for doing cool stuff" get() = "Technical entity responsible for doing cool stuff"
override fun callScript(fnName: String, vararg arguments: Any?): Array<Any?> { override fun callScript(fnName: String, arguments: JsonArray): JsonElement {
return lua.call(fnName, *arguments) TODO()
} }
override fun evalScript(code: String): Array<Any?> { override fun evalScript(code: String): Array<Any?> {

View File

@ -856,8 +856,9 @@ open class WorldObject(val config: Registry.Entry<ObjectDefinition>) : TileEntit
return luaMessageHandler.handle(message, connectionID == connection, arguments) return luaMessageHandler.handle(message, connectionID == connection, arguments)
} }
override fun callScript(fnName: String, vararg arguments: Any?): Array<Any?> { override fun callScript(fnName: String, arguments: JsonArray): JsonElement {
return lua.invokeGlobal(fnName, *arguments) //return lua.invokeGlobal(fnName, *arguments)
TODO()
} }
override fun evalScript(code: String): Array<Any?> { override fun evalScript(code: String): Array<Any?> {