SLib: Simplifying Power, Limitless Flexibility!

Welcome to SLib project!

You can see last release note here: SLib: Simplifying Power, Limitless Flexibility! - #17 by Mahan

Note: We use horizontal separator lines to indicate different parts of the post, if you want to skip a part, go to the next separator line.


The fastest answer to the question “What is SLib?”

SLib is a versatile library whose functions are used in any project, SLib improves code quality several times, increases its readability, prevents errors, and thus makes your project better and faster than before! The following code is just one of the things that SLib does:

With SLib: Just 1 Line, Just 1 Parameter For Work As Well, Automated Error-Handling, With Very Simple Syntax! :sunglasses:

Any code is even shorter than the text you’re writing about!

# This one line of code creates a backup of the player's data file with an optional
# suffix next to it, it has the ability to check all types of errors and manage them,
# prevent syntax errors, repeating lines and code length.
SLib.backup_file("user://main_data.json")

Without SLib: 11 Lines, Repeate Lines :confused:, Generate Useless Variablesm, Difficult Sytax :dizzy_face:

It’s so long that by the time you get to the end, you’ll have forgotten what this code is for…

# These 11 lines of code do the same thing as one line above, with the difference that
# the file suffix and path must be specified in several places each time. 
# and creates variables that are no longer usable!
var target_file = "user://main_data.json"
var file_access := FileAccess.open(target_file, FileAccess.READ)
var json_string := file_access.get_line()
file_access.close()
var json := JSON.new()
json.parse(json_string)
var data = json.data
var backup_json_string := JSON.stringify(data)
var backup_file_access := FileAccess.open(target_file.get_basename() + "-Backup." +target_file.get_extension(), FileAccess.WRITE)
backup_file_access.store_var(backup_json_string)
backup_file_access.close()
2 Likes

Thank you for your contribution.
One way to make it even better is if you could incorporate Godot-styled documentation. That way, the method documentation can be opened and explained straight from within the editor.

More on that can be found here.

2 Likes

I have done this and added new ones, this version is available, thank you very much!

Thanks for your work! I am looking for something like your library but at the moment I’d use maybe 2 functions, since it’s very project specific you know? I have the same issue with similar libraries for Godot that are hosted on Github. Will you accept contributions?

1 Like

A new version has been released, including a new suggested feature:

  • Consolidator of arrays

Available now from here, thanks for your participation!

The install instruction list:

But this variable is already accessable by the autoload? I believe this will produce a warning/error for shadowing the autoload and recommend removing this step 3 from the install instructions.


The SendError function is being used backwards in the SLib.gd, the first argument is defined as the error message, and the second argument is the location. So the doc comments reports errors will say

“Can’t load from -->file_location<–, file not exists!” From “BackupFile”

But the actual error reads:

“BackupFile” From “Can’t load from -->file_location<–, file not exists!”


I find myself using these two functions often, if you want to include them:

## finds the first child of a given class, does not find class_name declarations
func find_child_of_class(node: Node, typename: StringName, descendants: bool = false) -> Node:
	for child in node.get_children():
		if child.is_class(typename):
			return child
		elif descendants:
			var found: Node = find_child_of_class(child, typename, descendants)
			if found:
				return found
	return null


## time based smooth interpolation, [b]not framedependant[/b] like [code]a = lerp(a, b, delta)[/code]
## Set [i]decay[/i] to 1-25 for a good range of values
func exp_decay(a, b, decay: float, delta: float):
	return b + (a - b) * exp(-decay * delta)

Oh I’ll check these out soon, if it’s possible to express them on GitHub.

Thank you very much! All fixed and added the two functions you mentioned, I have publish a pre-release version for try, if there are any problems with it I will be happy to state it here!
The pre-release is available here:

1 Like

I publish new beta update:

  • Add FindChildOfClass function.
  • Add expDecay function.
  • Write types.
  • Error and Warning functions update.
  • Create SLibSettings.
  • Add Appear function.
  • Add Disapear function.
  • Add PauseChange function.

The major changes of these changes have been made according to the participation in this topic.
Thank you all and I hope you find this helpful!
I still welcome new suggestions but I recommend creating a fork.
1.0.3 Beta (2):

