
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
@onirix/escape-room-module
Advanced tools
This module allows you to implement Escape Rooms in a simple and intuitive way. Just add dasheets to the Studio elements and Onirix Escape Room Module will process them and display their data depending on the datasheet type.
If you want to know more about data sheets and data structures in Onirix Studio, take a look at our documentation about the Datastore module.
npm install @onirix/escape-room-module
Include the dependency within the HTML head tag:
<head>
<script src="https://cdn.jsdelivr.net/npm/@onirix/escape-room-module@1.0.2/+esm"/>
</head>
As ESM modules:
import OnirixEscapeRoomModule from "https://cdn.jsdelivr.net/npm/@onirix/escape-room-module@1.0.2/+esm";
To use this library, first, the embedsdk must be initialize and pass it to the constructor.
import OnirixEmbedSDK from "https://cdn.jsdelivr.net/npm/@onirix/embed-sdk@1.17.0/+esm";
import OnirixEscapeRoomModule from "https://cdn.jsdelivr.net/npm/@onirix/escape-room-module@1.0.2/+esm";
const embedSDK = new OnirixEmbedSDK();
await embedSDK.connect();
const oxEscapeRoom = new OnirixEscapeRoomModule(embedSDK);
Onirix Escape Room can be configured by adding a second parameter to the constructor:
const uiTexts = {
...
};
const oxEscapeRoom = new OnirixEscapeRoomModule(embedSDK, uiTexts);
The module contains its own default texts, but these can be modified if the uiTexts object contains all the necessary texts.
The data-structure ox-escape is the one that indicates to the module that an Escape Room is going to be implemented, without it no game will be initialized independently of the rest of the added datasheets. It is associated at scene level.
Its structure is as follows:
The data-structure ox-escape__alias is used to assign one or more names to an element, allowing through this/these name(s) to modify its visibility. It is associated at the element level.
Its structure is as follows:
The data-structure ox-escape__key indicates that it is an item that can be picked up, going to the player's inventory, and that can be used to resolve an element that includes a data-sheet of type ox-escape__lock that has the same activation code.
It should be understood that the term key represents the concept of an element that activates, opens or resolves another element when employed, and does not imply that physically this element must be a key in the strict sense of the word. It is associated at the element level.
Its structure is as follows:
The data-structure ox-escape__lock indicates that it is interactive but requires the use of an element of type ox-escape__key to be used, giving rise to the activation and/or deactivation of other elements. It is associated at the element level.
When interacting with an element of this type, a list of all the keys collected will be displayed so that the user can select the one he/she considers correct.
Its structure is as follows:
The data-structure ox-escape__mechanism indicates that it is interactive, giving rise to the activation and/or deactivation of other elements when used. It is associated at the element level.
When interacting with an element of this type, a dialog with relevant information of the game will be displayed.
Its structure is as follows:
The data-structure ox-escape__code indicates that it is interactive but requires the use of an alphanumeric code entered by the player in a text field, resulting in the activation and/or deactivation of other elements. It is associated at the element level.
Its structure is as follows:
The data-structure ox-escape__decision indicates that it is interactive but requires the user to choose between four possible options, resulting in the activation and/or deactivation of other elements. It is associated at the element level.
Its structure is as follows:
The body has a css class called ox-escape-room.
The different elements have these associated css classes:
By employing these selectors, you will be able to customize the style of individual elements under them in the DOM.
To modify the look and feel of the Escape Room you can add all the CSS you need to your experience through Onirix Studio's online code editor.
Let's add some code to change the white background of the top clock and the font.
.ox-escape-room .ox-escape-room-header div {
filter: contrast(150%) brightness(105%);
background-color: #FABADA;
color: #6228a7;
}
You can make infinite changes to the interface by adding the appropriate CSS selectors. Through your browser's development tools you can explore the names of the css classes used by the library and add your own custom selectors and rules.
This class includes three listener triggering client actions. When the escape room starts an event will be launched and you can hear it in your code in this way:
oxEscapeRoom.onInit = (element) => {
/**
* Your code here
*/
}
On the other hand, when the escape rooms ends an event will be launched with the diration of the game as a param:
oxEscapeRoom.onIsFinal = (time) => {
/**
* Your code here
*/
}
And finally when the user leaves de escape room one more event is launched:
oxEscapeRoom.onFinish = () => {
/**
* Your code here
*/
}
In addition, we can always know how long the user has been playing through the following method:
const time = oxEscapeRoom.getCurrentTime();
The constructor accepts essential data for subscribe to embedsdk events:
constructor(embedSdk, uiTexts);
The texts are the following:
{
init: {
rules: 'Rules of the game',
start: 'Start!',
record: 'Current record:',
title: "History and rules",
ar: "AR ESCAPE ROOM"
},
rules: {
rules: 'History and rules'
},
clues: {
clues: "Clues"
},
question: {
answer: "Answer"
},
activators: {
header: "Inventory of activators",
headerSelect: "Activator required",
subheader: "Use some of your inventory.",
empty: "You have not yet collected any activators",
use: "Use this activator"
},
final: {
header: "Congratulations! you have completed the game",
time: "Your time",
end: "Play again",
completed: "AR ESCAPE ROOM COMPLETED",
record: "Current record:",
new_record: "New record!"
},
decision: {
answer: "Answer"
},
unlock: {
resolved: "Resolved!"
},
dialog: {
button: "Continue playing",
button_mechanism: "OK, I understand",
button_activator: "+ Add to inventory",
success: "Resolved!",
fail: "Wow! it doesn't work",
fail_desc_1: "You receive a ",
fail_desc_2: " second penalty for failure."
}
}
👤 Onirix
FAQs
Onirix helper for Escape Room experiences.
We found that @onirix/escape-room-module demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.