The Luny repositories follows a modular architecture with clear separation between:
.Unity, .Godot, etc.)Note: The current setup will not allow multiple LunyEngine-based frameworks to coexist in a single project. This will be improved in the future.
Luny frameworks should be imported into projects via the engine-native concept of a βpluginβ (package).
addons/ folder, then enable pluginFully operable engine projects for LunyScript development:
Note: I will most likely rename the example repositories in the future, replacing βScratchβ with βScriptβ.
These repositories contain documentation, design, notes.
This outlines the high-level steps. Where in doubt analyze and follow LunyScriptβs repository structure and setup.
This assumes that your framework is named βMyFrameworkβ - adjust as needed. If Luny becomes popular this process will be eased eg via setup scripts - I understand itβs more than βthe usualβ and seems complicated at first.
MyFramework-Examples-<Engine> engine-native project repositories, one per engine. Replace <Engine> with the name of the engine.MyFramework.UnityPackages/com.<yourdomain>.myframeworkMyFramework.Godotaddons/myframeworkLunyLuny.<Engine>MyFrameworkMyFramework.<Engine>Tests are co-located within their respective modules:
Luny/Tests/ - Core framework testsLuny.Unity/Tests/ - Unity integration tests (includes test scenes)MyFramework/Tests/ - Script system testsMyFramework.Unity/Tests/ - Unity-specific script testsYour MyFramework Godot addon structure should look like this:
addons/
βββ myframework/
βββ plugin.cfg # Godot plugin config
βββ Luny/ # submodule
βββ Luny.Godot/ # submodule
βββ MyFramework/ # submodule
βββ MyFramework.Godot/ # submodule
This package is included as submodule in the MyFramework-Examples-Godot project and located in addons/myframework.
Your MyFramework Unity package structure should look like this:
Packages/
βββ de.<yourdomain>.myframework/
βββ package.json # Unity UPM package manifest
βββ Luny/ # submodule
βββ Luny.Unity/ # submodule
βββ MyFramework/ # submodule
βββ MyFramework.Unity/ # submodule
This package is included as submodule in the MyFramework-Examples-Unity project and located in Packages/de.<yourdomain>.myframework.
Ensure MyFramework Assembly Definition has No Engine References checked and depends on Luny. While MyFramework.Unity depends on both Luny and Luny.Unity.
Create Runtime or Editor folders as needed only within the MyFramework.Unity/ subfolder - donβt nest everything under Runtime or Editor folders!
This showcases the structure of a Unity upm package to get an idea of what it looks like. The Godot βaddonβ directory structure is practically identical.
de.codesmile.lunyscript/ (submodule in project, located in: Packages/de.codesmile.lunyscript)
βββ package.json # Unity UPM package manifest
βββ README.md # Plugin readme
βββ ... # Any other plugin files or support code
β
βββ Luny/ (submodule) # Core engine framework (engine-agnostic)
β βββ Core/ # Logging, number utilities, trace logging
β βββ Engine/ # Engine abstraction layer
β β βββ Bridge/ # Engine adapter interfaces
β β βββ Identity/ # Object identification structs
β β βββ Services/ # Service registry pattern
β β βββ Diagnostics/ # Profiling and logging
β βββ Exceptions/ # Framework-specific exceptions
β βββ Extensions/ # Utility extensions for System types
β βββ Tests/ # Core framework tests
β
βββ Luny.Unity/ (submodule) # Unity-specific engine integration
β βββ Engine/
β β βββ Bridge/ # Unity adapter implementation
β β βββ Services/ # Unity service implementations
β βββ Editor/ # Unity Editor utilities
β β βββ Linking/ # Linker stripping hints
β βββ Tests/ # Unity integration tests
β
βββ LunyScript/ (submodule) # Scripting DSL (engine-agnostic)
β βββ Blocks/ # Scripting blocks
β β βββ Debug/ # Debugging blocks
β β βββ Editor/ # Editor-related blocks
β β βββ Engine/ # Engine lifecycle blocks
β β βββ Object/ # Object manipulation blocks
β β βββ Run/ # Execution control blocks
β β βββ Scene/ # Scene management blocks
β βββ Core/ # Script definitions, variables, IDs
β βββ Diagnostics/ # Profiling and logging
β βββ Events/ # Event scheduling and response
β βββ Execution/ # Script runner, activator, context
β βββ Runnables/ # Executable script interfaces
β βββ Tests/ # Script system tests
β
βββ LunyScript.Unity/ (subm.) # Unity-specific scripting integration
β βββ Editor/ # Unity Editor tools for LunyScript
β βββ Tests/ # Unity-specific script tests
β
βββ LunyLua/ (submodule) # Lua runtime integration
βββ Lua-CSharp/ # Lua C# bindings
The repository uses git submodules extensively for modular development:
Packages/de.codesmile.lunyscript is the main submoduleLuny/, Luny.Unity/, LunyScript/, etc.) are also git submodulesTo ensure proper submodule workflows one must first commit to submodules before committing repositories containing a modified submodule. A pre-commit hook that verifies this and prevents βdetached headβ issues is included below.
This avoids all of the frustrations developers without submodule experience usually face when first working with submodules. Submodules are otherwise fine, except that you manage multiple repositories.
Save this script in the projectβs repository root under .git/hooks as pre-commit text file. Only add this to the root repository, not in any of the submodules.
This pre-commit hook prevents commits if a submodule is βdirtyβ and should be committed first. If that is the case, a message pops up instructing you to first commit the submodule (you do not lose any changes). Works with both command line and git GUI tools (eg SourceTree).
#!/bin/sh
# Check if any submodule has uncommitted changes
git submodule foreach --quiet --recursive '
if [ -n "$(git status --porcelain)" ]; then
echo "ERROR: Submodule $path has uncommitted changes!"
echo "Commit submodule changes first, then commit parent."
exit 1
fi
'
# Check if any submodule has unpushed commits
git submodule foreach --quiet --recursive '
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse @{u} 2>/dev/null || echo $LOCAL)
if [ "$LOCAL" != "$REMOTE" ]; then
echo "ERROR: Submodule $path has unpushed commits!"
echo "Push submodule changes first, then commit parent."
exit 1
fi
'
On Linux/OS X you may have to give execute permission to the file. Review the git hook documentation.