Λογότυπο Lua Best Practices

Lua Best Practices

Οργανισμός
overextended
lua-best-practices

Lua best practices for FiveM resources built on ox_lib, the way Overextended structures its own resources. Use when reading or editing any .lua file or fxmanifest.lua, or when the user asks when to use require, lib.load or lib.loadJson, how to split a resource into modules, where config goes, or how to use cache, lib.onCache, lib.points, lib.callback or locales.

Επισκόπηση

Εκδότηςoverextended
Αποθετήριοskills
Όνομα δεξιότηταςlua-best-practices
Αστέρια
22
Forks
4
Συνοδευτικά αρχεία
2
Άδεια χρήσηςGPL-3.0
Σύνδεσμοι
  • Οδηγίες σε Markdown

    Ένα αρχείο SKILL.md που το μοντέλο φορτώνει όταν χρειάζεται, ώστε να καταναλώνει token μόνο όταν ένα αίτημα είναι πράγματι σχετικό.

  • Λειτουργεί με οποιοδήποτε LLM

    Οι δεξιότητες AI είναι απλό Markdown, όχι κώδικας για συγκεκριμένο πάροχο, επομένως αυτή η δεξιότητα λειτουργεί με GPT, Claude, Gemini, Grok ή ένα τοπικό μοντέλο.

  • 2 συνοδευτικά αρχεία

    Σενάρια, πρότυπα και υλικό αναφοράς που μπορεί να διαβάζει το μοντέλο καθώς εργάζεται. Τα αρχεία είναι μόνο για ανάγνωση και δεν εκτελούνται ποτέ.

  • Ανοιχτού κώδικα

    Δημοσιεύτηκε από overextended στο GitHub. Διαβάστε το πηγαίο περιεχόμενο πριν εγκαταστήσετε τη δεξιότητα.

Εγκατάσταση

Εγκαταστήστε τη δεξιότητα AI Lua Best Practices στο TypingMind για να τη χρησιμοποιείτε με οποιοδήποτε LLM ή προσθέστε τη σε άλλον πράκτορα AI που διαβάζει αρχεία SKILL.md.

1

Εγκατάσταση στο TypingMind

Το TypingMind εγκαθιστά μια δεξιότητα απευθείας από τον φάκελό της στο GitHub — διαβάζει το SKILL.md, συγκεντρώνει τα συνοδευτικά αρχεία σε πακέτο και αποθηκεύει το αποτέλεσμα τοπικά.

  1. Ανοίξτε την εφαρμογή και μεταβείτε στα Πρόσθετα → Δεξιότητες.
  2. Επιλέξτε «Εγκατάσταση από GitHub».
  3. Επικολλήστε το παρακάτω URL του φακέλου της δεξιότητας και επιβεβαιώστε.
    https://github.com/overextended/skills/tree/main/skills/fivem/lua-best-practices
  4. Ενεργοποιήστε τη δεξιότητα σε κάθε συνομιλία όπου θέλετε να είναι διαθέσιμη.
Πρόσθετα → Δεξιότητες → Νέα δεξιότητα → Από URL του GitHub, έπειτα επικολλήστε το URL του φακέλου και πατήστε «Συνέχεια».
2

Εγκατάσταση σε άλλον πράκτορα AI

Κάθε πράκτορας AI που διαβάζει τη μορφή Agent Skills μπορεί να χρησιμοποιήσει αυτή τη δεξιότητα — αντιγράψτε τον φάκελο στον κατάλογο δεξιοτήτων του.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/overextended/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/fivem/lua-best-practices .claude/skills/lua-best-practices
Επανεκκινήστε το Claude Code μετά την αντιγραφή, ώστε να εντοπίσει τη νέα δεξιότητα.

Χρησιμοποιήστε τη στο TypingMind

Ενεργοποιήστε τη δεξιότητα Lua Best Practices σε οποιαδήποτε συνομιλία στο TypingMind και το μοντέλο αναλαμβάνει τα υπόλοιπα. Το όνομα και η περιγραφή της περιλαμβάνονται στην προτροπή συστήματος και, μόλις προκύψει ένα σχετικό αίτημα, το μοντέλο φορτώνει μόνο του τις πλήρεις οδηγίες — δεν χρειάζεται ποτέ να την καλείτε χειροκίνητα και δεν καταναλώνει token μέχρι να χρησιμοποιηθεί πραγματικά.

Το μοντέλο φορτώνει αυτόματα τη δεξιότητα Lua Best Practices μόλις λάβει ένα σχετικό αίτημα.

Λειτουργεί με οποιοδήποτε μοντέλο AI

