First, a heartfelt shout-out to my friend @Dbeard (David). He went to the trouble of working on my long Shuffle-bag script that , in another post, ran out of space trying to refactor for me. Dave - you're the best!
With David's rewrite, he shortened that long script from over 1,500 lines down to around 800. That's huge. It looks like he shortened many of the if/else chains into single-line constructs (I think they are called switch statements).
I'd like to ask to make the final refactor rewrite of this script with the upgrades she suggested:
- Centralize all clip durations into lookup tables.
- Make the entire script much easier to maintain (refactor). This should turn what we have into an easy-to-read and maintain final script.
- Feel free to convert any remaining if/else chains into switch statements where it benefits the refactor.
Context: This is a Synthiam ARC project (not ARCx). The script uses ControlCommand to call Soundboard Robot Skills (e.g., "Soundboard v4", "Dr_Smith", etc.) and also uses Digital/PWM/Servo calls (e.g., Digital.set, PWM.set, Servo.release), which implies the hardware I/O (servos, PWM, digital pins) is connected through an EZB. Please keep the existing logic flow and do not remove any comments, statements, commands, or block titles that explain what they are supposed to do. You may add more comments to make it easier to read and maintain.
, please rewrite the script below with the changes you suggested in the other thread. If needed, here’s that thread link: https://synthiam.com/Community/Questions/Shuffle-Bag-Rewrite-For-Arc-Script-23715?commentPage=2
Thanks - let’s see what happens.
// Impression Show Script - Will play three impersonations with robot comments
// before opening impersonation, between impersonations and at end of set. Then say a closing statement.
// ============================================================
// Original application: Synthiam ARC (not ARCx)
// Version: 2.0.0-refactor | 2026-11-09
// ===============================================================
function getShuffleBagItem(bagVarName, itemList, lastVarName) {
var bagText = getVar(bagVarName, "");
var bag = [];
if (bagText != null && bagText != "") {
bag = ("" + bagText).split(",");
}
if (bag.length == 0) {
bag = refillShuffleBag(itemList, lastVarName);
}
var selected = bag[0];
var newBag = [];
for (var i = 1; i < bag.length; i++) {
newBag.push(bag[i]);
}
setVar(bagVarName, newBag.join(","));
setVar(lastVarName, selected);
return selected;
}
function refillShuffleBag(itemList, lastVarName) {
var temp = [];
for (var i = 0; i < itemList.length; i++) {
temp.push(itemList[i]);
}
for (var j = temp.length - 1; j > 0; j--) {
var k = Utility.getRandom(0, j + 1);
var swap = temp[j];
temp[j] = temp[k];
temp[k] = swap;
}
var lastItem = getVar(lastVarName, "");
if (temp.length > 1 && temp[0] == lastItem) {
var swapFirst = temp[0];
temp[0] = temp[1];
temp[1] = swapFirst;
}
return temp;
}
// ------------------------------
// Sound and character tables
// ------------------------------
var OPENINGS = [
["Soundboard v4", "Track_60", 3500], // 1 - Say "I Do Impressions"
["Soundboard v4", "Track_61", 3000], // 2 - Say "Let's Party"
["Soundboard v4", "Track_62", 3000], // 3 - Say "Let's Rock"
[ // 4 - Say "What Would You Like Me To Do?" then "I Know"
["Soundboard v4", "Track_63", 3250], // Say "What Would You Like Me To Do?"
["Soundboard v4", "Track_35", 1500], // Say "I Know"
],
[ // 5 - Say "Will I be on telavision?" then "I enjoy being on Telavision"
["Soundboard v4", "Track_64", 2500], // Say "Will I be on telavision?"
["Soundboard v4", "Track_99", 3000], // Say "I enjoy being on Telavision"
],
["Soundboard v4", "Track_65", 2500], // 6 - Say "Affirmative"
["Soundboard v4", "Track_66", 3000], // 7 - Say "Affirmative" (alternate)
["Soundboard v4", "Track_67", 3000], // 8 - Say "OK"
["Soundboard v4", "Track_68", 3000], // 9 - Say "OK" (alternate)
["Soundboard v4", "Play", "HaveNoFear-RobotHere.mp3", 2500], // 10 - Say "Have no fear, robot here"
["Soundboard v4", "Track_23", 3000], // 11 - Say "Green and go"
["Soundboard 2", "Play", "Caution-PatienceAdvised.mp3", 3000], // 12 - Say "Caution, patience advised"
["Soundboard v4", "Track_33", 3500], // 13 - Say "Please stand by"
["Soundboard v4", "Track_35", 2500], // 14 - Say "I know"
["Soundboard v4", "Play", "HowSweet-It-Is.mp3", 3500], // 15 - Say "How Sweet It Is"
];
var CLOSINGS = [
["Soundboard v4", "Track_52", 3500], // 1 - Say "Thanks for coming"
["Soundboard v4", "Track_83", 3000], // 2 - Say "It's been a pleasure to serve you"
["Soundboard v4", "Track_84", 3000], // 3 - Say "Goodbye"
["Soundboard v4", "Track_85", 6000], // 4 - Say "My power pack needs charging"
["Soundboard v4", "Track_86", 3000], // 5 - Say "Conclusion"
["Soundboard v4", "Track_87", 2500], // 6 - Say "Do I amuse you?"
["Soundboard v4", "Track_88", 3000], // 7 - Say "End of report"
["Soundboard v4", "Track_89", 3000], // 8 - Say "How Sweet it is"
["Soundboard v4", "Track_90", 3000], // 9 - Say "Have no fear, the robot is here"
["Soundboard v4", "Track_91", 2500], // 10 - Say "May the force be with you"
["Soundboard v4", "Track_92", 4000], // 11 - Say "To Boldly go where no Robot has gone before"
["Soundboard v4", "Track_9", 3000], // 12 - Say "Hasta la vista baby"
["Soundboard v4", "Track_10", 3000], // 13 - Say "Live Long and Prosper"
["Soundboard v4", "Track_36", 2500], // 14 - Say "So it goes"
["Soundboard v4", "Track_51", 2500], // 15 - Say "Drinks are on me"
];
var INTERSTITIALS = [
["Soundboard v4", "Track_79", 1500], // 1 - Say "And"
["Soundboard v4", "Track_78", 1750], // 2 - Say "My Friend"
["Soundboard v4", "Track_77", 2000], // 3 - Say "Loading"
["Soundboard v4", "Track_76", 2500], // 4 - Say "What else Do I do?"
["Soundboard v4", "Track_75", 1500], // 5 - Say "Thank You"
["Soundboard v4", "Track_74", 1500], // 6 - Say "Thank You" (alternate)
["Soundboard v4", "Track_73", 2000], // 7 - Say "Priceless"
["Soundboard v4", "Track_71", 2000], // 8 - Say "Marvelous"
["Soundboard v4", "Track_35", 2000], // 9 - Say "I know"
["Soundboard v4", "Track_70", 2000], // 10 - Say "Swell"
["Soundboard v4", "Track_81", 2000], // 11 - Say "Wow"
["Soundboard v4", "Track_8", 2750], // 12 - Say "Good Night, Sleep Well"
];
var CHARACTER_AUDIO = [
{ // doDr_Smith, selections 2-50
board: "Dr_Smith", bag: "$drSmithBag",
last: "$lastDrSmith", first: 2,
clips: [
["Evil purpose.mp3", 5000],
["Fatal contamination.mp3", 9000],
["Genius.mp3", 4000],
["Greatful creatures.mp3", 4000],
["Irk_me.mp3", 3000],
["The_pain.mp3", 3500],
["silence.mp3", 3000],
["smith_is_here.mp3", 3000],
["System is full proof.mp3", 8500],
["wont_do_it.mp3", 6500],
["Alpha_Control.mp3", 13000],
["Aolia_14_umbra.mp3", 7000],
["Bha.mp3", 2500],
["Cold_man.mp3", 3250],
["Delightful.mp3", 3500],
["Glass_headded.mp3", 3000],
["Indeed.mp3", 2000],
["Motherload.mp3", 7500],
["Much_to_be_disired.mp3", 5000],
["Neanderthal_Ninny.mp3", 5000],
["Non_Discript_Ninny.mp3", 3000],
["Not_gold.mp3", 7000],
["Pairapharse.mp3", 7500],
["Resent_it.mp3", 4500],
["Splender.mp3", 7000],
["Starve.mp3", 4000],
["Talents.mp3", 12500],
["Underestamate.mp3", 4500],
["Working_robot.mp3", 7500],
["Fine_Howdy.mp3", 2500],
["Control_something.mp3", 5500],
["Robot_puppit.mp3", 7000],
["Spare_parts.mp3", 7000],
["Utmost.mp3", 4000],
["Bha(2).mp3", 2000],
["Bird_brain.mp3", 4500],
["Earth_so_Close.mp3", 5000],
["Errors.mp3", 7000],
["Junk_pile.mp3", 6000],
["Not_go.mp3", 7000],
["Proved_wrong.mp3", 6500],
["Bad Back.mp3", 5500],
["Better then that ninny.mp3", 3000],
["Heaven and Earth.mp3", 15500],
["Pinball.mp3", 8500],
["Return to J2.mp3", 6000],
["Scream.mp3", 2000],
["Scream2.mp3", 4000],
["Scream4.mp3", 3000],
]
},
{ // doR2D2, selections 2-10
board: "R2D2", bag: "$r2d2Bag",
last: "$lastR2d2", first: 2,
clips: [
["Proud R2D2.mp3", 3000],
["r2d2-scream.mp3", 5500],
["Playfull R2D2.mp3", 2500],
["Processing R2D2.mp3", 3000],
["r2d2-squeaks1.mp3", 3000],
["r2d2-squeaks5.mp3", 3000],
["Sad R2D2.mp3", 2000],
["Unbelievable R2D2.mp3", 2500],
["r2d2-whistle1.mp3", 3000],
]
},
{ // doWill, selections 1-18
board: "Will", bag: "$willBag",
last: "$lastWill", first: 1,
clips: [
["Will_identify.mp3", 3500],
["All_Right.mp3", 3500],
["But_dad.mp3", 1500],
["Dad_not_let_go.mp3", 3000],
["Dont_get_married.mp3", 23500],
["Hes_a_robot.mp3", 4000],
["Multi_demention.mp3", 4000],
["Murder.mp3", 6000],
["Robot_obey.mp3", 8000],
["Robot_part_of_comunity.mp3", 4000],
["Sunday_Chapel.mp3", 6000],
["Watch_me.mp3", 2500],
["Wheres_Smith.mp3", 2500],
["Are you sure.mp3", 3000],
["Change_mind.mp3", 3500],
["Explosive gas.mp3", 8000],
["Im_will.mp3", 2000],
["Superstition.mp3", 6000],
]
},
{ // doDon, selections 2-30
board: "Don", bag: "$donBag",
last: "$lastDon", first: 2,
clips: [
["MarkGoddard.wav", 3000],
["Dig_Deeper.mp3", 3500],
["Wonder_what_guidance.mp3", 3500],
["Abort_30B_mission.mp3", 6000],
["Atmosphere.mp3", 4000],
["Extra_weight.mp3", 7200],
["Flip_Lid.mp3", 4800],
["Get_away.mp3", 4000],
["Hogwash.mp3", 3500],
["Keep_Going.mp3", 3500],
["Know_your_in_trouble.mp3", 4500],
["Let_you_off.mp3", 6000],
["Meal_in_space.mp3", 6000],
["Meteors_clobbered.mp3", 6000],
["Nice_try_smith.mp3", 6500],
["Pay_attention.mp3", 3700],
["Robot_conditions.mp3", 3500],
["School_bus_driver.mp3", 4800],
["Slippery_eels.mp3", 4800],
["Smith_layer.mp3", 10500],
["Sure_John.mp3", 5500],
["Thank_the_robot.mp3", 3000],
["Tin_monster.mp3", 6750],
["Your_funeral.mp3", 2500],
["Hanky panky.mp3", 11000],
["Less work for Smith.mp3", 3500],
["Look at this.mp3", 3000],
["Primitave force.mp3", 5000],
["Swimming in bog.mp3", 10000],
]
},
{ // doMaureen, selections 1-18
board: "Maureen", bag: "$maureenBag",
last: "$lastMaureen", first: 1,
clips: [
["All_Rest.mp3", 5000],
["Bully_us.mp3", 7000],
["Cold_storage.mp3", 9500],
["Come_back.mp3", 3000],
["Dear_madum.mp3", 4500],
["Fighting_for_lives.mp3", 9500],
["Johns_eyes.mp3", 5000],
["Reanamate.mp3", 9500],
["Not_from_our_planet.mp3", 6500],
["Rude.mp3", 2500],
["Safeguard.mp3", 13000],
["Not_bees.mp3", 10500],
["Smith_explaned.mp3", 4000],
["Frighten her.mp3", 4500],
["How could you.mp3", 5750],
["In attic.mp3", 15000],
["mysterious.mp3", 3000],
["Ridiculous.mp3", 4500],
]
},
{ // doJohn, selections 1-26
board: "John", bag: "$johnBag",
last: "$lastJohn", first: 1,
clips: [
["Amen.mp3", 6000],
["Appointed_rounds.mp3", 6500],
["Busy_day.mp3", 3500],
["Can_you_hear_me.mp3", 4500],
["Cosmic_dust.mp3", 10000],
["Decision.mp3", 7000],
["Fix_the_charriot.mp3", 4500],
["Knew_what_we_were_getting_into.mp3", 4000],
["Magic_tricks.mp3", 4000],
["No_one_leaves_ship.mp3", 4000],
["Off_course.mp3", 6000],
["On_our_way.mp3", 11000],
["Robot_equipment.mp3", 3000],
["Safe_in_ship.mp3", 3000],
["Save_lives.mp3", 4000],
["Stand_much_more.mp3", 7000],
["Survival.mp3", 8000],
["Tamper_with_robot.mp3", 5000],
["Tests.mp3", 5000],
["Treated_as_Stowaway.mp3", 15000],
["Unload_Charriot.mp3", 4000],
["Where_are_we.mp3", 6000],
["Will_in_charge.mp3", 5000],
["Go right ahead.mp3", 10000],
["What did the robot say.mp3", 4250],
["What happened.mp3", 4500],
]
},
{ // doTufeld, selections 1-18
board: "Tufeld", bag: "$tufeldBag",
last: "$lastTufeld", first: 1,
clips: [
["Beginning.mp3", 13000],
["Derelict_epilog.mp3", 34500],
["Derelict_intro.mp3", 27600],
["Giants_intro.mp3", 15000],
["Island_Sky_intro.mp3", 34500],
["Wild_journy_intro.mp3", 15500],
["Another Era.mp3", 16000],
["Atomic fuel.mp3", 18500],
["Condemned.mp3", 28000],
["Distroy Robot.mp3", 11500],
["Forgotten Planet.mp3", 17500],
["ghostly Swamp.mp3", 21500],
["Robby Monster.mp3", 17500],
["Silence.mp3", 10500],
["Slipped away.mp3", 18000],
["Steal Spaceship.mp3", 24000],
["Watching every move.mp3", 16750],
["Weird eyes.mp3", 12000],
]
},
{ // doJudy, selections 1-13
board: "Judy", bag: "$judyBag",
last: "$lastJudy", first: 1,
clips: [
["Don.mp3", 1500],
["Earthquake.mp3", 7750],
["Garden.mp3", 3750],
["Im_not_tired.mp3", 2000],
["Not_like_School.mp3", 16000],
["Remoat_Planet.mp3", 6750],
["No_answers.mp3", 6750],
["As Long as I live.mp3", 6250],
["Feelings.mp3", 4750],
["Flat on Floor.mp3", 6500],
["Not my Style.mp3", 9000],
["Silly contest.mp3", 6500],
["Robot short circuit.mp3", 4500],
]
},
{ // doWall_e, selections 1-8
board: "Wall_e", bag: "$walleBag",
last: "$lastWallE", first: 1,
clips: [
["say-kiss.wav", 1500],
["say-sigh.wav", 2500],
["say-tada.wav", 2500],
["say-whistle.wav", 2500],
["say-whoa-interest.wav", 2000],
["e-brrr.mp3", 2500],
["e-caution.mp3", 3000],
["walle_eve_name_eva.mp3", 17750],
]
},
{ // doPenny, selections 2-14
board: "Penny", bag: "$pennyBag",
last: "$lastPenny", first: 2,
clips: [
["Penny.mp3", 5000],
["Eat_it_Debbie.mp3", 4000],
["I-saw_him.mp3", 5000],
["Model.mp3", 4500],
["Oh-Debie.mp3", 3000],
["Test.mp3", 3000],
["What_makes_you_think.mp3", 4000],
["Not a Baby.mp3", 5500],
["Ouija Board.mp3", 3500],
["Chess_this_evening.mp3", 4000],
["Spoken to him.mp3", 3500],
["Tight in wrong places.mp3", 7250],
["What happened.mp3", 3500],
]
},
{ // doHal9000, selections 1-24
board: "Hal9000", bag: "$halBag",
last: "$lastHal", first: 1,
clips: [
["cantdo.mp3", 4000],
[["chess.mp3", 2500], ["Phrases", "DidSomeoneSayChess-UsedToPlayLittle.mp3", 4250]],
["completed.mp3", 2000],
["daisy.mp3", 12250],
["dangerous_to_remain.mp3", 3000],
["disconnect_me.mp3", 7000],
["enough_info.mp3", 3500],
["feel_much_better.mp3", 7000],
["functional.mp3", 2250],
["good_evening.mp3", 3500],
["human_error.mp3", 7500],
["ignition.mp3", 2500],
["just_a_moment.mp3", 6500],
["just_what.mp3", 3750],
["mind_is_going.mp3", 6000],
["mission.mp3", 5000],
["operational.mp3", 5000],
["quite_like_this.mp3", 5750],
["sorry_dave.mp3", 7500],
["stop2.mp3", 11000],
["stress_pill.mp3", 8500],
["upset.mp3", 3250],
["well.mp3", 2250],
["2_good_morning_dave.mp3", 3000],
]
},
{ // doBender, selections 1-41
board: "Bender", bag: "$benderBag",
last: "$lastBender", first: 1,
clips: [
["Are you kidding.mp3", 2000],
["Bite my Ass (2).mp3", 3500],
["Bite my Ass.mp3", 3000],
["Bodies are for hookers.mp3", 4000],
["bringItOnBaby.mp3", 1750],
["Cant you see Im using the toilet.mp3", 3000],
["checkMyProgram.mp3", 2000],
["Dont make me kick your neck.mp3", 3000],
["Dream on skintube.mp3", 3000],
["Ever been beaten up by a guy.mp3", 3500],
["Hello peasants.mp3", 3000],
["Hitting your kids.mp3", 7750],
["I have all the money.mp3", 2500],
["in your face.mp3", 2000],
["Ive had it up to here.mp3", 3750],
["Lets go get drunk.mp3", 2000],
["Listen buddy Im in a hurry.mp3", 2500],
["looks like your neck.mp3", 3250],
["Luner Lander.mp3", 13000],
["makeThisQuick.mp3", 3250],
["My name is Coilette.mp3", 2500],
["Nothing a lawsuit wont cure.mp3", 3250],
["OMG.mp3", 2000],
["Pleasure to meet you.mp3", 2000],
["programEvil.mp3", 2500],
["radical.mp3", 4500],
["Right now I feel sorry for you.mp3", 3000],
["showsOver.mp3", 4500],
["So beautiful.mp3", 2500],
["So long coffin stuffers.mp3", 2500],
["Sroned in gutter.mp3", 7500],
["Thank you.mp3", 2500],
["Dirty double crossing *sugar plum*.mp3", 3500],
["These will teach those.mp3", 4000],
["This place has class.mp3", 3000],
["Wanna kill all humans.mp3", 3500],
["What am I gonna do.mp3", 3500],
["Whoooh hew.mp3", 2500],
["Would you kindly shut your...mp3", 3500],
["You got it genius.mp3", 3500],
["You gotta help me.mp3", 4000],
]
},
{ // doRobby, selections 1-35
board: "Robby", bag: "$robbyBag",
last: "$lastRobby", first: 1,
clips: [
["60 gallons.mp3", 8000],
["admit no one.mp3", 14250],
["Altair 4.mp3", 3500],
["Anyone need help.mp3", 14000],
["Approching from SW.mp3", 10500],
["Beemer.mp3", 5000],
["Blaster.mp3", 4250],
["Coffie is ready.mp3", 2500],
["Come for you.mp3", 16250],
["Dialects and Subtongues.mp3", 9500],
["Dimonds.mp3", 7250],
["Distroied Me.mp3", 4500],
["Engen plans.mp3", 10000],
["Function again.mp3", 11500],
["Harmless.mp3", 8250],
["Help You.mp3", 5250],
["Hostial act.mp3", 11500],
["I am analyzing.mp3", 3250],
["I'm in command.mp3", 12500],
["In study.mp3", 6250],
["No Assitance.mp3", 8000],
["Nothing coming.mp3", 4000],
["Obay.mp3", 4000],
["Oil Job.mp3", 8000],
["Parlay.mp3", 137000],
["Respond to Robby.mp3", 8000],
["Seatbelts.mp3", 4000],
["Servent.mp3", 6500],
["Service Sir.mp3", 2500],
["Sleep Well.mp3", 2500],
["Slept well.mp3", 6000],
["Ten Tons.mp3", 13750],
["That is correct.mp3", 2250],
["Welcome.mp3", 17750],
["You're Expected.mp3", 4000],
]
},
];
// ------------------------------
// Shared playback and bag utilities
// ------------------------------
function numberRange(first, last) {
var ids = [];
for (var i = first; i <= last; i++) ids.push(i);
return ids;
}
// A phrase row is either one command [board, command, (file), ms]
// or a list of commands played one after the other.
function playPhraseStep(step) {
if (step.length == 3) {
controlCommand(step[0], step[1]);
sleep(step[2]);
} else {
controlCommand(step[0], step[1], step[2]);
sleep(step[3]);
}
}
function playPhraseChoice(table, id) {
var row = table[Number(id) - 1];
if (!row) return;
if (typeof row[0] == "string") {
playPhraseStep(row);
} else {
for (var i = 0; i < row.length; i++) playPhraseStep(row[i]);
}
}
function playCharacterStep(board, step) {
if (step.length == 2) {
controlCommand(board, "Play", step[0]);
sleep(step[1]);
} else {
// Only used for recordings on another soundboard (HAL chess reply).
controlCommand(step[0], "Play", step[1]);
sleep(step[2]);
}
}
function playCharacter(id, repete) {
var config = CHARACTER_AUDIO[Number(id) - 1];
if (!config) return;
var selected = getShuffleBagItem(
config.bag,
numberRange(config.first, config.first + config.clips.length - 1),
config.last
);
sleep(100);
var row = config.clips[Number(selected) - config.first];
if (row) {
if (typeof row[0] == "string") {
playCharacterStep(config.board, row);
} else {
for (var i = 0; i < row.length; i++) playCharacterStep(config.board, row[i]);
}
}
doEnd_Character(repete);
}
// ------------------------------
// Show sequence and hardware control (unchanged)
// ------------------------------
function runImpressionShow() {
beginShow();
playOpeningAcknowledgement();
// Loop the random character section 3 times
for (var repete = 0; repete < 3; repete++) {
playRandomCharacter(repete);
}
finishCharacterPhase();
stopMotorsAndLights();
playClosingPhrase();
resetArmsAndReleaseServos();
endShow();
}
// ------------------------------
// Show lifecycle helpers
// ------------------------------
function beginShow() {
setVar("$Personality", "1"); // Mark "1" so all other scripts know this script is running
setVar("$animationStatus", "1"); // ADC watcher waits for this to change to 0 when complete
controlCommand("Personality Generator", "PauseOn");
controlCommand("Weather Loop", "ScriptStop");
sleep(100);
// Start motion/lighting
Digital.set(D0, true); // Ear Motors (board 0)
PWM.set(D9, 20); // Crown Motor (board 0)
Digital.set(D10, true); // Fast Brain Lights
Digital.set(D3, true); // Fast Chest Lights
// Initial arm and waist actions
controlCommand("Left Arm", "ScriptStart", "Left Claw Closed");
controlCommand("Right Arm", "ScriptStart", "Right Claw Closed");
controlCommand("Leg Section", "ScriptStart", "Loop Random Waist 1/4 turns");
}
function finishCharacterPhase() {
controlCommand("Head Section", "ScriptStart", "Bubble Up and Down");
controlCommand("Head Section", "ScriptStart", "Radar Fast Sweep");
controlCommand("Leg Section", "ScriptStop", "Loop Random Waist 1/4 turns");
}
function stopMotorsAndLights() {
Digital.set(D0, false); // Stop Ear Motors
sleep(50);
PWM.set(D9, 0); // Stop Crown Motor
Digital.set(D3, false); // Stop Fast Chest Lights
Digital.set(D10, false); // Stop Fast Brain Lights
}
function resetArmsAndReleaseServos() {
controlCommand("Left Arm", "ScriptStart", "Left Claw Rest Open");
controlCommand("Right Arm", "ScriptStart", "Right Claw Rest Open");
controlCommand("Leg Section", "ScriptStart", "Waist Center");
sleep(2000);
// Release wrist servos on board 2
Servo.release(D4, 2); // Left Wrist Up/Down
Servo.release(D5, 2); // Left Wrist Side/Side
Servo.release(D1, 2); // Right Wrist Up/Down
Servo.release(D0, 2); // Right Wrist Side/Side
}
function endShow() {
setVar("$Personality", "0");
setVar("$animationStatus", "0");
controlCommand("Personality Generator", "PauseOff");
controlCommand("Weather Loop", "ScriptStart");
sleep(100);
}
// ------------------------------
// Opening / closing phrases
// ------------------------------
function playOpeningAcknowledgement() {
var id = getShuffleBagItem("$acknowledgeBag", numberRange(1, OPENINGS.length), "$lastAcknowledge");
sleep(100);
playPhraseChoice(OPENINGS, id);
}
function playClosingPhrase() {
var id = getShuffleBagItem("$closingBag", numberRange(1, CLOSINGS.length), "$lastClosing");
sleep(100);
playPhraseChoice(CLOSINGS, id);
}
// ------------------------------
// Character introduction router (unchanged except dialogue calls)
// ------------------------------
function playRandomCharacter(repete) {
var response = getShuffleBagItem(
"$characterBag",
[1,2,3,4,5,6,7,8,9,10,11,12,13,14],
"$lastCharacter"
);
if (response == 1) {
var response_Dr_Smith = getShuffleBagItem("$drSmithMetaBag", [1,2], "$lastDrSmithMeta");
if (response_Dr_Smith == 1) {
controlCommand("Dr_Smith", "Track_0"); // Say Dr Smith
sleep(2000);
} else if (response_Dr_Smith == 2) {
controlCommand("Soundboard v4", "Track_96"); // Say "Jonathan Harris"
sleep(2000);
}
playCharacter(response, repete);
} else if (response == 2) {
controlCommand("R2D2", "Track_0"); // Say "R2D2"
sleep(2000);
playCharacter(response, repete);
} else if (response == 3) {
var response_Will = getShuffleBagItem("$willMetaBag", [1,2], "$lastWillMeta");
if (response_Will == 1) {
controlCommand("Will", "Track_0"); // Say "Will Robinson"
sleep(2000);
} else if (response_Will == 2) {
controlCommand("Soundboard v4", "Track_95"); // Say "Billy Mumy"
sleep(2000);
}
playCharacter(response, repete);
} else if (response == 4) {
var response_Don = getShuffleBagItem("$donMetaBag", [1,2], "$lastDonMeta");
if (response_Don == 1) {
controlCommand("Don", "Track_0"); // Say "Major West"
sleep(2000);
} else if (response_Don == 2) {
controlCommand("Soundboard v4", "Track_94"); // Say "Mark Goddard"
sleep(2000);
}
playCharacter(response, repete);
} else if (response == 5) {
controlCommand("Maureen", "Track_0"); // Say "June Lockhart"
sleep(2000);
playCharacter(response, repete);
} else if (response == 6) {
controlCommand("John", "Track_0"); // Say "Guy Williams"
sleep(2000);
playCharacter(response, repete);
} else if (response == 7) {
controlCommand("Tufeld", "Track_0"); // Say "Richard Tufeld"
sleep(2000);
playCharacter(response, repete);
} else if (response == 8) {
var response_Judy = getShuffleBagItem("$judyMetaBag", [1,2,3], "$lastJudyMeta");
controlCommand("Judy", "Track_0");
sleep(2000);
if (response_Judy == 1) {
controlCommand("Soundboard v4", "Track_93"); // Say "I liked Judy"
sleep(1700);
} else if (response_Judy == 2) {
controlCommand("Soundboard v4", "Track_97"); // Say "Judy Robinson is a babe"
sleep(4750);
} else if (response_Judy == 3) {
controlCommand("Soundboard v4", "Track_98"); // Say "Judy would socialize with me"
sleep(9250);
}
playCharacter(response, repete);
} else if (response == 9) {
controlCommand("Wall_e", "Track_0"); // Say "WallE"
sleep(2000);
playCharacter(response, repete);
} else if (response == 10) {
var response_Penny = getShuffleBagItem("$pennyMetaBag", [1,2], "$lastPennyMeta");
if (response_Penny == 1) {
controlCommand("Penny", "Track_0"); // Say "Angela Cartwright"
sleep(2000);
} else if (response_Penny == 2) {
controlCommand("Penny", "Track_1"); // Say "Penny"
sleep(2000);
}
playCharacter(response, repete);
} else if (response == 11) {
var response_Hal9000 = getShuffleBagItem("$halMetaBag", [1,2], "$lastHalMeta");
if (response_Hal9000 == 1) {
controlCommand("Hal9000", "Track_0"); // Say "I am Hal9000"
sleep(6000);
} else if (response_Hal9000 == 2) {
controlCommand("Hal9000", "Track_24"); // Say "Good Morning Dave"
sleep(3250);
}
playCharacter(response, repete);
} else if (response == 12) {
var response_Bender = getShuffleBagItem("$benderMetaBag", [1,2], "$lastBenderMeta");
if (response_Bender == 1) {
controlCommand("Bender", "Track_0"); // Say "I am Bender"
sleep(3000);
} else if (response_Bender == 2) {
controlCommand("Bender", "Track_42"); // Sing the "Bender Song"
sleep(8000);
}
playCharacter(response, repete);
} else if (response == 13) {
controlCommand("Robby", "Track_0"); // Say "Robby the Robot"
sleep(3000);
playCharacter(response, repete);
} else if (response == 14) {
doThadious(repete);
}
}
// ------------------------------
// Between-character movement and phrase
// ------------------------------
function doEnd_Character(repete) {
// Arm/head animation dependent on loop pass
if (repete == 0) {
controlCommand("Left Arm", "ScriptStart", "Left Claw Open");
controlCommand("Right Arm", "ScriptStart", "Right Claw Open");
controlCommand("Head Section", "ScriptStart", "Happy, Sad Bubble");
controlCommand("Head Section", "ScriptStart", "Radar Fast Sweep");
} else if (repete == 1) {
controlCommand("Head Section", "ScriptStart", "Radar Fast Sweep");
controlCommand("Left Arm", "ScriptStart", "Left Claw Closed");
controlCommand("Right Arm", "ScriptStart", "Right Claw Closed");
}
// Only play interstitial between 1st->2nd and 2nd->3rd runs
if (repete < 2) {
var id = getShuffleBagItem(
"$interstitialBag", numberRange(1, INTERSTITIALS.length), "$lastInterstitial"
);
sleep(100);
playPhraseChoice(INTERSTITIALS, id);
}
}
// ------------------------------
// Special one-shot character (original behavior)
// ------------------------------
function doThadious(repete) {
controlCommand("SFX", "Track_1"); // Play Uncle Thadious sound effect.
sleep(14000);
doEnd_Character(repete);
}
// Start only AFTER all tables have been defined.
runImpressionShow();