I have added a new feature that is very useful, here is the guide to use it:

1 Like

Version 1.0.3-Stable has been released!
New features, updated items, bug fixes and added a plugin for project settings.
Change Logs:

  • Add FindChildOfClass function.
  • Add expDecay function.
  • Write types.
  • Error and Warning functions update.
  • Add Appear function.
  • Add Disapear function.
  • Add PauseChange function.
  • Create SLibConfig plugin.

Special thanks to snipercup for the contribution.

Download and use this version:

A heads up, seems like you’ve committed the .godot directory to your github. It’s highly recommended to remove and ignore that directory. I can see your personal editor changes in the repository and some of your computer’s filepaths.

Oh, thanks, .gitignore file was corrupted in a merge.

A new version has been released!
Currently, this library has the following items:

  • Customization using the user interface for developers
  • Several different but useful, standard and fast ways to work with all kinds of files
  • A separate environment and GUI for working with paths and using them optimally
  • Integrated system for working with Tweens
  • Special tools for handling arrays and dictionaries
  • Intelligent management of scenes and easy to use them
  • Automatic recording of logs
  • Quick access to project settings
  • Intelligent and versatile communication with the OS
  • Automatic and simple management of pause and unpause
  • Built-in troubleshooting capabilities for your project
  • Improved delay system in Godot
  • Advanced and fast macros to speed up project development
  • and many other features…

SLib is free, open source, lightweight, easy to install, and helps make your code more readable and maintainable.

You can see all the details on the project page:

Or use the quick start notes:

Here is the latest version available for download:


SLib - Powered by GODOT ENGINE & SUBJECT TEAM


SLib is now available in AssetLib :tada: , installation guide from AssetLib:

SLib is ready for anything!

SLib is a plugin that makes your code much more readable, cleaner, and more stable after installation. This library offers long processes with just one line of code by putting frequently used code into ready-to-use functions. Join the SLib community and take your code to the next level:

Download latest version from releases

or get the v1.0.7-stable from the asset library!

Contributors

This project expands with your contributions:

Three months after our last release :spiral_calendar:, we’re thrilled to announce the launch of version 1.1.0 beta 1 today! With an astounding 600 changes and the longest changelog in our history, SLib is on the cusp of a stable release, and we can’t wait for you to explore the significant enhancements in structure and documentation. :gdparty:


SLib is designed to empower developers with a suite of complementary functions, all wrapped in user-friendly formats:

  • Experience unparalleled code readability that transforms debugging and development into an enjoyable journey. :dark_sunglasses:
  • Say goodbye to lengthy code; with just a single line, you can automate entire processes. :scroll:
  • Accelerate your development speed by cutting through code complexity, allowing you to concentrate on what truly matters—your project logic. :thinking:
  • Seamlessly connect related tasks, even those that lack syntactical similarities, to streamline your workflow. :toolbox:
  • Enjoy lightning-fast, efficient file interactions, bolstered by an intelligent automated error management system. :bug:
  • Personalize your debugging experience to suit your needs. :lady_beetle:
  • Break free from the constraints of default functions. :rocket:
  • Watch as keywords are automatically recognized and converted into library functions, letting you code without the traditional coding hassle! :keyboard:
  • And there’s so much more to discover.

This beta version boasts major updates and, as of now, is free from known issues. It’s your opportunity for a final review to ensure everything functions smoothly while we refine the documentation and macros, And it’s a great time to adapt your project to minor library changes before the official release! :relieved:


Don’t miss out on the latest version! For quick access to the updates, installation guides, and comprehensive tutorials, visit: Release v1.1.0-beta (1) · Subject-Team/SLib · GitHub :link:


Curious to see SLib in action? :wrench: Check out our project’s public webpage:


For projects that you already have SLib installed on, Merging Method for Update is the fastest way to update, review here to make sure you’re using the best possible method! :gear:

For the best experience for new developer with SLib, we highly recommend a quick start! :100:


A heartfelt thank you to @gertkeno, @snipercup, @Locher, @Moreus, @AlexanderLife, and all the incredible contributors who have made this project possible! :bulb:

2 Likes

Great Work thanks. seems like each function has good documentation impressive.

1 Like