// An ARRAY is a list of items.
// This array is a list of your friends' names.
var friendNames = ["Joan", "Ronan", "Nikita", "Augustus"];
// Array indices start at 0, not 1!
var friendIndex = 0;
// Loop over each name in the array.
// The .length property gets the length of the array.
while (friendIndex < friendNames.length) {
// Use square brackets to get a name from the array.
var friendName = friendNames[friendIndex];
// Tell your friend to go home.
// Use + to connect two strings./*
Steps for using:
1. Go to the level editor for the level.
2. Double click the Hero Placeholder to edit it.
3. Run the level so you have the child window open.
4. Make sure the equipment you have equipped matches the hero's equipment for for the course.
5. Copy paste the solution code from the level editor into level, press run/submit. (Just want all the frames to load and ensure it succeeds)
6. Put this script into the console of the level-editor tab/window
Now everything (seed, equipment, frames, hash) should be added to the solutions.
*/
(function () {
var currentView = globalVar.currentView;
if(!currentView.subviews.thangs_tab_view.editThangView) throw "No thang selected, double click the hero placeholder."
var thangData = currentView.subviews.thangs_tab_view.editThangView.thangData
var oldPath = currentView.subviews.thangs_tab_view.editThangView.oldPath
var pComp = _.findWhere(thangData.components, function (elem) {return elem.config && elem.config.programmableMethods}).config.programmableMethods.plan
var solutionArray = pComp.solutions;
var solutions = {
"python":{},
"javascript":{}
//"lua":{},
//"coffeescript":{}
};
for(var i = 0; i < solutionArray.length; i++) {
solutions[solutionArray[i].language].solution = solutionArray[i];
solutions[solutionArray[i].language].index = i;
}
for(var key in solutions) {
var solution = solutions[key].solution;
console.log(solution);
if(!solution) {
solution = {};
}
var index = solutions[key].index;
if(!solution.source) {
if(key == "javascript") {
solution.source = "TODO WRITE SOLUTION: \n" + pComp.source;
} else {
solution.source = "TODO WRITE SOLUTION: \n" + pComp.languages[key];
}
}
solution.language = key;
solution.succeeds = true;
if(solution.passes) {
delete solution.passes
}
var childWindow = currentView.childWindow.globalVar;
if(!childWindow) throw "No child window, press run.";
var dif = childWindow.currentView.session.get('state').difficulty;
if(dif) {
solution.difficulty = childWindow.currentView.session.get('state').difficulty;
}
solution.seed = childWindow.currentView.world.randomSeed;
var tInv = _.findWhere(currentView.subviews.thangs_tab_view.editThangView.thangData.components, function(elem) {return elem.config && elem.config.inventory})
if(tInv) {
tInv = tInv.config.inventory;
solution.heroConfig = {
inventory: tInv,
thangType: currentView.subviews.thangs_tab_view.editThangView.thangData.thangType
}
} else {
console.warn("No recommended inventory found, using the child window's equipped gear.")
solution.heroConfig = childWindow.currentView.session.get('heroConfig');
}
var hist = childWindow.currentView.session.get('state').flagHistory;
if(hist && hist.length > 0) {
solution.flagHistory = hist;
}
if(childWindow.currentView.world.frames.length >= 2) {
solution.lastHash = childWindow.currentView.world.frames[childWindow.currentView.world.frames.length - 2].hash;
}
solution.frameCount = childWindow.currentView.world.frames.length;
var goals = {};
for(var i = 0; i < childWindow.currentView.goalManager.goals.length; i++) {
goal = childWindow.currentView.goalManager.goals[i];
goals[goal.id] = childWindow.currentView.goalManager.getGoalState(goal.id);
}
solution.goals = goals;
if(index !== undefined && index !== null) {
pComp.solutions[index] = solution;
} else {
pComp.solutions.push(solution);
}
}
Backbone.Mediator.publish('editor:level-thang-edited', {thangData: $.extend(true, {}, thangData), oldPath: oldPath})
currentView.subviews.thangs_tab_view.editThangView.render()
})();
hero.say(friendName + ", go home!");
// Increment friendIndex to get the next name.
friendIndex += 1;
}
// Retreat to the oasis and build a "fence" on the X.
I just checked the level out, and i saw the same thing. I cleared out the junk and there is the starter code. Copy paste it instead of what you have then fill in the stuff required under the comments. @Haris
// An ARRAY is a list of items.
// This array is a list of your friends' names.
var friendNames = ["Joan", "Ronan", "Nikita", "Augustus"];
// Array indices start at 0, not 1!
var friendIndex = 0;
// Loop over each name in the array.
// The .length property gets the length of the array.
while (friendIndex < friendNames.length) {
// Use square brackets to get a name from the array.
var friendName = friendNames[friendIndex];
// Tell your friend to go home.
// Use + to connect two strings./*
hero.say(friendName + ", go home!");
// Increment friendIndex to get the next name.
}
// Retreat to the oasis and build a "fence" on the X.
PS: that is the part that is weird, you can delete it
Steps for using:
1. Go to the level editor for the level.
2. Double click the Hero Placeholder to edit it.
3. Run the level so you have the child window open.
4. Make sure the equipment you have equipped matches the hero's equipment for for the course.
5. Copy paste the solution code from the level editor into level, press run/submit. (Just want all the frames to load and ensure it succeeds)
6. Put this script into the console of the level-editor tab/window
Now everything (seed, equipment, frames, hash) should be added to the solutions.
*/
(function () {
var currentView = globalVar.currentView;
if(!currentView.subviews.thangs_tab_view.editThangView) throw "No thang selected, double click the hero placeholder."
var thangData = currentView.subviews.thangs_tab_view.editThangView.thangData
var oldPath = currentView.subviews.thangs_tab_view.editThangView.oldPath
var pComp = _.findWhere(thangData.components, function (elem) {return elem.config && elem.config.programmableMethods}).config.programmableMethods.plan
var solutionArray = pComp.solutions;
var solutions = {
"python":{},
"javascript":{}
//"lua":{},
//"coffeescript":{}
};
for(var i = 0; i < solutionArray.length; i++) {
solutions[solutionArray[i].language].solution = solutionArray[i];
solutions[solutionArray[i].language].index = i;
}
for(var key in solutions) {
var solution = solutions[key].solution;
console.log(solution);
if(!solution) {
solution = {};
}
var index = solutions[key].index;
if(!solution.source) {
if(key == "javascript") {
solution.source = "TODO WRITE SOLUTION: \n" + pComp.source;
} else {
solution.source = "TODO WRITE SOLUTION: \n" + pComp.languages[key];
}
}
solution.language = key;
solution.succeeds = true;
if(solution.passes) {
delete solution.passes
}
var childWindow = currentView.childWindow.globalVar;
if(!childWindow) throw "No child window, press run.";
var dif = childWindow.currentView.session.get('state').difficulty;
if(dif) {
solution.difficulty = childWindow.currentView.session.get('state').difficulty;
}
solution.seed = childWindow.currentView.world.randomSeed;
var tInv = _.findWhere(currentView.subviews.thangs_tab_view.editThangView.thangData.components, function(elem) {return elem.config && elem.config.inventory})
if(tInv) {
tInv = tInv.config.inventory;
solution.heroConfig = {
inventory: tInv,
thangType: currentView.subviews.thangs_tab_view.editThangView.thangData.thangType
}
} else {
console.warn("No recommended inventory found, using the child window's equipped gear.")
solution.heroConfig = childWindow.currentView.session.get('heroConfig');
}
var hist = childWindow.currentView.session.get('state').flagHistory;
if(hist && hist.length > 0) {
solution.flagHistory = hist;
}
if(childWindow.currentView.world.frames.length >= 2) {
solution.lastHash = childWindow.currentView.world.frames[childWindow.currentView.world.frames.length - 2].hash;
}
solution.frameCount = childWindow.currentView.world.frames.length;
var goals = {};
for(var i = 0; i < childWindow.currentView.goalManager.goals.length; i++) {
goal = childWindow.currentView.goalManager.goals[i];
goals[goal.id] = childWindow.currentView.goalManager.getGoalState(goal.id);
}
solution.goals = goals;
if(index !== undefined && index !== null) {
pComp.solutions[index] = solution;
} else {
pComp.solutions.push(solution);
}
}
Backbone.Mediator.publish('editor:level-thang-edited', {thangData: $.extend(true, {}, thangData), oldPath: oldPath})
currentView.subviews.thangs_tab_view.editThangView.render()
})();
@Chaboi_3000 can you see the source of the problem, so that other players won’t face the same thing