Debug libraryOverview
debug.setconstant
Represents modification of a function constant.
Aliases
setconstantDetails#
Replaces a constant at a one-based index only when the replacement has the existing constant's type. Table/function constants and type mismatches are left unchanged. Invalid indices raise an error; returns no values.
Examples#
Example
local f = assert(loadstring("return 'before'"))
for index, value in pairs(debug.getconstants(f)) do
if value == "before" then debug.setconstant(f, index, "after") end
end
print(f()) -- after