diff --git a/DefaultLayout.lua b/DefaultLayout.lua index 40d1b84..e46ee89 100644 --- a/DefaultLayout.lua +++ b/DefaultLayout.lua @@ -139,7 +139,7 @@ local shopProducts = {} if categories[selectedCategory] then catName = categories[selectedCategory].name - shopProducts = renderHelpers.getDisplayedProducts(categories[selectedCategory].products, props.configState.config.settings) + shopProducts = renderHelpers.getDisplayedProducts(categories[selectedCategory].products, props.configState.config.settings, props.shopState.selectedCurrency) end local productsHeight = display.bgCanvas.height - headerHeight - footerHeight - 2 local heightPerProduct = math.floor(productsHeight / #shopProducts) diff --git a/config.lua b/config.lua index 1d9c557..0fd79d3 100644 --- a/config.lua +++ b/config.lua @@ -5,6 +5,7 @@ }, settings = { hideUnavailableProducts = false, + hideNegativePrices = true, pollFrequency = 30, categoryCycleFrequency = -1, activityTimeout = 60, diff --git a/configDefaults.lua b/configDefaults.lua index 4606ede..36c0e69 100644 --- a/configDefaults.lua +++ b/configDefaults.lua @@ -4,6 +4,7 @@ }, settings = { hideUnavailableProducts = false, + hideNegativePrices = true, pollFrequency = 30, categoryCycleFrequency = -1, activityTimeout = 60, diff --git a/core/ShopState.lua b/core/ShopState.lua index e885412..2524084 100644 --- a/core/ShopState.lua +++ b/core/ShopState.lua @@ -438,7 +438,7 @@ local prices = {} local nbt = nil local predicates = nil - if not product.bundle and not product.hidden then + if not product.bundle and not product.hidden and product.modid then if product.predicates then nbt = nil -- TODO: Can we get an nbt hash? predicates = product.predicates @@ -456,12 +456,25 @@ else requiredMeta = product.address end - table.insert(prices, { - value = product.price / currency.value, - currency = currencyName, - address = address, - requiredMeta = requiredMeta - }) + + local price = product.price / currency.value + + if product.priceOverrides then + for _, override in pairs(product.priceOverrides) do + if override.currency == currency.id then + price = override.price + end + end + end + + if price >= 0 then + table.insert(prices, { + value = price, + currency = currencyName, + address = address, + requiredMeta = requiredMeta + }) + end end table.insert(items, { prices = prices, diff --git a/core/schemas.lua b/core/schemas.lua index 5a44e1e..7234b06 100644 --- a/core/schemas.lua +++ b/core/schemas.lua @@ -6,6 +6,7 @@ }, settings = { hideUnavailableProducts = "boolean", + hideNegativePrices = "boolean", pollFrequency = "number", categoryCycleFrequency = "number", activityTimeout = "number", diff --git a/radon.lua b/radon.lua index e855481..3982b13 100644 --- a/radon.lua +++ b/radon.lua @@ -1,4 +1,4 @@ -local version = "1.3.30" +local version = "1.3.31" local configHelpers = require "util.configHelpers" local schemas = require "core.schemas" local ScanInventory = require("core.inventory.ScanInventory") diff --git a/util/renderHelpers.lua b/util/renderHelpers.lua index 2a3798d..2c85306 100644 --- a/util/renderHelpers.lua +++ b/util/renderHelpers.lua @@ -1,12 +1,17 @@ local bigFont = require("fonts.bigfont") local smolFont = require("fonts.smolfont") +local Pricing = require("core.Pricing") -local function getDisplayedProducts(allProducts, settings) +local function getDisplayedProducts(allProducts, settings, currency) local displayedProducts = {} for i = 1, #allProducts do local product = allProducts[i] product.id = i - if not settings.hideUnavailableProducts or (product.quantity and product.quantity > 0) then + local productPrice = Pricing.getProductPrice(product, currency) + if + (not settings.hideUnavailableProducts or (product.quantity and product.quantity > 0)) + and (not settings.hideNegativePrices or (productPrice and productPrice >= 0)) + then table.insert(displayedProducts, product) end end