-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathClient_1_4_0
More file actions
1 lines (1 loc) · 82.7 KB
/
Client_1_4_0
File metadata and controls
1 lines (1 loc) · 82.7 KB
1
{"slots":{"0":{"name":"core","type":{"events":[],"methods":[]}},"1":{"name":"menudb","type":{"events":[],"methods":[]}},"2":{"name":"screen1","type":{"events":[],"methods":[]}},"3":{"name":"screen2","type":{"events":[],"methods":[]}},"4":{"name":"screen3","type":{"events":[],"methods":[]}},"5":{"name":"commsdb","type":{"events":[],"methods":[]}},"6":{"name":"core","type":{"events":[],"methods":[]}},"7":{"name":"slot8","type":{"events":[],"methods":[]}},"8":{"name":"slot9","type":{"events":[],"methods":[]}},"9":{"name":"slot10","type":{"events":[],"methods":[]}},"-1":{"name":"unit","type":{"events":[],"methods":[]}},"-2":{"name":"system","type":{"events":[],"methods":[]}},"-3":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"-- this code goes in the screen.mousedown(*,*) trigger\n\nclickMouseX = x*1920\nclickMouseY = y*1120\nCheckClick(clickMouseX, clickMouseY)\n\n","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"2"},"key":"0"},{"code":"response = commsdb.getStringValue(\"Res\"..channel)\n\nif not(response == nil) and not(response == \"\") then\n --system.print(\"Response:\"..response)\n response = string.gsub(response,[[\"in\":]], [[\"nd\":]])\n --system.print(\"Response:\"..response)\n --printResponse(response)\n if reqType == \"R\" then\n --system.print(\"Recipe response\")\n curRecipe = buildRecipe(response)\n reqType = \"C\"\n else\n --system.print(\"Ingred response\")\n curIngred = buildRecipe(response)\n unit.stopTimer(\"sendReq\")\n end\n commsdb.setStringValue(\"Res\"..channel,\"\")\n unit.stopTimer(\"sendReq\")\n DrawRecipeList()\nend\n\nif reqType == \"C\" then\n costStr = commsdb.getStringValue(\"oreCost\"..channel)\n schemaStr = commsdb.getStringValue(\"schemaCost\"..channel)\n --system.print(\"S=\"..schemaStr)\n talentStr = commsdb.getStringValue(\"talentCost\"..channel)\n --system.print(\"TL=\"..talentStr)\n if not(costStr == nil) and not(costStr == \"\") then\n --system.print(costStr)\n oreCost = json.decode(costStr)\n commsdb.setStringValue(\"oreCost\"..channel,\"\")\n end\n if not(schemaStr == nil) and not(schemaStr == \"\") then\n schemaCost = json.decode(schemaStr)\n commsdb.setStringValue(\"schemaCost\"..channel,\"\")\n end\n if not(talentStr == nil) and not(talentStr == \"\") then\n talentCost = json.decode(talentStr)\n commsdb.setStringValue(\"talentStr\"..channel,\"\")\n end\n if oreCost and schemaCost and talentCost then\n unit.stopTimer(\"sendReq\")\n end\n \n if s3Filter == \"Ore\" then\n DrawRecipeList()\n DrawCostScreen(oreCost)\n elseif s3Filter == \"Schema\" then\n DrawRecipeList()\n DrawSchemaScreen(schemaCost)\n elseif s3Filter == \"Talent\" then\n DrawRecipeList()\n DrawTalentScreen(talentCost)\n end\nend\n","filter":{"args":[{"value":"sendReq"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"1"},{"code":"\n-- table of abbreviations used in recipes and their decoded string values\nstringMap={}\nstringMap[\"nm\"]=\"name\"\nstringMap[\"ti\"]=\"tier\"\nstringMap[\"tp\"]=\"type\"\nstringMap[\"ms\"]=\"mass\"\nstringMap[\"vo\"]=\"volume\"\nstringMap[\"op\"]=\"outputQuantity\"\nstringMap[\"tm\"]=\"time\"\nstringMap[\"bp\"]=\"byproducts\"\nstringMap[\"in\"]=\"industries\"\nstringMap[\"ip\"]=\"input\"\nstringMap[\"Pu\"]=\"Pure\"\nstringMap[\"Np\"]=\"Nanopack\"\nstringMap[\"Rc\"]=\"Recycler\"\nstringMap[\"O2P\"]=\"Oxygen Pure\"\nstringMap[\"HP\"]=\"Hydrogen Pure\"\nstringMap[\"Re\"]=\"Refiner\"\nstringMap[\"Ind\"]=\"Industry\"\nstringMap[\"ChI\"]=\"Chemical Industry\"\nstringMap[\"Cat\"]=\"Catalyst\"\nstringMap[\"FeP\"]=\"Pure Iron\"\nstringMap[\"AlP\"]=\"Pure Aluminium\"\nstringMap[\"CP\"]=\"Pure Carbon\"\nstringMap[\"SiP\"]=\"Pure Silicon\"\nstringMap[\"CaP\"]=\"Pure Calcium\"\nstringMap[\"ChP\"]=\"Pure Chromium\"\nstringMap[\"CuP\"]=\"Pure Copper\"\nstringMap[\"NaP\"]=\"Pure Sodium\"\nstringMap[\"LiP\"]=\"Pure Lithium\"\nstringMap[\"NiP\"]=\"Pure Nickel\"\nstringMap[\"AgP\"]=\"Pure Silver\"\nstringMap[\"SP\"]=\"Pure Sulfur\"\nstringMap[\"CoP\"]=\"Pure Cobalt\"\nstringMap[\"FlP\"]=\"Pure Fluorine\"\nstringMap[\"AuP\"]=\"Pure Gold\"\nstringMap[\"ScP\"]=\"Pure Scandium\"\nstringMap[\"MnP\"]=\"Pure Manganese\"\nstringMap[\"NbP\"]=\"Pure Niobium\"\nstringMap[\"TiP\"]=\"Pure Titanium\"\nstringMap[\"VaP\"]=\"Pure Vanadium\"\nstringMap[\"AtA\"]=\"Atmospheric Airbrake\"\nstringMap[\"SpcC\"]=\"Space Core Unit\"\nstringMap[\"DynC\"]=\"Dynamic Core Unit\"\nstringMap[\"StaC\"]=\"Static Core Unit\"\nstringMap[\"Aly\"]=\"Alloy\"\nstringMap[\"Prd\"]=\"Product\"\nstringMap[\"Bsc\"]=\"Basic\"\nstringMap[\"Unc\"]=\"Uncommon\"\nstringMap[\"Adv\"]=\"Advanced\"\nstringMap[\"Smt\"]=\"Smelter\"\nstringMap[\"Asl\"]=\"Assembly Line\"\nstringMap[\"CaCu\"]=\"Calcium Reinforced Copper\"\nstringMap[\"StSt\"]=\"Stainless Steel\"\nstringMap[\"PlyC\"]=\"Polycarbonate Plastic\"\nstringMap[\"GlF\"]=\"Glass Furnace\"\nstringMap[\"AdvG\"]=\"Advanced Glass\"\nstringMap[\"ReiG\"]=\"Reinforced Glass\"\nstringMap[\"PlyA\"]=\"Polycalcite Plastic\"\nstringMap[\"PlyS\"]=\"Polysulfide Plastic\"\nstringMap[\"Sil\"]=\"Silumin\"\nstringMap[\"Stl\"]=\"Steel\"\nstringMap[\"Com\"]=\"Component\"\nstringMap[\"IntP\"]=\"Intermediary Part\"\nstringMap[\"ElcI\"]=\"Electronics Ind\"\nstringMap[\"Con\"]=\"Connector\"\nstringMap[\"Fix\"]=\"Fixation\"\nstringMap[\"3D\"]=\"3D Printer\"\nstringMap[\"Adv\"]=\"Advanced\"\nstringMap[\"MetI\"]=\"Metalwork Ind\"\nstringMap[\"Dur\"]=\"Duralumin\"\nstringMap[\"CpxP\"]=\"Complex Part\"\nstringMap[\"AtMC\"]=\"Antimatter Capsule\"\nstringMap[\"Brn\"]=\"Burner\"\nstringMap[\"Elec\"]=\"Electronics\"\nstringMap[\"ExpM\"]=\"Explosive Module\"\nstringMap[\"Hyd\"]=\"Hydraulics\"\nstringMap[\"Inj\"]=\"Injector\"\nstringMap[\"Scw\"]=\"Screw\"\nstringMap[\"Mgnt\"]=\"Magnet\"\nstringMap[\"PwrS\"]=\"Power System\"\nstringMap[\"Proc\"]=\"Processor\"\nstringMap[\"QCor\"]=\"Quantum Core\"\nstringMap[\"SinC\"]=\"Singularity Container\"\nstringMap[\"SWar\"]=\"Solid Warhead\"\nstringMap[\"AGC\"]=\"Anti-Gravity Core\"\nstringMap[\"QAU\"]=\"Quantum Alignment Unit\"\nstringMap[\"AMCU\"]=\"Antimatter Core\"\nstringMap[\"Ant\"]=\"Antenna\"\nstringMap[\"ChmC\"]=\"Chemical Container\"\nstringMap[\"CmbC\"]=\"Combustion Chamber\"\nstringMap[\"FunP\"]=\"Functional Part\"\nstringMap[\"ConS\"]=\"Control System\"\nstringMap[\"CorS\"]=\"Core System\"\nstringMap[\"ElcE\"]=\"Electric Engine\"\nstringMap[\"FirS\"]=\"Firing System\"\nstringMap[\"GasC\"]=\"Gas Cylinder\"\nstringMap[\"IonC\"]=\"Ionic Chamber\"\nstringMap[\"LasC\"]=\"Laser Chamber\"\nstringMap[\"MgtR\"]=\"Magnetic Rail\"\nstringMap[\"MecS\"]=\"Mechanical Sensor\"\nstringMap[\"MslS\"]=\"Missile Silo\"\nstringMap[\"MobP\"]=\"Mobile Panel\"\nstringMap[\"PwrC\"]=\"Power Converter\"\nstringMap[\"RobA\"]=\"Robotic Arm\"\nstringMap[\"Scn\"]=\"Screen\"\nstringMap[\"Cas\"]=\"Casing\"\nstringMap[\"ReiF\"]=\"Reinforced Frame\"\nstringMap[\"StrP\"]=\"Structural Part\"\nstringMap[\"StdF\"]=\"Standard Frame\"\n--stringMap[\"Atmo\"]=\"Atmospheric\"\nstringMap[\"HnyR\"]=\"Honeycomb Rey\"\nstringMap[\"Ail\"]=\"Aileron\"\nstringMap[\"Hny\"]=\"Honeycomb\"\nstringMap[\"HnyP\"]=\"Pure Honeycomb\"\nstringMap[\"AtmoE\"]=\"Atmospheric Engine\"\nstringMap[\"SpcE\"]=\"Space Engine\"\nstringMap[\"Rar\"]=\"Rare\"\nstringMap[\"Mil\"]=\"Military\"\nstringMap[\"Mnv\"]=\"Maneuver\"\nstringMap[\"Frt\"]=\"Freight\"\nstringMap[\"Cont\"]=\"Container\"\nstringMap[\"CabM-\"]=\"Cable Model \"\nstringMap[\"RG\"]=\"Railgun\"\nstringMap[\"Mis\"]=\"Missile\"\nstringMap[\"AM\"]=\"Antimatter\"\nstringMap[\"Prec\"]=\"Precision\"\nstringMap[\"Hvy\"]=\"Heavy\"\nstringMap[\"Dfn\"]=\"Defense\"\nstringMap[\"ElMg\"]=\"ElectroMgntic\"\nstringMap[\"VBst\"]=\"Vertical Booster\"\nstringMap[\"HovE\"]=\"Hover engine\"\n--stringMap[\"CUn\"]=\"Core Unit\"\nstringMap[\"Fur\"]=\"Furniture\"\nstringMap[\"ExP\"]=\"Exceptional Part\"\nstringMap[\"Can\"]=\"Cannon\"\nstringMap[\"Kin\"]=\"Kinetic\"\nstringMap[\"Ther\"]=\"Thermic\"\nstringMap[\"Wing Tip\"]=\"Wingtip\"\nstringMap[\"Fuel-Tank\"]=\"Fuel Tank\"\n\n-- table containing mapping of recipe abbreviations and corresponding container names\nstoreMap={}\nstoreMap[\"Bsc RobA S\"]=\"sbroboticarm\"\nstoreMap[\"Bsc RobA M\"]=\"mbroboticarm\"\nstoreMap[\"Bsc RobA L\"]=\"lbroboticarm\"\nstoreMap[\"Bsc MobP XS\"]=\"xsbmobilepanel\"\nstoreMap[\"Bsc MobP S\"]=\"sbmobilepanel\"\nstoreMap[\"Bsc MobP M\"]=\"mbmobilepanel\"\nstoreMap[\"Bsc MobP L\"]=\"lbmobilepanel\"\nstoreMap[\"Bsc StdF XS\"]=\"xsbstandard\"\nstoreMap[\"Bsc StdF S\"]=\"sbstandard\"\nstoreMap[\"Bsc StdF M\"]=\"mbstandard\"\nstoreMap[\"Bsc StdF L\"]=\"lbstandard\"\nstoreMap[\"Bsc ReiF XS\"]=\"xsbreinforced\"\nstoreMap[\"Bsc ReiF S\"]=\"sbreinforced\"\nstoreMap[\"Bsc ReiF M\"]=\"mbreinforced\"\nstoreMap[\"Bsc ReiF L\"]=\"lbreinforced\"\nstoreMap[\"Rar ReiF L\"]=\"lrreinforced\"\nstoreMap[\"Rar ReiF M\"]=\"mrreinforced\"\nstoreMap[\"Rar ReiF S\"]=\"srreinforced\"\nstoreMap[\"Rar ReiF XS\"]=\"xsrreinforced\"\nstoreMap[\"Rar CmbC L\"]=\"lrcombustion\"\nstoreMap[\"Rar CmbC M\"]=\"mrcombustion\"\nstoreMap[\"Rar CmbC S\"]=\"srcombustion\"\nstoreMap[\"Rar CmbC XS\"]=\"xsrcombustion\"\nstoreMap[\"Bsc Com\"]=\"bcomponent\"\nstoreMap[\"Unc Com\"]=\"ucomponent\"\nstoreMap[\"Adv Com\"]=\"acomponent\"\nstoreMap[\"Bsc Con\"]=\"bconnector\"\nstoreMap[\"Unc Con\"]=\"uconnector\"\nstoreMap[\"Adv Con\"]=\"aconnector\"\nstoreMap[\"Bsc Elec\"]=\"belectronic\"\nstoreMap[\"Unc Elec\"]=\"uelectronic\"\nstoreMap[\"Adv Elec\"]=\"aelectronic\"\nstoreMap[\"Bsc Scw\"]=\"bscrew\"\nstoreMap[\"Unc Scw\"]=\"uscrew\"\nstoreMap[\"Adv Scw\"]=\"ascrew\"\nstoreMap[\"Bsc Pipe\"]=\"bpipe\"\nstoreMap[\"Unc Pipe\"]=\"upipe\"\nstoreMap[\"Adv Pipe\"]=\"apipe\"\nstoreMap[\"Bsc LED\"]=\"bled\"\nstoreMap[\"Unc LED\"]=\"uled\"\nstoreMap[\"Adv LED\"]=\"aled\"\nstoreMap[\"Bsc AtMC\"]=\"bantimatter\"\nstoreMap[\"Unc AtMC\"]=\"uantimatter\"\nstoreMap[\"Adv AtMC\"]=\"aantimatter\"\nstoreMap[\"Adv AMCU\"]=\"aamc\"\nstoreMap[\"Bsc QCor\"]=\"bquantumcore\"\nstoreMap[\"Unc QCor\"]=\"uquantumcore\"\nstoreMap[\"Adv QCor\"]=\"aquantumcore\"\nstoreMap[\"Adv QAU\"]=\"aqau\"\nstoreMap[\"Bsc Mgnt\"]=\"bmagnet\"\nstoreMap[\"Unc Mgnt\"]=\"umagnet\"\nstoreMap[\"Adv Mgnt\"]=\"amagnet\"\nstoreMap[\"Bsc Hyd\"]=\"bhydraulic\"\nstoreMap[\"Unc Hyd\"]=\"uhydraulic\"\nstoreMap[\"Adv Hyd\"]=\"ahydraulic\"\nstoreMap[\"Bsc SinC\"]=\"bsingularity\"\nstoreMap[\"Unc SinC\"]=\"usingularity\"\nstoreMap[\"Adv SinC\"]=\"asingularity\"\nstoreMap[\"Bsc Brn\"]=\"bburner\"\nstoreMap[\"Unc Brn\"]=\"uburner\"\nstoreMap[\"Adv Brn\"]=\"aburner\"\nstoreMap[\"Rar Brn\"]=\"rburner\"\nstoreMap[\"Bsc PwrS\"]=\"bpowerunit\"\nstoreMap[\"Unc PwrS\"]=\"upowerunit\"\nstoreMap[\"Adv PwrS\"]=\"apowerunit\"\nstoreMap[\"Bsc Inj\"]=\"binjector\"\nstoreMap[\"Unc Inj\"]=\"uinjector\"\nstoreMap[\"Adv Inj\"]=\"ainjector\"\nstoreMap[\"Rar Inj\"]=\"rinjector\"\nstoreMap[\"Bsc Fix\"]=\"bfixation\"\nstoreMap[\"Unc Fix\"]=\"ufixation\"\nstoreMap[\"Adv Inj\"]=\"afixation\"\nstoreMap[\"Bsc Proc\"]=\"bprocessor\"\nstoreMap[\"Unc Proc\"]=\"uprocessor\"\nstoreMap[\"Adv Proc\"]=\"aprocessor\"\nstoreMap[\"SiP\"]=\"silicon\"\nstoreMap[\"AlP\"]=\"aluminium\"\nstoreMap[\"FeP\"]=\"iron\"\nstoreMap[\"CP\"]=\"carbon\"\nstoreMap[\"NaP\"]=\"sodium\"\nstoreMap[\"ChP\"]=\"chromium\"\nstoreMap[\"CaP\"]=\"calcium\"\nstoreMap[\"CuP\"]=\"copper\"\nstoreMap[\"AgP\"]=\"silver\"\nstoreMap[\"NiP\"]=\"nickel\"\nstoreMap[\"LiP\"]=\"lithium\"\nstoreMap[\"SP\"]=\"sulfer\"\nstoreMap[\"AuP\"]=\"gold\"\nstoreMap[\"FlP\"]=\"fluorine\"\nstoreMap[\"ScP\"]=\"scandium\"\nstoreMap[\"CoP\"]=\"cobalt\"\nstoreMap[\"MnP\"]=\"manganese\"\nstoreMap[\"NbP\"]=\"niobium\"\nstoreMap[\"TiP\"]=\"titanium\"\nstoreMap[\"VaP\"]=\"vanadium\"\nstoreMap[\"Stl\"]=\"steel\"\nstoreMap[\"Al-Fe Aly\"]=\"alfe\"\nstoreMap[\"CaCu\"]=\"cacu\"\nstoreMap[\"StSt\"]=\"stainless\"\nstoreMap[\"Sil\"]=\"silumin\"\nstoreMap[\"Dur\"]=\"duramin\"\nstoreMap[\"PlyA\"]=\"polycalcite\"\nstoreMap[\"PlyC\"]=\"polycarbonate\"\nstoreMap[\"Glass\"]=\"glass\"\nstoreMap[\"AdvG\"]=\"aglass\"\nstoreMap[\"Ag-Li ReiG\"]=\"agliglass\"\nstoreMap[\"Cu-Ag Aly\"]=\"agcu\"\nstoreMap[\"PlyS\"]=\"polysulfide\"\nstoreMap[\"Inconel\"]=\"inconel\"\nstoreMap[\"Al-Li Aly\"]=\"alli\"\nstoreMap[\"Maraging Stl\"]=\"maraging\"\nstoreMap[\"Sc-Al Aly\"]=\"scal\"\nstoreMap[\"Red Gold\"]=\"redgold\"\nstoreMap[\"Fluoropolymer\"]=\"polyfluoride\"\nstoreMap[\"Warp Cell\"]=\"warpcell\"\nstoreMap[\"Rar Mil AtmoE L\"]=\"lrmilatmo\"\nstoreMap[\"O2P\"]=\"oxygen\"\nstoreMap[\"HP\"]=\"hydrogen\"\nstoreMap[\"Cat 3\"]=\"cat3\"\nstoreMap[\"Cat 4\"]=\"cat4\"\n\nfunction string:map(delimiter,maxLen)\n local result = { }\n local from = 1\n if not(delimeter) then delimiter = \" \" end\n local delim_from, delim_to = string.find( self, delimiter, from )\n local mapped = \"\"\n if maxLen == nil then maxLen=0 end\n while delim_from do\n subStr = string.sub( self, from , delim_from-1 )\n resultMap = stringMap[subStr]\n if resultMap == nil or resultMap == \"\" then\n resultMap = subStr\n end\n mapped = mapped..resultMap..\" \"\n from = delim_to + 1\n delim_from, delim_to = string.find( self, delimiter, from )\n end\n subStr = string.sub( self, from )\n resultMap = stringMap[subStr]\n if resultMap == nil or resultMap == \"\" then\n resultMap = subStr\n end\n mapped = mapped..resultMap\n if maxLen > 0 and string.len(mapped) > maxLen then\n return self\n else\n return mapped\n end\nend\n\nlistStockContainers = {}\nlistStockIndex={}\nfunction setupMatierialIndex (material, values)\n listStockContainers[material]=values\n listStockIndex[#listStockIndex+1]=material\nend\n\n-- setupMatierialIndex(<containerName>,{<itemMass>, <containerSize>,<defaultQuantity>,<targetQuantity>})\n setupMatierialIndex(\"sbroboticarm\",{100, \"s\",0,20})\n setupMatierialIndex(\"mbroboticarm\",{ 927, \"s\",0,20})\n setupMatierialIndex(\"lbroboticarm\",{ 4930, \"s\",0,20})\n setupMatierialIndex(\"xsbmobilepanel\",{ 20, \"s\",0,20})\n setupMatierialIndex(\"sbmobilepanel\",{103, \"s\",0,20})\n setupMatierialIndex(\"mbmobilepanel\",{ 536, \"s\",0,20})\n setupMatierialIndex(\"lbmobilepanel\",{ 2830, \"s\",0,20})\n setupMatierialIndex(\"xsbstandard\",{ 4.20, \"s\",0,20})\n setupMatierialIndex(\"sbstandard\",{ 23.1, \"s\",0,20})\n setupMatierialIndex(\"mbstandard\",{ 155.4, \"s\",0,20})\n setupMatierialIndex(\"lbstandard\",{ 1080, \"s\",0,20})\n setupMatierialIndex(\"xsbreinforced\",{ 12.88, \"s\",0,20})\n setupMatierialIndex(\"sbreinforced\",{ 70.84, \"s\",0,20})\n setupMatierialIndex(\"mbreinforced\",{ 476, \"s\",0,20})\n setupMatierialIndex(\"lbreinforced\",{ 3320, \"s\",0,20})\n setupMatierialIndex(\"bcomponent\",{ 2.25, \"s\",0,2000})\n setupMatierialIndex(\"ucomponent\",{ 2.34, \"s\",0,1000})\n setupMatierialIndex(\"acomponent\",{ 2.5, \"s\",0,100})\n setupMatierialIndex(\"bconnector\",{ 3.75, \"s\",0,2000})\n setupMatierialIndex(\"uconnector\",{ 3.9, \"s\",0,1000})\n setupMatierialIndex(\"aconnector\",{ 4, \"s\",0,100})\n setupMatierialIndex(\"belectronic\",{ 5.22, \"s\",0,1000})\n setupMatierialIndex(\"uelectronic\",{ 5.34, \"s\",0,500})\n setupMatierialIndex(\"aelectronic\",{ 5.45, \"s\",0,50})\n setupMatierialIndex(\"bscrew\",{ 8.05, \"s\",0,2000})\n setupMatierialIndex(\"uscrew\",{ 7.9 , \"s\",0,1000})\n setupMatierialIndex(\"ascrew\",{ 7.5, \"s\",0,200})\n setupMatierialIndex(\"bpipe\",{ 2.4, \"s\",0,2000})\n setupMatierialIndex(\"upipe\",{ 2.32, \"s\" ,0,1000})\n setupMatierialIndex(\"apipe\",{ 2.19, \"s\",0,200})\n setupMatierialIndex(\"bled\",{ 1.25, \"s\",0,2000})\n setupMatierialIndex(\"uled\",{ 1.27 , \"s\",0,1000})\n setupMatierialIndex(\"aled\",{ 1.3, \"s\",0,200})\n setupMatierialIndex(\"bantimatter\",{ 24, \"s\",0,500})\n setupMatierialIndex(\"uantimatter\",{ 24.32, \"s\",0,100})\n setupMatierialIndex(\"aantimatter\",{ 24.88, \"s\",0,20})\n setupMatierialIndex(\"bquantumcore\",{ 10.72, \"s\",0,500})\n setupMatierialIndex(\"uquantumcore\",{ 11.04, \"s\",0,100})\n setupMatierialIndex(\"aquantumcore\",{ 11.24, \"s\",0,20})\n setupMatierialIndex(\"bmagnet\",{ 63.3, \"s\",0,200})\n setupMatierialIndex(\"umagnet\",{ 62.1, \"s\",0,200})\n setupMatierialIndex(\"amagnet\",{ 63.89, \"s\",0,150})\n setupMatierialIndex(\"bhydraulic\",{ 28.95, \"s\",0,500})\n setupMatierialIndex(\"uhydraulic\",{ 28.35, \"s\",0,200})\n setupMatierialIndex(\"ahydraulic\",{ 29.02, \"s\",0,50})\n setupMatierialIndex(\"bsingularity\",{ 45.36, \"s\",0,100})\n setupMatierialIndex(\"usingularity\",{ 44.88, \"s\",0,50})\n setupMatierialIndex(\"asingularity\",{ 46.22, \"s\",0,50})\n setupMatierialIndex(\"bburner\",{ 50.2, \"s\",0,500})\n setupMatierialIndex(\"uburner\",{ 49.4, \"s\",0,200})\n setupMatierialIndex(\"aburner\",{ 48.5, \"s\",0,50})\n setupMatierialIndex(\"bpowerunit\",{ 60, \"s\",0,500})\n setupMatierialIndex(\"upowerunit\",{ 62.4, \"s\",0,200})\n setupMatierialIndex(\"apowerunit\",{ 64.9, \"s\",0,150})\n setupMatierialIndex(\"binjector\",{ 20.3, \"s\",0,1000})\n setupMatierialIndex(\"uinjector\",{ 20.5, \"s\",0,500})\n setupMatierialIndex(\"ainjector\",{ 20.45, \"s\",0,100})\n setupMatierialIndex(\"bfixation\",{ 1.12, \"s\",0,1000})\n setupMatierialIndex(\"ufixation\",{ 1.16, \"s\",0,200})\n setupMatierialIndex(\"afixation\",{ 1.21, \"s\",0,100})\n setupMatierialIndex(\"bprocessor\",{ 14.84, \"s\",0,200})\n setupMatierialIndex(\"uprocessor\",{ 15.56, \"s\",0,100})\n setupMatierialIndex(\"aprocessor\",{ 15.56, \"s\",0,50})\n setupMatierialIndex(\"silicon\",{2.33, \"m\",0,80000})\n setupMatierialIndex(\"aluminium\",{2.7, \"m\",0,80000})\n setupMatierialIndex(\"iron\",{7.85, \"m\",0,80000})\n setupMatierialIndex(\"carbon\",{2.27, \"m\",0,80000})\n setupMatierialIndex(\"sodium\",{0.97, \"m\",0,40000})\n setupMatierialIndex(\"chromium\",{7.19, \"m\",0,40000})\n setupMatierialIndex(\"calcium\",{1.55, \"m\",0,40000})\n setupMatierialIndex(\"copper\",{8.96, \"m\",0,40000})\n setupMatierialIndex(\"silver\",{10.49, \"m\",0,10000})\n setupMatierialIndex(\"nickel\",{8.91, \"m\",0,10000})\n setupMatierialIndex(\"lithium\",{0.53, \"m\",0,10000})\n setupMatierialIndex(\"sulfer\",{1.82, \"m\",0,10000})\n setupMatierialIndex(\"gold\",{19.3, \"m\",0,5000})\n setupMatierialIndex(\"fluorine\",{1.7, \"m\",0,5000})\n setupMatierialIndex(\"scandium\",{2.98, \"m\",0,5000})\n setupMatierialIndex(\"cobalt\",{8.9, \"m\",0,5000})\n setupMatierialIndex(\"manganese\",{7.21, \"m\",0,100})\n setupMatierialIndex(\"niobium\",{8.57, \"m\",0,100})\n setupMatierialIndex(\"titanium\",{4.51, \"m\",0,100})\n setupMatierialIndex(\"vanadium\",{6, \"m\",0,100})\n setupMatierialIndex(\"steel\",{8.05, \"s\",0,2000})\n setupMatierialIndex(\"alfe\",{7.5, \"s\",0,2000})\n setupMatierialIndex(\"cacu\",{8.1, \"s\",0,1000})\n setupMatierialIndex(\"stainless\",{7.75, \"s\",0,1000})\n setupMatierialIndex(\"silumin\",{3, \"s\",0,2000})\n setupMatierialIndex(\"duramin\",{2.8, \"s\",0,500})\n setupMatierialIndex(\"polycalcite\",{1.5, \"s\",0,1000})\n setupMatierialIndex(\"polycarbonate\",{1.4, \"s\",0,2000})\n setupMatierialIndex(\"glass\",{2.5, \"s\",0,2000})\n setupMatierialIndex(\"aglass\",{2.6, \"s\",0,1000})\n setupMatierialIndex(\"agliglass\",{2.8, \"s\",0,500})\n setupMatierialIndex(\"agcu\",{9.2, \"s\",0,500})\n setupMatierialIndex(\"polysulfide\",{1.6, \"s\",0,500})\n setupMatierialIndex(\"inconel\",{8.5, \"s\",0,500})\n setupMatierialIndex(\"alli\",{2.5, \"s\",0,300})\n setupMatierialIndex(\"maraging\",{8.23, \"s\",0,300})\n setupMatierialIndex(\"scal\",{2.85, \"s\",0,300})\n setupMatierialIndex(\"redgold\",{14.13, \"s\",0,300})\n\n maxStockContainers = 40\n\nfunction string:map(delimiter,maxLen)\n local result = { }\n local from = 1\n if not(delimeter) then delimiter = \" \" end\n local delim_from, delim_to = string.find( self, delimiter, from )\n local mapped = \"\"\n if maxLen == nil then maxLen=0 end\n while delim_from do\n subStr = string.sub( self, from , delim_from-1 )\n resultMap = stringMap[subStr]\n if resultMap == nil or resultMap == \"\" then\n resultMap = subStr\n end\n mapped = mapped..resultMap..\" \"\n from = delim_to + 1\n delim_from, delim_to = string.find( self, delimiter, from )\n end\n subStr = string.sub( self, from )\n resultMap = stringMap[subStr]\n if resultMap == nil or resultMap == \"\" then\n resultMap = subStr\n end\n mapped = mapped..resultMap\n if maxLen > 0 and string.len(mapped) > maxLen then\n return self\n else\n return mapped\n end\nend","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"2"},{"code":"function initiateRequiredLibaries()\n json = require('dkjson')\nend\nif pcall(initiateRequiredLibaries) then\n system.print(\"Libaries loaded successfully\")\n else\n system.print(\"Libaries failed to load: check that the following libraries exist:\")\n system.print(\"(<ProgrmData> is the directory in to which you installed DU)\")\n system.print(\" <ProgrmData>/DualUniverse/Game/data/lua/dkjson\")\n system.print(\"\")\n unit.exit()\nend\n\n--jsa = require('cpml/json-a')\n\nversion = \"1_5_0\"\nrecipeIndexList={}\nelementIndexList={}\nconsumableIndexList={}\npartsIndexList={}\nuserFilterIndexList={}\ndisplayIndexList = {}\nchannel = 1 --export: PB channel ID (1 to 5)\nlocal BackgroundColor = \"#1e1e1e\"\n--[[ Default colours are 34b1eb and 6e3de3]]\nlocal RecPanelColour = \"99eeff\" --export Set the background color of the recipe Panel. YOU NEED TO LEAVE THE QUOTATION\nlocal IngPanelColour = \"aa99ff\" --export Set the background color of the Igredients panel. YOU NEED TO LEAVE THE QUOTATION\nlocal FontPanelColour = \"000000\" --export: Hex code for font colour of planet/locations panel (you need to include the quotes)\nlocal LineHighlightColour = \"ccffff\"--export: Hex code for colour of highlighted lines in planet/location panel (you need to include the quotes)\n\nlocal RecipeBackgroundColor = \"#\" ..RecPanelColour\nlocal IngredBackgroundColor = \"#\" ..IngPanelColour\nlocal MainFontColor = \"#\" .. FontPanelColour\nlocal HighlightColor = \"#\" .. LineHighlightColour\nlocal clickAreas = {}\nlocal ingredList={}\nlocal lastRecipeSelected = \"\"\nlocal lastIngredSelected = \"\"\nlocal recipeLines=12\nlocal ingredLines=10\nlocal displayRecipeList={}\nlocal displayIngredList={}\nlocal CurrentIngredPage = 1\nlocal CurrentRecipePage = 1\nlocal indexCount=0\nuserFilter = \"\" --export\n\n-- default ore prices on the market\ncostBauxite = 25 --export\ncostCoal = 25 --export\ncostQuartz = 25 -- export\ncostHematite = 25 -- export\ncostChromite = 53 --export\ncostMalachite = 54 --export\ncostLimestone = 54 -- export\ncostNatron = 53 -- export\ncostPetalite = 75 --export\ncostGarnierite = 80 --export\ncostAcanthite = 75 -- export\ncostPyrite = 90 -- export\ncostCobaltite = 450 --export\ncostCryolite = 450 --export\ncostKolbeckite = 350 -- export\ncostGold = 350 -- export\ncostRhodonite = 400 --export\ncostColumbite = 1000--export\ncostVanadinite = 1000-- export\ncostIllmenite = 1000-- export\n\n\ncurRecipe = {}\ncurIngred = {}\nreqType = \"R\"\n \nfunction commerise(amount)\n local formatted = amount\n while true do \n formatted, k = string.gsub(formatted, \"^(-?%d+)(%d%d%d)\", '%1,%2')\n if (k==0) then\n break\n end\n end\n return formatted\nend\n\nfunction string:split(delimiter,maxLen)\n --system.print(\"Self:\"..self)\n if not(delimeter) then delimiter = \" \" end\n local result = { }\n local from = 1\n local delim_from, delim_to = string.find( self, delimiter, from )\n local mapped = \"\"\n if maxLen == nil then maxLen=0 end\n while delim_from do \n table.insert( result, string.sub( self, from , delim_from-1 ) )\n subStr = string.sub( self, from , delim_from-1 )\n from = delim_to + 1\n delim_from, delim_to = string.find( self, delimiter, from )\n end\n table.insert( result, string.sub( self, from ) )\n subStr = string.sub( self, from )\n return result\nend\n\nfunction loadRecipeIndex() \n local indexStr = menudb.getStringValue(\"recipeIndex\")\n local pattern=[[([%w%s\"%-]*):]]\n local startIndex, endIndex, valueStr = string.find(indexStr, pattern, 1)\n repeat\n --system.print(\"s=\"..startIndex..\" e=\"..endIndex..\" ValueStr=\"..valueStr)\n if not(valueStr==nil) then\n recipeIndexList[#recipeIndexList + 1] = valueStr\n else\n break\n end\n --system.print(\"endIndex=\"..endIndex)\n startIndex, endIndex, valueStr = string.find(indexStr, pattern, endIndex+1)\n until (valueStr==nil)\n --system.print(\"Last Recipe=\"..recipeIndexList[#recipeIndexList])\n system.print(\"Recipe Menu = \"..#recipeIndexList..\" entries\")\n collectgarbage(\"collect\")\nend\n\nfunction loadElementIndex() \n local indexStr = menudb.getStringValue(\"menuElements\")\n local pattern=\"([%w%s%-]*):\"\n local startIndex, endIndex, valueStr = string.find(indexStr, pattern, 1)\n repeat\n --system.print(\"s=\"..startIndex..\" e=\"..endIndex..\" ValueStr=\"..valueStr)\n if not(tonumber(valueStr)==nil) then\n if tonumber(valueStr) > #recipeIndexList then\n system.print(\"Invalid Element Menu Item: \".. tonumber(valueStr))\n unit.exit()\n end\n elementIndexList[#elementIndexList + 1] = recipeIndexList[tonumber(valueStr)]\n end\n --system.print(\"endIndex=\"..endIndex)\n startIndex, endIndex, valueStr = string.find(indexStr, pattern, endIndex+1)\n until (endIndex==nil)\n --system.print(\"Last El=\"..elementIndexList[#elementIndexList])\n system.print(\"Element Menu = \"..#elementIndexList..\" entries\")\n collectgarbage(\"collect\")\nend\n\nfunction loadConsumableIndex() \n local indexStr = menudb.getStringValue(\"menuConsumables\")\n local pattern=\"([%w%s%-]*):\"\n local startIndex, endIndex, valueStr = string.find(indexStr, pattern, 1)\n repeat\n --system.print(\"s=\"..startIndex..\" e=\"..endIndex..\" ValueStr=\"..valueStr)\n if not(tonumber(valueStr)==nil) then\n if tonumber(valueStr) > #recipeIndexList then\n system.print(\"Invalid consumable Menu Item: \".. tonumber(valueStr))\n unit.exit()\n end\n consumableIndexList[#consumableIndexList + 1] = recipeIndexList[tonumber(valueStr)]\n end\n --system.print(\"endIndex=\"..endIndex)\n startIndex, endIndex, valueStr = string.find(indexStr, pattern, endIndex+1)\n until (endIndex==nil)\n --system.print(\"Last Con=\"..consumableIndexList[#consumableIndexList])\n system.print(\"Consumable Menu = \"..#consumableIndexList..\" entries\")\n collectgarbage(\"collect\")\nend\n\nfunction loadPartsIndex() \n local indexStr = menudb.getStringValue(\"menuParts\")\n local pattern=\"([%w%s%-]*):\"\n local startIndex, endIndex, valueStr = string.find(indexStr, pattern, 1)\n repeat\n --system.print(\"s=\"..startIndex..\" e=\"..endIndex..\" ValueStr=\"..valueStr)\n if not(tonumber(valueStr)==nil) then\n if tonumber(valueStr) > #recipeIndexList then\n system.print(\"Invalid consumable Menu Item: \".. tonumber(valueStr))\n unit.exit()\n end\n partsIndexList[#partsIndexList + 1] = recipeIndexList[tonumber(valueStr)]\n end\n --system.print(\"endIndex=\"..endIndex)\n startIndex, endIndex, valueStr = string.find(indexStr, pattern, endIndex+1)\n until (endIndex==nil)\n --system.print(\"Last Pa=\"..partsIndexList[#partsIndexList])\n system.print(\"Parts Menu = \"..#partsIndexList..\" entries\")\n collectgarbage(\"collect\")\nend\n \nfunction buildUserFilterList(filter)\n userFilterIndexList={}\n for i=1,#recipeIndexList do\n if string.match(string.lower(recipeIndexList[i]:map(\" \")),string.lower(filter)) then\n userFilterIndexList[#userFilterIndexList+1]=recipeIndexList[i]\n end\n end\nend\n\nfunction buildRecipe(recipeStr)\n return json.decode(recipeStr)\nend\n\nfunction reqRecipe(recipeName)\n reqType = \"R\"\n commsdb.setStringValue(\"Req\"..channel,recipeName)\n unit.setTimer(\"sendReq\",0.5)\nend\nfunction reqIngred(ingredName)\n reqType = \"I\"\n commsdb.setStringValue(\"Req\"..channel,ingredName)\n unit.setTimer(\"sendReq\",0.5)\nend\n\nfunction getStoreQty(ingredName)\n local containerName = storeMap[ingredName]\n if not(containerName==nil) and not(containerName==\"\") then\n --system.print(ingredName..\" Qty=\"..listStockContainers[containerName][3])\n return math.floor(listStockContainers[containerName][3],1)\n else\n return 0\n end\nend\n\nfunction getIndTierDesc(tier)\n if tier < 2 then return \"Basic\"\n elseif tier == 2 then return \"Uncommon\" \n elseif tier == 3 then return \"Advanced\"\n elseif tier == 4 then return \"Rare\"\n elseif tier == 5 then return \"Unique\"\n else\n return \"Unknown\"\n end\nend\n\nfunction DrawSVG(output,screen) screen.setSVG(output) end\n\nfunction AddClickArea(newEntry) table.insert(clickAreas, newEntry) end\n\nfunction RemoveFromClickAreas(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = nil\n break\n end\n end\nend\n\nfunction UpdateClickArea(candidate, newEntry)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n clickAreas[k] = newEntry\n break\n end\n end\nend\n\nfunction DisableClickArea(candidate)\n for k, v in pairs(clickAreas) do\n if v.id == candidate then\n UpdateClickArea(candidate, {\n id = candidate,\n x1 = -1,\n x2 = -1,\n y1 = -1,\n y2 = -1\n })\n break\n end\n end\nend\n\nfunction InitiateClickAreas()\n clickAreas = {}\n \n AddClickArea({id = \"Filter1\", x1 = 50, x2 = 200, y1 = 900, y2 = 960})\n AddClickArea({id = \"Filter2\", x1 = 220, x2 = 370, y1 = 900, y2 = 960})\n AddClickArea({id = \"Filter3\", x1 = 390, x2 = 540, y1 = 900, y2 = 960})\n AddClickArea({id = \"Filter4\", x1 = 560, x2 = 710, y1 = 900, y2 = 960})\n AddClickArea({id = \"Filter5\", x1 = 730, x2 = 880, y1 = 900, y2 = 960})\n AddClickArea({id = \"Ore\", x1 = 450, x2 = 600, y1 = 980, y2 = 1040})\n AddClickArea({id = \"Schema\", x1 = 625, x2 = 775, y1 = 980, y2 = 1040})\n AddClickArea({id = \"Talent\", x1 = 800, x2 = 950, y1 = 980, y2 = 1040})\n AddClickArea({id = \"RecipePageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"RecipePageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"IngredPageDown\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n AddClickArea({id = \"IngredPageUp\", x1 = -1, x2 = -1, y1 = -1, y2 = -1})\n \n for i = 1, recipeLines do\n AddClickArea({id = string.format(\"RList%d\",i), x1 = 90, x2 = 800, y1 = (150 + i * 55), y2 = (205 + i * 55)})\n end\n for i = 1, ingredLines do\n AddClickArea({id = string.format(\"IList%d\",i), x1 = 1030, x2 = 1800, y1 = (500 + i * 55), y2 = (555 + i * 55)})\n end\nend\n\nfunction FlushClickAreas() clickAreas = {} end\n\nfunction clearLocDispList()\n for i=1,pageLines do\n displayLocationList[i] = \"\"\n end\nend\n\nfunction CheckClick(x, y, HitTarget)\n HitTarget = HitTarget or \"\"\n --system.print(\"x=\"..x..\" y=\"..y)\n if HitTarget == \"\" then\n for k, v in pairs(clickAreas) do\n if v and x >= v.x1 and x <= v.x2 and y >= v.y1 and y <= v.y2 then\n HitTarget = v.id\n break\n end\n end\n end\n \n --system.print(\"Target Hit = \"..HitTarget)\n \n if HitTarget == \"RecipePageDown\" then\n CurrentRecipePage = CurrentRecipePage+1\n DrawRecipeList()\n elseif HitTarget == \"RecipePageUp\" then\n CurrentRecipePage = math.max(CurrentRecipePage-1,0)\n DrawRecipeList()\n elseif HitTarget == \"IngredPageDown\" then\n CurrentIngredPage = CurrentIngredPage+1\n DrawRecipeList()\n elseif HitTarget == \"IngredPageUp\" then\n CurrentIngredPage = math.max(CurrentIngredPage-1,0)\n DrawRecipeList()\n elseif HitTarget == \"Filter1\" then\n displayIndexList = recipeIndexList\n indexCount = #recipeIndexList\n CurrentRecipePage = 1\n displayFilter = \"All\"\n DrawRecipeList()\n elseif HitTarget == \"Filter2\" then\n displayIndexList = elementIndexList\n indexCount = #elementIndexList\n CurrentRecipePage = 1\n displayFilter = \"Element\"\n DrawRecipeList() \n elseif HitTarget == \"Filter3\" then\n displayIndexList = consumableIndexList\n indexCount = #consumableIndexList\n CurrentRecipePage = 1\n displayFilter = \"Consumable\"\n DrawRecipeList()\n elseif HitTarget == \"Filter4\" then\n displayIndexList = partsIndexList\n indexCount = #partsIndexList\n CurrentRecipePage = 1\n displayFilter = \"Parts\"\n DrawRecipeList() \n elseif HitTarget == \"Filter5\" and userFilter ~= \"\" then\n buildUserFilterList(userFilter)\n displayIndexList = userFilterIndexList\n indexCount = #userFilterIndexList\n CurrentRecipePage = 1\n displayFilter = \"userFilter\"\n DrawRecipeList() \n elseif HitTarget == \"Ore\" then\n s3Filter = \"Ore\"\n DrawRecipeList() \n DrawCostScreen(oreCost)\n elseif HitTarget == \"Schema\" then\n s3Filter = \"Schema\"\n DrawRecipeList() \n DrawSchemaScreen(schemaCost) \n elseif HitTarget == \"Talent\" then\n s3Filter = \"Talent\"\n DrawRecipeList()\n DrawTalentScreen(talentCost) \n else\n for i = 1,recipeLines do\n if HitTarget == string.format(\"RList%s\",i) then\n if displayRecipeList[i] ~= \"\" then\n lastRecipeSelected = displayRecipeList[i]\n currentIngred = {}\n lastIngredSelected=\"\"\n reqRecipe(lastRecipeSelected) \n DrawCostScreen(nil)\n DrawRecipeList()\n end\n end\n end\n for i = 1,ingredLines do\n if HitTarget == string.format(\"IList%s\",i) then\n if displayIngredList[i] ~= \"\" then\n lastIngredSelected = displayIngredList[i]\n reqIngred(lastIngredSelected)\n DrawRecipeList()\n end\n end\n end\n end\nend\n\n-----------------------------------------------\n-- More efficient JSON parsing using pattern matching - avids cpu overloads\n-----------------------------------------------\n\nlocal function extractListJsonValue (json, key, init)\n local pattern = [[\"]] .. key .. [[\"%s*:%s*([[][%g%s]*[]]..\"]\"..\"])\"\n local startIndex, endIndex, valueStr = string.find(json, pattern, init)\n return valueStr, startIndex, endIndex\nend\n-- Extracts values from a JSON string with pattern matching\n-- This is faster than using dkjson when only a few fields are needed\n\n-- Use this only with trusted data sources! Limitations:\n-- * Character escapes are not supported\n-- * Field nesting is ignored\n\nlocal find, gsub = string.find, string.gsub\n\n---@param json string\n---@param key string\n---@param init number|nil\n---@return string|nil, number|nil, number|nil\nlocal function extractStringJsonValue (json, key, init)\n local pattern = [[\"]] .. key .. [[\"%s*:%s*\"([^\"]*)\"]]\n local startIndex, endIndex, valueStr = find(json, pattern, init)\n return valueStr, startIndex, endIndex\nend\n\n---@param json string\n---@param key string\n---@param init number|nil\n---@return number|nil, number|nil, number|nil\nlocal function extractNumberJsonValue (json, key, init)\n local pattern = [[\"]] .. key .. [[\"%s*:%s*(-?[0-9.e-]+)]]\n local startIndex, endIndex, valueStr = find(json, pattern, init)\n return tonumber(valueStr), startIndex, endIndex\nend\n\n---@param json string\n---@param key string\n---@param init number|nil\n---@return list|nil, number|nil, number|nil\nlocal function extractListJsonValue (json, key, init)\n local pattern = [[\"]] .. key .. [[\"%s*:%s*([[][%g%s]*[]]..\"]\"..\"])\"\n local startIndex, endIndex, valueStr = string.find(json, pattern, init)\n return valueStr, startIndex, endIndex\nend\n\n---@param extractJsonValue function\n---@param json string\n---@param key string\n---@param stopAfterIndex number|nil\n---@param stopAfterValue any|nil\n---@return any[]\nlocal function extractAllJsonValues (extractJsonValue, json, key, stopAfterIndex, stopAfterValue)\n local values = {}\n local valuesLen = 0\n\n local jsonPos = 1\n local value, valueStartIndex, valueEndIndex -- luacheck: ignore valueStartIndex -- unused\n\n repeat\n value, valueStartIndex, valueEndIndex = extractJsonValue(json, key, jsonPos)\n\n if value ~= nil then\n valuesLen = valuesLen + 1\n values[valuesLen] = value\n\n jsonPos = valueEndIndex + 1\n end\n\n if value == stopAfterValue then break end\n if valuesLen == stopAfterIndex then break end\n until value == nil\n\n return values\nend\n\n---@param json string\n---@param key string\n---@param stopAfterIndex number|nil\n---@param stopAfterValue string|nil\n---@return string[]\nlocal function extractAllStringJsonValues (json, key, stopAfterIndex, stopAfterValue)\n return extractAllJsonValues(extractStringJsonValue, json, key, stopAfterIndex, stopAfterValue)\nend\n\n---@param json string\n---@param key string\n---@param stopAfterIndex number|nil\n---@param stopAfterValue number|nil\n---@return number[]\nlocal function extractAllNumberJsonValues (json, key, stopAfterIndex, stopAfterValue)\n return extractAllJsonValues(extractNumberJsonValue, json, key, stopAfterIndex, stopAfterValue)\nend\n\n-----------------------------------------------\n-- Code for monitoring industries and obtaining schematics\n-----------------------------------------------\nlocal industries = {}\nindustries[#industries+1] = \"electronics\"\nindustries[#industries+1] = \"metalwork\"\nindustries[#industries+1] = \"glass\"\nindustries[#industries+1] = \"smelter\"\nindustries[#industries+1] = \"refiner\"\nindustries[#industries+1] = \"recycler\"\nindustries[#industries+1] = \"chemical\"\nindustries[#industries+1] = \"assembler\"\nindustries[#industries+1] = \"3d\"\n\nfunction isIndustry(elem)\n for i=1,#industries do\n if elem == industries[i] then return true end\n end\n return false\nend\n\nfunction getIndustryInfo()\n local uids = core.getElementIdList()\n local words = {}\n local industryJson = \"\"\n\n for _, uid in ipairs(uids) do\n local uidName = string.lower(core.getElementNameById(uid))\n local uidType = string.lower(core.getElementTypeById(uid))\n --system.print(uidType)\n local words=uidType:split()\n --system.print(json.encode(words))\n if not(words == nil) and #words > 1 then\n local uidState = \"\"\n local uidSchemaId = 0\n if isIndustry(words[2]) then\n local uidStatusStr = core.getElementIndustryStatus(uid)\n uidState = extractStringJsonValue(uidStatusStr,\"state\",1)\n uidSchemaId = extractNumberJsonValue(uidStatusStr,\"schematicId\",1)\n --uidStatus = json.decode(uidStatusStr)\n if uidState and not(uidState == \"STOPPED\") then\n local schemaStr = core.getSchematicInfo(uidSchemaId)\n --system.print(\"Schema Data=\"..schemaStr)\n\n local uidProducts = extractListJsonValue(schemaStr,\"products\",1)\n local uidSchema = extractStringJsonValue(uidProducts,\"name\",1)\n --system.print(\"Type=\"..uidType..\", Name=\"..uidName..\", Status=\"..uidStatusStr)\n --system.print(\"Status=\"..uidStatus.state..\", Schema=\"..uidStatus.schematicId)\n --system.print(uidType..\"/\"..uidName..\" running=\"..uidSchema)\n if industryJson == \"\" then industryJson = \"[\" else industryJson = industryJson..\",\" end\n industryJson = industryJson .. \"{\" ..\n [[\"uid\":]] .. uid ..[[,]]..\n [[\"name\":\"]] .. uidName ..[[\",]]..\n [[\"type\":\"]] .. uidType ..[[\",]]..\n [[\"state\":\"]] .. uidState ..[[\",]]..\n [[\"schema\":\"]] .. uidSchema ..[[\"]]..\n \"}\"\n end\n end\n end\n end\n if not(industryJson == \"\") then industryJson = industryJson .. \"]\" else industryJson = \"[]\" end\n return industryJson\nend\n\nfunction getContainerMass (containerCode)\n -- container sizes based on hit point\n local containerSizeTable ={ 400, 1281.31, 7421.35, 8000 }\n if containerCode == \"xs\" then return containerSizeTable[1]\n else if containerCode == \"s\" then return containerSizeTable[2]\n \telse if containerCode == \"m\" then return containerSizeTable[3]\n \telse if containerCode == \"l\" then return containerSizeTable[4]\n end\n end\n end\n end\n return 0\nend\n\nfunction monitorStock()\n local uids = core.getElementIdList()\n --clear temporary counts from last tick\n for i = 1, #listStockIndex do\n listStockContainers[listStockIndex[i]][3]=0\n end\n \n for _, uid in ipairs(uids) do\n \tlocal uidType = core.getElementTypeById(uid)\n \tif string.lower(uidType) == \"container\" then\n local uidName = string.lower(core.getElementNameById(uid)) \n \t\tif not(listStockContainers[uidName]==nil) then\n listStockContainers[uidName][3]=listStockContainers[uidName][3]+\n (core.getElementMassById(uid) - \n getContainerMass(listStockContainers[uidName][2])) /\n \t listStockContainers[uidName][1]\n end\n \tend\n end\nend\n\n-----------------------------------------------\n-- Code for building screen content and displaying it\n-----------------------------------------------\n\nlocal svgBootstrap = [[<svg class=\"bootstrap\" viewBox=\"0 0 1920 1120\" width=\"1920\" height=\"1120\">\n <defs><style>\n .ftitle { font-size: 60px; text-anchor: start;fill: white; }\n .ftitlew { font-size: 60px; text-anchor: start;fill: red; }\n .ftitle2 { font-size: 60px; text-anchor: start;fill: #565656; }\n .ftopmiddle { font-size: 40px; text-anchor: middle;}\n .ftopend { font-size: 40px; text-anchor: end;}\n .fcapstart { font-size: 30px; text-anchor: start; fill: white;}\n .fcapstarthy { font-size: 30px; text-anchor: start; fill: yellow;}\n .fcapstarthr { font-size: 30px; text-anchor: start; fill: red;}\n .fcapmiddle { font-size: 30px; text-anchor: middle; fill: white;}\n .fcapend { font-size: 30px; text-anchor: end; fill: #1e1e1e;}\n .fcapendw { font-size: 30px; text-anchor: end; fill: white;}\n .fmstart { font-size: 25px; text-anchor: start; fill: white;}\n .fmstartr { font-size: 25px; text-anchor: start; fill: red;}\n .fmschema { font-size: 25px; text-anchor: start; fill: ]]..MainFontColor..[[;}\n .fmschemag { font-size: 25px; text-anchor: end; fill: ]]..MainFontColor..[[;}\n .fmdesc { font-size: 25px; text-anchor: start; fill: ]]..MainFontColor..[[;}\n .fmstartg { font-size: 25px; text-anchor: start; fill: ]]..MainFontColor..[[;}\n .fmstartp { font-size: 25px; text-anchor: start; fill:]]..RecipeBackgroundColor..[[;}\n .fmstartl { font-size: 25px; text-anchor: start; fill:]]..IngredBackgroundColor..[[;}\n .fmstarty { font-size: 25px; text-anchor: start; fill: #aaaa00;}\n .fmstartr { font-size: 25px; text-anchor: end; fill: #ff0000;}\n .fmmiddle { font-size: 30px; text-anchor: middle; fill: white;}\n .fmmiddleb { font-size: 30px; text-anchor: middle; fill: black;}\n .fmmiddler { font-size: 30px; text-anchor: middle; fill: red;}\n .fmend { font-size: 25px; text-anchor: end; fill: ]]..MainFontColor..[[;}\n .fmendg { font-size: 25px; text-anchor: end; fill: white;}\n .fmendy { font-size: 25px; text-anchor: end; fill: yellow;}\n .fmingreddesc { font-size: 25px; text-anchor: start; fill: ]]..MainFontColor..[[;}\n </style></defs>]]\n\nfunction DrawRecipeList()\n local healthyColor = \"#00aa00\"\n local brokenColor = \"#aa0000\"\n local damagedColor = \"#aaaa00\"\n local integrityColor = \"#aaaaaa\"\n local healthyTextColor = \"white\"\n local brokenTextColor = \"#ff4444\"\n local damagedTextColor = \"#ffff44\"\n local integrityTextColor = \"white\"\n \n\n local screenOutput = \"\"\n\n -- Draw Header\n screenOutput = screenOutput .. svgBootstrap\n \n -- Draw main background\n screenOutput = screenOutput ..\n [[<rect width=\"1920\" height=\"1120\" style=\"fill: #]]..BackgroundColor..[[\"/><g></g>]]\n screenOutput = screenOutput ..\n [[<text x=\"70\" y=\"120\" class=\"ftitle\">Crafting Recipes</text>]]\n screenOutput = screenOutput ..\n [[<text x=\"1900\" y=\"120\" class=\"fmstartr\">Version: ]]..version..[[</text>]]\n screenOutput = screenOutput ..\n [[<rect x=\"70\" y=\"150\" rx=\"10\" ry=\"10\" width=\"900\" height=\"]] ..\n ((recipeLines + 1) * 55) ..\n [[\" style=\"fill:]].. RecipeBackgroundColor .. [[;stroke:#ffff00;stroke-width:3;\" />]]\n screenOutput = screenOutput ..\n [[<rect x=\"80\" y=\"160\" rx=\"5\" ry=\"5\" width=\"890\" height=\"40\" style=\"fill:#33331a;\" />]] \n screenOutput = screenOutput ..\n [[<text x=\"90\" y=\"191\" class=\"fcapstart\">Recipes</text>]]\n \n\n local i = 0\n for j = 1 + (CurrentRecipePage - 1) * recipeLines, recipeLines +\n (CurrentRecipePage - 1) * recipeLines, 1 do\n i = i + 1\n if j < #displayIndexList and j>0 then\n if lastRecipeSelected == displayIndexList[j] then\n screenOutput = screenOutput ..\n [[<rect x=\"70\" y=\"]]..(140 + i * 55) .. \n [[\" width=\"900\" height=\"55\"]] ..\n [[\" style=\"fill:]].. HighlightColor .. [[;\" />]]\n end\n screenOutput = screenOutput .. [[<text x=\"90\" y=\"]] ..\n (180 + i * 55) .. [[\" class=\"fmstartg\">]] ..\n string.format(\"%30s\", displayIndexList[j]:map()) .. [[</text>]]\n displayRecipeList[i]=displayIndexList[j]\n else\n displayRecipeList[i]=\"\"\n end\n end\n \n if indexCount > recipeLines then\n screenOutput = screenOutput ..\n [[<text x=\"70\" y=\"1000\" class=\"fmstartp\">Page ]] ..\n CurrentRecipePage .. \" of \" ..\n math.ceil(indexCount / recipeLines) ..\n [[</text>]]\n\n if CurrentRecipePage < math.ceil(indexCount / recipeLines) then\n screenOutput = screenOutput .. [[<svg x=\"70\" y=\"1050\">\n <rect x=\"0\" y=\"0\" rx=\"10\" ry=\"10\" width=\"200\" height=\"50\" style=\"fill:]]..RecipeBackgroundColor..[[;\" />\n <svg x=\"80\" y=\"15\"><path d=\"M52.48,35.23,69.6,19.4a3.23,3.23,0,0,0-2.19-5.6H32.59a3.23,3.23,0,0,0-2.19,5.6L47.52,35.23A3.66,3.66,0,0,0,52.48,35.23Z\" transform=\"translate(-29.36 -13.8)\"/></svg>\n </svg>]]\n UpdateClickArea(\"RecipePageDown\", {\n id = \"RecipePageDown\",\n x1 = 70,\n x2 = 270,\n y1 = 1050,\n y2 = 1105\n })\n else\n DisableClickArea(\"RecipePageDown\")\n end\n\n if indexCount > 1 and CurrentRecipePage > 1 then\n screenOutput = screenOutput .. [[<svg x=\"280\" y=\"1050\">\n <rect x=\"0\" y=\"0\" rx=\"10\" ry=\"10\" width=\"200\" height=\"50\" style=\"fill:]]..RecipeBackgroundColor..[[;\" />\n <svg x=\"80\" y=\"15\"><path d=\"M47.52,14.77,30.4,30.6a3.23,3.23,0,0,0,2.19,5.6H67.41a3.23,3.23,0,0,0,2.19-5.6L52.48,14.77A3.66,3.66,0,0,0,47.52,14.77Z\" transform=\"translate(-29.36 -13.8)\"/></svg>\n </svg>]]\n UpdateClickArea(\"RecipePageUp\", {\n id = \"RecipePageUp\",\n x1 = 280,\n x2 = 480,\n y1 = 1050,\n y2 = 1105\n })\n else\n DisableClickArea(\"RecipePageUp\")\n end\n end\n screenOutput = screenOutput ..\n [[<rect x=\"1000\" y=\"150\" rx=\"10\" ry=\"10\" width=\"900\" height=\"]] ..\n ((5 + 1) * 55) ..\n [[\" style=\"fill:]]..\n RecipeBackgroundColor..\n [[;stroke:#ffff00;stroke-width:3;\" />]]\n screenOutput = screenOutput ..\n [[<rect x=\"1010\" y=\"160\" rx=\"5\" ry=\"5\" width=\"890\" height=\"40\" style=\"fill:#33331a;\" />]] \n screenOutput = screenOutput ..\n [[<text x=\"1020\" y=\"191\" class=\"fcapstart\">]].. lastRecipeSelected:map() ..[[ Details</text>]]\n if curRecipe.nm then\n --system.print(\"Cur Recipe: \"..curRecipe.nm)\n ingredList={}\n ingredCList={}\n for i, v in pairs(curRecipe.ip) do\n ingredList[#ingredList+1] = i\n ingredCList[#ingredCList+1] = v\n end\n --system.print(\"Tier: \"..curRecipe.tp)\n screenOutput = screenOutput .. [[<text x=\"1030\" y=\"]] ..\n (180 + 2 * 35) .. [[\" class=\"fmingreddesc\">Time: ]] ..\n string.format(\"%.1f mins\", (curRecipe.tm/60)) .. [[</text>]]\n screenOutput = screenOutput .. [[<text x=\"1500\" y=\"]] ..\n (180 + 2 * 35) .. [[\" class=\"fmingreddesc\">Tier: ]] ..\n string.format(\"%d\", (curRecipe.ti)) .. [[</text>]]\n screenOutput = screenOutput .. [[<text x=\"1030\" y=\"]] ..\n (180 + 3 * 35) .. [[\" class=\"fmingreddesc\">Type: ]] ..\n string.format(\"%s\", curRecipe.tp:map(\" \")) .. [[</text>]]\n screenOutput = screenOutput .. [[<text x=\"1030\" y=\"]] ..\n (180 + 4 * 35) .. [[\" class=\"fmingreddesc\">Mass: ]] ..\n string.format(\"%.2f\", curRecipe.ms) .. [[ kg</text>]]\n screenOutput = screenOutput .. [[<text x=\"1030\" y=\"]] ..\n (180 + 5 * 35) .. [[\" class=\"fmingreddesc\">Volume: ]] ..\n string.format(\"%.2f\", curRecipe.vo) .. [[ l</text>]]\n screenOutput = screenOutput .. [[<text x=\"1030\" y=\"]] ..\n (180 + 6 * 35) .. [[\" class=\"fmingreddesc\">Volume: ]] ..\n string.format(\"%.2f\", curRecipe.op) .. [[ l</text>]]\n\n\n i=1\n industries=\"\"\n indTier=getIndTierDesc(curRecipe.ti-1)\n while curRecipe.nd[i] and not(curRecipe.nd[i]==\"\") do\n if industries == \"\" then\n industries = indTier .. \" \" .. curRecipe.nd[i]:map(\" \",25)\n else\n industries = industries..\", \"..indTier .. \" \" .. curRecipe.nd[i]:map(\" \",25)\n end\n i=i+1\n end\n screenOutput = screenOutput .. [[<text x=\"1030\" y=\"]] ..\n (180 + 7 * 35) .. [[\" class=\"fmingreddesc\">Industry: ]] ..\n string.format(\"%s\", industries) .. [[</text>]]\n end \n screenOutput = screenOutput ..\n [[<rect x=\"1000\" y=\"500\" rx=\"10\" ry=\"10\" width=\"900\" height=\"]] ..\n ((ingredLines + 1) * 55) ..\n [[\" style=\"fill:]]..\n IngredBackgroundColor..\n [[;stroke:#ffff00;stroke-width:3;\" />]]\n screenOutput = screenOutput ..\n [[<rect x=\"1010\" y=\"510\" rx=\"5\" ry=\"5\" width=\"890\" height=\"40\" style=\"fill:#33331a;\" />]] \n screenOutput = screenOutput ..\n [[<text x=\"1020\" y=\"540\" class=\"fcapstart\">Ingredients</text>]]\n screenOutput = screenOutput .. [[<text x=\"1740\" y=\"540\" class=\"fcapendw\">Required</text>]]\n screenOutput = screenOutput .. [[<text x=\"1880\" y=\"540\" class=\"fcapendw\">Stores</text>]]\n\n\n if not(ingredList == nil) and not(ingredList == \"\") then\n --system.print(\"Ingred: \")\n local i = 0\n for j = 1 + (CurrentIngredPage - 1) * ingredLines, ingredLines +\n (CurrentIngredPage - 1) * ingredLines, 1 do\n --system.print(\"IngredList: \"..ingredList[j])\n i = i + 1\n if j <= #ingredList and j>0 then\n --system.print(\"...\"..ingredList[j])\n if lastIngredSelected == ingredList[j] then\n screenOutput = screenOutput ..\n [[<rect x=\"1000\" y=\"]]..(500 + i * 55) .. \n [[\" width=\"900\" height=\"55\"]] ..\n [[\" style=\"fill:]].. HighlightColor .. [[;\" />]]\n end\n\n screenOutput = screenOutput .. [[<text x=\"1030\" y=\"]] ..\n (530 + i * 55) .. [[\" class=\"fmstartg\">]] ..\n string.format(\"%s\", ingredList[j]:map()) .. [[</text>]]\n displayIngredList[i]=ingredList[j]\n screenOutput = screenOutput .. [[<text x=\"1740\" y=\"]] ..\n (530 + i * 55) .. [[\" class=\"fcapend\">]] ..\n string.format(\"%s\", commerise(ingredCList[j])) .. [[</text>]]\n screenOutput = screenOutput .. [[<text x=\"1880\" y=\"]] ..\n (530 + i * 55) .. [[\" class=\"fcapend\">]] ..\n string.format(\"%s\", commerise(getStoreQty(ingredList[j]))) .. [[</text>]]\n\n else\n displayIngredList[i]=\"\"\n end\n end\n if #ingredList > ingredLines then\n screenOutput = screenOutput ..\n [[<text x=\"1020\" y=\"1000\" class=\"fmstartl\">Page ]] ..\n CurrentIngredPage .. \" of \" ..\n math.ceil(#ingredList / ingredLines) ..\n [[</text>]]\n\n if CurrentIngredPage < math.ceil(#ingredList / ingredLines) then\n screenOutput = screenOutput .. [[<svg x=\"1070\" y=\"1050\">\n <rect x=\"0\" y=\"0\" rx=\"10\" ry=\"10\" width=\"200\" height=\"50\" style=\"fill:]]..IngredBackgroundColor..[[;\" />\n <svg x=\"80\" y=\"15\"><path d=\"M52.48,35.23,69.6,19.4a3.23,3.23,0,0,0-2.19-5.6H32.59a3.23,3.23,0,0,0-2.19,5.6L47.52,35.23A3.66,3.66,0,0,0,52.48,35.23Z\" transform=\"translate(-29.36 -13.8)\"/></svg>\n </svg>]]\n UpdateClickArea(\"IngredPageDown\", {\n id = \"IngredPageDown\",\n x1 = 1070,\n x2 = 1270,\n y1 = 1050,\n y2 = 1105\n })\n else\n DisableClickArea(\"IngredPageDown\")\n end\n\n if #ingredList > 1 and CurrentIngredPage > 1 then\n screenOutput = screenOutput .. [[<svg x=\"1280\" y=\"1050\">\n <rect x=\"0\" y=\"0\" rx=\"10\" ry=\"10\" width=\"200\" height=\"50\" style=\"fill:]]..IngredBackgroundColor..[[;\" />\n <svg x=\"80\" y=\"15\"><path d=\"M47.52,14.77,30.4,30.6a3.23,3.23,0,0,0,2.19,5.6H67.41a3.23,3.23,0,0,0,2.19-5.6L52.48,14.77A3.66,3.66,0,0,0,47.52,14.77Z\" transform=\"translate(-29.36 -13.8)\"/></svg>\n </svg>]]\n UpdateClickArea(\"IngredPageUp\", {\n id = \"IngredPageUp\",\n x1 = 1280,\n x2 = 1480,\n y1 = 1050,\n y2 = 1105\n })\n else\n DisableClickArea(\"IngredPageUp\")\n end\n end\n end\n\n screenOutput = screenOutput ..[[<rect x=\"50\" y=\"900\" rx=\"10\" ry=\"10\" width=\"150\" height=\"60\" ]]\n if displayFilter == \"All\" then\n screenOutput = screenOutput .. [[style=\"fill:green;\" />]]\n else\n screenOutput = screenOutput .. [[style=\"fill:#ff6666;\" />]]\n end\n screenOutput = screenOutput .. [[<text x=\"125\" y=\"940\" class=\"fmmiddle\">All</text>]]\n \n screenOutput = screenOutput ..[[<rect x=\"220\" y=\"900\" rx=\"10\" ry=\"10\" width=\"150\" height=\"60\" ]]\n if displayFilter == \"Element\" then\n screenOutput = screenOutput .. [[style=\"fill:green;\" />]]\n else\n screenOutput = screenOutput .. [[style=\"fill:#ff6666;\" />]]\n end\n screenOutput = screenOutput .. [[<text x=\"295\" y=\"940\" class=\"fmmiddle\">Elems</text>]]\n\n screenOutput = screenOutput ..[[<rect x=\"390\" y=\"900\" rx=\"10\" ry=\"10\" width=\"150\" height=\"60\" ]]\n if displayFilter == \"Consumable\" then\n screenOutput = screenOutput .. [[style=\"fill:green;\" />]]\n else\n screenOutput = screenOutput .. [[style=\"fill:#ff6666;\" />]]\n end\n screenOutput = screenOutput .. [[<text x=\"465\" y=\"940\" class=\"fmmiddle\">Cons</text>]]\n\n screenOutput = screenOutput ..[[<rect x=\"560\" y=\"900\" rx=\"10\" ry=\"10\" width=\"150\" height=\"60\" ]]\n if displayFilter == \"Parts\" then\n screenOutput = screenOutput .. [[style=\"fill:green;\" />]]\n else\n screenOutput = screenOutput .. [[style=\"fill:#ff6666;\" />]]\n end\n screenOutput = screenOutput .. [[<text x=\"635\" y=\"940\" class=\"fmmiddle\">Parts</text>]]\n\n screenOutput = screenOutput ..[[<rect x=\"730\" y=\"900\" rx=\"10\" ry=\"10\" width=\"150\" height=\"60\" ]]\n if displayFilter == \"userFilter\" then\n screenOutput = screenOutput .. [[style=\"fill:green;\" />]]\n else\n screenOutput = screenOutput .. [[style=\"fill:#ff6666;\" />]]\n end\n screenOutput = screenOutput .. [[<text x=\"805\" y=\"940\" class=\"fmmiddle\">]]\n ..string.sub(userFilter,1,6)..[[</text>]]\n\n\n -- Screen 3 options\n \n screenOutput = screenOutput ..[[<rect x=\"450\" y=\"980\" rx=\"10\" ry=\"10\" width=\"150\" height=\"60\" ]]\n if s3Filter == \"Ore\" then\n screenOutput = screenOutput .. [[style=\"fill:green;\" />]]\n else\n screenOutput = screenOutput .. [[style=\"fill:blue;\" />]]\n end\n screenOutput = screenOutput .. [[<text x=\"525\" y=\"1020\" class=\"fmmiddle\">Ore</text>]]\n\n screenOutput = screenOutput ..[[<rect x=\"625\" y=\"980\" rx=\"10\" ry=\"10\" width=\"150\" height=\"60\" ]]\n if s3Filter == \"Schema\" then\n screenOutput = screenOutput .. [[style=\"fill:green;\" />]]\n else\n screenOutput = screenOutput .. [[style=\"fill:blue;\" />]]\n end\n screenOutput = screenOutput .. [[<text x=\"700\" y=\"1020\" class=\"fmmiddle\">Schema</text>]]\n\n screenOutput = screenOutput ..[[<rect x=\"800\" y=\"980\" rx=\"10\" ry=\"10\" width=\"150\" height=\"60\" ]]\n if s3Filter == \"Talent\" then\n screenOutput = screenOutput .. [[style=\"fill:green;\" />]]\n else\n screenOutput = screenOutput .. [[style=\"fill:blue;\" />]]\n end\n screenOutput = screenOutput .. [[<text x=\"875\" y=\"1020\" class=\"fmmiddle\">Talent</text>]]\n\n\n screenOutput = screenOutput .. [[</svg>]]\n\n DrawSVG(screenOutput,screen1)\n DrawIngredList()\n --DrawCostScreen(nil)\nend\n\nfunction DrawIngredList()\n local screenOutput = \"\"\n\n -- Draw Header\n screenOutput = screenOutput .. svgBootstrap\n \n -- Draw main background\n screenOutput = screenOutput ..\n [[<rect width=\"1920\" height=\"1120\" style=\"fill: #]]..BackgroundColor..[[\"/><g></g>]]\n screenOutput = screenOutput ..\n [[<text x=\"70\" y=\"120\" class=\"ftitle\">Recipe Ingredients</text>]]\n screenOutput = screenOutput ..\n [[<rect x=\"70\" y=\"150\" rx=\"10\" ry=\"10\" width=\"1500\" height=\"]] ..\n ((17) * 55) ..\n [[\" style=\"fill:]].. IngredBackgroundColor .. [[;stroke:#ffff00;stroke-width:3;\" />]]\n screenOutput = screenOutput ..\n [[<rect x=\"80\" y=\"160\" rx=\"5\" ry=\"5\" width=\"1480\" height=\"40\" style=\"fill:#33331a;\" />]] \n if curIngred.nm then\n screenOutput = screenOutput ..\n [[<text x=\"90\" y=\"191\" class=\"fcapstart\">]]..curIngred.nm:map(\" \")..[[ Ingredient Details</text>]]\n screenOutput = screenOutput .. [[<text x=\"90\" y=\"]] ..\n (180 + 1 * 55) .. [[\" class=\"fmstartg\">Time: ]] ..\n string.format(\"%.1f mins\", (curIngred.tm/60)) .. [[</text>]]\n screenOutput = screenOutput .. [[<text x=\"90\" y=\"]] ..\n (180 + 2 * 55) .. [[\" class=\"fmstartg\">Type: ]] ..\n string.format(\"%s\", curIngred.tp:map(\" \")) .. [[</text>]]\n screenOutput = screenOutput .. [[<text x=\"90\" y=\"]] ..\n (180 + 3 * 55) .. [[\" class=\"fmstartg\">Mass: ]] ..\n string.format(\"%.2f\", curIngred.ms) .. [[ kg</text>]]\n screenOutput = screenOutput .. [[<text x=\"90\" y=\"]] ..\n (180 + 4 * 55) .. [[\" class=\"fmstartg\">Volume: ]] ..\n string.format(\"%.2f\", curIngred.vo) .. [[ l</text>]]\n local i=1\n local industries=\"\"\n indTier=getIndTierDesc(curIngred.ti-1)\n while curIngred.nd[i] and not(curIngred.nd[i]==\"\") do\n if industries == \"\" then\n industries = indTier..\" \"..curIngred.nd[i]:map()\n else\n industries = industries..\", \"..indTier..\" \"..curIngred.nd[i]:map()\n end\n i=i+1\n end\n screenOutput = screenOutput .. [[<text x=\"90\" y=\"]] ..\n (180 + 5 * 55) .. [[\" class=\"fmstartg\">Industry: ]] ..\n string.format(\"%s\", industries) .. [[</text>]]\n \n local i=0\n screenOutput = screenOutput ..\n [[<rect x=\"70\" y=\"490\" rx=\"10\" ry=\"10\" width=\"1500\" height=\"]] ..\n ((17) * 55) ..\n [[\" style=\"fill:]].. IngredBackgroundColor .. [[;stroke:#ffff00;stroke-width:3;\" />]]\n screenOutput = screenOutput ..\n [[<rect x=\"80\" y=\"500\" rx=\"5\" ry=\"5\" width=\"1480\" height=\"40\" style=\"fill:#33331a;\" />]] \n\n screenOutput = screenOutput .. [[<text x=\"90\" y=\"]] ..\n (530) .. [[\" class=\"fcapstart\">Ingredient</text>]]\n screenOutput = screenOutput .. [[<text x=\"1040\" y=\"]] ..\n (530) .. [[\" class=\"fcapendw\">Required</text>]]\n screenOutput = screenOutput .. [[<text x=\"1280\" y=\"]] ..\n (530) .. [[\" class=\"fcapendw\">In Stores</text>]]\n for k,v in pairs(curIngred.ip) do \n i=i+1\n screenOutput = screenOutput .. [[<text x=\"90\" y=\"]] ..\n (530 + i * 55) .. [[\" class=\"fmstartg\">]] ..\n k:map(\" \",25) .. [[</text>]]\n screenOutput = screenOutput .. [[<text x=\"1040\" y=\"]] ..\n (530 + i * 55) .. [[\" class=\"fcapend\">]] ..\n string.format(\"%s\", commerise(v)) .. [[</text>]]\n screenOutput = screenOutput .. [[<text x=\"1280\" y=\"]] ..\n (530 + i * 55) .. [[\" class=\"fcapend\">]] ..\n string.format(\"%s\", commerise(getStoreQty(k))) .. [[</text>]]\n end\n end \n screenOutput = screenOutput .. [[</svg>]]\n DrawSVG(screenOutput,screen2)\nend\n\nfunction DrawCostScreen(oreCost) \n\n local screenOutput = \"\"\n\n -- Draw Header\n screenOutput = screenOutput .. svgBootstrap\n \n -- Draw main background\n screenOutput = screenOutput ..\n [[<rect width=\"1920\" height=\"1120\" style=\"fill: #]]..BackgroundColor..[[\"/><g></g>]]\n screenOutput = screenOutput ..\n [[<text x=\"70\" y=\"120\" class=\"ftitle\">Recipe Unit Cost</text>]]\n screenOutput = screenOutput ..\n [[<rect x=\"70\" y=\"150\" rx=\"10\" ry=\"10\" width=\"1800\" height=\"]] ..\n ((17) * 55) ..\n [[\" style=\"fill:]].. RecipeBackgroundColor .. [[;stroke:#ffff00;stroke-width:3;\" />]]\n screenOutput = screenOutput ..\n [[<rect x=\"80\" y=\"160\" rx=\"5\" ry=\"5\" width=\"1800\" height=\"40\" style=\"fill:#33331a;\" />]] \n screenOutput = screenOutput ..\n [[<text x=\"100\" y=\"191\" class=\"fcapstart\">Ores</text>]]\n screenOutput = screenOutput ..\n [[<text x=\"550\" y=\"191\" class=\"fcapendw\">quantity (l)</text>]]\n screenOutput = screenOutput ..\n [[<text x=\"800\" y=\"191\" class=\"fcapendw\">cost (q)</text>]]\n screenOutput = screenOutput ..\n [[<text x=\"1000\" y=\"191\" class=\"fcapstart\">Ores</text>]]\n screenOutput = screenOutput ..\n [[<text x=\"1450\" y=\"191\" class=\"fcapendw\">quantity (l)</text>]]\n screenOutput = screenOutput ..\n [[<text x=\"1700\" y=\"191\" class=\"fcapendw\">cost (q)</text>]]\n\n if oreCost and not(oreCost==\"\") then\n local totalCost = 0\n local oreList={}\n local priceList={}\n if oreCost.amount[\"Bauxite\"] > 0 then \n oreList[#oreList+1]=\"Bauxite\"\n priceList[#priceList+1]=costBauxite\n end\n if oreCost.amount[\"Quartz\"] > 0 then \n oreList[#oreList+1]=\"Quartz\" \n priceList[#priceList+1]=costQuartz\n end\n if oreCost.amount[\"Hematite\"] > 0 then \n oreList[#oreList+1]=\"Hematite\" \n priceList[#priceList+1]=costHematite\n end\n if oreCost.amount[\"Coal\"] > 0 then \n oreList[#oreList+1]=\"Coal\" \n priceList[#priceList+1]=costCoal\n end\n \n if oreCost.amount[\"Chromite\"] > 0 then \n oreList[#oreList+1]=\"Chromite\" \n priceList[#priceList+1]=costChromite\n end\n if oreCost.amount[\"Malachite\"] > 0 then \n oreList[#oreList+1]=\"Malachite\" \n priceList[#priceList+1]=costMalachite\n end\n if oreCost.amount[\"Limestone\"] > 0 then \n oreList[#oreList+1]=\"Limestone\" \n priceList[#priceList+1]=costLimestone\n end\n if oreCost.amount[\"Natron\"] > 0 then \n oreList[#oreList+1]=\"Natron\" \n priceList[#priceList+1]=costNatron\n end\n \n if oreCost.amount[\"Petalite\"] > 0 then \n oreList[#oreList+1]=\"Petalite\" \n priceList[#priceList+1]=costPetalite\n end\n if oreCost.amount[\"Garnierite\"] > 0 then \n oreList[#oreList+1]=\"Garnierite\" \n priceList[#priceList+1]=costGarnierite\n end\n if oreCost.amount[\"Acanthite\"] > 0 then \n oreList[#oreList+1]=\"Acanthite\" \n priceList[#priceList+1]=costAcanthite\n end\n if oreCost.amount[\"Pyrite\"] > 0 then \n oreList[#oreList+1]=\"Pyrite\" \n priceList[#priceList+1]=costPyrite\n end\n \n if oreCost.amount[\"Cobaltite\"] > 0 then \n oreList[#oreList+1]=\"Cobaltite\" \n priceList[#priceList+1]=costCobaltite\n end\n if oreCost.amount[\"Cryolite\"] > 0 then \n oreList[#oreList+1]=\"Cryolite\" \n priceList[#priceList+1]=costCryolite\n end\n if oreCost.amount[\"Kolbeckite\"] > 0 then \n oreList[#oreList+1]=\"Kolbeckite\" \n priceList[#priceList+1]=costKolbeckite\n end\n if oreCost.amount[\"Gold Nuggets\"] > 0 then \n oreList[#oreList+1]=\"Gold Nuggets\" \n priceList[#priceList+1]=costGold\n end\n\n if oreCost.amount[\"Rhodonite\"] > 0 then \n oreList[#oreList+1]=\"Rhodonite\" \n priceList[#priceList+1]=costRhodonite\n end\n if oreCost.amount[\"Columbite\"] > 0 then \n oreList[#oreList+1]=\"Columbite\" \n priceList[#priceList+1]=costColumbite\n end\n if oreCost.amount[\"Illmenite\"] > 0 then \n oreList[#oreList+1]=\"Illmenite\" \n priceList[#priceList+1]=costIllmenite\n end\n if oreCost.amount[\"Vanadinite\"] > 0 then \n oreList[#oreList+1]=\"Vanadinite\" \n priceList[#priceList+1]=costVanadinite\n end\n\n local ocost=0\n local boldLine=false\n for i=1,#oreList,2 do\n if boldLine then boldLine = false else boldLine = true\n screenOutput = screenOutput ..\n [[<rect x=\"70\" y=\"]]..(200 + (i+1)/2 * 55) .. \n [[\" width=\"1800\" height=\"55\"]] ..\n [[\" style=\"fill:]].. \"#b0fffa\" .. [[;\" />]]\n end\n ocost = oreCost.amount[oreList[i]]*priceList[i]\n totalCost = totalCost + ocost\n screenOutput = screenOutput .. [[<text x=\"100\" y=\"]] ..\n (235 + (i-1)/2 * 55) .. [[\" class=\"fmschema\">]] .. oreList[i].. [[</text>]]\n screenOutput = screenOutput .. [[<text x=\"550\" y=\"]] ..\n (235 + (i-1)/2 * 55) .. [[\" class=\"fmend\">]] .. commerise(string.format(\"%.2f\", oreCost.amount[oreList[i]])) .. [[</text>]]\n screenOutput = screenOutput .. [[<text x=\"800\" y=\"]] ..\n (235 + (i-1)/2 * 55) .. [[\" class=\"fmend\">]] .. commerise(string.format(\"%.0f\", ocost)) .. [[</text>]]\n\n if i+1 <= #oreList and not(oreList[i+1] == nil) then\n ocost = oreCost.amount[oreList[i+1]]*priceList[i+1]\n totalCost = totalCost + ocost\n screenOutput = screenOutput .. [[<text x=\"1000\" y=\"]] ..\n (235 + (i-1)/2 * 55) .. [[\" class=\"fmschema\">]] .. oreList[i+1].. [[</text>]]\n screenOutput = screenOutput .. [[<text x=\"1450\" y=\"]] ..\n (235 + (i-1)/2 * 55) .. [[\" class=\"fmend\">]] .. commerise(string.format(\"%.2f\", oreCost.amount[oreList[i+1]])) .. [[</text>]]\n screenOutput = screenOutput .. [[<text x=\"1700\" y=\"]] ..\n (235 + (i-1)/2 * 55) .. [[\" class=\"fmend\">]] .. commerise(string.format(\"%.0f\", ocost)) .. [[</text>]]\n end\n end\n screenOutput = screenOutput .. [[<text x=\"400\" y=\"]] ..\n (180 + 16 * 55) .. [[\" class=\"ftitle\">TOTAL COST: ]] ..\n commerise(string.format(\"%.0f\", totalCost)) .. [[</text>]]\n\n end \n screenOutput = screenOutput ..\n [[<line stroke-linecap=\"undefined\" stroke-linejoin=\"undefined\" x1=\"990\" y1=\"200\" x2=\"990\" y2=\"1000\" stroke-width=\"2\" stroke=\"#33331a\" fill=\"none\"/>]]\n screenOutput = screenOutput .. [[</svg>]]\n DrawSVG(screenOutput,screen3)\nend\n\nfunction findIndBySchema(schemaName, indSchema)\n --system.print(\"SN:\"..schemaName)\n local schemaWords=schemaName:split()\n --system.print(\"W1:\"..schemaWords[1])\n --system.print(json.encode(indSchema))\n if schemaWords and not(schemaWords==nil) then\n --if schemaWords[2] == \"pure\" then schemaName = schemaWords[2]..\" \"..schemaWords[1] end\n end\n if indSchema then\n for i = 1,#indSchema do\n --system.print(\"SN=\".. schemaName..\", IN=\"..indSchema[i])\n if string.lower(indSchema[i]) == schemaName then \n --system.print(\"Match\")\n return i end\n if string.lower(indSchema[i]) == schemaName .. \" product\" then return i end\n end\n end\n return 0\nend\n\nfunction buildIndStr(indType, indName)\n local pattern = [[.*[[](%d*)[]]..\"]\"..\"]\"\n if string.len(indName) > 10 then \n local startIndex, endIndex, matchStr = string.find(indName, pattern, 1)\n if matchStr then indName = matchStr else indName=string.format(\"%.10s\",indName) end\n end\n \n words=indType:split()\n if words[1] == \"basic\" then classStr = \"B\"\n elseif words[1] == \"uncommon\" then classStr = \"U\"\n elseif words[1] == \"advanced\" then classStr = \"A\"\n elseif words[1] == \"rare\" then classStr = \"R\"\n else classStr = \"X\"\n end\n \n if string.lower(words[2]) == \"electronics\" then typeStr = \"Elec\"\n elseif string.lower(words[2]) == \"metalwork\" then typeStr = \"Met\"\n elseif string.lower(words[2]) == \"glass\" then typeStr = \"Gls\"\n elseif string.lower(words[2]) == \"smelter\" then typeStr = \"Sml\"\n elseif string.lower(words[2]) == \"refiner\" then typeStr = \"Ref\"\n elseif string.lower(words[2]) == \"recycler\" then typeStr = \"Rec\"\n elseif string.lower(words[2]) == \"chemical\" then typeStr = \"Che\"\n elseif string.lower(words[2]) == \"assembler\" then typeStr = \"Ass\"\n elseif string.lower(words[2]) == \"3d\" then typeStr = \"Prt\"\n else typeStr = \"Y\"\n end\n \n return classStr .. typeStr ..\" \"..indName\nend\n\nfunction DrawSchemaScreen(schemaList)\n \n if schemaList then\n table.sort(schemaList)\n \n local screenOutput = \"\"\n if industryInfo and not(industryInfo==\"\" or industryInfo==\"[]\") then\n indUid = extractAllNumberJsonValues(industryInfo,\"uid\")\n indName = extractAllStringJsonValues(industryInfo,\"name\")\n indType = extractAllStringJsonValues(industryInfo,\"type\")\n indState = extractAllStringJsonValues(industryInfo,\"state\")\n indSchema = extractAllStringJsonValues(industryInfo,\"schema\")\n end\n -- Draw Header\n screenOutput = screenOutput .. svgBootstrap\n \n -- Draw main background\n screenOutput = screenOutput ..\n [[<rect width=\"1920\" height=\"1120\" style=\"fill: #]]..BackgroundColor..[[\"/><g></g>]]\n screenOutput = screenOutput ..\n [[<text x=\"70\" y=\"120\" class=\"ftitle\">Schema List</text>]]\n screenOutput = screenOutput ..\n [[<rect x=\"70\" y=\"150\" rx=\"10\" ry=\"10\" width=\"1800\" height=\"]] ..\n ((17) * 55) ..\n [[\" style=\"fill:]].. RecipeBackgroundColor .. [[;stroke:#ffff00;stroke-width:3;\" />]]\n screenOutput = screenOutput ..\n [[<rect x=\"80\" y=\"160\" rx=\"5\" ry=\"5\" width=\"1800\" height=\"40\" style=\"fill:#33331a;\" />]] \n screenOutput = screenOutput ..\n [[<text x=\"100\" y=\"191\" class=\"fcapstart\">Schema</text>]]\n screenOutput = screenOutput ..\n [[<text x=\"950\" y=\"191\" class=\"fcapendw\">Available Ind</text>]]\n screenOutput = screenOutput ..\n [[<text x=\"1000\" y=\"191\" class=\"fcapstart\">Schema</text>]]\n screenOutput = screenOutput ..\n [[<text x=\"1850\" y=\"191\" class=\"fcapendw\">Available Ind</text>]]\n\n\n boldLine=false\n for i=1,#schemaList,2 do\n if boldLine then boldLine = false else boldLine = true\n screenOutput = screenOutput ..\n [[<rect x=\"70\" y=\"]]..(205 + (i+1)/2 * 35) .. \n [[\" width=\"1800\" height=\"35\"]] ..\n [[\" style=\"fill:]].. \"#b0fffa\" .. [[;\" />]]\n end\n\n local schemaName = string.format(\"%.35s\",schemaList[i]:map())\n screenOutput = screenOutput .. [[<text x=\"100\" y=\"]] ..\n (235 + (i-1)/2 * 35) .. [[\" class=\"fmschema\">]] .. schemaName .. [[</text>]]\n local indIndex = findIndBySchema(string.lower(schemaName), indSchema)\n if indIndex and indIndex > 0 then\n screenOutput = screenOutput .. [[<text x=\"950\" y=\"]] ..\n (235 + (i-1)/2 * 35) .. [[\" class=\"fmschemag\">]] ..\n buildIndStr(indType[indIndex], indName[indIndex]) .. [[</text>]] \n end\n screenOutput = screenOutput .. [[</text>]]\n \n if i+1 <= #schemaList and not(schemaList[i+1] == nil) then\n schemaName = string.format(\"%.35s\",schemaList[i+1]:map())\n screenOutput = screenOutput .. [[<text x=\"1000\" y=\"]] ..\n (235 + (i-1)/2 * 35) .. [[\" class=\"fmschema\">]] .. schemaName .. [[</text>]]\n indIndex = findIndBySchema(string.lower(schemaName), indSchema)\n if indIndex and indIndex > 0 then\n screenOutput = screenOutput .. [[<text x=\"1850\" y=\"]] ..\n (235 + (i-1)/2 * 35) .. [[\" class=\"fmschemag\">]] ..\n buildIndStr(indType[indIndex], indName[indIndex]) .. [[</text>]]\n end\n end\n end\n screenOutput = screenOutput ..\n [[<line stroke-linecap=\"undefined\" stroke-linejoin=\"undefined\" x1=\"990\" y1=\"200\" x2=\"990\" y2=\"1100\" stroke-width=\"2\" stroke=\"#33331a\" fill=\"none\"/>]]\n screenOutput = screenOutput .. [[</svg>]]\n DrawSVG(screenOutput,screen3)\n end\nend\n\nfunction DrawTalentScreen(talentList)\n \n local screenOutput = \"\"\n if talentList then\n -- Draw Header\n screenOutput = screenOutput .. svgBootstrap\n \n -- Draw main background\n screenOutput = screenOutput ..\n [[<rect width=\"1920\" height=\"1120\" style=\"fill: #]]..BackgroundColor..[[\"/><g></g>]]\n screenOutput = screenOutput ..\n [[<text x=\"70\" y=\"120\" class=\"ftitle\">Talent Proficiency List</text>]]\n screenOutput = screenOutput ..\n [[<rect x=\"70\" y=\"150\" rx=\"10\" ry=\"10\" width=\"1800\" height=\"]] ..\n ((17) * 55) ..\n [[\" style=\"fill:]].. RecipeBackgroundColor .. [[;stroke:#ffff00;stroke-width:3;\" />]]\n screenOutput = screenOutput ..\n [[<rect x=\"80\" y=\"160\" rx=\"5\" ry=\"5\" width=\"1800\" height=\"40\" style=\"fill:#33331a;\" />]] \n screenOutput = screenOutput ..\n [[<text x=\"100\" y=\"191\" class=\"fcapstart\">Talent</text>]]\n screenOutput = screenOutput ..\n [[<text x=\"600\" y=\"191\" class=\"fcapstart\">Proficiency Level</text>]]\n boldLine=false\n for i=1,#talentList do\n if boldLine then boldLine = false else boldLine = true\n screenOutput = screenOutput ..\n [[<rect x=\"70\" y=\"]]..(200 + i * 55) .. \n [[\" width=\"1800\" height=\"55\"]] ..\n [[\" style=\"fill:]].. \"#b0fffa\" .. [[;\" />]]\n end\n screenOutput = screenOutput .. [[<text x=\"100\" y=\"]] ..\n (235 + i * 55) .. [[\" class=\"fmschema\">]]..talentList[i].ind:map()..[[</text>]]\n screenOutput = screenOutput .. [[<text x=\"700\" y=\"]] ..\n (235 + i * 55) .. [[\" class=\"fmschemag\">]] ..talentList[i].lev .. [[</text>]]\n end\n screenOutput = screenOutput .. [[</svg>]]\n DrawSVG(screenOutput,screen3)\n end\nend\n\n-----------------------------------------------\n-- Execute\n-----------------------------------------------\n\nstartupCycle =0\nsystem.print(\"Loading industry schematic from factory\")\nindustryInfo = getIndustryInfo()\nsystem.print(\"Loading container content from factory\")\nmonitorStock()\nunit.setTimer(\"startup\",1)\nunit.hide()\n","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"3"},{"code":"startupCycle = startupCycle + 1\n\nif startupCycle == 1 then\n loadRecipeIndex()\nelseif startupCycle == 2 then\n loadElementIndex()\nelseif startupCycle == 3 then\n loadConsumableIndex()\nelseif startupCycle == 4 then\n loadPartsIndex()\nelse\n displayIndexList = recipeIndexList\n unit.stopTimer(\"startup\")\n table.sort(recipeIndexList)\n table.sort(elementIndexList)\n table.sort(consumableIndexList)\n table.sort(partsIndexList)\n displayFilter = \"All\"\n s3Filter = \"Ore\"\n indexCount = #displayIndexList\n system.print(\"Startup Complete\")\n InitiateClickAreas()\n CurrentRecipePage=1\n DrawRecipeList()\n CheckClick(0, 0, \"Filter1\")\nend\n\ncollectgarbage(\"collect\")","filter":{"args":[{"value":"startup"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"4"},{"code":"if string.sub(text,1,6) == \"filter\" then\n userFilter = string.sub(text,8,string.len(text))\n CheckClick(0, 0,\"Filter5\")\nend","filter":{"args":[{"variable":"*"}],"signature":"inputText(text)","slotKey":"-2"},"key":"5"}],"methods":[],"events":[]}