Whisper: Read and Rewrite Power Kit for Hacking and Spell Rewriting
- ..
- .metadata95 B
- README.md11.7 KB
- RewriteDemo.scene
- RewriteGallery.component
- RewriteGallery.scene
- RewritePower.component
- adapter.module
- adapters
- api.module
- core.module
- example-build-a-hacker-dungeon-room-where-you-rewrite-traps-and-doors.guide
- fx.module
- how-to-add-a-hacking-or-spell-rewriting-power-to-my-game.guide
- how-to-add-hacking-puzzles-to-my-game.guide
- looks.module
- media-puzzle-holo.jpg115 KB
- package.yaml922 B
- puzzles.module
- rewriteKitTests.testSuite
- samplePuzzles.module
- screen.module
- sounds
README.md
rewriteKit 1.0.1: Whisper, the read-and-rewrite power
A hacking, spell-rewriting or reality-editing power for any Zero game. The player targets something, READs its hidden code (an enemy's HP and weakness, a trap's target, why a door will not open) and REWRITEs one line of it: point the spike trap at the monsters, patch the collapsed bridge, unlock the door, charm the wolf, switch the boss's attack pattern. Every rewrite costs a per-player resource and can glitch. It was built for Ren's Software Whispering in Kicked Out of the Hero's Party, and it works the same for a cyberpunk netrunner, a wizard editing true names or a puzzle game.
What a world gets:
- The power (
RewritePowercomponent): targeting (your lock-on, the cursor, a tap, or the nearest thing in view), the rewrite screen, keyboard and mouse, gamepad, phone portrait and landscape, optional slow motion, sounds and juice. - Eight rewrite screen looks behind one setting, each a world-space overlay wrapped around the target plus a code panel with a command rail:
anime(glowing cyan code panels floating around the target, gold rail),terminal(green phosphor),holo(holographic sci-fi HUD),runes(arcane grimoire and spell circle),parchment(ink and quill marginalia),pixel(8-bit window),minimal(clean glass),glitch(RGB-split corrupted). - Eleven adapters, components you drop on an entity to make it rewritable:
RewritableEnemy,RewritableAllegiance,RewritableTrap,RewritableDoor,RewritableBridge,RewritablePlatform,RewritableChest,RewritableZone,RewritableLight,RewritableBossRule,RewritableNpcFlag. - Multiplayer: every READ and REWRITE is validated on the room host (range, read first, allowed value, cost, glitch roll), applied there and broadcast, so everyone sees the same result; the resource is per player.
- Hacking puzzles (new in 1.0.1): multi-step code puzzles where the player READs lines and picks REWRITE options in order; a wrong pick crashes with a SYSTEM ERROR and retries the step, then a results screen with stars. Data-driven (
Rewrite.definePuzzle(id, spec),Rewrite.playPuzzle(id, opts, onDone)), four built-in kinds (sequence,fixBug,tune,logicGate) and four sample puzzles, in all eight looks, with keyboard, gamepad and touch. - A gallery scene (
RewriteGallery: every look and every adapter) and a playable demo room (RewriteDemo: rewrite a trap to hit a slime, read a golem's weakness, patch a bridge, fix a door).
Depends on juiceKit (installed with it). Everything else (combat, health, mana, lock-on) is passed in by your game, so the kit never requires a package you do not have.
Quick start
- Install
rewriteKit.packagefrom ZeroMind (search "hacking power rewrite traps doors"). - Add the power once per scene: an entity with
rewriteKit.RewritePower(fields:look,range,readCost,glitchChance,maxResource,regen,slowMo,openKey, ...). - Drop adapters on things, or expose your own entities from code (below).
- Play: Q (keyboard), Y (gamepad) or the </> button (phone) opens the screen on the best target; clicking or tapping a rewritable thing opens it on that one.
Controls
| Keyboard and mouse | Gamepad | Touch | |
|---|---|---|---|
| open / close | Q, click a target | Y | </> button, tap a target |
| pick line | W/S, arrows, click | d-pad up/down | tap the line |
| change value | A/D, arrows, 1-9, click a chip | d-pad left/right | tap a chip (tap again to write) |
| READ | R | X | READ button |
| REWRITE | Enter / Space | A | REWRITE button |
| next target | Tab (Shift+Tab back) | RB / LB | NEXT button |
| close | Esc | B | EXIT button |
Expose anything from code (the shared contract)
local Rewrite = require("rewriteKit.api")
Rewrite.expose(trapId, {
kind = "trap", -- enemy | boss | trap | door | bridge | platform | chest | npc | anything
title = "Spike Trap",
lines = { "HP 40/40", "WEAK fire" }, -- facts shown on READ, or function(playerId) -> lines
fields = {
{ key = "target", label = "TARGET", value = "players", options = { "players", "monsters", "nobody" }, cost = 2 },
{ key = "damage", label = "DMG", value = 10, min = 0, max = 50, step = 5, cost = 1 },
},
apply = function(key, newValue, playerId) end, -- runs on the authority when a rewrite commits
revertAfter = nil, -- seconds, or nil to keep the rewrite
})
Rewrite.unexpose(trapId)
Rewrite.read(playerId, trapId)
Rewrite.commit(playerId, trapId, "target", "monsters")
Rewrite.on("read" | "rewrite" | "fail" | "glitch" | "revert" | "open" | "close" | "resource", fn)
Field options: risk (this line's glitch chance), revertAfter (per line), optionCost = { mimic = 6 }, perStep (extra cost per step of a range), locked = true. Events carry { playerId, id, key, value, old, cost, record }; fail carries reason (range, resource, unread, invalid, locked, same, missing). Adapters also fire trapHit, damaged, defeated and chestOpened.
Plug in your game
Rewrite.useTargeting(function(playerId) return lockedEnemyId end) -- your lock-on wins over auto targeting
Rewrite.useResource(function(pid) return mana, maxMana end, -- your mana instead of the built-in pool
function(pid, amount) return spendMana(pid, amount) end) -- return false when it cannot pay
Rewrite.useDamage(function(targetId, amount, sourceId, element) end) -- traps and glitches deal damage through this
Rewrite.useTeams(function(id) return teamOf(id) end) -- who a trap's "monsters" / "players" means
Rewrite.useGlitchChance(function(pid, record, field, base) return base * (1 - level * 0.05) end)
Rewrite.useCombat(function(pid) return inCombat end) -- slow motion only in combat
Rewrite.configure({ look = "holo", range = 18, readCost = 1, glitchChance = 0.1, requireRead = true })
Rewrite.setLook("runes"); Rewrite.looks(); Rewrite.defineLook("myLook", { ... })
Rewrite.open(id?); Rewrite.close(); Rewrite.toggle(); Rewrite.isOpen(); Rewrite.target()
Rewrite.force(id, key, value) -- game-driven change, no cost, everyone sees it
Rewrite.value(id, key); Rewrite.hasRead(playerId, id); Rewrite.resource(playerId); Rewrite.grant(playerId, amount)
actionCombatKit and a mana resource (how Ren is wired)
local Combat = require("actionCombatKit.api")
Rewrite.useTargeting(function(pid) local s = Combat.state(pid); return s and s.lockTarget end)
Rewrite.useCombat(function(pid) local s = Combat.state(pid); return s ~= nil and s.lockTarget ~= nil end)
Rewrite.useResource(function(pid) return Mana.get(pid), Mana.max(pid) end, function(pid, n) return Mana.spend(pid, n) end)
Rewrite.useDamage(function(target, amount, source, element) SecondWind.damage(target, amount, { source = source, element = element }) end)
Rewrite.on("rewrite", function(e) if e.key == "allegiance" then SecondWind.setTeam(e.id, e.value) end end)
Hacking puzzles
Rewrite.loadSamplePuzzles()
Rewrite.definePuzzle("vault_door", { kind = "fixBug", title = "Vault Door", line = { code = "door.locked", value = "true" }, fix = "false",
crashes = { { value = "nil", note = "The lock panics." } } })
Rewrite.playPuzzle("vault_door", { look = "terminal", budget = 12 }, function(r) print(r.success, r.stars) end)
| Call | What it does |
|---|---|
definePuzzle(id, spec) | Register a puzzle: steps of lines (READ hidden lines, REWRITE edit / PATCH patch options with effect nil, "glitch" or "crash") and solveWhen, order or check; or kind + params. |
playPuzzle(id, { look, budget, costs, layer }, onDone) | Show the puzzle screen on this peer; onDone(result) gets { success, reason, crashes, glitches, actions, spent, seconds, stars, steps }. |
puzzleSession(id, opts) | The same run without UI: :read, :edit, :retry, :abort, :result, :view. |
buildPuzzle(kind, params), PUZZLE_KINDS, PUZZLE_COSTS | The four kinds and the READ / EDIT / PATCH / glitch costs. |
puzzles(), puzzle(id), currentPuzzle(), puzzlePress(action), closePuzzle() | Registry and screen control. |
loadSamplePuzzles() | sample.sequence, sample.fixBug, sample.tune, sample.logicGate. |
Guide: how-to-add-hacking-puzzles-to-my-game.
Multiplayer
Requests go to the room host (multiplayer.isHost(), or this peer offline), which validates and applies them and broadcasts the outcome on rewriteKit:evt; clients only ask (rewriteKit:req). apply runs on the authority only. Adapters keep their values in Sync fields so a player who joins later sees the rewritten world. The built-in resource is a pool per player id (the player's body id) kept by the host. Slow motion only engages when the player is alone in the room.
Looks
Set RewritePower.look or Rewrite.setLook(id): anime, terminal, holo, runes, parchment, pixel, minimal, glitch. Each renames the verbs (READ / REWRITE, cat / patch, SCAN / OVERRIDE, Divine / Inscribe, Study / Amend, LOOK / HACK, Read / Apply, D3CRYPT / C0RRUPT) and the resource (MANA, CPU, POWER, AETHER, INK, MP, Energy, SANITY). Phone portrait puts the panel along the bottom; short landscape screens collapse the unselected lines into a tab strip.
Guides
how-to-add-a-hacking-or-spell-rewriting-power-to-my-gameexample-build-a-hacker-dungeon-room-where-you-rewrite-traps-and-doorshow-to-add-hacking-puzzles-to-my-game
Tests
zero tests run rewriteKitTests: 15 tests covering expose (field kinds, values kept through a re-expose), READ and REWRITE validation (unread, locked, invalid, same, missing, out of resource), costs (option costs, per-step range costs, cost scale), glitch, timed revert, the adapter helpers, and the hacking puzzles (every kind solves, crash and retry, glitch surcharge, budget, sequence order, tune limits and gates, malformed specs refused, the screen in all eight looks).
Verified
On @builtin 28ef193, in play in a sub-client: real keys (R, D, Enter) rewrote the demo's spike trap from players to monsters and it struck the pacing slime 6 times until it fell (40 HP to 0); the collapsed bridge patched with all 10 planks active; a gamepad (Y open, X read, d-pad, A rewrite, B close) rewrote the Ember Golem's DEFENCE from 10 to 5; all eight looks, the all-looks grid and the adapters row were captured; phone portrait (390x844) and landscape (844x390) show the whole panel and rail. The touch button's callback opens the screen; a simulated finger in a headless client was caught by the engine's own app-menu overlay, so a real-phone tap test is still worth doing.
Known limits
- Built-in HP exists only on
RewritableEnemy; useuseDamagefor anything else. RewritableZone's SPEED is a value your movement code reads; the kit only applies GRAVITY itself (to dynamic bodies).- Two adapters on one entity replace each other's record; put one adapter per entity (RewritableEnemy already includes allegiance).
History
- 1.0.1: hacking puzzles (
definePuzzle,playPuzzle,puzzleSession, four kinds, four sample puzzles, all eight looks, keyboard, gamepad and touch); the four bundled sounds have their own asset guids (they duplicated the game's, which blocked a push of any world holding both); the code flash no longer errors when its target is removed mid-flash; a test suite (rewriteKitTests). - 1.0.0: first release.
Sounds: whisper_on, code_read, code_edit and error are from Kicked Out of the Hero's Party (MIT, generated with audio_gen).