Skip to content

Conversation

@skypher
Copy link
Contributor

@skypher skypher commented Nov 26, 2025

Summary

  • Add Lua manaShield property (read/write) to Player usertype with proper network sync
  • Add new level module with type() function and dungeon type constants
  • Add LeavingLevel and EnterLevel events for level transition hooks
  • Include sample persist_mana_shield mod demonstrating the API

API

Player module

local player = require("devilutionx.player")
local p = player.self()
p.manaShield = true  -- Enable mana shield
local active = p.manaShield  -- Check if mana shield is active

Level module

local level = require("devilutionx.level")
local currentType = level.type()  -- Get current dungeon type

-- Available constants:
level.TOWN
level.CATHEDRAL
level.CATACOMBS
level.CAVES
level.HELL
level.NEST
level.CRYPT

Events

local events = require("devilutionx.events")

events.LeavingLevel.add(function()
  -- Called before leaving current level (before mana shield is cleared)
end)

events.EnterLevel.add(function()
  -- Called after entering a new level
end)

Test plan

  • Unit tests for manaShield property (LuaPlayerModuleTest)
  • Unit tests for Lua script access to manaShield (LuaPlayerModuleTest)
  • Unit tests for level.type() function (LuaLevelModuleTest)
  • Unit tests for level type constants (LuaLevelModuleTest)
  • Regression test for mana shield persistence logic (ManaShieldPersistenceTest)
  • Regression test for level module Lua access pattern (ManaShieldPersistenceTest)
  • Integration test with real player and Lua events (ManaShieldIntegration)
  • Integration test for town level type check (ManaShieldIntegration)
  • Manual test - mod on, mana shield stays / mod off, default behavior of clearing mana shield on level exit.

- Add player.manaShield property (read/write) to Lua player module
- Add level module with type() function and level type constants
- Add LeavingLevel and EnterLevel events for level change hooks
- Add persist_mana_shield example mod that preserves mana shield across
  dungeon levels (but not into town)
- Add integration tests that load and verify the mod behavior
- Add SetModEnabled() to ModOptions for programmatic mod control in tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant