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

Support embedding the Block Coding Editor in-game #196

Open
sgaseretto opened this issue Aug 14, 2024 · 7 comments
Open

Support embedding the Block Coding Editor in-game #196

sgaseretto opened this issue Aug 14, 2024 · 7 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@sgaseretto
Copy link

sgaseretto commented Aug 14, 2024

What Happened

This is not an issue but a question. Is it possible to embed the code editor in a game? Sorry if this is a very obvious question, I'm very new to godot and want to know if:

  • The editor can be rendered insied a godot game
  • We can create custom Blocks with specific functions, like move forward 5 times, turn left, move forward 5 times, and so on
  • Can the generated code be executed while the game is running? (Don't know if gdscript is compiled at some point and cannot be executed dynamically while the game runs)

I know it sounds very meta, but basically the idea is to build something like blockly-games

@manuq
Copy link
Contributor

manuq commented Aug 20, 2024

@sgaseretto this would be interesting to investigate. The way it works today: the BlockCode node replaces the script of the parent node with the code generated by its blocks. So it wouldn't be too hard.

@ghost
Copy link

ghost commented Aug 20, 2024

Hope this happens!

This is just about 'killer feature' territory for me --
And can actually imagine way more usecases (personally),
in-instance / in-game than using in-built in the existing editor.

Would be cool if there was like a custom.gd or something
that we could just have a bunch of dict definitions for
basic structure of block, category, etc (no idea how it works now lol)

@dylanmccall dylanmccall added enhancement New feature or request help wanted Extra attention is needed labels Aug 24, 2024
@SanchoPanza8000
Copy link

I have been wondering about this extension or possibility as well:

  • it would enable an incredible foundation for automation or programming-focused games like desynced, adventure land or stationeers coming to mind as some of the better examples
  • ideally the functionality, addon/plugin would become exposable to the client-side and support godot's multiplayer and sync modes as well.

@DavidGasku
Copy link

After looking at the code, seems like a big refactor to me. The whole code generation should be replaced by a interpreter, that runs one block each time.

@goatchurchprime
Copy link

I have an in-game version working, after a fashion at:
https://github.com/goatchurchprime/godot-block-coding/tree/blockcodingingame
(Open the scene res://jgt/node_2d.gd and then Run Current Scene (F6)).

The minimal hacking I needed to do required setting all uses of EditorInterface.get_inspector() to null and disabling the undo_redo system. It is unfortunate the runtime UndoRedo class can't be swapped in for the EditorUndoRedoManager class for although they have the same functions, the arguments are different.

This is enough to do some experiments to see if this system works satisfactorily in VR. However we're going to want several panels open at once, which would require more than one BlockEditorContext, not only the get_default() instance.

After that, it would be necessary to make the editor work multiplayer so it is possible for friends to work together and teach one another. The Resonite community have had a lot of success with their far-more-complex Flux node-based coding system within their platform, which I present as evidence that this drag-and-drop procedural-hybrid coding system could take off in a similar milieu. https://steamcommunity.com/sharedfiles/filedetails/?id=3174193671

@manuq
Copy link
Contributor

manuq commented Oct 18, 2024

@goatchurchprime awesome, this is what @dylanmccall was trying to do in this draft PR #223 . Feel free to open a PR based on it.

@manuq manuq changed the title Ingame Block Coding Editor with custom blocks Support embedding the Block Coding Editor in-game Oct 18, 2024
@goatchurchprime
Copy link

Okay, I've done what I can to make it do the right thing, more or less
#280

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants