I added Lua Support to V-slice. I don't know what to add mor-
You can download the LuaSlice Versions Here:
.luascripts are isolated. They get private script environments..luagscripts are global. They share globals with other global Lua scripts.- Both script types can use the Lua API.
.luagis best for shared helpers and compatibility modules.- Lua support is enabled by default on native C++ builds, including normal
lime build windowsandlime test windows. - Use
-DNO_LUAto build without Lua support.
LuaSlice looks for scripts in these places:
mods/global.luamods/global.luagmods/scripts/global.luamods/scripts/global.luagmods/scripts/*.luamods/scripts/*.luagmods/scripts/freeplay/*.luamods/scripts/freeplay/*.luagmods/scripts/story/*.luamods/scripts/story/*.luagmods/scripts/results/*.luamods/scripts/results/*.luagmods/scripts/song-SongId.luamods/scripts/SongId.luamods/scripts/stage-StageId.luamods/scripts/StageId.luamods/scripts/stages/StageId.luamods/SongId/script.luamods/SongId/scripts/song.luamods/stages/StageId.luamods/<mod name>/global.luamods/<mod name>/global.luagmods/<mod name>/script.luamods/<mod name>/script.luagmods/<mod name>/scripts/global.luamods/<mod name>/scripts/global.luagmods/<mod name>/scripts/song-SongId.luamods/<mod name>/scripts/SongId.luamods/<mod name>/scripts/stage-StageId.luamods/<mod name>/scripts/stages/StageId.luamods/<mod name>/songs/SongId/script.luamods/<mod name>/data/songs/SongId/script.luamods/<mod name>/stages/StageId.luamods/<mod name>/script/*.luamods/<mod name>/script/*.luagmods/<mod name>/scripts/*.luamods/<mod name>/scripts/*.luagmods/<mod name>/scripts/freeplay/*.luamods/<mod name>/scripts/freeplay/*.luagmods/<mod name>/scripts/story/*.luamods/<mod name>/scripts/story/*.luagmods/<mod name>/scripts/results/*.luamods/<mod name>/scripts/results/*.luag
Folder rule:
scripts/lualoads.luaonly.scripts/luagloads.luagonly.scripts/menuloads on the Main Menu only.scripts/optionsloads in the Options menu only.scripts/pauseloads in PlayState and can configure the pause menu when it opens.scripts/freeplayloads in Freeplay.scripts/storyloads in Story Menu.scripts/resultsloads in Results.- F5 reloads PlayState Lua from normal gameplay folders, including modules, gameplay, player/opponent, songs, stages, characters, events, notekinds, shaders, dialogue, levels, pause, lua, and luag folders.
- Other script folders can load both
.luaand.luag.
mods/?.luamods/?.luagmods/?/init.luamods/?/init.luagmods/scripts/?.luamods/scripts/?.luagmods/scripts/?/init.luamods/scripts/?/init.luagmods/<mod name>/?.luamods/<mod name>/?.luagmods/<mod name>/?/init.luamods/<mod name>/?/init.luagmods/<mod name>/script/?.luamods/<mod name>/script/?.luagmods/<mod name>/scripts/?.luamods/<mod name>/scripts/?.luag
- F5 reloads Lua scripts in PlayState.
reloadLuaScripts()safely requests the same reload from Lua.- Reload rescans mod folders, so added or removed
.luaand.luagscripts update. onReload()is called after scripts reload.- Script-created sprites, text, sounds, tweens, timers, menus, shaders, and objects are cleaned up before reload.
These are small wrappers for common Lua work:
addLuaMainMenu(id, position, target, assetPath, animName)adds a main menu item.makeLuaMenuSimple(id, items, x, y, spacing)creates a simple text menu.makeLuaImageMenuSimple(id, items, x, y, spacing)creates a simple image menu.initLuaShader(name)loads a shader by name and uses that name as the tag.initLuaShader(name, tag)loads a shader by name and stores it under a custom tag.makeLuaShader(tag, path, vertexPath)creates a shader from a fragment path/source and optional vertex path/source.setLuaShader(tag, target)applies a shader to a Lua object or engine path.setShaderOnSprite(sprite, tag)applies a shader to a sprite using sprite-first argument order.setLuaCameraShader(tag, camera)applies a shader to a camera.getLuaSave(key, fallback)andsetLuaSave(key, value)store Lua data in the game save.
Options still use the normal simple option API: createLuaOptionPage, addLuaCheckbox, addLuaNumber, and addLuaEnum.
- Pause menu items are added/edited with
configureLuaPauseMenu({ items = {...} }). - Pause menu item targets:
resume,restartSong,changeDifficulty,practiceMode,exitToMenu,options,callback, or a custom.hx/.hxcstate class. - Pause menu targets can use per-item config, such as
options = { hideExit = true, howExit = "BackToSong" }for the pause-opened Options screen. setLuaPauseOptions(howExit)controls where pause-opened Options goes when backing out.- Freeplay hooks:
onFreeplayCreate()onFreeplayUpdate(elapsed)onFreeplayClose()
- Story Menu hooks:
onStoryCreate()onStoryUpdate(elapsed)onStoryClose()
- Results hooks:
onResultsCreate()onResultsUpdate(elapsed)onResultsClose()
- These screen hooks load from
scripts/freeplay,scripts/story, andscripts/results.
- Lua errors write reports to
logs/lua. - Error windows show script path, hook/API name, line number when Lua provides it, report path, and the error text.
- Suggestions show in the popup when LuaSlice knows a likely fix.
- If there is no useful suggestion, reports say
Suggestions: None. - Per-frame hook errors show a warning when repeated errors could hurt FPS or memory.
-DFEATURE_LOGGERenables LuaSlice's live Lua logger.- Example:
lime test windows -DFEATURE_LOGGER. - Logger builds still include the Lua API by default unless
-DNO_LUAis also passed. - Logger output includes loaded Lua script lists, Lua errors, and simple variable logs.
- Logger builds output to
export/logger/<target>/bin. - The normal Windows build keeps
FEATURE_LOGGERdisabled and outputs toexport/release/<target>/bin.
- Core helpers:
require, JSON, text files, random numbers, keyboard input, mouse input. - PlayState/song: song position, beat, step, section, song id/name, difficulty, variation, stage id, playback rate, scroll speed, health, score, combo, tallies, accuracy, botplay, practice mode, countdown, restart, end song, vocals volume.
- Events: create, reload, update, step, beat, section, destroy, countdown, song start/end, pause/resume, game over, note hit/miss, ghost miss, hold drop, note incoming, song events, retry, key up/down, focus, state/substate, dialogue.
- Live event editing: current event access, event fields, event canceling, propagation control.
- Notes: note payloads, strum time, direction, kind/noteData, raw note object access.
- Strumlines: player/opponent strumlines, position, alpha, visible, receptor positions, receptor animations, note splashes, scroll speed.
- Characters: boyfriend, dad, girlfriend, health icons, animations, raw fields and methods.
- Stage: current stage, stage props, stage characters, camera zoom, raw stage access, PlayState object insertion, z-index refresh.
- Sprites: static sprites, Sparrow sprites, solid sprites, cameras, position, scale, size, alpha, visibility, angle, color, velocity, acceleration, scroll factor, zIndex, screen centering, kill/revive, animations.
- Text/HUD: FlxText creation, formatting, HUD camera, score text, health bar, combo popups, icons.
- Cameras: flash, fade, shake, zoom, alpha, background color, visibility, position, follow point, camera bop, reset, tween zoom, tween position, cancel camera tweens.
- Audio: tagged sounds, music controls, vocals, volume controls, raw
FlxG.soundaccess. - Tweens/timers: tagged tweens, X/Y/alpha/angle aliases, canceling, timers, completion hooks.
- Custom options:
LuaOptionManagermakes Lua options easier, cleaner, and less complex. - Custom menus:
LuaMenusManagercan make Lua menus, insert real main menu entries, configure pause menu items, and open base menus or custom.hx/.hxcstate classes. - Shaders:
LuaShaderManagermakes shaders easier to load, apply, and un-apply from Lua. - Lua save data: persistent Lua values through
getLuaSaveandsetLuaSave. - Menu hooks: Freeplay, Story Menu, and Results scripts can run create/update/close hooks.
- Lua logger:
-DFEATURE_LOGGERenables cleaner live Lua logging for scripts, errors, and simple variable logs. - Raw bridge:
getProperty,setProperty,callMethod, static access, arrays, stored objects, object creation/destruction.
- HTML5 does not use hxlua. | Never.
-DNO_LUAdisables Lua support for builds that need it.