The Wayback Machine - https://web.archive.org/web/20201229161105/https://github.com/godotengine/godot/pull/44796
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ScriptServer & add all script class support. #44796

Open
wants to merge 1 commit into
base: 3.2
from

Conversation

@willnationsdev
Copy link
Contributor

@willnationsdev willnationsdev commented Dec 29, 2020

This is is 3.2 port of #40147 since there are presumably going to be core changes that make these features inapplicable to 4.0.

I've created a demo of it:

Demo_GP22_3_2.zip

Relevant code samples:

# main.tscn
- Node (main.gd)
    - Node "MyGDClass" (MyGDClass.gd)
    - Node "MyVSClass" (MyVSClass.vs)
    - Node "MyCSClass" (MyCSClass.cs)
# MyGDClass.gd
extends Node
class_name MyGDClass, "res://skill.png"
func _ready():
    print("MyGDClass")
// MyCSClass.cs
using System;
using Godot;

[Global("MyCSClass", "res://skill.png")]
public class MyCSClass : Node
{
    public override void _Ready()
    {
        GD.Print("MyCSClass");
    }
}

VisualScript sample:

visual_script_sample

# main.gd
extends Node

onready var gd = $MyGDClass
onready var vs = $MyVSClass
onready var cs = $MyCSClass

func _ready():
	if gd is ScriptServer.MyGDClass:
		print("gd is MyGDClass")
	if vs.get_script() == ScriptServer.MyVSClass:
		print("vs is MyVSClass")
	if cs.get_script() == ScriptServer.MyCSClass:
		print("cs is MyCSClass")

Output:

MyGDClass
MyCSClass
MyVSClass
gd is MyGDClass
vs is MyVSClass
cs is MyCSClass

It seems as though the is keyword doesn't like to cooperate with non-GDScript script types on the right-hand side. Should I try to incorporate that into the feature? Iirc, it worked fine in my 4.0 demo project.

@willnationsdev willnationsdev requested a review from neikeq as a code owner Dec 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.