Skip to content

Scripts can now be saved ANYWHERE!#669

Merged
adriengivry merged 8 commits intomainfrom
feature/no_more_scripts_folder
Apr 8, 2026
Merged

Scripts can now be saved ANYWHERE!#669
adriengivry merged 8 commits intomainfrom
feature/no_more_scripts_folder

Conversation

@adriengivry
Copy link
Copy Markdown
Member

@adriengivry adriengivry commented Apr 8, 2026

Description

Previously, Overload always created a Scripts/ folder inside of a user's project folder.
Scripts can now be located anywhere inside of the project's Assets/ folder.
This allow scripts to be placed anywhere, including inside of sub-folders.

Technically this would be a breaking change, but a nice window has been added to automatically relocate scripts from Scripts/ to Assets/Scripts/ when an old project is opened.

image

In Lua, behaviours can be retrieved using GetBehaviour:

--- Assuming a script Foo.lua is located in a Scripts/ folder
--- The following calls are valid:
self.owner:GetBehaviour("Foo") --- by script name
self.owner:GetBehaviour("Scripts/Foo") --- by script path
self.owner:GetBehaviour("Scripts/Foo.lua") --- by script path with extension

Related Issue(s)

Fixes #385

Review Guidance

Write here.

Screenshots/GIFs

image

Checklist

  • My code follows the project's code style guidelines
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • My changes don't generate new warnings or errors

@adriengivry adriengivry self-assigned this Apr 8, 2026
@adriengivry adriengivry added Breaking Change Something that will break retro-compatibility or can affect other parts of the code base QoL Quality of Life : Something that can improve users productivity labels Apr 8, 2026
Comment on lines +75 to +97
// First try matching by script name (stem without path or extension)
OvCore::ECS::Components::Behaviour* behaviour = nullptr;
for (auto& [key, b] : p_this.GetBehaviours())
{
if (std::filesystem::path(b.name).stem().string() == p_name)
{
behaviour = &b;
break;
}
}

// Fall back to path-based match: try as-is, then with .lua appended if no extension given
if (!behaviour)
{
behaviour = p_this.GetBehaviour(p_name);
}

if (!behaviour && std::filesystem::path(p_name).extension().empty())
{
behaviour = p_this.GetBehaviour(p_name + ".lua");
}

if (behaviour)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not exactly thrilled about this, but this is necessary to keep all the GetBehaviour("{name}") from breaking after this update. Another option would be to move this code to GetBehaviour itself, but having lua-specific code in there wouldn't make much sense. Could definitely be improved in the future tho.

@adriengivry adriengivry marked this pull request as ready for review April 8, 2026 21:07
@adriengivry adriengivry merged commit 221ebfc into main Apr 8, 2026
4 checks passed
@adriengivry adriengivry deleted the feature/no_more_scripts_folder branch April 8, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking Change Something that will break retro-compatibility or can affect other parts of the code base QoL Quality of Life : Something that can improve users productivity

Development

Successfully merging this pull request may close these issues.

Move scripts to the Assets/ folder

1 participant