EasyActionService
- Contents:
- About
- Module
- API
- Examples
- Contact Me
About
EasyActionService is a Luau type-safe customizable module designed to simplify and organize the usage of Roblox’s ContextActionService
. It provides a more intuitive interface for handling actions within your Roblox games or experiences.
- I created this module for my personal use-case, but I decided to release it online for everybody who might want to use it.
Pros:
- Simplifies the process of binding and handling actions.
- Offers a structured approach to managing actions in your game.
- Provides additional options for customization.
Cons:
- May not offer the full flexibility of directly using
ContextActionService
for advanced users who require fine-grained control.
Module
Grab the module here.
API
Functions
Expand functions list
--[[
1. EAS.new(action_name: string, create_touch: boolean?, options: _options?): _EAS
2. EAS:Connect(callback: (input_state: Enum.UserInputState, input_object: InputObject) -> (),
3. EAS:ConnectAtPriority(callback: (input_state: Enum.UserInputState, input_object: InputObject) -> (),
4. EAS:GetButton(): ImageButton
5. EAS:Disconnect(): ()
6. EAS:GetActionInfo(): action_info
7. EAS.DisconnectAllActions(): ()
8. EAS.GetAllActionInfo(): all_action_info
]]
Properties
- action_name: (button’s actual ActionName)
- create_touch: (whether or not if it creates a touch button)
- options: (options table for titles, descriptions, images, positions)
NOTE: Each time you modify a property, you must reconnect the button again so it applies, do not disconnect/reconnect, just manually reconnect it using EAS:Connect(…) function. See API → Functions
Exported Types
- _options (the option’s table type that you can assert it)
- _EAS (EasyActionService instance type)
- action_info (action info return type for
EAS:GetActionInfo()
. See API → Functions) - all_action_info (all action info return type for
EAS.GetAllActionInfo()
. See API → Functions)
Examples:
- Binding an action
local EAS = require(path.to.EasyActionService)
local MyAction: EAS._EAS = EAS.new("Jump")
MyAction:Connect(function(input_state: Enum.UserInputState, input_object: InputObject)
if input_state == Enum.UserInputState.Begin then
-- ...
end
end, Enum.KeyCode.Space)
- Customizing actions with options + use of exported types:
local EAS = require(path.to.EasyActionService)
local Button: EAS._EAS = EAS.new("test", true, {
Title = "hi",
Description = "Cool button",
Position = UDim2.new(0.5, 0, 0.5, 0),
} :: EAS._options)
Button:Connect(print, Enum.KeyCode.G, Enum.UserInputType.MouseButton1)
local Info: EAS.action_info = Button:GetActionInfo()
local AllInfo: EAS.all_action_info = EAS.GetAllActionInfo()
print(Info)
print(AllInfo)
task.wait(2)
Button:Disconnect()
Contact Me
For any inquiries or suggestions, feel free to reach out:
- Discord: netheround
- Roblox: my roblox
Would you use it?
- Yes
- No
- Maybe
- Not now
- In the future
0 voters