New Library: ActionContext

Howdy ya’ll, this post is to let you all know I released a handy little library recently: ActionContext. It’s an object-oriented way of using Roblox’s ContextActionService and alleviates a good amount of boilerplate code you’d find surrounding BindAction/UnbindAction calls. Rather than re-hash the documentation, I’ll just leave a quick bit of example code here.

local honkAction = {
    ActionName = "Honk",
    Inputs = { Enum.KeyCode.H, Enum.KeyCode.ButtonY },
    Handle = function (userInputState, inputObject)
        if userInputState == Enum.UserInputState.Begin then
            sound:Play()
        end
    end,
}
local actionContext = ActionContext.new({ honkAction })
-- Entering and leaving the car:
actionContext:Enter()
actionContext:Leave()
Continue reading “New Library: ActionContext”

Shift Lock for Roblox on Mobile Devices

Add support for mouse lock (aka shift lock) for games on Roblox’s mobile app by adding this resource to your game/experience.

I made a handy resource for Roblox developers to support “Mouse Lock” (aka “Shift Lock”) mode in their games for mobile players!

Also consider getting the Model from the Roblox website so it’s available in Studio’s toolbox and on your Roblox account!

Continue reading “Shift Lock for Roblox on Mobile Devices”

ParticleEmitter:Emit(n) Version 2 is now available!

A quality-of-life update to this particle-emission plugin from 2015 is now available: attributes, better onboarding, passive update notifications, bug fixes and more.

It’s all freshened up for the modern-day Roblox developer! This simple yet useful plugin got some love in its version 2 release.

  • Now uses the EmitCount attribute, so emitters can burst different amounts of particles
  • A new on-boarding experience and update notifications
  • …and so much more. Check out the full post, or install it right now!
Continue reading “ParticleEmitter:Emit(n) Version 2 is now available!”

Introducing: Modules

The logo for Modules
A fancy logo for Modules I came up with

It’s my pleasure to announce Modules, a simple dependency loader for Roblox!

Modules comes with goodies, too: Event , Maid  and StateMachine  classes just to name a few. These patterns are so commonplace in Roblox development today, they felt right at home to be included.

With Modules, you can require strings instead of ModuleScripts. This greatly simplifies your scripts’ dependencies and streamlines creation of client and server code.

local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Modules"))
local MyModule = require("MyNamespace:MyModule")

Download: Model on Roblox.com, GitHub releases
Links:
Documentation, Repository on GitHub

Continue reading “Introducing: Modules”

repr — function for printing Lua tables

Hey all!

I wrote a function that will come in handy when printing tables in Lua. Normally, when you call print on a table, it is first tostring-ed into a memory address and looks something like `table: 000002074CD2C070`. How unhelpful! If only there was a better way…

I’ve created a function, repr, that works like Python’s repr. It returns a nice, printable representation of Lua values (strings, numbers, bools, and of course tables). It is designed with two goals in mind: (1) be as close as possible to a literal code representation and (2) be as useful as possible during debugging. Check it out at this GitHub repository, or keep reading this post!

local repr = require(3148021300)
local myTable = {
   hello = "world";
   score = 5;
   isCool = true;
}
print(repr(myTable)) --> {hello = "world", isCool = true, score = 5}

Continue reading “repr — function for printing Lua tables”