Skip to content

Instantly share code, notes, and snippets.

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;
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");
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") {
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",
});
}
@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);
});
@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 / 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 / package.json
Created March 15, 2020 17:54
rollup with typescript
{
"name": "topz2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"couch:start": "docker run -p 5984:5984 -it -v $(pwd)/couchdata:/opt/couchdb/data -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=local_development_password topzcouch"
},
"keywords": [],
"author": "",
@confraria
confraria / rightdrawerconfig.js
Created June 21, 2019 15:41
Add a a new link to rightdrawer
angular.module('c8y.ui').decorator('c8yDocs', ($delegate) => {
'ngInject';
const listFn = $delegate.list.bind($delegate);
$delegate.list = function() {
return listFn().then(links => {
links.push({
{
icon: 'c8y-book', // choose from http://styleguide.cumulocity.com/icons/fontawesome or http://styleguide.cumulocity.com/icons/cumulocity
label: 'My link'
function orderBy(property) {
let prop = property;
if (_.isArray(prop)) {
prop = prop.join('.');
}
const [, sign, iterateeString] = prop.match(/^(-?)(.*)$/);
const order = sign === '-' ? 'desc' : 'asc';
let iteratee = iterateeString;