Apps Home
|
Create an App
aacroventure
Author:
backrublovin
Description
Source Code
Launch App
Current Users
Created by:
Backrublovin
var g_oUserLoc = {}; var g_oLocList = {}; var g_sStart = "label1"; g_oLocList['label1'] = {desc: "You :av_soldier are standing in front of a terrifying dragon :av_dragon_1", choice: [{desc: "attack the dragon", next: "label2"}, {desc: "run away", next: "label3"}]}; g_oLocList['label2'] = {desc: "Amazingly, you defeat the dragon :av_dragon_die_003 with your sword :av_soldier_attack_002", win: true}; g_oLocList['label3'] = {desc: "The dragon :av_dragon_attack_001 breathes fire on your back and you die :av_soldier_die_003", win: false}; function advance(oTip) { if (oTip.amount !== 3) return; var sUser = oTip.from_user; if (typeof g_oUserLoc[sUser] === undefined || g_oUserLoc[sUser] === undefined) g_oUserLoc[sUser] = g_oLocList[g_sStart]; else // advance user to next label based on choice { var oChoice = g_oUserLoc[sUser].choice; for (var nIndex = 0; nIndex < oChoice.length; nIndex++) { if (oTip.message.localeCompare(oChoice[nIndex].desc) === 0) g_oUserLoc[sUser] = g_oLocList[oChoice[nIndex].next]; // update user state on match } } var oLoc = g_oUserLoc[sUser]; cb.sendNotice(oLoc.desc, sUser); if (typeof oLoc.win === undefined || oLoc.win === undefined) // check for win condition being set cb.sendNotice("Tip 3 and choose your next move on the tip menu.", sUser); else { var sWon = " lost."; if (oLoc.win) sWon = " won."; cb.sendNotice("You " + sWon, sUser); cb.sendNotice(sUser + sWon, cb.room_slug); g_oUserLoc[sUser] = undefined; // reset user state } } function showActions(sUser) { if (typeof g_oUserLoc[sUser] === undefined || g_oUserLoc[sUser] === undefined) return; var oOptions = {}; oOptions.label = "Select your next action:"; oOptions.options = []; var oLoc = g_oUserLoc[sUser]; for (var nIndex = 0; nIndex < oLoc.choice.length; nIndex++) { var oChoice = {}; // create new object each iteration oChoice.label = oLoc.choice[nIndex].desc; // copy choice description oOptions.options[nIndex] = oChoice; // save choice in array } return oOptions; } cb.onTip(advance); cb.tipOptions(showActions);
© Copyright Chaturbate 2011- 2026. All Rights Reserved.