diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/lua/bindings/RootBindings.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/lua/bindings/RootBindings.kt index db74f5b7..c3e12de6 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/lua/bindings/RootBindings.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/lua/bindings/RootBindings.kt @@ -4,10 +4,8 @@ import com.google.gson.JsonNull import com.google.gson.JsonObject import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap import org.apache.logging.log4j.LogManager -import org.classdump.luna.ByteString import org.classdump.luna.LuaRuntimeException import ru.dbotthepony.kstarbound.Globals -import ru.dbotthepony.kstarbound.item.RecipeRegistry import ru.dbotthepony.kstarbound.Registries import ru.dbotthepony.kstarbound.Registry 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.item.ItemDescriptor 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.LuaType -import ru.dbotthepony.kstarbound.lua.from 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.set -import ru.dbotthepony.kstarbound.lua.tableOf import ru.dbotthepony.kstarbound.util.random.random -import kotlin.collections.isNotEmpty import kotlin.collections.set -import kotlin.collections.withIndex private val LOGGER = LogManager.getLogger() diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/lua/bindings/WorldEntityBindings.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/lua/bindings/WorldEntityBindings.kt index e3bd91a1..1911fb12 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/lua/bindings/WorldEntityBindings.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/lua/bindings/WorldEntityBindings.kt @@ -8,11 +8,9 @@ import ru.dbotthepony.kstarbound.defs.EntityType import ru.dbotthepony.kstarbound.defs.item.ItemDescriptor import ru.dbotthepony.kstarbound.defs.`object`.LoungeOrientation import ru.dbotthepony.kstarbound.item.ItemStack -import ru.dbotthepony.kstarbound.json.builder.IStringSerializable import ru.dbotthepony.kstarbound.lua.LuaThread import ru.dbotthepony.kstarbound.lua.LuaType import ru.dbotthepony.kstarbound.lua.nextAABB -import ru.dbotthepony.kstarbound.lua.nextInt import ru.dbotthepony.kstarbound.lua.nextPoly import ru.dbotthepony.kstarbound.lua.nextVector2d import ru.dbotthepony.kstarbound.lua.nextVector2i diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/ActorEntity.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/ActorEntity.kt index dcb85d48..4507a369 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/ActorEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/ActorEntity.kt @@ -1,5 +1,7 @@ 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.Table import ru.dbotthepony.kommons.util.IStruct2d @@ -111,9 +113,10 @@ abstract class ActorEntity : DynamicEntity(), InteractiveEntity, ScriptedEntity return emptyList() } - override fun callScript(fnName: String, vararg arguments: Any?): Array { - require(isLocal) { "Calling script on remote entity" } - return lua.invokeGlobal(fnName, *arguments) + override fun callScript(fnName: String, arguments: JsonArray): JsonElement { + //require(isLocal) { "Calling script on remote entity" } + //return lua.invokeGlobal(fnName, *arguments) + TODO() } override fun evalScript(code: String): Array { diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PathController.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PathController.kt index 4c811a85..f6ebddc8 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PathController.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PathController.kt @@ -1,9 +1,11 @@ package ru.dbotthepony.kstarbound.world.entities import com.google.gson.JsonArray +import com.google.gson.JsonPrimitive import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.defs.actor.ActorMovementModifiers import ru.dbotthepony.kstarbound.defs.ActorMovementParameters +import ru.dbotthepony.kstarbound.json.jsonArrayOf import ru.dbotthepony.kstarbound.math.AABB import ru.dbotthepony.kstarbound.math.vector.Vector2d import ru.dbotthepony.kstarbound.util.supplyAsync @@ -189,9 +191,9 @@ class PathController(val controller: ActorMovementController, var edgeTimer: Dou for (it in entities) { 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()) any = true } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/StagehandEntity.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/StagehandEntity.kt index a1dc6897..da2a997a 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/StagehandEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/StagehandEntity.kt @@ -145,8 +145,8 @@ class StagehandEntity(isRemote: Boolean = false) : AbstractEntity(), ScriptedEnt override val description: String get() = "Technical entity responsible for doing cool stuff" - override fun callScript(fnName: String, vararg arguments: Any?): Array { - return lua.call(fnName, *arguments) + override fun callScript(fnName: String, arguments: JsonArray): JsonElement { + TODO() } override fun evalScript(code: String): Array { diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/tile/WorldObject.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/tile/WorldObject.kt index 6537a91a..575e4aab 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/tile/WorldObject.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/tile/WorldObject.kt @@ -856,8 +856,9 @@ open class WorldObject(val config: Registry.Entry) : TileEntit return luaMessageHandler.handle(message, connectionID == connection, arguments) } - override fun callScript(fnName: String, vararg arguments: Any?): Array { - return lua.invokeGlobal(fnName, *arguments) + override fun callScript(fnName: String, arguments: JsonArray): JsonElement { + //return lua.invokeGlobal(fnName, *arguments) + TODO() } override fun evalScript(code: String): Array {