diff --git a/changelog.md b/changelog.md index 9317d70..6df0687 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,7 @@ # The Modding Tree changelog: - Fixed demo.html +- You can now use "this" in tabFormat! - Fixed certain things skipping negative rows (now they are treated like non-numeric rows, and don't appear in the tree still). ### v2.5.11.1 - 5/27/21 diff --git a/docs/!general-info.md b/docs/!general-info.md index 30afb72..7fbffef 100644 --- a/docs/!general-info.md +++ b/docs/!general-info.md @@ -52,7 +52,7 @@ While reading this documentation, the following key will be used when describing - [Bars](bars.md): Display some information as a progress bar, gauge, or similar. They are highly customizable, and can be horizontal and vertical as well. - [Subtabs and Microtabs](subtabs-and-microtabs.md): Create subtabs for your tabs, as well as "microtab" components that you can put inside the tabs. You can even use them to embed a layer inside another layer! -- [Grids][grids.md]: Create a group buttons that behave the same, but have their own data. Good for map tiles, an inventory grid, and more! +- [Grids](grids.md): Create a group buttons that behave the same, but have their own data. Good for map tiles, an inventory grid, and more! - [Infoboxes](infoboxes.md): Boxes containing text that can be shown or hidden. - [Trees](trees-and-tree-customization.md): Make your own trees. You can make non-layer button nodes too! - [Particle system](particles.md): Can be used to create particles for visual effects, but also interactable things like golden cookies or collectables. diff --git a/js/Demo/demoLayers.js b/js/Demo/demoLayers.js index a5aafd1..0e4fdf0 100644 --- a/js/Demo/demoLayers.js +++ b/js/Demo/demoLayers.js @@ -304,7 +304,7 @@ addLayer("c", { ["display-text", "Name your points!"], ["text-input", "thingy"], ["display-text", - function() {return 'I have ' + format(player.points) + ' ' + player.c.thingy + ' points!'}, + function() {return 'I have ' + format(player.points) + ' ' + player[this.layer].thingy + ' points!'}, {"color": "red", "font-size": "32px", "font-family": "Comic Sans MS"}], "h-line", "milestones", "blank", "upgrades", "challenges"], glowColor: "blue", diff --git a/js/components.js b/js/components.js index 1652046..41f2687 100644 --- a/js/components.js +++ b/js/components.js @@ -306,9 +306,9 @@ function loadVue() { Vue.component('respec-button', { props: ['layer', 'data'], template: ` -
+
- +
` }) diff --git a/js/technical/displays.js b/js/technical/displays.js index 9fefff8..48d07df 100644 --- a/js/technical/displays.js +++ b/js/technical/displays.js @@ -147,9 +147,9 @@ function constructTabFormat(layer, id, family){ } if (isFunction(tabLayer)) { - return tabLayer() + return tabLayer.bind(location)() } - updateTempData(tabLayer, tabTemp, tabFunc) + updateTempData(tabLayer, tabTemp, tabFunc, {layer, id, family}) return tabTemp } diff --git a/js/technical/temp.js b/js/technical/temp.js index 36a569f..074fdee 100644 --- a/js/technical/temp.js +++ b/js/technical/temp.js @@ -109,18 +109,20 @@ function updateTemp() { } } -function updateTempData(layerData, tmpData, funcsData) { - +function updateTempData(layerData, tmpData, funcsData, useThis) { for (item in funcsData){ if (Array.isArray(layerData[item])) { if (item !== "tabFormat" && item !== "content") // These are only updated when needed - updateTempData(layerData[item], tmpData[item], funcsData[item]) + updateTempData(layerData[item], tmpData[item], funcsData[item], useThis) } else if ((!!layerData[item]) && (layerData[item].constructor === Object) || (typeof layerData[item] === "object") && traversableClasses.includes(layerData[item].constructor.name)){ - updateTempData(layerData[item], tmpData[item], funcsData[item]) + updateTempData(layerData[item], tmpData[item], funcsData[item], useThis) } else if (isFunction(layerData[item]) && !isFunction(tmpData[item])){ - let value = layerData[item]() + let value + + if (useThis !== undefined) value = layerData[item].bind(useThis)() + else value = layerData[item]() if (value !== value || value === decimalNaN){ if (NaNalert === true || confirm ("Invalid value found in tmp, named '" + item + "'. Please let the creator of this mod know! Would you like to try to auto-fix the save and keep going?")){ NaNalert = true