What functions do you use a lot?

Hello! I have recently created a library for frequently used code, but I have no idea how to extend it, so I decided to ask your ideas, what functions do you use a lot?
Maybe I can help your code by expanding this library :slight_smile:
Thank you in advance.

1 Like

I have one Global autoload which houses lots of universally used methods. As I like working with Tweens, I got global methods to make objects appear and disappear.

func appear(object) -> void:
    object.show() 
    create_tween().tween_property(object, "modulate", Color.WHITE, 1.0)

func disappear(object) -> void:
    var tween = create_tween()
    tween.tween_property(object, "modulate", Color.TRANSPARENT, 1.0)
    tween.finished.connect(func(): object.hide())

There are also some others like pausing and unpausing, or waiting a float amount of seconds. The latter has the problem that i need to add the await keyword.
await Global.delay(1.5)

2 Likes

Me too, but I don’t use it for frequently used functions, because that makes it impossible for me to use it in every project (because every program has its own global variables); That’s why I decided to make this project.
I am working on these things you mentioned.
Do you keep other functions in your Global autoload?

this one
obraz

because every program has its own global variables

I trying make my base code not depends on global things,

I have base class with logic and expected returns
sorry is C# but I mainly work with it

[GlobalClass]
public abstract partial class ConditionValidator : Resource
{
    public abstract bool Validate();
}

now i can make lots custom Validators they can connect to globals and return me true or false on Validate();
obraz

My most used C# interface is

public interface IDamageable<T>
{
    void Damage(T damageTaken);
}

is generic but usually use float anyway

I actually have a number of Autoloads that all serve specific functions

  • Global: houses globally available methods to be used by all objects (sometimes I also called it Util)
  • Connect: has all signals (I dont declare signals inside of classes or other scripts)
  • Path: has all resource and filepaths (I dont declare paths inside of classes or other scripts)
  • Session: has methods and variables in concern to game session and savedata

back to the Global autoload of mine, many methods are also debug methods so i can print out whatever i require, or abuse the Global methods to shift data from one object to another object that have no way to communicate with each other.

2 Likes
static func ReverseDic(D:Dictionary):
	var R:Dictionary={}
	for K in D.keys():
		R[D[K]]=K
	return R

I thank you very much! I’ve added the code I found here, although I’m still unable to add some things (I’m not very good at C#). Check out what I’ve added, I hope it’s helpful!

I found a solution to the problem (necessary to use await) and this led me to add a lot of things that are very useful:

You can also use this method to write await Global.delay(1.5), but I recommend using SLib, it’s all ready!

thank you for the response!
Right now I am making use of Macros and already like my workflow

I am pretty sure many other people will find use for SLib and thanks for advertising it.