utopia-rise / godot-kotlin-jvm

Godot Kotlin JVM Module
MIT License
585 stars 38 forks source link

Cannot attach Kotlin scripts #470

Closed SWRHARD closed 11 months ago

SWRHARD commented 1 year ago

When i'm trying to attach kotlin script (Simple.kt) to a node, i got errors and the field "Language" are not changed to Kotlin image

Godot version: 4.0.3 stable

piiertho commented 1 year ago

Hello ! In 4.0 you need to attach the .gdj file that is generated at compile time. See #441

SWRHARD commented 1 year ago

Hello! Okay, i read this topic, but still dont understand how to generate .gdj files from idea, i have Simple.kt file:

@RegisterClass class Simple: Spatial() { @RegisterFunction override fun _ready() { GD.print("Hello world!") } }

i build the project (./gradlew build) and gdj file has to appear? Thanks

piiertho commented 1 year ago

Can you provide your gradle build script ?

SWRHARD commented 1 year ago

build.gradle.kts

  plugins {
      kotlin("jvm") version "1.7.20"
      id("com.utopia-rise.godot-kotlin-jvm") version "0.6.0-3.5.2"
  }

  group = "org.example"
  version = "1.0-SNAPSHOT"

  repositories {
      mavenCentral()
  }

  dependencies {
      testImplementation(kotlin("test"))
  }

  tasks.test {
      useJUnitPlatform()
  }

  tasks.withType<KotlinCompile> {
      kotlinOptions.jvmTarget = "1.8"
  }
piiertho commented 1 year ago

You're using godot kotlin 0.6.0-3.5.2, which is built for godot 3.5.2. As we did not finished 4.0 work yet, you will need to build locally this repo (master branch) or use dependency substitution to test godot with 4.0

SWRHARD commented 1 year ago

okay, thanks! probably i will use godot 3.5.2 now update: i downloaded 3.5.2 version, but still can't to open my Simple.kt file :/

piiertho commented 1 year ago

You need godot with kotlin module: https://github.com/utopia-rise/godot-kotlin-jvm/releases

SWRHARD commented 1 year ago

You need godot with kotlin module: https://github.com/utopia-rise/godot-kotlin-jvm/releases

Yee now it works, thanks! But my script is not working now, i attached it to sprite node:

@RegisterClass
class Simple: Sprite() {        
          @RegisterFunction
          override fun _ready() {
              GD.print("I am ready!")
          }
      }

But the scene is closed immediately, i have only two rows in console, "I am ready" is not writing(:

--- Debugging process started ---
--- Debugging process stopped ---

If i remove my script, scene works)

Godot version: v3.5.2.stable.custom_build [170ba337a]

Update: i found logs file

  Godot Engine v3.5.2.stable.custom_build.170ba337a - https://godotengine.org
  OpenGL ES 3.0 Renderer: GeForce RTX 2070 SUPER/PCIe/SSE2
  Async. shader compilation: OFF

  WARNING: Godot-JVM: Godot-JVM: No embedded jvm found on path: C:/Godot/projects/Test/jre-amd64/bin\server\jvm.dll!
     at: jni::JvmLoader::get_jvm_lib_path (modules\kotlin_jvm\src\jni\jvm_loader.cpp:64) - Godot-JVM: Godot-JVM: No embedded jvm found on path: C:/Godot/projects/Test/jre-amd64/bin\server\jvm.dll!
  WARNING: Godot-JVM: Godot-JVM: You really should embedd a jre in your game with jlink! See the documentation if you don't know how to do that
     at: jni::JvmLoader::get_jvm_lib_path (modules\kotlin_jvm\src\jni\jvm_loader.cpp:66) - Godot-JVM: Godot-JVM: You really should embedd a jre in your game with jlink! See the documentation if you don't know how to do that
  Godot-JVM: Starting JVM ...
  Godot-JVM: Loading bootstrap jar: C:/Godot/godot-bootstrap.jar

  ================================================================
  CrashHandlerException: Program crashed
  Engine version: Godot Engine v3.5.2.stable.custom_build (170ba337a5d9e4c1e40d63b89dc1ba297b71860b)
  Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
  [0] <couldn't map PC to fn name>
  [1] <couldn't map PC to fn name>
  [2] <couldn't map PC to fn name>
  [3] <couldn't map PC to fn name>
  [4] <couldn't map PC to fn name>
  [5] <couldn't map PC to fn name>
  [6] <couldn't map PC to fn name>
  [7] <couldn't map PC to fn name>
  [8] <couldn't map PC to fn name>
  [9] <couldn't map PC to fn name>
  [10] <couldn't map PC to fn name>
  [11] <couldn't map PC to fn name>
  -- END OF BACKTRACE --
  ================================================================
chippmann commented 1 year ago

0.5.2 was a broken build 0.6.2 should work without issues.

CedNaru commented 11 months ago

Closing issue as there is no news and the logs provided didn't contain any debug symbols that could help. The user is free to open another issue if the problem is still ongoing.