Something went wrong. Try again.
Monorepo for PackTools - tooling for Minecraft Modpacks!
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152#pragma once
#include "header.hpp"#include "packluau.h"#include "report.hpp"
#include <cstdint>#include <string>
struct lua_State;
namespace packluau {
enum class Stop : std::uint8_t { none, budget, canceled, refused, failed };
/// What one run owns: the host it reads through, its report, and its budgets. The interrupt and/// every `pw` function reach it through `context`; it exists only while `Runtime::run` runs.struct RunContext { const pl_host *host = nullptr; Report report; /// What the script's `--!pw` header declared. Header header; /// Whether the run is the user tier's: only a user script may require a workspace module. bool user = false; std::uint64_t ticks = 0; /// Bytes the run may still hold outside Luau's heap (report items and plan operations). std::uint64_t outside_budget = 0; /// Bytes this run's plans hold so far, charged with the report against `outside_budget`. std::uint64_t plan_bytes = 0; Stop stop = Stop::none; /// Why the run was refused or failed, when `stop` is `Stop::refused` or `Stop::failed`. std::string refusal; /// How `pw.fail` classified the failure, when `stop` is `Stop::failed`. pl_fail_kind fail_kind = PL_FAIL_NONE; /// Distinguishes this run's lock handles from another run's; never 0. std::uint64_t generation = 0; /// The registry reference of this run's `pw.pack` table, or LUA_NOREF before first use. int pack_ref = -1; /// The registry reference of this run's `require` cache, or LUA_NOREF before first use. int module_cache_ref = -1;};
/// The running script's context; raises a Luau error when no script is running.[[nodiscard]] RunContext &context(lua_State *state);
/// `context`, after checking the script's header declared `capability`. An undeclared use stops/// the run with PL_REFUSED (SPEC.md section 5.3): the stop is sticky, so `pcall` cannot keep the/// script going.[[nodiscard]] RunContext &context(lua_State *state, Capability capability);
} // namespace packluau