DramaticShapeVoxelMod archival mirror · read-only
34e7da5c12c5b93b4a0c37375a07866903c1e9c1

v-grid toggle on battles

DramaticShape · 2026-08-08 · parent 9ddb940bc8

v-grid toggle on battles

Changed files

lib/BattleScene.lua           | 12 ++++--------
 lib/VoxelGrid.lua             | 18 ++++++------------
 tests/dramatic_shape_test.lua | 29 ++++++++++++-----------------
 3 files changed, 22 insertions(+), 37 deletions(-)

Diff

diff --git a/lib/BattleScene.lua b/lib/BattleScene.lua
index 8694046..e2ceba2 100644
--- a/lib/BattleScene.lua
+++ b/lib/BattleScene.lua
@@ -40,7 +40,6 @@ local TerrainAtlas = V.require("TerrainAtlas")
 local VoxelScene = V.require("VoxelScene")
 local BattleCam = V.require("BattleCam")
 local BattleBillboard = V.require("BattleBillboard")
-local VoxelGrid = V.require("VoxelGrid")
 local DayNight = V.require("DayNight")
 local AntiAlias = V.require("AntiAlias")
 local PaletteFX = require("src.render.PaletteFX")
@@ -640,12 +639,10 @@ function BattleScene.render(state, arena, textures, token)
   local sunWas = Voxel3D.SHADOW_ALPHA
   Voxel3D.SHADOW_ALPHA = BattleScene.SHADOW_ALPHA
                          * DayNight.shadowScale(outdoor)
-  -- and the wireframe is ON for a battle whatever the V-GRID row says. The
-  -- arena is a staged shot rather than the world being walked through, and
-  -- the seams are what make it read as built rather than photographed. Forced
-  -- through the override so the player's own row is never written to.
-  local gridWas = VoxelGrid.override
-  VoxelGrid.override = true
+  -- The wireframe is whatever the V-GRID row says, exactly as it is out in
+  -- the world (see VoxelGrid): the arena is drawn a unit per voxel like
+  -- everything else, so the seams follow the one toggle and a player who
+  -- turned them off does not get them back for the length of a fight.
   local out = nil
   local ok, err = pcall(function()
     -- its own canvas slot: this renders at the window's pixel size and the
@@ -845,7 +842,6 @@ function BattleScene.render(state, arena, textures, token)
   -- renders (the free-roam pipeline, next frame) must find the orbit back
   Voxel3D.camera = nil
   Voxel3D.SHADOW_ALPHA = sunWas
-  VoxelGrid.override = gridWas
   if not ok then
     -- endScene never ran, so the canvas is still bound and the shader still
     -- set; put the frame back the way it was found before rethrowing
diff --git a/lib/VoxelGrid.lua b/lib/VoxelGrid.lua
index b585072..fdaf68c 100644
--- a/lib/VoxelGrid.lua
+++ b/lib/VoxelGrid.lua
@@ -61,19 +61,13 @@ end
 VoxelGrid.setting = ModSetting.new(VoxelGrid.KEY, VoxelGrid.LABEL,
                                    { false, true }, { "OFF", "ON" })
 
--- A pass that needs the wireframe whatever the player left the row on sets
--- this for the length of its own draw and puts it back after. nil means
--- "follow the setting", which is every frame outside such a pass.
---
--- The overworld battle is the one user: a fight is a STAGED shot, not the
--- world being walked around in, and the seams are what make it read as
--- constructed rather than as a photograph of somewhere. The row still owns
--- what free-roam looks like, and is not written to -- switching the mode off
--- mid-battle would silently rewrite the player's own setting.
-VoxelGrid.override = nil
-
+-- The row is the whole answer, everywhere: free-roam and the battle arena
+-- alike. The battle used to force the seams on regardless -- a fight is a
+-- STAGED shot, and the seams are what make it read as constructed rather
+-- than photographed -- but a player who turns the wireframe off means the
+-- whole mod, and a mode that came back for every fight read as the row not
+-- working rather than as a deliberate framing.
 function VoxelGrid.enabled()
-  if VoxelGrid.override ~= nil then return VoxelGrid.override end
   return VoxelGrid.setting:get() and true or false
 end
 
diff --git a/tests/dramatic_shape_test.lua b/tests/dramatic_shape_test.lua
index e121062..2f3ed88 100644
--- a/tests/dramatic_shape_test.lua
+++ b/tests/dramatic_shape_test.lua
@@ -3631,25 +3631,20 @@ T.eq(Battles.flashing({ fx = { flash = 16 }, frame = 2 }), false,
 T.eq(Battles.flashing({ fx = { flash = 16 }, frame = 5 }), true,
   "on a four-frame cycle")
 
--- ------- the wireframe is forced on in a battle
+-- ------- the wireframe follows the V-GRID row, battles included
 --
--- A fight is a staged shot rather than the world being walked through, so it
--- always wears the seams. The player's own V-GRID row must not be touched by
--- that -- an override, not a write, or switching the mode off mid-battle
--- would quietly rewrite a setting they chose.
+-- The row is the whole answer. A battle used to force the seams on whatever
+-- it said -- so nothing may override enabled(), and the battle pass must not
+-- write the row either: a fight that flipped it would rewrite a setting the
+-- player chose.
 local Grid = run.loader.exports.DRAMATIC_SHAPE.lib.require("VoxelGrid")
-Grid.override = nil
-local rowWas = Grid.setting:get()
-T.eq(Grid.enabled(), rowWas and true or false,
-  "with no override the wireframe follows the row")
-Grid.override = true
-T.eq(Grid.enabled(), true, "an override forces it on")
-T.eq(Grid.setting:get(), rowWas, "and leaves the player's row alone")
-Grid.override = false
-T.eq(Grid.enabled(), false, "an override can force it off too")
-Grid.override = nil
-T.eq(Grid.enabled(), rowWas and true or false,
-  "and clearing it hands the answer back to the row")
+local idxWas = Grid.setting.index
+Grid.setting:sync(true)
+T.eq(Grid.enabled(), true, "the wireframe is on when the row is on")
+Grid.setting:sync(false)
+T.eq(Grid.enabled(), false, "and off when the row is off -- nothing overrides it")
+T.eq(Grid.override, nil, "and there is no override left to force a battle on")
+Grid.setting.index = idxWas
 
 -- ------- the depth of field is measured off the two marks
 --