EasyActionService | Simple/Organized ContextActionService actions

EasyActionService

  • Contents:
    1. About
    2. Module
    3. API
    4. Examples
    5. 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

--[[
  1. EAS.new(action_name: string, create_touch: boolean?, options: _options?): _EAS
  2. EAS:Connect(callback: (action_name: string, input_state: Enum.UserInputState, input_object: InputObject) -> (),
  3. EAS:ConnectAtPriority(callback: (action_name: string, 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
]]

NOTE: If you want a brief explanation of how each function work, check the module’s source code there are clear comments pointing out everything.

Properties

  1. _action_name: (button’s actual ActionName)
  2. _create_touch: (whether or not if it creates a touch button)
  3. _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

  1. _options (the option’s table type that you can assert it)
  2. _EAS (EasyActionService instance type)
  3. action_info (action info return type for EAS:GetActionInfo(). See API → Functions)
  4. all_action_info (all action info return type for EAS.GetAllActionInfo(). See API → Functions)

Examples:

  1. Binding an action
local EAS = require(path.to.EasyActionService)

local MyAction: EAS._EAS = EAS.new("Jump")
MyAction:Connect(function(action_name: string, input_state: Enum.UserInputState, input_object: InputObject)
	if input_state == Enum.UserInputState.Begin then
		-- ...
	end
end, Enum.KeyCode.Space)
  1. 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:


Would you use it?

  • Yes
  • No
  • Maybe
  • Not now
  • In the future

0 voters

I appreciate the resource but I think this is the biggest issue I have with this module, ContextActionService isn’t that difficult to bind and handle actions I believe atleast in my opinion. So sticking to the regular service in my opinion is good enough, especially since I have full control. But I understand why some may need this module if they need cleaner and more understandable code.

And to be fair I don’t really use modules like fastcast or what not at all, so this may be a nitpick.

This module is based of ContextActionSerivce, so techncially you can create your own functions if the API isn’t enough to you.

For instance a custom unbind:

local ContextActionService = game:GetService("ContextActionService")

local Button = ...
Button:Connect(...)

ContextActionService:UnbindAction(Button._action_name)

This might be a reason why are there properties, so you can expand it yourself if you like it and might plan on adding more functionallity for yourself.

1 Like

Yeah I see, sorry if I sounded like I was nitpicking at your work. It’s definitely good, just not for me.

1 Like