Skip to content

Latest commit

 

History

History
154 lines (117 loc) · 4.77 KB

File metadata and controls

154 lines (117 loc) · 4.77 KB

globals

Summary

Core script globals in every Luau chunk:

  • print
  • warn
  • loadstring
  • require
  • _G

Standard Luau libraries and LuauAPI namespaces (task, geode, imgui, gd3d, and others) are included. See Other globals below.

This page covers signatures for the core globals plus error shapes.

Script basics

Runtime rules live in Getting started. Caps and error strings live in Limits and errors.

All modules

Group Page Role
Core hooks Hook game functions
Core modules Sandboxed require
Core sharing APIs between mods _G mod APIs
Core tasks and time task and time
Core callbacks C++ callback lifetime
Core delegates Virtual interface tables
Game enums GD and Geode enum constants
Game game objects Cocos and GD objects
Game cocos Node and color helpers
Game ColorProvider Theme colors
Game Keybind Keybind strings
Game Keyboard input Keyboard events
UI UI and layouts Cocos UI factories
UI imgui Dear ImGui overlay
UI gd3d 3D viewport rendering
IO mod Saved values and settings
IO loader Installed mod list
IO fs Sandboxed filesystem
IO json JSON parse and dump
Network web HTTP client
Network websocket WebSocket client and server
Utils geode.utils Utils namespace index
Utils clipboard System clipboard
Utils string String helpers
Utils random Random strings and UUIDs
Utils game Game process control
Utils base64 Base64 encode and decode
Utils permission OS permissions
Utils VersionInfo Version parsing
Meta type stubs geode.d.luau reference

Error shapes

Some APIs return nil and an error string instead of throwing. Examples include loadstring, fs reads, json parse, geode.Keybind.fromString, and websocket.serve. Other APIs raise on failure, such as json.dump and invalid hook targets. Check each function's signature for which shape it uses.

print

print(...any) -> ()

Writes a single line to the Geode log. Each argument is converted to text and joined with a tab.

print("value", 1, true)

warn

warn(...any) -> ()

Same formatting and path redaction as print, but writes to the Geode log at warn level.

warn("deprecated path", featureName)

loadstring

loadstring(source: string, chunkName: string?) -> (((...any) -> ...any)?, string?)

Compiles a Luau source string and returns a callable function. It does not run the chunk. On syntax or load failure it returns nil plus an error string instead of throwing.

local fn, err = loadstring("return 1 + 1")
if not fn then
    print("compile failed:", err)
    return
end
print(fn())

chunkName is used in diagnostics. If omitted, LuauAPI uses =loadstring. Sources over the script size cap return nil and an error message. If the runtime is not ready, it returns nil, "luau runtime not ready".

loadstring bypasses the require sandbox. Treat its output as trusted code. Calling it does not start a new script deadline. It inherits an existing guarded call path, such as code already running inside a task callback.

require

require(path: string) -> any

Loads a sibling Luau module and returns its single value. See modules for the full rules. See Examples.

_G

_G: { [string]: any }

The shared global table for every script in the runtime. Values you set on _G are visible to all scripts and mods. Read shared values through _G[key] rather than as a bare global name. See sharing APIs between mods.

Other globals

Standard Luau libraries and LuauAPI namespaces (task, geode, imgui, gd3d, and others) are listed in type stubs. Hook helpers such as geode.skip are documented in hooks.

Related

Source

  • src/core/Runtime.cpp
  • src/require/Requirer.cpp
  • src/core/Config.hpp