-
-
Notifications
You must be signed in to change notification settings - Fork 2
AmbleScript ( LUA ) & JSON defined GUIs #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add core Lua infrastructure (GuiScript, GuiScriptManager, LuaBinder, LuaExpose annotation) - Add LuaElement wrapper to expose AmbleElement properties to Lua scripts - Add Minecraft API bindings (MinecraftData, MinecraftEntity, LuaItemStack) - Integrate script callbacks (onInit, onClick, onRelease, onHover) into AmbleButton - Add script property support in JSON GUI definitions - Improve AmbleText with proper text wrapping and shadow toggle - Add setDimensions helper to AmbleElement
- Rename GuiScript to AmbleScript and GuiScriptManager to ScriptManager - Move scripts from gui/script/ to script/ folder for broader use - Add ExecuteScriptCommand (/amblescript execute) to run scripts via chat - Auto-discover scripts on resource reload for command tab-completion - Add onExecute callback support for scripts triggered by command
Introduce server-side Lua scripting system parallel to client scripts: - Add ServerScriptManager for managing data pack scripts - Add ServerScriptCommand with enable/disable/execute/toggle/list commands - Refactor Lua bindings to shared script.lua package - Add ServerMinecraftData with server-specific APIs - Include example server scripts (admin_commands, tick_counter, etc.)
- enable/disable/toggle only suggest scripts with onTick method - execute only suggests scripts with onExecute method
src/main/java/dev/amble/lib/client/gui/registry/AmbleGuiRegistry.java
Outdated
Show resolved
Hide resolved
Key improvements: - Extract AbstractScriptManager for DRY between client/server scripts - Add type-specific coercion methods to LuaBinder for clarity - Add toString methods for Vector3f, Vec3d, BlockPos in Lua - Add structured NBT access via nbt() method, deprecate nbtString() - Use IntIntImmutablePair from fastutil in AmbleElement - Add text caching in AmbleText to avoid recalculation - Add @ApiStatus.Internal and javadoc to LuaElement.unwrap() - Add init() method with javadoc to AmbleGuiRegistry - Pass resourceId to parse() for better error context - Add validation for array sizes and identifier parsing - Add FALLBACK_LAYOUT constant in AmbleContainer - Add script name logging via setScriptName/getLogPrefix - Rename ExecuteScriptCommand to ClientScriptCommand - Use Command.SINGLE_SUCCESS consistently
…actor, constants, docs
|
All review comments have been addressed. Changes include:
Ready for re-review. @drtheodor |
|
Implemented support for checking any registered keybind, not just the hardcoded movement keys. Changes to \isKeyPressed:
New method \getKeybinds():
This allows Lua scripts to check any keybind from vanilla Minecraft or mods. |
- Support shorthand keybind names: forward, jump, inventory, sprint, etc. - Support raw keyboard keys: r, h, space, left_shift, escape, f1, etc. - Support registered keybind translation keys - Add isMouseButtonPressed for mouse button checks - Falls back through keybinds then raw keys for maximum flexibility
|
Updated: Merged the functionality into a single \isKeyPressed\ method that now supports:
Example usage in Lua: -- Still works with keybinds Also added \isMouseButtonPressed()\ for mouse button checks. |
- Add LUA_SCRIPTING.md with full API reference, lifecycle callbacks, and examples - Add GUI_SYSTEM.md with JSON structure docs, properties reference, and Lua integration - Update README.md with brief descriptions and links to new documentation - Fix AmbleGuiRegistry to auto-create child AmbleText when button has text property
src/main/java/dev/amble/lib/client/command/ClientScriptCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/dev/amble/lib/client/command/ClientScriptCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/dev/amble/lib/client/command/ClientScriptCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/dev/amble/lib/client/command/ClientScriptCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/dev/amble/lib/client/command/ClientScriptCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/dev/amble/lib/client/command/ClientScriptCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/dev/amble/lib/client/command/ClientScriptCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/dev/amble/lib/client/command/ClientScriptCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/dev/amble/lib/client/command/ClientScriptCommand.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| @LuaExpose | ||
| public int x() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This question still stands.
…method for improved Lua scripting support
src/main/java/dev/amble/lib/client/command/ClientScriptCommand.java
Outdated
Show resolved
Hide resolved
…istency Add Testmod Client 2 configuration in build.gradle
drtheodor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yk
accidentally merged #58