mtasa-blue
mtasa-blue copied to clipboard
New Lua constants (#3022)
This PR is a direct response to the #3022 feature which adds new global variable: constants
and assigns new fields to it:
- ElementType
- TriggerPriority
- DebugMessageLevels
- KeyState
- KeyNames
- ControlNames
- AnimationBlocks
- BodyPartName
- ClothesType
- Weather
- PedStats
- PedWalkingStyle
- PedFightingStyle
- HudComponents
- BlipIcons
- MarkerTypes
- PickupTypes
- ModelPickupTypes
- VehicleLights
- VehicleLightState
- VehicleDoorType
- VehicleDoorState
- VehicleLightOverride
- CarPanels
- PlanePanels
- VehiclePanelState
- VehicleWheelState
- VehicleSeat
- TrafficLightState
- WeaponSlot
- WeaponSkillLevel
- WeaponSkillName
- WeaponProperties
I think that the length of these constants makes them cumbersome and difficult to use. I doubt that long constructions like constants.VehicleLightOverride.Disable
can be usefull. I would suggest to make them shorter.
In addition, I would suggest to make the table read-only.
Also something I just realized, these constants are pretty useless on their own. There should be a way to convert to/from name/value. Given:
local MyEnum = {
First = 1
}
MyEnum['First']
should return 1
. MyEnuim(1)
should return First
This is similar to how Python work (Though Python returns special EnumValue objects that we can't afford in terms of performance, so we're going with the simpler solution here).