A module for handling modes and contexts in Roblox.
- Download the
rbxm
model file attached to the latest release from the GitHub releases page. - Insert the model into Studio into a place like
ReplicatedStorage
- Copy the
src
directory into your codebase - Rename the folder to
Romode
- Use a plugin like Rojo to sync the files into a place
- Use kayak to put the file into your porject
For a complete documentation of the langauge visit the github page
-- Context Action Service goes well with Romode
local ContextActionService = game:GetService("ContextActionService")
-- Get romode
local Romode = require(romode.path)
-- Create a mode tree
local mode = Romode.new({
Playing = {
Monster = {
data = {
health = 200
}
},
Spectator = {
data = {
subject = "monster"
}
},
Player = {
data = {
health = 100
}
}
},
Lobby = {}
})
-- Bind these functions when the mode starts and ends
mode.Playing.Spectator:when(function()
-- Turn on spectator gui
end, function()
-- Turn off spectator gui
end)
-- Bind these functions when the mode starts and ends
mode.Monster:when(function()
-- Bind the monsters controls
ContextActionService:BindAction(...)
end, function()
-- Unbind the monsters controls
ContextActionService:UnbindAction()
end)
--Set the inital mode
mode.Lobby:setMode()
This code is under the MIT license. See license.txt.