Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@aceworks-studio/state-machine
Advanced tools
A Luau utility to easily create simple state machines
A Luau utility to easily create simple state machines.
Add @aceworks-studio/state-machine
in your dependencies:
yarn add @aceworks-studio/state-machine
Or if you are using npm
:
npm install @aceworks-studio/state-machine
function StateMachine.create(config: StateMachineConfiguration): () -> ()
type StateController = {
addCleanup: (...Teardown) -> () -> (),
next: (nextState: string, nextConfig: any) -> never,
}
type StateEvent = { state: string, config: any, time: number }
type StateHistory = { StateEvent }
type StateMachineConfiguration = {
defaultState: string,
defaultStateConfig: any,
states: {
[string]: (StateController, config: any) -> (),
},
onStateChange: (state: string, config: any) -> ()?,
onStateHistoryChange: (StateHistory) -> ()?,
}
create({
defaultState = "startup",
defaultStateConfig = { mapName = "defaultMap" },
states = {
startup = function(controller, config)
controller.addCleanup(task.spawn(function()
local model = loadMap(config.mapName)
task.wait(2)
controller.next("match", { model = model })
end))
end,
match = function(controller, config)
teleportAllPlayersInMap(config.model)
controller.addCleanup(
task.delay(30, function()
controller.next("expired")
end),
task.spawn(function()
Time.yieldUntil(0.2, function()
return not hasEnoughPlayer()
end)
local remaining = getRemainingPlayers()
local remainingCount = #remaining
if remainingCount == 1 then
controller.next("winner", { winner = remaining[1] })
else
controller.next("startup", { mapName = pickRandomMap() })
end
end)
)
end,
winner = function(controller, config)
print("winner!", config.winner)
controller.addCleanup(task.delay(3, function()
controller.next("startup")
end))
end,
expired = function(controller)
print("expired!")
controller.addCleanup(task.delay(3, function()
controller.next("startup")
end))
end,
},
})
This project is available under the MIT license. See LICENSE.txt for details.
If you would like to use this library on a Lua environment where it is currently incompatible, open an issue (or comment on an existing one) to request the appropriate modifications.
The library uses darklua to process its code.
FAQs
A Luau utility to easily create simple state machines
We found that @aceworks-studio/state-machine demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.