ProjectUnifree / unifree

MIT License
1.43k stars 75 forks source link

Ternary Operators #36

Closed ngrealish closed 11 months ago

ngrealish commented 12 months ago

In C# / Unity, to write a Ternary operator, syntax is

variable = (condition) ? true : false;

Where in GDScript, it's

variable = true if (condition) else false

Here is an example from one of my projects:

C#: max_pos.x = (booster_offset.x > max_pos.x) ? booster_offset.x : max_pos.x GDScript: max_pos.x = booster_offset.x if (booster_offset.x > max_pos.x) else max_pos.x

If there's a way to add this to the conversion or train gpt for this, that'd be great for someone like me who uses ternary operators quite often.

FlooferLand commented 12 months ago

I've made a branch, but I can't test it out because of OpenAI's API rate limits. Feel free to try it out at FlooferLand/unifree/tree/ternary and provide any feedback!

bshikin commented 11 months ago

@FlooferLand I think we have a more comprehensive solution with the RAG LLM approach (https://github.com/ProjectUnifree/unifree/pull/47)

@ngrealish once the PR above is merged ternary operator would be translated correctly.

PLEASE FILE TRANSLATION REQUESTS We now have a framework to accommodate them.

bshikin commented 11 months ago

Fix has been merged into master.