Lua Scripting on Red Dead

Run Lua scripts in Raiden Red: the folder, RDR2 natives, option callbacks, appearance and memory.

  • 10 min read
  • Updated 17 Nov 2026
On this page
  1. Where scripts go
  2. Running code every tick, or when an option changes
  3. Natives on RDR2
  4. Draw callbacks on RDR2
  5. Changing your character's look
  6. Reading and writing memory
  7. Script globals and locals
  8. RDR2-only functions
  9. Not on RDR2 yet
  10. Questions

Raiden Red runs the same Lua engine as Raiden for GTA V, so a script uses the same functions on both games: raiden.*, script.*, gui.*, event.*, ImGui.*, natives, memory, json, filesystem and the YimMenu layers. This page covers what's different on Red Dead. For the full reference, examples and troubleshooting, see Lua Scripting.

Warning

Only run scripts from people you trust. A script can read and write files on your PC, change game memory and call any native. A broken script can crash your game.

Where scripts go

  • Folder: %APPDATA%\Raiden\RDR2\Scripts. Misc → Lua → Open folder opens it.
  • A .lua file in that folder is one script. A subfolder is a multi-file script: its <FolderName>.lua, main.lua or init.lua runs, and require() looks inside the folder.
  • Scripts load once you're signed in. Reload (on Misc → Lua, or Miscellaneous → Lua scripts in the list-style menu) unloads and reloads all of them.
  • -- @access STANDARD in the first 30 lines sets who can load a script, as on GTA V.
  • YimMenu-style scripts keep their config files in %APPDATA%\Raiden\RDR2\scripts_config\<script file name>\.
  • The log is %APPDATA%\Raiden\RDR2\Raiden.log, and it's also shown in the Raiden console window and on the Engine log tab of the in-game Log window (`). Script lines are tagged LuaScript. print(...) and raiden.log(...) write there, and print lines start with the script's file name.

gui.* options show on Misc → Lua under Script options, one section per group that you can collapse. They're also in search (Ctrl+K) and the console, and can be pinned to the quick bar. YimMenu gui.add_tab tabs show under Script tabs. A tab also holds your options whose group is the tab's name: local tab = gui.add_tab("My Script"), then tab:add_toggle("Invincible", false, fn) or gui.add_toggle("My Script", "Invincible", false, fn).

Running code every tick, or when an option changes

A script's top-level code runs once, when it loads. It can wait with script.sleep(ms), and the rest runs after the wait. Raiden doesn't call functions by name, so a function called OnTick or Tick does nothing until you register it. To run code later:

You want toUse
Run something every tickraiden.on_tick(fn) or script.register_looped(fn). You can call raiden.on_tick at any time, as often as you like.
Run something every few secondsscript.register_looped(fn) with script.sleep(ms) inside
React when someone flips your toggle or moves your sliderPass a function as the last argument of gui.add_toggle / add_slider_* / add_combo, or call handle:on_change(fn)
React to a buttongui.add_action(group, label, fn)
Wait in top-level code, a button or a change callbackscript.sleep(ms)
Wait inside raiden.on_tick, an event handler or a draw callbackscript.run_in_fiber(function() ... script.sleep(ms) ... end)
Lua
-- @access STANDARD

-- Runs once each time you switch it, with the new value.
gui.add_toggle("My Script", "Invincible", false, "Stops you taking damage", function(on)
    ENTITY.SET_ENTITY_INVINCIBLE(PLAYER.PLAYER_PED_ID(), on)
end)

-- Checked over and over: keeps your horse invincible while the toggle is on.
local horse_god = gui.add_toggle("My Script", "Horse godmode", false)

script.register_looped(function(s)
    local horse = self.get_mount()
    if horse ~= 0 then
        ENTITY.SET_ENTITY_INVINCIBLE(horse, horse_god:get())
    end
    s:sleep(250)
end)

To read an option from another part of your script, keep the handle gui.add_* returns and call handle:get(), or look it up with gui.get("My Script", "Horse godmode"). gui.toggle() opens and closes Raiden's menu; it doesn't read options. Raiden has no Wait() or lib.* functions. Use script.sleep, and filesystem.get_appdata_path for file paths.

Natives on RDR2

