From b6bc8beb2155deceb925cbe50f66dff57f732b3d Mon Sep 17 00:00:00 2001 From: Harley White Date: Wed, 2 Jun 2021 16:45:05 -0400 Subject: [PATCH] Improved milestone completion + docs --- changelog.md | 2 ++ docs/!general-info.md | 4 ++-- docs/milestones.md | 4 +++- js/technical/temp.js | 2 +- js/utils.js | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 3abc690..b6506e5 100644 --- a/changelog.md +++ b/changelog.md @@ -3,7 +3,9 @@ - Fixed demo.html - You can now use "this" in tabFormat! - The prestige/sec display now shows decimals. +- Added onComplete for milestones. - Fixed certain things skipping negative rows (now they are treated like non-numeric rows, and don't appear in the tree still). +- Things are 0.2% more optimized. ### v2.5.11.1 - 5/27/21 - Fixed issues caused when the tree tab is disabled. diff --git a/docs/!general-info.md b/docs/!general-info.md index 7fbffef..f172a4d 100644 --- a/docs/!general-info.md +++ b/docs/!general-info.md @@ -28,8 +28,8 @@ While reading this documentation, the following key will be used when describing ### General -- [Getting Started](tutorial/getting-started.md): A guide to getting your own copy of the code set up with Github Desktop. -- [Making a Mod](tutorial/making-a-mod.md): A guide to using TMT to make a basic mod. +- [Getting Started](tutorials/getting-started.md): A guide to getting your own copy of the code set up with Github Desktop. +- [Making a Mod](tutorials/making-a-mod.md): A guide to using TMT to make a basic mod. - [Main mod info](main-mod-info.md): How to set up general things for your mod in [mod.js](/js/mod.js). - [Basic layer breakdown](basic-layer-breakdown.md): Breaking down the components of a layer with minimal features. - [Layer features](layer-features.md): Explanations of all of the different properties that you can give a layer. diff --git a/docs/milestones.md b/docs/milestones.md index f15add6..924a978 100644 --- a/docs/milestones.md +++ b/docs/milestones.md @@ -23,6 +23,8 @@ Milestone features: - done(): A function returning a boolean to determine if the milestone should be awarded. +- onComplete() - **optional**. this function will be called when the milestone is completed. + - toggles: **optional**. Creates toggle buttons that appear on the milestone when it is unlocked. The toggles can toggle a given boolean value in a layer. It is defined as an array of paired items, one pair per toggle. The first is the internal name of the layer the value being toggled is stored in, and the second is the internal name of the variable to toggle. (e.g. [["b", "auto"], ["g", "auto"]) **Tip:** Toggles are not de-set if the milestone becomes locked! In this case, you should also check if the player has the milestone. @@ -35,4 +37,4 @@ Milestone features: - id: **assigned automagically**. It's the "key" which the milestone was stored under, for convenient access. The milestone in the example's id is 0. -Disaable milestone popups by adding `milestonePopups: false` to the layer. +Disable milestone popups by adding `milestonePopups: false` to the layer. diff --git a/js/technical/temp.js b/js/technical/temp.js index 074fdee..ed2d4b0 100644 --- a/js/technical/temp.js +++ b/js/technical/temp.js @@ -10,7 +10,7 @@ var activeFunctions = [ "sellOne", "sellAll", "pay", "actualCostFunction", "actualEffectFunction", "effectDescription", "display", "fullDisplay", "effectDisplay", "rewardDisplay", "tabFormat", "content", - "onComplete", "onPurchase", "onEnter", "onExit", + "onComplete", "onPurchase", "onEnter", "onExit", "done", "getUnlocked", "getStyle", "getCanClick", "getTitle", "getDisplay" ] diff --git a/js/utils.js b/js/utils.js index 0bcfe46..9a348c3 100644 --- a/js/utils.js +++ b/js/utils.js @@ -261,6 +261,7 @@ function updateMilestones(layer) { for (id in layers[layer].milestones) { if (!(hasMilestone(layer, id)) && layers[layer].milestones[id].done()) { player[layer].milestones.push(id) + if (layers[layer].milestones[id].onComplete) layers[layer].milestones[id].onComplete() if (tmp[layer].milestonePopups || tmp[layer].milestonePopups === undefined) doPopup("milestone", tmp[layer].milestones[id].requirementDescription, "Milestone Gotten!", 3, tmp[layer].color); player[layer].lastMilestone = id }