Here’s the whole code, spoiled the whole mod, but I’ll try to make it work;
var answers = [answer1, answer2, answer3, answer4, answer5, answer6, answer7, answer8, answer9, answer0]
var number = Math.random()
//Picker
picker = function () {
switch (number) {
case 'answer1':
if (number <= 0.1) {
answers[0]
}
break;
case 'answer2':
if (number <= 0.2) {
answers[1]
}
break;
case 'answer3':
if (number <= 0.3) {
answers[2]
}
break;
case 'answer4':
if (number <= 0.4) {
answers[3]
}
break;
case 'answer5':
if (number <= 0.5) {
answers[4]
}
break;
case 'answer6':
if (number <= 0.6) {
answers[5]
}
break;
case 'answer7':
if (number <= 0.7) {
answers[6]
}
break;
case 'answer8':
if (number <= 0.8) {
answers[7]
}
break;
case 'answer9':
if (number <= 0.9) {
answers[8]
}
break;
case 'answer0':
if (number <= 0.999999999999999) {
answers[9]
}
break;
}
}
//Notifications
var header = "Magic 8 Ball".localize("heading")
var answer1 = {
id : "mb_a1",
getNotification: function() {
return new Notification({
header: header,
text: "I say that you shouldn't do such a thing. Not worth it. Think of something else.".localize(), //negative
image: magicBall_FireChaos.modPath + '/images/notifications/ballNegative.png'
});
}
}
var answer2 = {
id : "mb_a2",
getNotification: function() {
return new Notification({
header: header,
text: "Hmmm, what if you rethink that idea more. It sounds good, but it needs more thinking.".localize(), //maybe
image: magicBall_FireChaos.modPath + '/images/notifications/ballMaybe.png'
});
}
}
var answer3 = {
id : "mb_a3",
getNotification: function() {
return new Notification({
header: header,
text: "No way! A bad idea, don't do it. If you do, it will have a bad affection to your company.".localize(), //negative
image: magicBall_FireChaos.modPath + '/images/notifications/ballNegative.png'
});
}
}
var answer4 = {
id : "mb_a4",
getNotification: function() {
return new Notification({
header: header,
text: "The best idea you've ever had! I'm training you so well! Do it. I'll give you a cookie after".localize(), //positive
image: magicBall_FireChaos.modPath + '/images/notifications/ballPositive.png'
});
}
}
var answer5 = {
id : "mb_a5",
getNotification: function() {
return new Notification({
header: header,
text: "Do it. Seems an okay idea to me. What can go wrong! Start doing it right now.".localize(), //positive
image: magicBall_FireChaos.modPath + '/images/notifications/ballPositive.png'
});
}
}
var answer6 = {
id : "mb_a6",
getNotification: function() {
return new Notification({
header: header,
text: "Look, I'm not sure about this idea. It's complicated boss. I wonder what goes wrong...".localize(), //maybe
image: magicBall_FireChaos.modPath + '/images/notifications/ballMaybe.png'
});
}
}
var answer7 = {
id : "mb_a7",
getNotification: function() {
return new Notification({
header: header,
text: "Just no. That's just bad. Nope, nope, nope. Skip this idea now. Do something else instead.".localize(), // negative
image: magicBall_FireChaos.modPath + '/images/notifications/ballNegative.png'
});
}
}
var answer8 = {
id : "mb_a8",
getNotification: function() {
return new Notification({
header: header,
text: "Definitely. Do what you're thinking. I've taught you well. Just don't end up doing it wrong.".localize(), //positive
image: magicBall_FireChaos.modPath + '/images/notifications/ballPositive.png'
});
}
}
var answer9 = {
id : "mb_a9",
getNotification: function() {
return new Notification({
header: header,
text: "I'm confused. You better recall me again later. Your ideas can be sometimes confusing.".localize(), //maybe
image: magicBall_FireChaos.modPath + '/images/notifications/ballMaybe.png'
});
}
}
var answer0 = {
id : "mb_a0",
getNotification: function() {
return new Notification({
header: header,
text: "Yeah. Whatever. Choose yourself this time. I'm bored of you. I'd better go and get an upgrade this time.".localize(), //maybe
image: magicBall_FireChaos.modPath + '/images/notifications/ballMaybe.png'
});
}
}
//Event adders:
GDT.addEvent(answer0)
GDT.addEvent(answer1)
GDT.addEvent(answer2)
GDT.addEvent(answer3)
GDT.addEvent(answer4)
GDT.addEvent(answer5)
GDT.addEvent(answer6)
GDT.addEvent(answer7)
GDT.addEvent(answer8)
GDT.addEvent(answer9)
//Menu item
var menu = UI._showContextMenu;
var showMenu = function(type, menuItems, x, y) {
menuItems.push({
label: "Magic 8 Ball".localize("menu item"),
action: function() {
Sound.click();
createWindow();
GameManager.resume(true);
var div = $("#magicBall");
div.scrollTop();
div.gdDialog({
popout: !0,
close: !0
});
}
})
menu(type, menuItems, x, y);
}
UI._showContextMenu = showMenu;
//Button Effect
UI.magicBall = function(company) {
Sound.click();
switch (company.id) {
case "magicButton":
picker();
break;
default:
return;
}
}
createWindow = function() {
//Main Window - Uses HTML
var div = $("body");
div.append('<div id="magicBall" class="windowBorder tallWindow" style="overflow:auto;display:none;"> <div id="magicBallDivTitle" class="windowTitle smallerWindowTitle">Magic 8 Ball</div><p>Think a question, and click the "Shake Me" button. I hope you are being as descriptive as you can</div>');
div = $("#magicBall");
//Buttons
div.append('<div id="magicButton" class="selectorButton orangeButton" centeredButtonWrapper onclick="UI.magicBall(this)" style="margin-left:50px;width: 250px">Shake Me</div>');
}