The native tables are Red Dead's, so names and arguments are RDR2's: ENTITY.GET_ENTITY_COORDS(ped, true, true), PED.GET_MOUNT(ped). GTA V's SYSTEM namespace is another name for RDR2's BUILTIN, and a native named _FOO also answers to FOO_.

Both calling styles work for natives with output parameters:

Lua
-- Raiden style: leave the output parameters out; they come back after the result
local found, z = MISC.GET_GROUND_Z_FOR_3D_COORD(x, y, 1000.0, false)
-- YimMenu style: pass every parameter, outputs included
local found, z = MISC.GET_GROUND_Z_FOR_3D_COORD(x, y, 1000.0, 0.0, false)
  • Hash parameters take a number or a name: STREAMING.REQUEST_MODEL("A_C_Horse_Arabian_White").
  • BOOL parameters take true/false or 1/0. Unlike on GTA V, 0 counts as false here.
  • Vector3* outputs come back as vec3, char* outputs as strings, and Any* parameters take an address from memory.allocate(size) or a number.

Draw callbacks on RDR2

raiden.on_draw, menu.add_imgui and menu.add_always_draw_imgui run on the render thread, and Raiden Red only changes the game from the game thread. Inside a draw callback:

  • A native that returns nothing, and every class setter such as Entity:set_position or Ped:give_weapon, is queued and runs on the next tick, one frame later.
  • Natives that return a value run straight away, as reads.
  • Anything that waits for the game refuses: Entity:request_control with a timeout, Ped.create, scripts.run_as_script and script.execute_as_script. Call those from script.run_in_fiber.

Changing your character's look

Note

Changes stay in Red Dead Online. Online, the game's long_update script puts your saved look back soon after anything changes it. Raiden Red stops it while you're in an Online session, so there's nothing to turn on.

GTA V's appearance natives don't exist on Red Dead: there's no SET_PED_COMPONENT_VARIATION, SET_PED_PROP_INDEX or SET_PED_HEAD_BLEND_DATA. Calling one fails because it's nil, and the log names the native. A Red Dead character is built from MetaPed assets instead: hair, beard, eyebrows, eyes, skin, clothing, hats, glasses. Each one has a drawable, textures, a palette and three tints from 0 to 255. These natives read and change them:

NativeWhat it does
PED._GET_NUM_COMPONENTS_IN_PED(ped)How many assets the ped wears
PED.GET_META_PED_ASSET_GUIDS(ped, index)found, drawable, albedo, normal, material of one asset
PED.GET_META_PED_ASSET_TINT(ped, index)found, palette, tint0, tint1, tint2 of one asset
PED._SET_META_PED_TAG(ped, drawable, albedo, normal, material, palette, tint0, tint1, tint2)Puts that asset on, replacing the one it matches
PED._APPLY_SHOP_ITEM_TO_PED(ped, item_hash, immediately, is_mp, p4)Puts a shop item on: a hairstyle, beard, eye colour, hat, pair of glasses or piece of clothing
PED._UPDATE_PED_VARIATION(ped, false, true, true, true, false)Applies the changes. Call it after any of the above.

This script adds an Appearance group to Script options. Press List assets to write each asset's number and tints to the log, set Asset number to the one you want, then move the tint sliders. It keeps the asset's own drawable and palette and only changes the tints, so it re-colours hair, a beard or eyebrows without changing their style.

Lua
-- @access STANDARD
local GROUP = "Appearance"
local asset = gui.add_slider_int(GROUP, "Asset number", 0, 0, 40)

local function retint()
    local ped = PLAYER.PLAYER_PED_ID()
    local i = asset:get()
    local found, drawable, albedo, normal, material = PED.GET_META_PED_ASSET_GUIDS(ped, i)
    local tinted, palette = PED.GET_META_PED_ASSET_TINT(ped, i)
    if not (found and tinted) then
        raiden.notify("Your character has no asset " .. i)
        return
    end
    PED._SET_META_PED_TAG(ped, drawable, albedo, normal, material, palette,
        gui.get(GROUP, "Tint 1"), gui.get(GROUP, "Tint 2"), gui.get(GROUP, "Tint 3"))
    PED._UPDATE_PED_VARIATION(ped, false, true, true, true, false)
end

gui.add_slider_int(GROUP, "Tint 1", 0, 0, 255, retint)
gui.add_slider_int(GROUP, "Tint 2", 0, 0, 255, retint)
gui.add_slider_int(GROUP, "Tint 3", 0, 0, 255, retint)

