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

Implement running a single function within the script editor for debugging purposes #9211

Open
RustoMCSpit opened this issue Feb 29, 2024 · 4 comments

Comments

@RustoMCSpit
Copy link

Describe the project you are working on

Irrelevent

Describe the problem or limitation you are having in your project

Slow debugging of functions that can be made more swift

Describe the feature / enhancement and how it helps to overcome the problem or limitation

zed-industries/zed#8344 (comment)

So you'd highlight a function via highlighting it with your mouse and then hit something like F6 (or maybe right click its name, whatever) and then you'd be prompted in the terminal to input the values of all the arguments and it would show you what the function returned as well as outputted (etc.). Useful debugging feature.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

def coinToss (color, amount, speed):
CODE HERE

the terminal would be prompt me for all parameters (someone else can figure out if we should make the user define the variable type while inputting too)
Insert color:
Insert amount:
Insert speed:

and it would then show the outputs of all variables and what returned.

if the function is recursive it would display each recursuions values and if the function had args (undefined amount of parameters) the terminal would ask how many you want to put in

or maybe have it just display return output, or have it as an option for the user. general idea. maybe for handling of recursive functions or functions with an undefined amount of parameters, etc. we just show recursion graphs and have a certain string to stop inputting?

If this enhancement will not be used often, can it be worked around with a few lines of script?

no this is integral

Is there a reason why this should be core and not an add-on in the asset library?

it's a core debugging tool

@Calinou Calinou changed the title Run single function Implement running a single function within the script editor for debugging purposes Feb 29, 2024
@AThousandShips
Copy link
Member

no this is integral

This question doesn't ask if the exact feature can be worked around, but if you can achieve something sufficient

For this the answer is very simple, yes, with an editor script calling the method

The main issue I see here is this: other than static methods this requires an instance to run on, your proposal doesn't mention this at all, how do you call a method that's on, for example, the Player.gd script? What instance is it called on?

If it's not a matter of such a method it's simple to do this with an editor script, if not the way to achieve it needs to be explained

@KoBeWi
Copy link
Member

KoBeWi commented Mar 1, 2024

This is basically #4473, no?

@Mickeon
Copy link

Mickeon commented Mar 1, 2024

There should be some addons out there that allow you to swiftly test pieces of code. I have definitely seen them, but I cannot provide them currently.

If you want to run a function from the Editor you could write a EditorScript, too. For your use-cases it would probably require some copy-pasting, but it is not easily avoidable.

It's important to note that GDScript is primarily based on classes, objects, instances... The result of a function can greatly vary depending on the instance calling it. The proposal you suggest may not be feasible because how would the Script Editor know what instance is supposed to call the method?

@AThousandShips
Copy link
Member

See also:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants