3/14/25, 11:10 AM [Link].
io/codePrint/
//list that contains images of each tower
var towerList = getColumn("BloonsTowers", "towerName");
var towerDPS = getColumn("BloonsTowers", "dps");
var towerPrices = getColumn("BloonsTowers", "price");
var towerRoles = getColumn("BloonsTowers", "role");
var imageList = ["[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
"[Link]
];
var dpsChoice = "";
var priceChoice = "";
var roleChoice = "";
//onEvents for the dropdown menus to function
onEvent("damageDropdown", "change", function() {
dpsChoice = getText("damageDropdown");
});
[Link] 1/2
3/14/25, 11:10 AM [Link]/codePrint/
54 onEvent("priceDropdown", "change", function() {
55 priceChoice = getText("priceDropdown");
56
57 });
58
59 onEvent("roleDropdown", "change", function() {
60 roleChoice = getText("roleDropdown");
61
62 });
63
64 /*function: filters items in a list based on the parameters determined
65 by user input
66
67 purpose: filters towers based on user selected dps, price, and role, then
68 displays a randomly chose matching towers name and image. it iterates through
69 lists checking for mathces and storing them in arrays, if matches exist,
70 it updates the UI, otherwise it displays an error message
71
72 */
73 function filterTower(dpsChoice, priceChoice, roleChoice) {
74
75 var filteredTowers = [];
76 var filteredImages = [];
77
78 for (var i = 0; i < [Link]; i++) {
79 if (towerDPS[i] === dpsChoice && towerPrices[i] === priceChoice && towerRoles[i] === roleC
80 appendItem(filteredTowers, towerList[i]);
81 appendItem(filteredImages, imageList[i]);
82 }
83
84 }
85
86 if ([Link] > 0) {
87 var randomIndex = randomNumber(0, [Link] - 1);
88 setProperty("towerImage1", "image", filteredImages[randomIndex]);
89 setProperty("bestTowerLabel", "text", filteredTowers[randomIndex]);
90 } else {
91 [Link]("No towers match the criteria.");
92 setProperty("bestTowerLabel", "text", "No towers match the criteria");
93 setProperty("towerImage1", "image", "icon://fa-exclamation");
94 }
95
96 }
97
98 //onEvent to apply the function when the user clicks the generate button
99
100 onEvent("generateButton", "click", function() {
101 filterTower(dpsChoice, priceChoice, roleChoice);
102 });
103
104 //Citations:
105 //Images: [Link]
106 //I made my own dataset by manually adding information from the link above
PDF document made with CodePrint using Prism
[Link] 2/2