Overview
Britannia Craftsbook turns crafting into a book. A player uses a book from their inventory, its leather cover swings open, and inside is a contents page followed by one recipe on every page. They craft straight from the book, earn crafting XP, and unlock harder recipes as their level rises.
- Any number of books, each opened by its own item, each with its own recipes, cover title, cover picture and colour.
- A contents page with search and a "can make now" filter; click a recipe to turn straight to its page.
- Every recipe page shows the item's picture, what it makes, how long it takes, the XP it gives, the level it needs, and every ingredient with how many the player has.
- Craft several at once. The server times the craft and checks everything again at the end.
- Recipes above the player's level are stamped "Not yet learned".
- Levels per book (or shared between books), on XP ladders you set.
- English, Spanish and French.
The Lua is encrypted by Cfx.re; the settings, recipes, text and server settings stay editable.
Requirements
- poggy_core (free), version 0.11.0 or newer.
- oxmysql.
- One of VORP, RSG Core or QBCore RedM (poggy_core connects the script to it).
Install
- Download
Britannia_Craftbookfrom your Cfx.re account (portal.cfx.re → Assets → Granted Assets). - Put the
Britannia_Craftbookfolder in your server'sresourcesfolder. Don't rename it. - Add
ensure Britannia_Craftbooktoserver.cfg, afterensure oxmysqlandensure poggy_core. - Add the book items (see Items).
- Set up your books in
shared/config.luaand their recipes inshared/recipes.lua. - Restart the server. The XP table
britannia_craftbook_xpis created automatically.
Items
The example config has two books. Each one is opened by its own item:
| Item | Label | Opens |
|---|---|---|
survival_guide | Survival Guide | The Survival Guide: tools and camp cooking |
bakehouse_ledger | The Bakehouse Ledger | The Bakehouse Ledger (bakers only in the example) |
- VORP: run
SQL.sqlin your database. It's safe to run more than once. - RSG Core / QBCore RedM: copy the entries from
installation/items_rsg_qbcore.txtinto your shared items list. - Icons: copy
installation/images/*.pnginto your inventory's item pictures (VORP:vorp_inventory/html/img/items/).craftsbook.pngis a spare copy for any new book item.
Any item can open a book: set its item in the config.
Configuration
Settings are in shared/config.lua, and every option is commented. Recipes are in shared/recipes.lua; text is in locales/.
| Setting | What it does | Default |
|---|---|---|
Config.Locale | Language file to use: en, es or fr | 'en' |
Config.Debug | Prints extra lines in the server and F8 consoles | false |
Config.Crafting.MaxBatch | The most of one recipe a player can make in one go | 20 |
Config.Crafting.CancelIfMoved | Walking away while crafting cancels it (nothing is used up) | false |
Config.Crafting.MoveLimit | How far (metres) a player may move before that cancel | 5.0 |
Config.Crafting.Scenario | A different animation while crafting; false keeps the reading animation | false |
Config.ReadScenario | The animation while the book is open | 'WORLD_HUMAN_WRITE_NOTEBOOK' |
Config.ImageBase | Where item pictures come from. false asks poggy_core (works on VORP, RSG Core and QBCore RedM); another inventory sets its picture folder, e.g. 'nui://my_inventory/html/images/' | false |
Config.Ladders | XP ladders: the XP each level takes; the number of entries is the top level | default, 10 levels |
Config.Books | Your books (see below) | two examples |
server/sv_config.lua holds a Discord webhook for a log of every craft (SvConfig.Webhook).
Books
{
id = 'survival',
item = 'survival_guide', -- the item that opens it
title = 'Survival Guide', -- the book's own name
subtitle = 'Tools, camp cooking and the plain arts of staying alive',
coverTitle = 'Britannia Craftsbook', -- the big title on the cover: put your server's name here
coverImage = 'images/emblem.png', -- a picture in html/images/, a full https:// link, or false
imprint = 'Printed by Boyd Press, Saint Denis, 1899',
leather = '#1d1c1b', -- the cover colour
recipes = 'survival', -- the list in shared/recipes.lua
ladder = 'default', -- the XP ladder
xpKey = 'survival', -- the name its XP is saved under; books sharing one share a level
jobs = { baker = 0 }, -- optional: jobs (and lowest grade) that may open it
zone = { coords = vector3(0, 0, 0), radius = 50.0 }, -- optional: only works here
}To put your own picture on the cover, drop a .png or .jpg into html/images/ and set coverImage = 'images/yourfile.png'.
Recipes
{
item = 'pickaxe', amount = 1, -- what one craft makes
desc = 'An iron tool for breaking rock.',
level = 0, xp = 10, time = 60, -- level needed, XP per item, seconds per craft
price = 0, -- optional cash cost per item
jobs = { blacksmith = 1 }, -- optional: who may craft it
ingredients = {
{ item = 'pickaxe_head', amount = 1 },
{ item = 'hammer', amount = 1, keep = true }, -- a tool: needed, not used up
},
extras = { { item = 'wood_shavings', amount = 1 } }, -- optional bonus items
weapon = false, -- true when item is a WEAPON_...
}Commands and permissions
There are no commands: players open a book by using its item. Books and recipes can be locked to jobs and grades in the config.
How it works
Opening. Using a book's item closes the inventory and opens the book. The cover swings open onto the contents page. The arrows in the page corners (or A/D and the arrow keys) turn the pages; the ribbon goes back to the contents. Escape closes the book.
Crafting. On a recipe's page, choose how many with − and +, then press Craft. The server checks the book, job, level, cash and ingredients, then times the craft (the recipe's time × how many). When the time is up it checks everything again, takes the ingredients and cash, and gives the items, any bonus items and the XP. Nothing is taken before then, so Stop, closing the book or logging out costs nothing. Closing the book doesn't stop a craft: the player gets a message when it's done.
Levels. Each book saves XP under its xpKey. A recipe with level = 3 can only be crafted at level 3 or above; until then its page is stamped "Not yet learned".
Troubleshooting
Nothing happens when using the book item
The item isn't usable or doesn't match. Check the item exists in your items table, is usable, and is spelled exactly as item in the config. The server console prints a line for a book that has no recipes.
Item pictures show a gold star
The picture wasn't found. If your inventory isn't VORP, RSG Core or QBCore RedM, set Config.ImageBase to its picture folder.
"This book can only be used in its proper place."
The book has a zone. Stand inside it, or remove the zone.
"You can't make sense of this book."
The book has jobs and the player's job or grade isn't on the list.
A craft says an ingredient is missing at the end
The player dropped, sold or used an ingredient during the craft. Nothing is taken and nothing is made.
Version history
- 1.0.0: first release.
Still stuck?
Open a ticket on our Discord with your framework, your poggy_core version and what you see, and we'll help you get it running.
Get help on Discord