Skip to content

Latest commit

 

History

History
127 lines (109 loc) · 26.3 KB

EXAMPLES.md

File metadata and controls

127 lines (109 loc) · 26.3 KB

BSX Lua example scripts

The example scripts in examples, with their hotkeys and what each one shows. The BSX Lua guide explains the functions they use.

Example scripts

Example hotkeys

Every example has its own default chord. Plain F10 opens the BSX Overlay when it is enabled; no example uses F10, F12 (Steam's screenshot key) or a chord without Ctrl. Chords match modifiers exactly, so Ctrl+F6 and Ctrl+Shift+F6 are different keys. Pick a free chord from this table for your own scripts.

Example Default chord What it does
gear_report Ctrl+Shift+F1 Logs equipped items and a distinct inventory-row count
travel_journal Ctrl+Shift+F2 Appends a position, time and weather journal entry
first_mod Ctrl+F6 ([FirstMod] Hotkey) Logs the player
clock_log Ctrl+F7 ([ClockLog] Hotkey) Logs game time and weather
quick_potion Ctrl+Shift+F6 Uses one configured item (approved scripts)
heal_hotkey Ctrl+F8 Change-approval refusal probe
where_am_i Ctrl+F9 Scope-read diagnostic
outfits Ctrl+Shift+F7 save, Ctrl+Shift+F8 restore Session-only equipped set; restore requires Changes approval
inventory_dump Ctrl+Shift+F9 Logs at most 50 copied inventory records
waypoints Ctrl+F11 save, Ctrl+Shift+F11 distance Saves a position and measures to it
weather_dial Ctrl+Shift+F5 Cycles rain/snow scaling (approved scripts, [Policies] precipitation=1)
instant_interact Ctrl+Shift+F3 Hold prompts finish at once (native hook rules)
gather_rates Ctrl+Shift+F4 ([Catch] Hotkey) More bugs and fish per catch (native hook rules)
stack_limits Ctrl+F1 ([StackLimits] Hotkey) Pauses raising item stack limits (native)
infinite_items Ctrl+F2 ([InfiniteItems] Hotkey) Cycles infinite-item modes (native hook rule)
stat_factors Ctrl+F4 ([StatFactors] Hotkey) Stamina and HP cost/recovery factors (native hook rules)
durability_wear Ctrl+Numpad1 ([Durability] Hotkey) Less or no durability wear (native hook rule)
ammo_saving Ctrl+Numpad2 ([Ammo] Hotkey) Ammunition is not used up (native hook rules)
flight_freedom Ctrl+Numpad3 ([FlightFreedom] Hotkey) No-fly zone and town-flight rules (native)
flight_cooldown_preview Ctrl+F5 Globally clears a configured matching status using an earlier row capture; inert until both values are supplied (native preview)
slow_motion Ctrl+Numpad0 ([SlowMotion] Hotkey) Switches world slow motion (native hook rule)
menu_pause Ctrl+Numpad5 ([MenuPause] Hotkey) Slow menus pause the game (native hook rule)
skill_gain Ctrl+Numpad6 ([SkillGain] Hotkey) Faster skill experience (native hook rule)
bounty_carry Ctrl+Numpad8 ([BountyCarry] Hotkey) Opens a carry window for teleporting with a bounty (native hook rules)
blackstar_stays Ctrl+Shift+Numpad1 ([BlackstarStays] Hotkey) Blackstar stays after landing (native hook rule)
wind_tuning Ctrl+Alt+Numpad2 ([WindTuning] Hotkey) Calmer dust wind (native hook rules)
wind_result Ctrl+Alt+Numpad6 Calmer dust wind, scaled after the getter returns (native after rule)
gear_transition Ctrl+Alt+Numpad3 ([GearTransition] Hotkey) Hides one known gear part key (native memory write)
marker_observer Ctrl+Alt+Numpad7 ([MarkerObserver] Hotkey) Logs changed map markers (native, observation only)
marker_guard_window Ctrl+Alt+Numpad9 Short damage guard window, armed by hand (native hook rule)
menu_instant_smoothing Ctrl+Shift+Numpad4 Menu speed changes at once (native memory write)
menu_first_descriptor Ctrl+Alt+Shift+Numpad1 Pause only when the first open menu asks for one configured speed, as Instant Menu Pause's full-pause filter does (native each list walk)
combat_hold_probe Ctrl+Alt+Shift+Numpad5 Counts combat condition checks while a key is held (default Space, 400 ms), stamped with cdal.tick; changes nothing (native observation rule)
mobility_jitter_guard Ctrl+Alt+Shift+Numpad6 Global horizontal multiplier with a 16-row per-position direction/time guard; see its eviction and input limits (native hook rules)
onfoot_reload_predicate Ctrl+Alt+Shift+Numpad7 On-foot reload predicate and formula preview with a checked state-link offset; name identity remains inferred (native hook rule)
mounted_reload_predicate Ctrl+Alt+Shift+Numpad2 ([MountedReloadPredicate] Hotkey) Dispatch-table reload preview; name and indirect callers remain unestablished (native hook rule)
motion_smooth_history Ctrl+Alt+Shift+Numpad8 Global per-position smooth direction preview; player, input and lock selection are unmapped (native hook rules)
slow_motion_ramp Ctrl+Shift+Numpad5 Eases world slow motion in and out (native hook rule)
legacy_motion_compensation Ctrl+Shift+Numpad6 Fixed horizontal speed-up for slow motion (native hook rule)
skill_cap_rule Ctrl+Shift+Numpad8 ([SkillCap] Hotkey) Raises the skill level cap (native memory write)
catch_types Ctrl+Alt+F4 ([Catch] Hotkey) Bug and fish catch quantities by type (native hook rules)
pet_loose_toggle Ctrl+Alt+F5 ([PetLooseLoot] Hotkey) Pets stop picking up loose items (native hook rule)
pet_body_toggle Ctrl+Alt+F8 ([PetBodyLoot] Hotkey) Pets stop looting bodies (native hook rule)
item_gain_factor Ctrl+Alt+F11 ([ItemGainFactor] Hotkey) Scales item amounts gained (native hook rule)
palm_boost Ctrl+Shift+Numpad3 Timed upward boost (native rules with clocks and cells)
infinite_items_exact Ctrl+Alt+F6 Cycles infinite-item modes at the exact store (native hook rule)
clock_fast_forward Ctrl+Alt+F1 Runs the game's clocks faster for a short hold (native clock rate)
clock_slow_preview Ctrl+Alt+F2 Switches the game's clocks to half speed (native clock rate)
motion_direction_step Ctrl+Alt+Numpad8 Fixed horizontal step along the movement direction (native hook rule)
horse_display_limit Ctrl+Numpad9 Older horse stamina display record edit (native hook rule)
key_echo none (logs every key for 30 seconds) Finds key codes

Some of these examples arrive in separate pull requests; the table lists the chords they reserve. UI panel examples (combat_overhaul_kit, api4_panel, api7_showcase, multi_file_kit, world_explorer_api6, world_inspector, world_controller, player_toolkit, gameplay_tweaks, photo_studio, appearance_studio, hud_overlay, wardrobe_presets, smart_town_sprint, spellcraft_recipes, vfx_playback_controls, vfx_beam_tether, vfx_socket_layers, raycast_projectiles, reactive_combat_vfx) use BSX Overlay controls (F10 / StartOpen=1) and optional configurable hotkeys instead of reserving global Ctrl chords.

Complete scripts are in examples; first_mod is the script built in Write your first Lua mod. To try one, copy its folder into BSX/scripts/ (for example BSX/scripts/hello/), start the game, and read its lines in BSX/bsx.log. Lua messages share that BSX log; there is no separate Lua log file.

  • combat_overhaul_kit (setup guide, lua_api 8, changes: true, uses "uses": ["combat", "player", "snapshots", "server_commands", "world", "ui"]) demonstrates an interactive combat overhaul overlay panel scaling attack/action/move speed, damage dealt/taken (coexisting with God Mode damage_taken = 0.0), knockback, life steal, groggy/stagger, and HP/Stamina/MP regeneration alongside reactive attack_hit hitstop triggers, just_action/kill/groggy_changed/buff_applied/buff_removed telemetry, game.stats.find_by_name, optional Wwise cues, debounced settings.ini persistence, and on_unload() auto-revert.

  • spellcraft_recipes (lua_api 7, changes: true, Experimental Test, uses "uses": ["ui", "player", "snapshots", "positions", "definitions", "world", "server_commands"]) demonstrates the composable multi-stage native .effect recipe engine (lib.catalog_resolver + lib.spellcraft_recipe) and shareable data/presets/*.json recipes across all 9 motion modes (straight, arc, homing, bounce, spiral, orbit, ring, follow, beam), surface-clamped ground zones, triggers (weapon_draw, combat_damage, battle_state, weapon_swap, hit, death), and elemental combos.

  • vfx_playback_controls (lua_api 7, changes: true, Experimental Test, uses "uses": ["ui", "snapshots", "positions"]) demonstrates native .effect playback and time controls (:set_speed(), :pause(), :resume(), :restart(), :set_looping(), :info()), short-duration looping wrap checks, and fail-closed pure-GPU detection.

  • vfx_beam_tether (lua_api 7, changes: true, Experimental Test, uses "uses": ["ui", "player", "snapshots", "positions"]) demonstrates spawn-time point-to-point native .effect beam/tether linking (attach_actor, socket, target_actor, target_bone) via game.vfx.spawn(...) and :info().

  • vfx_socket_layers (lua_api 7, changes: true, Experimental Test, uses "uses": ["ui", "player", "snapshots", "positions"]) demonstrates enumerating game.vfx.sockets(actor) and attaching multiple simultaneous native .effect layers with local offset, Euler rot, quaternion quat, non-uniform scale, and continuous :set_transform(...) updates.

  • raycast_projectiles (lua_api 7, changes: true, Experimental Test, uses "uses": ["ui", "player", "snapshots", "positions"]) demonstrates 3D Havok raycasting (game.world.raycast_segment, game.world.raycast_dir) driving native .effect gravity arcs, wall-normal bounces, piercing homing shots, spiral trajectories, and surface-clamped ground hazards.

  • reactive_combat_vfx (lua_api 7, changes: true, Experimental Test, uses "uses": ["ui", "player", "snapshots", "positions"]) demonstrates bsx.on("weapon_draw", ...) equipping/removing a weapon-socket native .effect aura on draw/sheathe alongside combat_damage, battle_state, weapon_swap, hit, death, and low-HP reactive bursts.

  • api7_showcase (setup guide, lua_api 7, changes: true, UI/4 tabs/tables/colored text/tooltips, bsx.tween.to, bsx.audio.master_volume, tweaks.json v4 recipe overrides, game.recipes/wind_scale/dye_palettes/on_wind, and passive events)

  • world_explorer_api6 (setup guide, lua_api 6, changes: true, tabbed UI v3 browser for all 7 definition tables, buffs.active/quests.active/factions.agreement/skills.sublevels/equipped_dyes/visual_items, and on_item_cooldown/on_loot_drop hooks)

  • multi_file_kit (setup guide, lua_api 4, safe tier, modular require(), bsx.json + sandboxed bsx.fs mkdir/exists/list, UI v3 tabs & color picker, and Draw v2 font_scale)

  • zero_code_balance_pack (setup guide, lua_api 5, data_only: true, uses tweaks.json schema v2 with item-stat scaling and preset multipliers without writing Lua)

  • wardrobe_presets (setup guide, lua_api 6, uses game.appearance presets/equipped_dyes/visual_items, bsx.json, bsx.fs, and zone_changed to save and auto-swap wardrobe presets)

  • smart_town_sprint (setup guide, flow graph, lua_api 5, generated with Studio's Visual Flow Builder using bsx.events, game.player, game.input, and bsx.mcm)

  • hud_overlay (setup guide, lua_api 4, safe tier, uses "uses": ["ui", "player", "snapshots", "positions"]) builds a schema-driven bsx.ui.mcm settings menu synced with settings.ini, projects nearby actor positions via game.camera.world_to_screen, and draws reticle, compass header, and 3D world labels onto BSX Overlay's foreground draw list (bsx.draw.*).

  • photo_studio (setup guide, lua_api 4, changes: true, uses "uses": ["ui", "snapshots", "positions", "world", "server_commands"]) creates two overlay panels (Photo Studio and Photo Studio: DOF & Lighting) with Free Cam (game.camera.set_free_cam + panel:hotkey), slow-motion / freeze speed controls (game.world.set_game_speed), FOV & roll sliders, Depth of Field presets/sliders (game.camera.set_dof), TP Player to Cam / TP to Crosshair (game.world.raycast), time/weather framing presets, and 3 persistent JSON camera bookmarks under data/bookmarks.json.

  • appearance_studio (setup guide, lua_api 4, changes: true, uses "uses": ["ui", "player", "snapshots", "inventory", "definitions", "server_commands"]) lists currently equipped visual gear, observed controlled-player appearance parts with resolved IndexedStringA names (game.appearance.parts()), per-part Hide / Show / Native / Clear All overrides (game.appearance.set_part_visibility), 3 persistent JSON visibility presets (data/preset_1.json..preset_3.json), and an active Character Customization observer (game.appearance.customization()).

  • travel_journal (lua_api 3, read-only) uses Ctrl+Shift+F2 to append a UTC date/time and Unix timestamp, client day/time, rounded player XYZ, raw rain/snow and optional [TravelJournal] Note to data/journal.txt. It logs the entry and straight-line distance from the previous rounded position in game units, including after reload; neither metre scale nor compass directions are established. The first entry creates data/journal.txt; keep it when updating the script. Any other failed read refuses to write; at most 500 lines and 64 KiB are retained, dropping oldest lines as needed. The file is shared across saves and writes are not transactional on disk failure.

  • world_inspector (setup guide, lua_api 4, safe tier, uses "uses": ["ui", "player", "snapshots", "positions", "world", "bus"]) creates a collapsible bsx.ui.panel overlay window (section/end_section, progress, combo, input_text, checkbox, same_line, button, set_items) showing resolved character_name, live player position, HP bar, zone/time/weather summary, sortable/filterable captured actors with Alive only and Hide Objects, a paginated Target Actor combo (< Prev / Next >, 8 targets/page) + live HP/faction/distance readout, and a TP to Selected bsx.bus emitter (world_controller.teleport_request) when [Lua] SnapshotProvider=1 is enabled, persists sort/filter/alive/hide-objects/auto preferences via bsx.save when [BSX] CoSave=1 is active, and publishes world_inspector.summary / world_inspector.snapshot on bsx.bus.

  • world_controller (setup guide, lua_api 4, changes: true, uses "uses": ["ui", "snapshots", "positions", "world", "server_commands", "bus"]) creates World Controller and World Tools overlay panels with time-of-day presets, hour slider, Freeze Time, World Speed presets, volumetric weather presets/reset plus collapsible Weather Fine-Tuning sliders (cloud cover, fog/haze, rain, snow, wind speed, cloud speed, sun brightness, dust), 4 named per-save teleport waypoints (bsx.save), Map Pin teleport (Up +10m), TP to Crosshair (game.world.raycast), Map Zoom Scale (game.world.set_map_zoom_scale), a safe Quick Menu panel opener (game.ui.open_panel), and toggleable world_controller.teleport_request bus handling (on by default). Requires player Changes approval and [Lua] ServerCommands=1.

  • player_toolkit (setup guide, lua_api 4, changes: true, uses "uses": ["ui", "player", "snapshots", "inventory", "definitions", "server_commands", "bus"] + ItemInfo::* & Localization::sTextPoolManager needs_ids) creates a themed BSX.Lua.UI/5 bsx.ui.panel (Player Toolkit) with Items & Currency and Stats tabs: live HP (0), Stamina (25), and MP (26) readouts ([id:N] labels) with stat delta / Full Heal buttons (game.stats.add), Money (2075, localized Copper, 100 copper = 1 silver) silver+copper readout + +100 Silver (10k) / +10k Silver (1M) buttons (game.inventory.add), full-catalog indexed Item Catalog with live multi-word Search Item, full-catalog Browse Categories, 200-item pagination, 4096-slot My Bag, Refresh Catalog, item-row game.item_info lookup, quantity slider + Grant Item, and Remove 1 / Remove Stack (infinite HP/Stamina/MP toggles live in godmode_sandbox). Requires player Changes approval, [Lua] SnapshotProvider=1, [Lua] ServerCommands=1, and BSX Overlay Enabled=1.

  • gameplay_tweaks (setup guide, lua_api 4, changes: true, uses "uses": ["ui", "player", "snapshots", "inventory", "definitions", "server_commands"] + ItemInfo::* & Localization::sTextPoolManager needs_ids) creates a 3-panel overlay control suite (Gameplay Tweaks, Combat & Exploration, Movement & World) plus optional Gameplay HUD with Instant Interact, Unbreakable Gear, Gather Multiplier, God Mode, Craft Cost Scale (0=Free) (game.gameplay.set_craft_cost_scale), Map Zoom Scale (game.world.set_map_zoom_scale), Free Fly + hotkey picker, stealth/bounty/shop toggles, named presets & JSON profiles, Save Defaults to INI, and Bag Manager/Diff. Requires player Changes approval, [Lua] ServerCommands=1, [Lua] SnapshotProvider=1, [BSX] CoSave=1, and BSX Overlay Enabled=1.

  • api4_panel (lua_api 4, read-only, uses "uses": ["player", "snapshots", "bus", "ui"]) creates a live bsx.ui.panel status window showing controlled player HP/actor snapshot data when [Lua] SnapshotProvider=1 is enabled, a refresh button emitting a bsx.bus event, an auto-refresh checkbox, a poll-interval slider, and a bsx.bus.provide state endpoint. Requires BSX Overlay (Enabled=1) to display the panel interactively in game.

  • supply_check (lua_api 3, read-only) checks up to eight exact row ordinals in [SupplyCheck] Rows against the shared Min after save_loaded and every IntervalMinutes of real time. Rows defaults to empty; configure known rows first. It logs one low on: line when any successful count is below the minimum, and reports unavailable reads. Cached internal item names are not localized; counts cover the controlled character's own holder and may differ from the HUD. Checks are spread across frames and are not an atomic inventory snapshot.

  • gear_report (lua_api 3, read-only) uses Ctrl+Shift+F1 to log slot tags, cached internal item names and exact decimal ItemNo values, plus the count of distinct inventory rows. It emits at most 20 lines, spaced 250 ms apart, and reports omitted gear, unassigned ItemNo, unavailable reads and a truncated inventory. The equipment and inventory copies are separate observations, not an atomic snapshot.

  • outfits (lua_api 3, changes: true) saves the equipped set with Ctrl+Shift+F7 and restores it with Ctrl+Shift+F8 using equip/unequip requests. It keeps no files or storage references.

  • inventory_dump (lua_api 3, read-only) logs at most 50 inventory lines per Ctrl+Shift+F9, one every 250 ms to stay below the host log quota. The last line marks truncation. Another press during the dump is ignored; reload cancels queued lines.

  • equip_toggle (lua_api 3, changes: true) queues unequip/re-equip of a chosen slot a few seconds after SAVE_LOADED, correlates APPLIED events and state, and cancels on replacement, refusal or timeout; see equipment requests.

  • quick_potion (lua_api 3, changes: true) uses Ctrl+Shift+F6 to request one default use of the first matching configured item row via item-use requests; default row -1 keeps it idle.

  • heal_on_load (lua_api 3, changes: true) attempts a five-HP change after each distinct save_loaded and logs whether Changes approval and [Lua] ServerCommands=1 allowed it; without approval it logs read-only HP values (Changing the game).

  • hello (lua_api 1) logs the first frame and then every 600th (change it with [Hello] FrameEvery= in a settings.ini next to the script), every save load (marked (replayed) when BSX replays a load that happened before the script started), save_loaded when this game build offers it, and a 5-second timer. It shows how pcall(bsx.on, ...) keeps a script running when an event is unavailable.

  • item_tracker (lua_api 3) checks the exact inventory row in [ItemTracker] ItemRow after save/equipment completion events and every IntervalMs, logging only changed counts. The default -1 tracks nothing; set the row you want. Its internal name comes from the cached definition and can be unavailable. Counts cover the controlled character's own holder and may differ from the HUD.

  • clock_log (lua_api 3) logs the client day/time and raw rain/snow base values on [ClockLog] Hotkey (default ctrl+f7). If hotkey registration fails, it logs why once and checks every IntervalMinutes of real time instead. Values are not a named weather forecast.

  • key_echo (lua_api 3) logs non-repeat key-down virtual keys and modifier masks for 30 seconds and reports reset markers. The timer runs on a later FRAME; afterward the callback ignores keys, and because lua_api: 1-3 bsx.on returns no handle it stays registered until the script stops or reloads (lua_api: 4+ scripts receive a handle with handle:off()). Log and queue limits can drop observations.

  • weapon_watch (lua_api 2, read-only) reads the player's current weapon or tool selection every 10th frame from the equipment component (offset IDs 3047 and 3048) and logs each switch, such as switch 1: nothing selected -> main weapon #0. This is the player's own switch, which weapon_swap does not see.

  • player_status (lua_api 2) lists the eight IDs the game helpers walk in needs_ids, then logs the controlled character's actor, equipment component and stat container at start and after each save_loaded. On a build without save_loaded it checks once a second until a player exists. It only reads.

  • smoke (lua_api 3) logs API versions, FRAME counts about every ten seconds, save events, and the first controlled equip/unequip completion after a save. The first save_loaded starts deferred helper checks for player/stored HP, equipment, inventory, item definitions, stat names and time/weather; see guarded reads and the time limit. [Smoke] ItemId=-1 (the default) searches already cached definitions for Money_Copper via game.item_info; an explicit ItemId selects any known row. Missing/unloaded names fail the check cleanly, and missing completion-event support stops before declaring a pass.

Cookbook starters

Focused starter scripts live in cookbook:

  • auto_potion_lifesaver (lua_api 7, changes: true): searchable bag food/consumable picker with auto-fallback, low-HP auto-use, and debounced INI saves.
  • dps_meter (lua_api 8, safe): combat DPS meter, floating damage text, and actor nameplates with Combat/Aggro default filtering, non-hostile wildlife & prop/chest exclusion, persistent manual nameplate exclusions (Exclusions tab, pre-seeded with Shadow Harpy), internal buff filtering, and menu suppression.
  • fast_travel_bookmarks (lua_api 7, changes: true): saved world coordinate bookmarks with live search, teleport, and clipboard sharing.
  • fastload_qol (lua_api 7, changes: true): skip-to-world quality-of-life helper using world, positions, and ui.
  • fishing_gathering_qol (lua_api 7, changes: true): life-skill catch/gather sliders, instant interact, and Dragon Anywhere toggles.
  • godmode_sandbox (lua_api 8, changes: true): standalone sandbox & invulnerability panel (God Mode, Infinite Stamina/MP, No Fall Damage, Unbreakable Gear, Free Fly, Stealth, No Wanted).
  • load_profiler (lua_api 7, safe): load-time timing breakdown and history panel using bsx.ui.panel.
  • perf_hud (lua_api 7, safe): lightweight viewport/FPS/1%-low performance HUD.
  • resume_anywhere (lua_api 7, changes: true): save-slot & JSON position bookmark with game.world.raycast_segment rock/prop surface probing, post-resume anti-clip check, and ServerCommands=1 teleport resume panel.
  • smart_memory_trim (lua_api 7, safe): periodic/hotkey working-set trim helper using bsx.memory.
  • spellcraft_enchants (lua_api 8, changes: true, Experimental Test): native .effect weapon VFX enchantments and 3D blade socket gizmo using game.vfx v2.