Expose a `constants` dictionary to Lua.
C people:
-
lib_getenumworks functionally identically to how it worked before I made any changes. - The difference is now
getEnumcontains the main comparison portion. - The
constantsuserdata uses an anonymous metatable.
Lua people:
- A new userdata named
constantsnow exists for you to get the value of a constant, or check if it exists. This is helpful for seeing if a value in_Gis a constant or not. - This read-only userdata expects table accesses with strings as keys. Failed accesses will return
nilwith no errors.
Example:print(constants["FRACUNIT"]) -- 65536 -
userdataandfunctiontype variables are excluded fromconstants, soA_*andsuperaren't considered constants.
Attached is a Lua script you can use to test the code.
constantTable.lua
Edited by Golden