Skip to content

A Godot Engine plugin to simplify using F# through the C# Mono language.

License

Notifications You must be signed in to change notification settings

willnationsdev/godot-fsharp-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Godot F# Tools

A Godot Engine plugin to simplify using F# through the C# Mono language.

Features

  • Generating an F# project file and adding it to your Godot C# project/solution
    • via Tools menu shortcut.
  • Generating an F# script from a selected C# script.
    • via Tools menu shortcut.
  • Automatically Generating F# scripts from all C# scripts.
    • via configuration in ProjectSettings under Mono > F# Tools
    • Note: All F# classes must have the same name as their C# counterpart with an "Fs" on the end, e.g. MyClass.cs -> MyClassFs.fs.

How to install

  1. Download the .zip from GitHub or clone the repository.
  2. Copy/paste the addons directory into your project or create a symlink between the addons/godot-fsharp-tools directory and a similar one in your project.
  3. Open the ProjectSettings, go to the Plugins tab, find "Godot F# Tools" and switch it from "Inactive" to "Active" on the right-hand side.
  4. Make sure that you've installed the Mono version of Godot and the dotnet command line tool of which this plugin makes heavy use.

How to use

These instructions assume that you...

  1. Have already created a C# project/solution by first creating at least one C# script in your Godot project.
  2. Have installed and activated the plugin.

Generate F# Project

  1. Go to Project > Tools > Setup F# project.... A dialog will open.
  2. Fill in the necessary fields. Unnecessary fields will tell you what default value they become if left empty.
  3. Once confirmed, the dialog will generate the F# project and connect it to your C# project/solution for you. This may take a short while.

Generate single F# script from a C# script

  1. Go to Project > Tools > Generate F# script from C# script.... A dialog will open.
  2. Fill in the necessary fields. Unnecessary fields will tell you what default value they become if left empty.
    • The namespace must match that of the F# library project to which you plan to add it.
  3. Once confirmed, the dialog will generate the F# script and update the C# script to inherit from your F# class and include its namespace.
  4. You will need to add the new F# script file to your F# library project manually.*

Generate F# scripts from all created C# scripts

  1. Go to Project > ProjectSettings. Go to the General tab. Scroll all the way to the bottom and find the Mono > F# Tools category.
  2. Fill in information for all fields in this section.
    • The namespace must match that of the F# library project to which you plan to add it.
    • For better organization, we recommend using the F# library project directory for the output directory.
  3. Create a C# script. The editor will generate a corresponding F# script in the output directory and update the C# script to inherit from your F# class and include its namespace.
  4. You will need to add the new F# script file to your F# library project manually.*

* The reason you must do this manually is because...

  1. the dotnet tool from Microsoft does not support adding items to projects ("Really? Seriously? Professional stuff here guys").
  2. Godot's XmlParser class only allows you to read XML nodes, but not insert them into an .xml file ("Really? I mean, that could be useful guys...").
  3. If you want to write your own XML parsing code to inject the file reference into the <ItemGroup> tag hierarchy, it would be appreciated.

For the uninformed, you add an existing item to an F# project in the following way:

  1. Have Visual Studio installed with F# support.
  2. Open the Godot .sln file in Visual Studio.
  3. Right click on the F# library project in the Solution Explorer dock.
  4. Go to Add > Add Existing Item....
  5. Choose the <classname>Fs.fs file you generated. Hit "OK".

OR

  1. Have Visual Studio Code installed with the Ionide-fsharp extension.
  2. Open the Godot directory in your workspace. Ionide's F# solution tab should automatically detect and add the F# project.
  3. In the F# tab on the left, you should see your project's .sln and under it the .csproj / .fsproj directories.
  4. Right-click the F# project directory. Choose Add file.
  5. Within the command pallete line edit, type out the name of the F# source file in that directory you want to add. Hit Enter.

The F# source file is now added to the F# project!


If you like the project, please give it a star and consider donating to my Kofi. If you have any problems whatsoever, do not hesitate to open an Issue.

About

A Godot Engine plugin to simplify using F# through the C# Mono language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published