Skip to content

Instantly share code, notes, and snippets.

@confraria
confraria / samplescene.xml
Last active March 24, 2020 14:58
scripts
<performance title="Battle of Wits">
<!--Information about the graphical elements of the play-->
<header>
<!--Cast of characters and props-->
<castList>
<character id="vizzini">
<name>
Vizzini
</name>
<!--Character models defined for this character. The first model is designated the default model-->
@confraria
confraria / actor.ts
Last active March 25, 2020 15:56
game scripting
/*
The ids: system and player are builtin and don't need to be defined
*/
export const actors: Catalogue<Actor> = {
system: {
name: "Talent digital",
email: "no-reply@talent-digital.eu",
type: ActorType.System,
avatarUrl:
"https://talentdigital.eu/wp-content/themes/TalentDigital/images/FM_TDLOGO_small.png",
@confraria
confraria / scripts.js
Created April 17, 2020 21:00
villares
Array.from(document.querySelectorAll('[id]')).forEach(e => {
const a = document.createElement('a');
a.href=`#${e.id}`;
e.parentNode.replaceChild(a, e);
a.appendChild(e);
});
const streams = {};
function callback(topic, message) {
const [type, cluster] = topic.split("/");
if (type === "log") {
let stream = streams[topic];
if (!stream) {
stream = streams[topic] = fs.createWriteStream(`log_${cluster}.txt`, {
flags: "a",
});
}
function addLinks() {
Array.from(document.querySelectorAll("[id]")).forEach((e) => {
const a = document.createElement("a");
a.href = `#${e.id}`;
e.parentNode.replaceChild(a, e);
a.appendChild(e);
});
}
if (document.readyState === "complete" || document.readyState === "loaded") {
function iFrameFix(aId, divId) {
const $a = document.getElementById(aId);
const $div = document.getElementById(divId);
const renderIframe = (img = {}) => {
const w = img.naturalWidth || 100;
const h = img.naturalHeight || 100;
$div.innerHTML = `<iframe src="${a.href}" frameborder=0 width="${w}" height="${h}"></iframe>`;
};
if ($a !== null && $div !== null) {
let img = div.querySelector("img");
private addStep(step) {
step.id = `scriptStep${this.stepId++}`;
this.ctxQuest.lastStep = step;
this.ctxQuest.steps.push(step);
step.quest = this.ctxQuest;
if (this.state !== 'directC' && step.type === DIRECT_COMMUNICATION_SEND_DIRECT_MESSAGE) {
this.state = 'directC';
}
if (this.state === 'directC' && ![DIRECT_COMMUNICATION_SEND_DIRECT_MESSAGE, ADD_DECISION].includes(step.type)) {
this.state = undefined;