Hello!

I've looked around but can't find an answer for why this is not working. I'm using a C# library to handle OSC messages to interface with Supercollider and am trying to send a signal out with some data to a root node that controls the scene. Currently, I have access to the signal in the inspector but when I attempt to emit the signal I get an error. Here's my code:

`using Godot;
using System;
using System.Net;
using SharpOSC;

public partial class OSCServer : Node
{

[Signal]
public delegate void SendLightEventHandler(int val);

//private static UDPSender send;

private static UDPListener reciever;

public static int light_val;

public static int port = 8003;

public static string IPAddress = "127.0.0.1";


// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
	//send = new UDPSender(IPAddress,port);
	reciever =  new UDPListener(8004, callback);
	//passing = GetParent.GetChild()GetNode<Node3D>("Sub");
	
	
	
}

HandleOscPacket callback = delegate(OscPacket packet)
{

		var messageReceived = (OscMessage)packet;
		// GD.Print(messageReceived.Arguments);
		var light_val = messageReceived.Arguments[0];


        //EmitSignal("Sendo", 2);
        EmitSignal(SignalName.SendLight, 1);
		
    };


// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
	
}

}
`

And here's the error when I attempt to build the project:

A field initializer cannot reference the non-static field, method, or property 'GodotObject.EmitSignal(StringName, params Variant[])'

Any help would be greatly appreciated.

Edit: Removing the emitting code from the OSC callback function seems to fix the compiler error. I've put it in the process function instead, which works until I try to convert the incoming OSC message to useable data.

New code:

` public override void _Process(double delta)
{

	messageReceived = (OscMessage)receiver.Receive();

	// GD.Print(messageReceived);
    if (messageReceived == null)
    {
		
		var new_val = messageReceived.Arguments[0];
		EmitSignal(SignalName.SendLight, new_val);
		GD.Print("here");
    }





}

`

And the new error:
Argument 2: cannot convert from 'object' to 'Godot.Variant'

    drewmfarrar The code highlighting makes it a bit complicated to figure out tbh.

    But at least for your last error the problem is, that you try to emit a signal with a payload that is not a Godot.Variant compatible type (see here).

    If you convert whatever type comes out of messageReceived.Arguments[0] to something compatible like an int or string it should work. Maybe you can create your own representation of the OscMessage by inheriting GodotObject. (see here) Then you can emit signals with the complete payload (if that is something you want).

      greeen_tomato Oh that's a very interesting idea, I'll have to try it! And thank you, I had figured out that I had to convert to a double instead of a float. I also am not quite sure why the code is highlighted that way, it wasn't intentional. I'll try to fix the formatting in the future but for now everything seems to be working.