Git Product home page Git Product logo

Comments (10)

Geequlim avatar Geequlim commented on August 12, 2024 1

@MichaelBelousov Thank your for reporting the bug and provide the demo project. This issue is fixed now :)

from ecmascript.

Geequlim avatar Geequlim commented on August 12, 2024

from ecmascript.

Geequlim avatar Geequlim commented on August 12, 2024

Here is a demo project I tested.
Everything works as expected

import { signal, gdclass, property } from "./decorators";
console.LOG_OBJECT_TO_JSON = true;
@gdclass
class MyNode extends godot.Control {
	@signal
	test_func: string;
	
	js_method_test() {}

	@property({ default: "Hello Godot Property" })
	string_prop: string;
}

@gdclass
class MyMyNode extends MyNode {
	@signal
	test_func2: string;
};

export default class Control extends godot.Control {

	_ready() {
		var n = new MyMyNode();

		console.log('--------------');
		console.log(n.has_signal('test_func'));
		console.log(n.has_signal('test_func2'));
		console.log(n.string_prop === 'Hello Godot Property');
		console.log(n.has_method('js_method_test'));
		console.log('--------------');
		n.connect('test_func', this.callback1, ['AAA', 'BBB']);
		n.connect('test_func', this.callback2, ['CCC', 'DDD']);
		n.emit_signal('test_func', {a: 'a'}, 2);
		n.emit_signal('test_func', {b: 'b'}, 4);
		console.log('--------------');

		n.free();
	}

	callback1(a, b, c, d) {
		console.log("callback1", a, b, c, d);
	}

	callback2(a, b, c, d) {
		console.log("callback2", a, b, c, d);
	}

}

Output content

--------------
true
true
true
true
--------------
callback1 {"a":"a"} 2 AAA BBB
callback2 {"a":"a"} 2 CCC DDD
callback1 {"b":"b"} 4 AAA BBB
callback2 {"b":"b"} 4 CCC DDD
--------------

from ecmascript.

MichaelBelousov avatar MichaelBelousov commented on August 12, 2024

I'll try making a reproduction tomorrow, I couldn't do it minimally either so maybe it's something else. But I do have some strange behavior going on...

from ecmascript.

MichaelBelousov avatar MichaelBelousov commented on August 12, 2024

Alright I did it tonight instead :). This is a weird one. Check out this reproduction code:
A.jsx

import B from "./B.jsx";
export default class A extends godot.Node2D {
	static my_signal = "my_signal";
	_ready() {
		this.add_child(new B());
		this.add_child(new B());
		this.emit_signal(A.my_signal, {a: new godot.Vector2(5, 5)});
	}
}
godot.register_signal(A, A.my_signal);

B.jsx

import A from "./A.jsx";
export default class B extends godot.Node2D {
    _ready() {
        this.material = new godot.ShaderMaterial();
        this.$("..").connect(A.my_signal, obj => {
            this.material.set_shader_param('color', new godot.Color(1,1,0,0.5));
            godot.print(obj);
        });
    }
}

Basic scene for running script A:

[gd_scene load_steps=2 format=2]

[ext_resource path="res://A.jsx" type="Script" id=1]

[node name="Root" type="Node2D"]
script = ExtResource( 1 )

Output:

{a:(5, 5)}
Null

So on the second call it receives null. I haven't yet tested for a less specific reproduction, but I know that setting the shader parameter will do it, and I don't even have to attach the shader. I can look for the problem in the implementation tomorrow if you don't figure it out by then :)

from ecmascript.

Geequlim avatar Geequlim commented on August 12, 2024

@MichaelBelousov Your code contains cycle import whic should not work

from ecmascript.

MichaelBelousov avatar MichaelBelousov commented on August 12, 2024

It does work though. Anyway, you can remove the cycle like this, and the bug remains:

//import A from "./A.jsx";
export default class B extends godot.Node2D {
  _ready() {
    this.material = new godot.ShaderMaterial();
    this.$("..").connect("my_signal", (obj) => {
      this.material.set_shader_param("color", new godot.Color(1, 1, 0, 0.5));
      godot.print(obj);
    });
  }
}
//# sourceMappingURL=TestB.jsx.map

from ecmascript.

Geequlim avatar Geequlim commented on August 12, 2024

from ecmascript.

MichaelBelousov avatar MichaelBelousov commented on August 12, 2024

Here's my minimal demo:
ecmascript-multisignal-mvr.zip
It produces:

Godot Engine v3.2.3.beta.custom_build.9e4e83738 - https://godotengine.org
OpenGL ES 3.0 Renderer: Quadro P2000/PCIe/SSE2
 
{a:(5, 5)}
Null

on my system. If you can't reproduce, maybe I should try rebasing on a different version of godot and see if that fixes it? Also I have one other module in my local engine source.

from ecmascript.

MichaelBelousov avatar MichaelBelousov commented on August 12, 2024

Thank you! awesome work!

from ecmascript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.