Groups
A file with more than one @tweak is a group. Each @tweak is its own tweak with its own box, key and values, but they can share data and code.
@group "Combat"
@data u32 multiplier = 2@sym party = [game.exe+0xD600A8]+0x38
@jsfunction itemName(id) { return sym.party.offset(0x100 + id * 0x40).readString()}
@tweak "Max bravery"@key F5@inject sig("8B 81 ?? ?? ?? ?? 89 44 24") mov dword ptr [rcx+0x2C], 100
@tweak "Override item"@data [Choices(itemList)] u32 item@jsfunction itemList() { return [1, 2, 3].map((id) => [id, itemName(id)])}That’s two tweaks in the menu, under Combat.
The shared part
Section titled “The shared part”Everything above the first @tweak is shared. It can have @data, @sym, @schema, code changes and script, the same as a tweak. It can’t have @mode, since that belongs to each tweak.
@group "Name" goes right at the top and names it. Leave it out and the group goes by the file’s name.
A file with one @tweak and no @group is just a tweak, like always.
Groups in groups
Section titled “Groups in groups”Further down, @group "Name" opens a group inside the one it’s in. It runs to its @end, and groups and tweaks can sit side by side at any depth.
@group "Kai"@sym table = [[kai.exe+0xD600A8]+0x38]@luafunction itemName(id) return sym.table:offset(0x100 + id * 0x40):readString() end
@group "Combat"@children on off@data [Toggle] bool logHits@luafunction combatHelper() return itemName(1) end
@tweak "Max bravery"@inject sig("8B 81 ?? ?? ?? ?? 89 44 24") mov dword ptr [rcx+0x2C], 100
@group "Party"@tweak "Max HP"@data u32 y = 999@end
@end
@tweak "Override item"@luax = 1A nested group has a shared part of its own, from its @group line to its first @tweak or @group. It’s the same as the file’s, with data, names, code changes and script.
The @group at the top of the file needs no @end. Every other one does, and the file says which one is missing it and where it opened. Two things next to each other in a group can’t have the same name, and a file with groups in it can’t have / in a name.
Its own box
Section titled “Its own box”Every group has a box of its own, nested or not. A group’s values are its shared part’s @data, and it can have a @key, which turns its box on and off.
@children goes right after the @group line and says what the box does to what’s in it, like Cheat Engine’s “activate children as well”.
@children |
Turning it on | Turning it off |
|---|---|---|
on off, the default |
Turns them on | Turns them off |
on |
Turns them on | Leaves them |
off |
Leaves them | Turns them off |
none |
Leaves them | Leaves them |
It goes to the tweaks and groups right in it. A group among them then does what its own @children says, so a none group keeps what’s in it out of it. Actions are never run this way.
When the box is off but something in it is on, the box shows it’s partly on.
When it’s on
Section titled “When it’s on”A group’s shared part is up while its box is on, or while anything in it is on.
Turning on a tweak deep in a file brings up every group it’s in first, from the outside in. Their boxes stay off. When the last reason for a group to be up goes, its shared part stops with everything in it, from the inside out.
That’s different from Cheat Engine. There, a script in a group only runs when you tick the group. Here, a group’s shared code runs whenever anything in it is on, since what’s in it can use it.
Turning one tweak off only undoes what that tweak made. The others keep going.
Sharing
Section titled “Sharing”Functions and data in a shared part work from everything in its group, at any depth. Above, Max HP can call combatHelper and itemName, and its asm can use table by name. Scripts get data and names as data.logHits and sym.table, like in a lone tweak.
Choices(itemList) can name a function in its own tweak or in any group it’s in.
Groups next to each other don’t see each other’s.
If something in a group’s shared part fails, everything that’s on in it goes off with it, groups too. If one tweak fails, only that one does.
Each part’s own
Section titled “Each part’s own”Every tweak and group gets its own top level, so two can use the same names without stepping on each other. To share globals between them instead, see Shared globals.
@tweak "Fast"@jslet speed = 2function off() { console.log("fast is off") }
@tweak "Slow"@jslet speed = 0.5In JS each one runs in a function of its own, and what’s in a nested group runs inside its group’s names. In Lua each gets its own _ENV, which falls back to its group’s, and so on up to the usual globals.
tick() and off() work for each tweak and group. A tweak’s off() runs when that tweak goes off. A group’s runs when its shared part stops, after everything in it.
Shared globals
Section titled “Shared globals”Sometimes the tweaks in a group need to see each other’s globals, like scripts from a Cheat Engine table that all ran in one Lua state. Put @globals shared in the group’s shared part, before any code.
@group "Kai"@globals shared
@tweak "Count frames"@luaframes = 0function tick() frames = frames + 1 end
@tweak "Say frames"@mode action@luaprint("frames so far: " .. tostring(frames))Each tweak and group under it still gets its own top level, but a plain global write, to a name that isn’t local, goes to the group’s top level, where everything in it can read it. In JS that’s an assignment to an undeclared name, and top-level var and function too. let, const and class stay the tweak’s own.
It works at any depth. A write goes to the nearest group above it that says @globals shared, and a group without one keeps things apart like before.
tick(), off() and the functions Choices names still come from each tweak’s own code, so two tweaks can both have an off().
The trade-off is that the tweaks aren’t kept apart anymore. Two that use the same name share it, and what a tweak wrote stays after it turns off, like in Cheat Engine. It all goes when the group’s shared part stops.
The Cheat Engine importer puts @globals shared at the top of every table it brings over.
While it’s on, the game’s names get the titles of the groups it’s in.
Kai.tablefor the file’s group.Kai.Combat.logHitsfor a nested group’s.Kai.Combat.Party.Max HP.yfor a tweak’s, andKai.Combat.Max bravery.xif Max bravery had anx. They have spaces, so put them in quotes, like"Kai.Combat.Party.Max HP.y".
A lone tweak keeps xp.multiplier for tweaks/xp.rwt.
What’s on is kept by path in the file, like kai/Combat/Max bravery for tweaks/kai.rwt. Tweaks in a group with no nested groups keep the names they’ve always had.
Libraries
Section titled “Libraries”@use name loads a script library into a group’s shared part, or a lone tweak, before any of its code. It goes under the @group or @tweak line, at any depth, and a file can have more than one.
@group "Kai"@use ce@lualocal hp = getAddressList().getMemoryRecordByDescription("HP")What it does depends on the library:
- If it has
install(env, options), that runs with the part’s own top level asenv, so whatever it puts there is seen by everything in the group.optionshasname, the group’s title,path, the group’s path in the file, andtweaks, which turns tweaks on and off. The name then holds whatinstallgave back. - If it doesn’t, the name just holds the library, like
local util = require("util")would, but for the whole group.
When the part stops, what install gave back gets its stop() called, if it has one. In JS, install gets the globals, which are the file’s own.
Scripts load the same libraries with require("name"), in Lua and JS alike. In a Lua plugin a file of its own by that name comes first. Wraith has one built in so far, ce, the Cheat Engine layer that imported tables use.
Turning tweaks on from scripts
Section titled “Turning tweaks on from scripts”Any script can turn a tweak on or off by its saved id, the same as clicking its box, so @children and everything else apply.
if not tweaks.isOn("kai/Combat") then tweaks.setOn("kai/Combat", true)end-- In a tweak, ./ is its own filetweaks.setOn("./Combat/Max bravery", false)-- Hear every switch, however it happenedtweaks.onSwitched(function(e) print(e.name, e.on) end)setOn happens on the next frame, so it’s safe from inside any callback, even the tweak’s own. Until then isOn says what was asked for. An id that isn’t there raises.
Group or separate tweaks?
Section titled “Group or separate tweaks?”| You have | Use |
|---|---|
| Tweaks that use the same pointers, data or helper functions | A group |
| Several cheats for one system, like combat or inventory | A group |
| Cheats for a few systems that share a game’s pointers | Groups in a group |
| Tweaks that have nothing to do with each other | Separate files |
| One tweak | A file of its own |
Separate files are simpler to share and rename. Reach for a group when you’d otherwise copy the same @sym or functions into each file.
Made with ♥ by Asgard
