diff --git a/Krypton b/Krypton index 8daa576..bdf56fd 160000 --- a/Krypton +++ b/Krypton @@ -1 +1 @@ -Subproject commit 8daa57641b5bf07b021df80f4c021a2bcea695a8 +Subproject commit bdf56fdcd3794550804594ef972e4e851a02ff9d diff --git a/config.lua b/config.lua index 90970ec..de7a64b 100644 --- a/config.lua +++ b/config.lua @@ -120,6 +120,8 @@ modem = nil, -- Modem for inventories, if not specified, will use the first wired modem found speaker = nil, -- Speaker to play sounds on, if not specified, will use the first speaker found shopSyncModem = nil, -- Modem for ShopSync, if not specified, will use the first wireless modem found + blinker = nil, -- Side that a redstone lamp or other redstone device is on + -- Will be toggled on and off every 3 seconds to indicate that the shop is online exchangeChest = nil, outputChest = "self", -- Chest peripheral or self -- NOTE: Chest dropping is NYI in plethora 1.19, so do not use unless @@ -129,7 +131,8 @@ start = nil, -- function(version, config, products) purchase = nil, -- function(product, amount, refundAmount, transaction, transactionCurrency) failedPurchase = nil, -- function(transaction, transactionCurrency, product, errorMessage) - programError = nil -- function(err) + programError = nil, -- function(err) + blink = nil, -- function(blinkState) called every 3 seconds while shop is running }, exchange = { -- Not yet implemented diff --git a/core/ConfigValidator.lua b/core/ConfigValidator.lua index f7915e4..0054730 100644 --- a/core/ConfigValidator.lua +++ b/core/ConfigValidator.lua @@ -105,6 +105,7 @@ speaker = "speaker?", modem = "modem?", shopSyncModem = "modem?", + blinker = "enum<'left' | 'right' | 'front' | 'back' | 'top' | 'bottom'>?: side", exchangeChest = "chest?", outputChest = "chest", }, @@ -113,6 +114,7 @@ purchase = "function?", failedPurchase = "function?", programError = "function?", + blink = "function?", }, shopSync = { enabled = "boolean?", diff --git a/core/ShopState.lua b/core/ShopState.lua index 2713df0..80962ff 100644 --- a/core/ShopState.lua +++ b/core/ShopState.lua @@ -4,6 +4,7 @@ local sound = require("util.sound") local eventHook = require("util.eventHook") +local blinkFrequency = 3 local shopSyncFrequency = 30 local shopSyncChannel = 9773 @@ -256,6 +257,18 @@ sleep(math.min(1, state.config.settings.categoryCycleFrequency)) end end, function() + local blinkState = false + while state.running do + blinkState = not blinkState + if state.config.peripherals.blinker then + redstone.setOutput(state.config.peripherals.blinker, blinkState) + end + if state.config.hooks and state.config.hooks.blink then + eventHook.execute(state.config.hooks.blink, blinkState) + end + sleep(blinkFrequency) + end + end, function() while state.running do sleep(shopSyncFrequency) if state.config.shopSync and state.config.shopSync.enabled and state.shopSyncModem then diff --git a/radon.lua b/radon.lua index 8e49bba..2df55be 100644 --- a/radon.lua +++ b/radon.lua @@ -1,7 +1,7 @@ local oldPullEvent = os.pullEvent os.pullEvent = os.pullEventRaw -local version = "1.1.9" +local version = "1.1.10" --- Imports local _ = require("util.score")