Οι δεξιότητες AI είναι απλές οδηγίες Markdown και όχι κώδικας για συγκεκριμένο πάροχο, οπότε η δεξιότητα Lua Best Practices δεν περιορίζεται στο μοντέλο για το οποίο γράφτηκε. Εγκαταστήστε τη μία φορά στο TypingMind και χρησιμοποιήστε τη με GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ή ένα τοπικό μοντέλο που εκτελείτε εσείς — πάντα με τα δικά σας κλειδιά API.

  • Φόρτωση μόνο όταν χρειάζεται

    Η προτροπή συστήματος περιλαμβάνει μόνο το όνομα και την περιγραφή. Οι οδηγίες ανακτώνται με το πρώτο σχετικό αίτημα, οπότε μια δεξιότητα που δεν χρησιμοποιείται δεν έχει κόστος.

  • Αλλάξτε μοντέλα κατά τη συνομιλία

    Επειδή η δεξιότητα αποτελείται από οδηγίες και όχι από κώδικα, η αλλαγή μοντέλου δεν επηρεάζει τη λειτουργία της — το επόμενο μοντέλο διαβάζει το ίδιο αρχείο SKILL.md.

Οδηγίες δεξιότητας

Αυτό είναι το περιεχόμενο του αρχείου SKILL.md που φορτώνει το μοντέλο. Διαβάστε το πριν από την εγκατάσταση — μια δεξιότητα αποτελείται από οδηγίες που θα ακολουθήσει το μοντέλο σας.

Lua best practices

Write resource Lua the way Overextended writes ox_inventory, ox_target and ox_fuel: one entry script per side, every other file a module loaded with require, data loaded with lib.load, settings read from convars, and ox_lib's cache and lib.* modules instead of hand-rolled loops. Checked against ox_lib 3.40.3. Read the ox resources line of .ox/config.md (walk up from the current directory) for the server's ox_lib version; if it is older, check anything below against that version's source.

Including @ox_lib/init.lua replaces the global require with ox_lib's own loader. It resolves paths from the resource root, not the calling file, and it can load files from other resources. Everything below assumes it.

Loading code and data

