Giter Club home page Giter Club logo

godot-uncruft's Introduction

Uncruft

Uncruft adds expressive macro/code generating capability to your GDScripts so you don't have to hand write large amounts of code.

Features:

  • Flexibility: Macros can be expanded or their expanded code cleared with 1 button press.
  • Transparent expansion and encapsulation: Macros expand visibly in code with clear demarcations of where they start and end.
  • Optional end user usage: Making a library or OSS? No worries, expanded macros are embedded in your code.
  • Unintrusive and backwards compatible: You can use macros in any version of Godot and you don't even need to (re)compile the engine.
  • Expandable and customizable: Make your own macros with the simple built in templating function or write your own templating function.

Motivation

While GDScript is a great language with a lot of features, I found myself having to write a lot of glue code to get things to work as intended. This addon is designed specifically to solve that issue.

Issues

Uncruft is currently in Beta, expect bugs/explosions. The API and/or macro usage language may change. Use of a VCS is recommended!

Installation

Installing Uncruft is similar to installing other Godot addons. Simply download the addon via Git or Zip. Place the "uncruft" directory in the "addons" folder in your project and enable it through the addons menu.

Macros

Macros are written with the #@ suffix and have a fixed language structure not dissimilar to CLI applications:

#@command positional_key_1=value position_key_2=value

Built in macros

export

The export macro allows you to write setget exports that require a function to be called after the property has been set:

Motivation

When writing Godot tools it's often imperitive that the control be updated when a property is changed in the properties toolbar. With the export macro this can be achieved quite simply without having to write multiple lines of code, copying each line for each property.

Example

#@export type=String name=sword_name default="\"New Sword\"" post_func=_on_property_changed

Will expand to:

#@export type=String name=sword_name default="\"New Sword\"" post_func=_on_property_changed
export(String) var sword_name = "New Sword" setget set_prop_sword_name;
func set_prop_sword_name(v):
    sword_name = v;
    _on_property_changed("sword_name", v);
#@/export

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.