gui.add_action(GROUP, "List assets", function()
    local ped = PLAYER.PLAYER_PED_ID()
    for i = 0, PED._GET_NUM_COMPONENTS_IN_PED(ped) - 1 do
        local found, drawable = PED.GET_META_PED_ASSET_GUIDS(ped, i)
        local tinted, palette, t1, t2, t3 = PED.GET_META_PED_ASSET_TINT(ped, i)
        if found and tinted then
            log.info(string.format("asset %d: drawable 0x%08X, palette 0x%08X, tints %d %d %d",
                i, drawable, palette, t1, t2, t3))
        end
    end
end, "Writes each asset's number, drawable and tints to the log")

Outfits load before they go on, so put them on from a fiber:

  1. local request = PED._REQUEST_META_PED_OUTFIT(ENTITY.GET_ENTITY_MODEL(ped), outfit_hash)
  2. Wait until PED._HAS_META_PED_OUTFIT_LOADED(request) is true, with script.sleep between checks. Give up after a second or two.
  3. PED._APPLY_PED_META_PED_OUTFIT(request, ped, p2, p3), then PED._UPDATE_PED_VARIATION(ped, false, true, true, true, false)
  4. PED._RELEASE_META_PED_OUTFIT_REQUEST(request), whether or not it loaded

Things to know:

  • Other players see your new look only if the game sends it to them. We haven't confirmed that for every kind of change.
  • You don't need memory writes. The natives above make the changes; Raiden Red only stops Online undoing them.
  • Asset numbers aren't fixed. They depend on what your character is wearing, so list them again after you change clothes.
  • Clothes, hats, glasses, hairstyles, beards and eye colours are shop items. Putting one on with _APPLY_SHOP_ITEM_TO_PED needs the item's hash, which you can find in community lists of RDR2 clothing and shop items.
  • In story mode, expect the game to put your saved look back when it reloads your character, for example when you change outfits.

Reading and writing memory

Scripts can read game memory as well as write it. A pointer has get_byte, get_word, get_int, get_dword, get_qword, get_float and get_string, the matching set_* methods, and add, sub, deref and rip to move around. Reads of unreadable memory return nil instead of crashing.

To find an entity in memory, memory.handle_to_ptr(handle) returns a pointer to its game object, which is a null pointer if the handle isn't valid. memory.ptr_to_handle(pointer) goes the other way.

Lua
local p = memory.handle_to_ptr(PLAYER.PLAYER_PED_ID())
if not p:is_null() then
    log.info(string.format("my ped is at 0x%X", p:get_address()))
    local value = p:add(0x10):get_int()   -- read 4 bytes, 0x10 bytes into the object
end

The layout of RDR2's game objects isn't documented and changes with game updates, and a wrong write can crash the game. When a native does what you want, use the native.

Script globals and locals

globals.* and ScriptGlobal read and write Red Dead's script globals, in story mode or online, whichever is running. locals.* and ScriptLocal read a named game script's locals while that script runs. Indexes belong to a game build, so expect them to change after updates.

RDR2-only functions

FunctionDescription
raiden.game"RDR2" here. nil in Raiden for GTA V, so a shared script can tell them apart.
self.get_mount() / self.get_owned_mount()The horse you're riding / your own horse
Entity:is_animal()true for animals
Ped:get_mount(), :get_last_mount(), :set_in_mount(horse, [seat])Horse riding
Ped:get_stamina(), :set_stamina(value), :get_max_stamina()Stamina
Vehicle:is_draft(), :get_num_draft_animals(), :get_ped_in_harness(index)Wagons and their animals
Player:get_mount()That player's horse

Not on RDR2 yet

These keep their names so a script shared with GTA V still loads, but they do nothing and say so once in the log:

  • stats.*, tunables.* and transactions.*. They're GTA V systems.
  • ScriptPointer, ScriptPatch, ScriptFunction and scr_function.call_script_function
  • network.trigger_script_event, network.force_script_host and network.force_script_on_player. Raiden Red sends nothing to other players.
  • Player:get_rank(), :get_rp() and :get_money() return 0, :is_modder() returns false, and the armour and number-plate methods do nothing.
  • get_game_branch() returns 0.

Questions

Short answers to questions scripters often ask. Most apply to both games.

No questions here yet.