-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
re-added MultiScript #8502
re-added MultiScript #8502
Conversation
@@ -1696,9 +1696,9 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so | |||
//same thing for placeholders | |||
#ifdef TOOLS_ENABLED | |||
|
|||
while (E->get()->placeholders.size()) { | |||
for (Set<PlaceHolderScriptInstance *>::Element *P = E->get()->placeholders.front(); P; P = P->next()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that when I tried to save a GDScript that's a part of a multiscript the editor froze.
This was an endless loop before, this fixes that.
The very first Godot version (when it was open sourced) had "MultiScript" which lets you use multiple scripts on one object. With the addition of mulitple new scripting languages (VisualScript, soon C# and GDNative) it can be of use to combine scripts rather than delegating (with huge maintainance cost) or creating child nodes which could impact performance. I used the code from 0b806ee as the base and made it work with the current master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is madness.
awesome , very useful 💯 been missing this functionality in godot |
I don't think this is that useful, which is why it was removed.. also it
has some obvious limitations. It's easier and cleaner to add a child node
with another script. But given it's so simple.. why not ;)
Yet if anyone wants to use
…On Apr 24, 2017 4:35 AM, "Avril" ***@***.***> wrote:
awesome , very useful 💯 been missing this functionality in godot
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8502 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF-Z2y85Rm6VLGW08Ccv5rbUxtBKpuwtks5rzAqEgaJpZM4NFj6U>
.
|
Wow I never though this was possible, quite cool! It may be cleaner to add children with scripts, but its so no nice because then the path to access the nodes changes depending on that. I'm willing to give this a try and split my huge .gd scripts into smaller logical ones :) |
Because one object can only have one script I create a dummy object for each script that delegates the call to the "real" object. That means that a script need to Question: Should I re-enable that type so scripts are easier identifyable as "part of a MultiScript" or just keep it as object? |
I'm curious too about the benefit, uses and meaning of the multiple scripts (having that documented would be nice). |
I changed the loop in godotengine#8502, turns out it fixed the error I was facing but introduced a new one. This fixes both
Though with the addition of the Multiscript-entry, I can't seem to create a Visual Script anymore. I can't select it from the menu and trying to create a new vscript with Multiscript selected throws an error at me. |
@novemberist I noticed that as well, my code didn't touch anything VS related, it actually can't load the VS files. I don't think it's the fault of this PR, but I'd love to be corrected! 😉 |
@karroffel actually already existing .vs scripts can be loaded by multiscript (even though there is still something wrong with running them #8040 ) |
@novemberist Yeah, I can reproduce, not sure why, but I encountered a similar error when I first started with GDNative. For a temporary fix, you could disable a scripting language you don't need. For example |
Its not like i insist for multi scripts attached to one node. Indeed we can create multiple nodes, each with one script and its same good. So just chose whats more clean / better performance.
Aside from simple manipulating node to which script is attached there are uses going far beyound it. |
@avril-gh but the first script extends the node (in some way, can be changed on runtime), adds/modifies properties and methods; what is the relation of the n+1 script with the node and the other scripts? |
It is common practice that script that is attached to a node extends it and operate on its methods/properties, but its not obligatory. This could be limitation, and exacly what i LOVE in godot is its mega flexibility, where combining nodes into scenes then instancing one into another, is best example of godot's limitles awesomeness. For example, Lets say i make NPC which is self sufficient object (scene) One can say - navigation node, navmesh and script, they all should be bound. Well, no... Whats more, as i said above. I just drop NPC to game world and he must work.
so i have navigation node, wherever it been, same with camera, and use it simply like
even tho, i do it in script attached to simple node, which extends Node and is within NPC not in navmesh nor extends it. (look NPC picture above) This way its modular and easy to maintain. (All changes within NPC without touching game world) They all are separate scripts to keep on topic in logical way, become modular and easy to maintain in large projects. At least thats how i use 'multi-scripts'. |
@avril-gh making scenes independent of the environment is what I usually do (more for testing purposes) and after reading, trying and thinking a bit more I see it could make more flexible frameworks and better team work in some cases, also cleaner code/scene-tree respect of loading sub-scripts/adding nodes (although this has some disadvantages, I may open an issue about that). Noticed that the resulting node is like a fusion of the classes, this means if I add 2 service-like scripts I will be performing daemon fusion? (sorry) |
Exacly... As we speak, more and more wonders about possible problems appear and theres perhaps another ones awaits to jump in. Considering that current design 'one node - one script' is clean, safe and does not limits game developer who still may put as many nodes with scripts as he wants, - attempt to forcefuly attach many scripts to one node knowing that it will raise complexity and possible conflicts in exchange for no special gain - is like doing it just for an art. and this way, we came to the same conclusion which @reduz found long a go allready.
|
It was worth a try, took me like an hour to port to 3.0. At least now people can't say we didn't try 😂 Another idea: What about introducing a special syntax for "subscripts" in GDScript?
The |
@karroffel subscripts sound cool, it can clean a lot of scenes and plugins |
removes MultiScript which was re-added in godotengine#8502 (aka 4c14700). This feature didn't turn out to be as useful as most expected. It causes more troubles than it does good.
I changed the loop in godotengine#8502, turns out it fixed the error I was facing but introduced a new one. This fixes both
removes MultiScript which was re-added in godotengine#8502 (aka 4c14700). This feature didn't turn out to be as useful as most expected. It causes more troubles than it does good.
For those stumbling upon this PR, since this feature got removed in Godot in #8718, I still got curious about the feature and decided to resurrect it in Goost (using Godot 3.3), see goostengine/goost#92 (with dedicated script editor, and the Also, the implementation prior to removal in #8718 was buggy, I've fixed some things to make not crash in some cases. Mixing in GDScript and VisualScript works, haven't tested other languages, but I think this would be really nice feature for combining GDScript + NativeScript functionalities (probably that's why karroffel got inspired to re-add this feature in the first place). |
Are you crazy?! That's insane we now have multiscript support ! 😄 |
To eliminate confusion, Godot won't likely have this feature in future versions, but I'm going to merge the feature in Goost, and eventually make a release of Godot + Goost extension once Godot 3.4 comes out (or so), and lets see how it goes! As discussed above, it's not like this feature will revolutionize the way scripting is done in Godot. The particular implementation is suboptimal, but the idea is really great (that's why this PR exists and goostengine/goost#92), but unfortunately "multi-script" does have limitations which can only be eliminated on the core level (the most prominent one is lack of autocompletion in GDScript, since all classes must extend That said, I wouldn't recommend using "multi-script" on main classes like characters (anything which is going to be used often in a game, really). But even with those limitations, this could be used for:
If a script is placed below the other and both have the same method, only the method defined in the class above will be called. This is a property of mixins, name resolution is done implicitly, unlike traits. That's why I've renamed Communicating between scripts is possible by using I've already tried to describe this in goostengine/goost#92, the PR does have some minimal documentation for future built-in classes. |
There can I read about the main issues with having multiscripts? |
Based on the talk I had with @reduz in Paris:
The very first Godot version (when it was open sourced) had "MultiScript" which lets you use multiple scripts on one object.
With the addition of mulitple new scripting languages (VisualScript, soon C# and GDNative) it can be of use to combine scripts rather than delegating (with huge maintainance cost) or creating child nodes
which could impact performance.
I used the code from 0b806ee as the base and made it work with the current master.