CallUse it forHow it behaves
require 'client.utils'Code modules: files that define functions or state and return a tableRuns the file once per resource and side, then returns the cached value to every later caller, so every module shares one instance. Errors on a circular require. A file that returns nothing gives true.
lib.load 'data.stations'Data files (data/*.lua returning a table), and files run for their side effectsRuns the file on every call and returns a fresh value; nothing is cached. Takes an optional environment table as its second argument.
lib.loadJson 'data.prices'JSON data filesReads data/prices.json and returns the decoded table.
require '@ox_core.lib.init'Another resource's Lua libraryRuns that file inside your resource: you get your own copy, not shared state. Read another resource's live state through its exports.

Path rules, shared by all three:

  • Dots separate directories and there is no extension: require 'modules.inventory.server' loads modules/inventory/server.lua. File names can't contain dots.
  • require 'client' tries client.lua, then client/init.lua.
  • @resource.path loads from another resource; @resource alone loads its init.lua.
  • A file loaded on the client must be listed in the manifest's files. Server-side files load from disk and need no listing.

Choosing:

  • Code goes through require. Put local utils = require 'client.utils' at the top of the file that uses it, and end every module with return of its table.
  • Data goes through lib.load, called once where the data is consumed (for id, data in pairs(lib.load('data.crafting') or {}) do). It isn't cached, so never call it inside a loop or an event handler.
  • Read-only config shared by several modules can be a module: config.lua returns a table and every file does local config = require 'config'.
  • A file is a manifest script or a module, never both. Listing a file in client_scripts and also requiring it runs it twice.
  • Load optional parts lazily: if config.ox_target then return require 'client.target' end, or a framework bridge required only in the branch that detects that framework.
  • Don't hand-roll LoadResourceFile plus load. ox_inventory's own data() loader is deprecated in favour of lib.load.

Manifest

  • fx_version 'cerulean', lua54 'yes' and use_experimental_fxv2_oal 'yes', as every ox resource has.
  • shared_script '@ox_lib/init.lua' comes before any of the resource's own scripts, and ox_lib is in dependencies.
  • One entry script per side (client/init.lua, server/init.lua, or a single init.lua that ends with require 'server' or require 'client' depending on lib.context). The entry script requires everything else.
  • files lists every module, data file and locale the client loads ('client/*.lua', 'data/*.lua', 'locales/*.json'). Every client downloads everything in files, so don't list server-only code there.
  • ox_libs { 'locale', 'table' } loads those lib modules when the resource starts. Listing locale there also loads the locale strings, which ox_lib prefers over calling lib.locale() yourself. Any other lib.* module loads on first use, so never require one.

Config

  • Settings a server owner tunes are convars named <resource>:<setting>, read once at the top of the file that uses them: GetConvarInt('ox_target:debug', 0), GetConvarBool('inventory:target', false), GetConvar('ox_target:defaultHotkey', 'LMENU'). Structured settings go through json.decode(GetConvar(...)). Owners set them in server.cfg, so an update never overwrites their changes.
  • Structured data (locations, items, shops, recipes) lives in data/*.lua files returning tables, loaded with lib.load.
  • A small resource can use a config.lua that returns a table, required as a module. Follow whichever approach the resource already uses.

Scope

  • Every variable, function and module table is local. A module is local Utils = {}, its functions function Utils.raycast(...), and return Utils at the end.
  • A global is a deliberate choice for state every file on that side reads, never a forgotten local. All of a resource's scripts and modules on one side share one global scope.
  • In a hot loop, cache a native as a local upvalue: local GetVehiclePedIsIn = GetVehiclePedIsIn.

Layout

Code reads top to bottom in short steps, with blank lines between them and few long lines.

  • One statement per line. count = 0 return false is two lines.
  • A blank line between steps: the guards, the lookups, the work, the reply.
  • A guard stays on one line only when it's short and its body is a bare return or return false: if not player or not player.shop then return false end. A guard that returns a table or does more goes across lines.
  • A condition too long for one line becomes several guards, never one if wrapped across lines.
  • A call or table constructor that runs past about 120 characters goes one argument or field per line. Shorter ones stay on one line.
  • Indent with whatever .editorconfig or the file uses.

ox_lib at runtime

  • cache holds the player's state on the client, refreshed every 100 ms: cache.ped, cache.vehicle (false on foot), cache.seat, cache.weapon, plus cache.playerId and cache.serverId. Both sides have cache.resource and cache.game. Read cache.ped, not PlayerPedId().
  • lib.onCache('vehicle', function(value, oldValue) end) runs when a cached value changes. Use it instead of a loop that polls for the change.
  • Threads: CreateThread and Wait. For repeating work use ox_lib's SetInterval(fn, ms) and ClearInterval(id). For "do something near a location" use lib.points.new({ coords = ..., distance = ..., onEnter = ..., onExit = ..., nearby = ... }), not a distance loop. To wait for a value, use lib.waitFor(fn, errMessage, timeout), which errors after timeout ms (default 1000).
  • Callbacks: the server registers lib.callback.register(name, function(source, ...) end) and the client calls lib.callback.await(name, delay, ...). delay is a client-side rate limit in ms, or false; a throttled call returns nothing. The client chooses every argument, so the server callback checks each one (type, range, ownership, distance) before acting.
  • Locales: locales/en.json is the fallback, merged under the language set by the ox:locale convar. locale('key', ...) formats with string.format and returns the key itself when it's missing.
  • Logging: lib.print.error, warn, info, verbose, debug. Owners filter them with the ox:printlevel convar, or ox:printlevel:<resource> for one resource.
  • Dependencies: check a minimum version at the top of the entry script with if not lib.checkDependency('ox_lib', '3.30.0', true) then return end. Guard an optional resource with GetResourceState('ox_target') == 'started'.

CfxLua

FiveM's Lua 5.4 runtime adds syntax that ox resources use everywhere. Match it:

  • Backtick hashes for constant names: `WEAPON_UNARMED` is hashed at compile time. Keep joaat(name) for names built at runtime.
  • Safe navigation: data.server?.export instead of data.server and data.server.export.
  • Compound assignment: count += 1.
  • table.create(arraySize, hashSize) to preallocate, table.wipe(t) to clear in place.

Annotations

Annotate module functions with LuaLS comments (---@param, ---@return, ---@class) and narrow with --[[@as OxClient]] where a value's type can't be inferred. ox_lib ships its own annotations, so lib.* calls type-check in the editor.

Examples

Read PATTERNS.md for a full resource layout and an example of each section.

Συνοδευτικά αρχεία

Το μοντέλο τα διαβάζει όποτε χρειάζεται, όσο η δεξιότητα είναι φορτωμένη. Διατίθενται ως αρχεία για ανάγνωση και δεν εκτελούνται ποτέ.

Συχνές ερωτήσεις

Τι κάνει η δεξιότητα AI Lua Best Practices;

Lua best practices for FiveM resources built on ox_lib, the way Overextended structures its own resources. Use when reading or editing any .lua file or fxmanifest.lua, or when the user asks when to use require, lib.load or lib.loadJson, how to split a resource into modules, where config goes, or how to use cache, lib.onCache, lib.points, lib.callback or locales.

Γιατί να χρησιμοποιήσετε τη δεξιότητα Lua Best Practices στο TypingMind;

Επειδή την εγκαθιστάτε μία φορά και τη χρησιμοποιείτε με οποιοδήποτε μοντέλο. Η Lua Best Practices είναι απλό Markdown και όχι κώδικας ειδικά για κάποιον πάροχο, επομένως η ίδια δεξιότητα λειτουργεί με GPT-5, Claude, Gemini, Grok ή ένα τοπικό μοντέλο — και μπορείτε να αλλάξετε μοντέλο κατά τη διάρκεια της συνομιλίας χωρίς να διακοπεί η λειτουργία της. Το TypingMind λειτουργεί με τα δικά σας κλειδιά API, οπότε πληρώνετε απευθείας τους παρόχους αντί για συνδρομή ανά θέση χρήστη, ενώ οι δεξιότητες και οι συνομιλίες σας παραμένουν στον δικό σας χώρο αποθήκευσης.

Πώς εγκαθιστώ τη Lua Best Practices στο TypingMind;

Στο TypingMind, ανοίξτε Πρόσθετα → Δεξιότητες → Εγκατάσταση από το GitHub και επικολλήστε το https://github.com/overextended/skills/tree/main/skills/fivem/lua-best-practices. Το TypingMind διαβάζει το αρχείο SKILL.md, συγκεντρώνει τα συνοδευτικά αρχεία και εγκαθιστά τη δεξιότητα, την οποία μπορείτε να ενεργοποιείτε ανά συνομιλία.

Ποια μοντέλα AI μπορούν να χρησιμοποιήσουν τη δεξιότητα Lua Best Practices;

Οποιοδήποτε μοντέλο συνδέετε στο TypingMind. Οι δεξιότητες AI είναι απλές οδηγίες Markdown και όχι κώδικας ειδικά για κάποιον πάροχο, επομένως τα GPT, Claude, Gemini, Grok και τα τοπικά μοντέλα μπορούν όλα να φορτώσουν αυτή τη δεξιότητα όταν ένα αίτημα αντιστοιχεί σε αυτή.

Με πόσα μοντέλα AI μπορώ να χρησιμοποιήσω τη Lua Best Practices;

Με όσα θέλετε. Εφόσον ένα μοντέλο υποστηρίζει δεξιότητες, μπορείτε να χρησιμοποιήσετε τη Lua Best Practices με αυτό — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama και άλλα — όλα στο TypingMind με τα δικά σας κλειδιά API.

Είναι δωρεάν η δεξιότητα AI Lua Best Practices;

Ναι. Δημοσιεύεται στο GitHub από τον χρήστη overextended με την άδεια χρήσης GPL-3.0. Πληρώνετε μόνο τον δικό σας πάροχο AI για τα token που χρησιμοποιείτε.

Τι είναι οι δεξιότητες AI;

Μια δεξιότητα AI είναι ένα επαναχρησιμοποιήσιμο πακέτο οδηγιών που διδάσκει σε ένα μοντέλο AI πώς να εκτελεί μια συγκεκριμένη εργασία. Ακολουθεί την ανοιχτή μορφή Agent Skills: ένα αρχείο SKILL.md με όνομα και περιγραφή, μαζί με τυχόν σενάρια κώδικα, πρότυπα ή αρχεία αναφοράς που μπορεί να χρειαστεί το μοντέλο. Το μοντέλο διαβάζει τις οδηγίες μόνο όταν το αίτημά σας αντιστοιχεί στη δεξιότητα, οπότε μια εγκατεστημένη δεξιότητα δεν κοστίζει τίποτα μέχρι να χρησιμοποιηθεί.

Σε τι διαφέρουν οι δεξιότητες AI από τα πρόσθετα ή τους συνδέσμους MCP;

Ένα πρόσθετο ή ένας σύνδεσμος MCP παρέχει στο μοντέλο νέα εργαλεία που μπορεί να καλέσει — κώδικα που εκτελείται κάπου και επιστρέφει ένα αποτέλεσμα. Μια δεξιότητα AI παρέχει αντί γι’ αυτό γνώσεις και διαδικασίες στο μοντέλο: πώς να προσεγγίσει μια εργασία, ποια βήματα να ακολουθήσει και ποια χαρακτηριστικά έχει ένα καλό αποτέλεσμα. Οι δεξιότητες είναι απλό Markdown, επομένως δεν χρειάζονται διακομιστή, κλειδί API ή περιβάλλον εκτέλεσης και λειτουργούν με οποιοδήποτε μοντέλο.

Προβολή όλων

Στήστε δικό σας χώρο εργασίας AI τώρα

Εγγραφείτε στο ενημερωτικό μας δελτίο για να ενημερώνεστε για νέες λειτουργίες και μελλοντικές κληρώσεις δώρων 👇