Your page in /w
Add a page of your own to the /w menu, a debug tool switch, or Object Viewer options. They show only to a developer with developer mode on.
A page of your own
Your page is a row at the end of Panels; picked, it shows your rows, and its first row (or Backspace) goes back. whip_core draws the rows and asks for them again after every pick. For levels of your own, return a view with back, and the way back calls your onBack.
exports.whip_core:HasDevTools(source).Adds your page to /w, or replaces yours with this id. Declare it in Whip.register: whip_core forgets every page when it restarts. The page goes when your resource stops, and /w reopens on the page it was shut on with Escape.
| Field | Type | Description |
|---|---|---|
| id | string | Letters, digits, _ and -; another resource's page with the same id is another page |
| label | string | The row in /w and the page's title |
| desc | string|nil | The line under the list while your row is picked |
| rows | function | Returns a list of rows, or { title, back, select, rows } for a level (back names the level above, select the row picked first). Called on open, after every pick, and on RefreshDevPage |
| onSelect | function(rowId) | A row was picked. It must not wait: start a thread, then call RefreshDevPage |
| onBack | function|nil | The way back on a level that returned back |
| onOpen / onClose | function|nil | The page came on screen, or left it |
| Row field | Type | Description |
|---|---|---|
| id | string|number | What onSelect gets. Every row but a note needs one |
| label | string | The row's text |
| kind | string|nil | 'run' (default), 'toggle' (lit by active), 'open' (a chevron into a level) or 'note' (never picked) |
| active | boolean|nil | A toggle's switch |
| desc | string|nil | The line under the list while the row is picked |
| close | boolean|nil | Shut the menu after onSelect, for an action that needs a clear screen |
| icon | string|nil | One of the prompts' glyphs by name ('target', 'car'...); an unknown name draws nothing |
| sep | string | A group header instead of a row: { sep = 'Playback' } |
true, or false, why (a bad id, no label, no rows or onSelect)local open, level = false, 'top'
Whip.register(function()
Whip.core:RegisterDevPage('cafe', {
label = 'Café',
rows = function()
if level == 'menu' then
return { title = 'Menu', back = 'Café', rows = { { id = 'coffee', label = 'Coffee' } } }
end
return { rows = {
{ id = 'open', label = 'Open', kind = 'toggle', active = open },
{ id = 'restock', label = 'Restock', desc = 'Fills every shelf.' },
{ id = 'menu', label = 'Menu', kind = 'open' },
} }
end,
onSelect = function(rowId)
if rowId == 'open' then open = not open
elseif rowId == 'menu' then level = 'menu'
else TriggerServerEvent('mycafe:devAction', rowId) end -- the server checks HasDevTools
end,
onBack = function() level = 'top' end,
})
end)
Your rows changed without a pick (a list arrived from the server). If your page is on screen, whip_core calls rows again, keeping the same row picked; otherwise it costs nothing.
true, or false, why (no page of yours has that id)exports.whip_core:RefreshDevPage('cafe')
Takes your page out of /w while your resource keeps running; it goes by itself when your resource stops.
true, or false, why (no page of yours has that id)Debug tools
A switch of your own among /w's debug tools, shown while its Debug row is on, after WHIP's own, by label. Turning it on checks with the server, as any dev tool does; the same id again replaces it. Declare it in Whip.register; it goes when your resource stops.
| Field | Type | Description |
|---|---|---|
| label | string | Its row in /w (40 characters at most) |
| desc | string? | The line under the list while its row is picked |
| onToggle | function | onToggle(on), also with false when Debug or developer mode goes off. Return false to stay off |
true, or false, whyexports.whip_core:RegisterDebugTool('mine', {
label = 'My Debug', desc = 'What my overlay shows.',
onToggle = function(on) ShowMyOverlay(on) end,
})
Takes your debug tool out of /w (it goes by itself when your resource stops). One that's on isn't switched off: that's yours to do.
true, or false, why (no debug tool of yours has that id)Object Viewer options
Adds or changes an option in the Object Viewer's options, the list G opens on what's picked out (whip_autos' Open Whiplash is one). The id is '<your namespace>.<name>'. From @whip_core/lib/satellite.lua, called at file scope; picked, your select runs in a thread of its own.
| Field | Type | Description |
|---|---|---|
| label | string | The option's line (48 characters at most) |
| kinds | string[] | vehicle, player, npc, object |
| whip | boolean? | true: only WHIP's own (a saved car, a player). false: only the game's. Left out: both |
| group | string? | Its heading (24 characters); default your resource's name |
| tint | string? | blue, teal, green, amber, red, violet or slate (default) |
| hint | string? | The line under the list while it's pointed at (160 characters) |
| select | function | select(target), with target = { kind, entity, netId, whip, vehicleId, serverId, model, name, coords = { x, y, z, heading } } |
true, or false when it isn't valid (the reason is printed). Whip.removeObjectViewerOption(id) removes one; it goes by itself when your resource stops.Whip.objectViewerOption('mycafe.refuel', {
label = 'Fill the tank', group = 'My cafe', tint = 'amber', kinds = { 'vehicle' }, whip = true,
select = function(target)
TriggerServerEvent('mycafe:server:refuel', target.vehicleId) -- the server checks HasDevTools
end,
})
HasDevTools(source), or the permission it needs.