So I'm trying to load a script from an external directory. I get the external path, verified, file.new() open, read, all good. Then I tried to load it as a value to just by magic have it as an object. Didn't work so I saw Script. Then I did, get text from file, then in a build script function i did Script.new Script.set_source_code() ? Return tempScript.get_base_script() ? ? I get an error... well this...

https://github.com/godotengine/godot-docs/issues/5063

make script Set code Make object Set script to object return object

.... dosent work

func _build_script(sourcecode):
	var tempScript=Script.new()
	#Instance: Class 'Script' or it's base class cant be Instantiated
	#_new: Class type:'Script' is no instantiable 
    tempScript.set_source_code(sourcecode)
    var tempObject=Node.new()
    tempObject.set_script(tempScript)
    return tempScript.get_base_script()

So you kinda did help me. As I understand it the Script class is Abstract so I can't actually do:

tempScript=Script.new ()
self.add_child(tempScript)

It's Abstract, not an Object

so for anyone interested this is what i got


Main Script: Method1:

func _build_script_method_1(sourcecode):
	print("Method 1")
	var tempScript=Script.new()
#	var tempBuild=load("res://Structure/Static/Console/PlaceHolder/ExternalPlaceHolder.gd")
	var tempNode=Node.new()
#	tempBuild.source_code=sourcecode
	
	tempNode.set_script(tempScript)
	tempNode.get_script().set_source_code(sourcecode)
	tempNode.get_script().reload()
#	tempScript.set_source_code(sourcecode)
#	tempScript.reload(false)
#	tempBuild.source=sourcecode
#	tempNode.get_script().source_code=sourcecode
#	tempBuild.reload()
#	tempNode.set_script(tempBuild)
	self.add_child(tempNode)
	if "test" in tempNode:
		print(str("Failed to Set source:",tempNode.test))
	if "call" in tempNode and "command_names" in tempNode:
		print("Method 1 has stats")
		var tempKeys=Syntax_Apd.keys() #Need Size
		var tempKeyName=tempKeys.size()
		if "syntaxName" in tempNode:
			tempNode.name=tempNode.syntaxName
		else: tempNode.name=str("External_",tempKeyName)
		Syntax_Apd[tempKeyName]=[]
		Syntax_Apd[tempKeyName].append(tempNode.call)
		Syntax_Apd[tempKeyName].append(tempNode.name)
		Syntax_Loaded[tempKeyName]=tempNode
		print(GroupConsole,Collar,str("External Preloaded: ",Syntax_Apd[tempKeyName][_synName]))
		return tempNode
	else:# If it dosen't have a command_name library
		print(GroupConsole,Collar,str("External Failed:",tempNode," !Call or !Command Names"))
#		tempNode.queue_free()# Remove Syntax Entry

Method 2:

func _build_script_method_2(gdFile):
	print("running method 2")
	var tempNode=load(gdFile).new()
	var failed=false
	#Print_DEBUG(GroupConsole,str("?:",syntax_name_apd[i]))
	self.add_child(tempNode,false)
	if "call" in tempNode and "command_names" in tempNode:
		var tempKeys=Syntax_Apd.keys() #Need Size
		var tempKeyName=tempKeys.size()
		for i in tempKeys.size():
			if Syntax_Apd[tempKeys[i]][_synCall]==tempNode.call:
				print(GroupConsole,Collar,str("External Load Failed:",gdFile," ::Table ",Syntax_Apd[tempKeys[i]][_synName]," already has Key:",tempNode.call))
				tempNode.queue_free()
				return
		if "syntaxName" in tempNode:
			tempNode.name=tempNode.syntaxName
		else: tempNode.name=str("External_",tempKeyName)
		Syntax_Apd[tempKeyName]=[]
		Syntax_Apd[tempKeyName].append(tempNode.call)
		Syntax_Apd[tempKeyName].append(tempNode.name)
		Syntax_Loaded[tempKeyName]=tempNode
		print(GroupConsole,Collar,str("External Preloaded: ",Syntax_Apd[tempKeyName][_synName]))
	else:# If it dosen't have a command_name library
		print(GroupConsole,Collar,str("External Load Failed:",gdFile," !Call or !Command Names"))
		tempNode.queue_free()# Remove Syntax Entry

ExternalPlaceHolder:

extends Node

var test="found this"
#This Script is a Placeholder to load External Scripts
#Don't Delete unless you want to remove this functionality

ExternalScript: #To Replace the Text of ExternalPlaceHolder in Script of Node

extends Node
const syntaxName="External_Table"
const version=""
#	TEXT to 'call' external syntax / can NOT conflict with other keys or wi9ll not be loaded
const call="Ex"

enum {typeINT,typeSTRING,typeBOOL,typeFLOAT}

const command_prefix=["?","*"]
const command_names={
	"help":[typeSTRING]
}

func help(iHELP):
	match iHELP:
		"Catagory":
			Console.Output(str("Add Information Here","/n",
			"A Help Command Supplys Usefull Information"))
		_:Console.Output(str("This is the Default Catagory"))

func help_prefixed(iprefix,icontext):pass

Now the weird part im having trouble with, is if i run method 1, I get the script, set its code put it in the Node. If I Node.get_script().get_source_code() the text is correct but when i call a variable I get it from ExternalPlaceHolder not External script like the text of the script should suggest. Because I have to reinstance 'reload' the node for the change to be takeing place on the node in the tree not an imaginary node im getting text from? I realize trying to build a script in code is a bit redundant when i can just have it loaded as I did with Internal Scripts

btw: The point of this is for someone to be able to bring a gdScript into the Program from an outside source, make a folder at runtime put the script in, boom running the code

9 months later