From 38c239a77b7d9c12678ee572fa7f90bfc2631c08 Mon Sep 17 00:00:00 2001 From: sfokin Date: Sun, 6 Apr 2025 06:15:09 +0300 Subject: [PATCH] don't add values if they already exists --- fabric_order_controller.lua | 151 +++++++++++++++++++----------------- 1 file changed, 81 insertions(+), 70 deletions(-) diff --git a/fabric_order_controller.lua b/fabric_order_controller.lua index 8ce388e..b600f84 100644 --- a/fabric_order_controller.lua +++ b/fabric_order_controller.lua @@ -1,55 +1,58 @@ local function createui() -if mem.controls then return end - -mem.controls = { +--if mem.controls then return end +mem.controls = { { command = "clear" }, { - command = "adddropdown", - Y = 1.2, - label = "Drawer Controller", - selected_id = 1, - W = 10, X = 0.4, H = 0.8, - name = "ddController", + command = "adddropdown", choices = { "drawercontroller" - } + }, + W = 10, + label = "Drawer Controller", + selected_id = 1, + Y = 1.2, + name = "ddController" }, { - command = "adddropdown", - Y = 3.2, - label = "Item name", - selected_id = 1, - X = 0.4, - W = 10, - H = 0.8, - name = "ddItem", choices = { "basic_materials:oil_extract", + "default:coal_lump", "default:cobble", "default:copper_ingot", + "default:copper_lump", "default:gold_ingot", + "default:gravel", "default:iron_lump", "default:mese_crystal", + "default:silver_sand", + "default:steel_ingot", "default:stone", + "farming:chocolate_dark", + "farming:cocoa_beans", "flowers:tulip_black", "mesecons_materials:glue", "moreblocks:cobble_compressed", - "moretrees:rubber_tree_trunk" - } - }, - { - command = "adddropdown", - Y = 5.2, - label = "Destination", + "moretrees:rubber_tree_trunk", + "technic:chromium_lump", + "technic:sulfur_lump" + }, + H = 0.8, + label = "Item name", selected_id = 1, W = 10, + command = "adddropdown", + Y = 3.2, + X = 0.4, + name = "ddItem" + }, + { X = 0.4, H = 0.8, - name = "ddDestination", + command = "adddropdown", choices = { "Tacit:cobblecompress", "Tacit:extract", @@ -60,81 +63,92 @@ mem.controls = { "Tacit:obsidian", "Tacit:plasticin", "Tacit:refab" - } + }, + W = 10, + label = "Destination", + selected_id = 1, + Y = 5.2, + name = "ddDestination" }, { default = "99", - label = "Stack size", - X = 0.7, - W = 1.2, command = "addfield", - Y = 7.1, name = "fldStackSize", - H = 0.8 + W = 1.2, + X = 0.7, + Y = 7.1, + H = 0.8, + label = "Stack size" }, { default = "1", - label = "Stacks count", - X = 1.9, - W = 1.6, command = "addfield", - Y = 7.1, name = "fldStacksCount", - H = 0.8 + W = 1.6, + X = 1.9, + Y = 7.1, + H = 0.8, + label = "Stacks count" }, { - label = "Order", + command = "addbutton", + name = "btnOrder", W = 1.6, X = 3.2, - command = "addbutton", + Y = 6.8, H = 0.8, - name = "btnOrder", - Y = 6.8 + label = "Order" }, { default = "", - label = "Enter drawer controller or select one", - X = 0.7, - W = 9.2, command = "addfield", - Y = 0.7, name = "fldController", - H = 0.8 - }, - { - default = "", - label = "Enter item id or select one", W = 9.2, X = 0.7, - command = "addfield", - Y = 2.7, - name = "fldItem", - H = 0.8 - }, - { - default = "", - label = "Enter destination name or select one", - X = 0.7, - W = 9.2, - command = "addfield", + Y = 0.7, H = 0.8, + label = "Enter drawer controller or select one" + }, + { + default = "", + command = "addfield", + name = "fldItem", + W = 9.2, + X = 0.7, + Y = 2.7, + H = 0.8, + label = "Enter item id or select one" + }, + { + default = "", + command = "addfield", + X = 0.7, + W = 9.2, name = "fldDestination", - Y = 4.7 + Y = 4.7, + H = 0.8, + label = "Enter destination name or select one" }, { command = "addlabel", - label = "Created with SX Digi labs Touch Designer", Y = 8.11, - X = 7.18 + X = 7.18, + label = "Created with SX Digi labs Touch Designer" } } - end local function addvalues(control, value) local controls = mem.controls - - for k,v in pairs(controls) do + + for k,v in pairs(controls) do if v.name and v.name == control then + + for kc,vc in pairs(v.choices) do + if vc == value then + return + end + end + table.insert(v.choices, value) table.sort(v.choices) end @@ -144,11 +158,8 @@ local function addvalues(control, value) end if event.type == "program" then - mem = {} createui() digiline_send("touch", mem.controls) - mem.orderNumber = 0 - end if event.type == "digiline" then