Differences From
Artifact [c28c8fe2b6]:
39 39 -- crafting, while programs require a certain amount of memory.
40 40 -- chips have a variable number of program slots and a single bootloader slot
41 41 --
42 42 starlit.item.chip = lib.registry.mk 'starlit_electronics:chip'
43 43
44 44 -- software is of one of the following types:
45 45 -- schematic: program for your matter compiler that enables crafting a given item.
46 --- output: the result
46 +-- output (convertible to ItemStack): the result
47 47 -- driver: inserted into a Core to control attached hardware
48 48 -- suitPower: provides suit functionality like nanoshredding or healing
49 49 -- passive powers are iterated on suit application/configuration and upon fst-tick
50 50 -- cost: what the software needs to run. some fields are fab-specific
51 51 -- energy: for fab, total energy cost of process in joules
52 52 -- for suitPassive, added suit power consumption in watts
53 53 starlit.item.sw = lib.registry.mk 'starlit_electronics:sw'
................................................................................
214 214 inventory_image = def.img or 'starlit-item-battery.png';
215 215 description = starlit.ui.tooltip {
216 216 title = def.name;
217 217 desc = def.desc;
218 218 color = lib.color(0,.2,1);
219 219 props = {
220 220 { title = 'Optimal Capacity', affinity = 'info';
221 - desc = lib.math.si('J', def.capacity) };
221 + desc = lib.math.siUI('J', def.capacity) };
222 222 { title = 'Discharge Rate', affinity = 'info';
223 - desc = lib.math.si('W', def.dischargeRate) };
223 + desc = lib.math.siUI('W', def.dischargeRate) };
224 224 { title = 'Charge Efficiency', affinity = 'info';
225 225 desc = string.format('%s%%', (1-def.leak) * 100) };
226 226 { title = 'Size', affinity = 'info';
227 - desc = lib.math.si('m', def.fab.size.print) };
227 + desc = lib.math.siUI('m', def.fab.size.print) };
228 228 };
229 229 };
230 230 _starlit = {
231 231 event = {
232 232 create = function(st, how)
233 233 --[[if not how.gift then -- cheap hack to make starting batteries fully charged
234 234 E.battery.setCharge(st, 0)
................................................................................
274 274 -- eluthrai ("uncompromising"): high power, high quality, wildly expensive
275 275 -- firstborn ("god-tier"): exceptional
276 276
277 277 local batteryTiers = {
278 278 makeshift = {
279 279 name = 'Makeshift'; capacity = .5, decay = 3, leak = 2, dischargeRate = 1,
280 280 fab = starlit.type.fab {
281 - metal = {copper=10};
281 + element = {copper=10};
282 282 };
283 283 desc = "Every attosecond this electrical abomination doesn't explode in your face is but the unearned grace of the Wild Gods.";
284 284 complexity = 1;
285 285 sw = {rarity = 1};
286 286 };
287 287 imperial = {
288 288 name = 'Imperial'; capacity = 2, decay = 2, leak = 2, dischargeRate = 2;
289 289 fab = starlit.type.fab {
290 - metal = {copper=15, iron = 20};
290 + element = {copper=15, iron = 20};
291 291 size = { print = 0.1 };
292 292 };
293 293 desc = "The Empire's native technology is a lumbering titan: bulky, inefficient, unreliable, ugly, and awesomely powerful. Their batteries are no exception, with raw capacity and throughput that exceed even Usukinwya designs.";
294 294 drm = 1;
295 295 complexity = 2;
296 296 sw = {rarity = 2};
297 297 };
298 298 commune = {
299 299 name = 'Commune'; capacity = 1, decay = .5, leak = .2, dischargeRate = 1;
300 300 fab = starlit.type.fab {
301 - metal = {vanadium=50, steel=10};
301 + element = {vanadium = 50};
302 + metal = {steel=10};
302 303 size = { print = 0.05 };
303 304 };
304 305 desc = "The Commune's proprietary battery designs prioritize reliability, compactness, and maintenance concerns above raw throughput, with an elegance of engineering and design that would make a Su'ikuri cry.";
305 306 complexity = 5;
306 307 sw = {rarity = 3};
307 308 };
308 309 usukwinya = {
309 310 name = 'Usukwinya'; capacity = 2, decay = 1, leak = 1, dischargeRate = 1.5,
310 311 fab = starlit.type.fab {
311 - metal = {vanadium=30, argon=10};
312 + element = {argon=10};
313 + metal = {vanadium=30};
312 314 size = { print = 0.07 };
313 315 };
314 316 desc = "A race of consummate value engineers, the Usukwinya have spent thousands of years refining their tech to be as cheap to build as possible, without compromising much on quality. The Tradebirds drive an infamously hard bargain, but their batteries are more than worth their meagre cost.";
315 317 drm = 2;
316 318 sw = {rarity = 10};
317 319 complexity = 15;
318 320 };
319 321 eluthrai = {
320 322 name = 'Eluthrai'; capacity = 3, decay = .4, leak = .1, dischargeRate = 1.5,
321 323 fab = starlit.type.fab {
322 - metal = {beryllium=20, platinum=20, technetium = 1, cinderstone = 10 };
324 + element = {beryllium=20, platinum=20, technetium = 1};
325 + metal = {cinderstone = 10};
323 326 size = { print = 0.03 };
324 327 };
325 328 desc = "The uncompromising Eluthrai are never satisfied until every quantifiable characteristic of their tech is maximally optimised down to the picoscale. Their batteries are some of the best in the Reach, and unquestionably the most expensive -- especially for those lesser races trying to copy the designs without the benefit of the sublime autofabricator ecosystem of the Eluthrai themselves.";
326 329 complexity = 200;
327 330 sw = {rarity = 0}; -- you think you're gonna buy eluthran schematics on SuperDiscountNanoWare.space??
328 331 };
329 332 firstborn = {
330 333 name = 'Firstborn'; capacity = 5, decay = 0.1, leak = 0, dischargeRate = 3;
331 334 fab = starlit.type.fab {
332 - metal = {neodymium=20, xenon=150, technetium=5, sunsteel = 10 };
335 + element = {neodymium=20, xenon=150, technetium=5};
336 + metal = {sunsteel = 10};
333 337 crystal = {astrite = 1};
334 338 size = { print = 0.05 };
335 339 };
336 340 desc = "Firstborn engineering seamlessly merges psionic effects with a mastery of the physical universe unattained by even the greatest of the living Starsouls. Their batteries reach levels of performance that strongly imply Quantum Gravity Theory -- and several major holy books -- need to be rewritten. From the ground up.";
337 341 complexity = 1000;
338 342 sw = {rarity = 0}; -- lol no
339 343 };
................................................................................
367 371
368 372 complexity = 3;
369 373 };
370 374 chemical = {
371 375 name = 'Chemical';
372 376 desc = '';
373 377 fab = starlit.type.fab {
374 - element = { lithium = 3};
375 - metal = {iron = 5};
378 + element = { lithium = 3 };
376 379 size = {print=1.0};
377 380 };
378 381 sw = {
379 382 cost = {
380 383 cycles = 1e9; -- 1 bil cycles
381 384 ram = 2e9; -- 2GB
382 385 };
................................................................................
409 412 };
410 413 hybrid = {
411 414 name = 'Hybrid';
412 415 desc = '';
413 416 capacity = 1;
414 417 fab = starlit.type.fab {
415 418 element = {
416 - lithium = 3;
417 - };
418 - metal = {
419 - iron = 5;
419 + lithium = 10;
420 + carbon = 20;
420 421 };
421 422 size = {print=1.5};
422 423 };
423 424 sw = {
424 425 cost = {
425 426 cycles = 65e9; -- 65 bil cycles
426 427 ram = 96e9; -- 96GB
................................................................................
500 501 else
501 502 rare = bType.sw.rarity + bTier.sw.rarity
502 503 end
503 504
504 505 starlit.item.sw.link(swID, {
505 506 kind = 'schematic';
506 507 name = name .. ' Schematic';
508 + input = fab;
507 509 output = id;
508 510 size = bType.sw.pgmSize;
509 511 cost = bType.sw.cost;
510 512 rarity = rare;
511 513 })
512 514
513 515 E.schematicGroupLink('starlit_electronics:battery', swID)
................................................................................
686 688 data = {}
687 689 defOnly = true
688 690 end
689 691 def = assert(def._starlit.chip)
690 692 end
691 693 local props = {
692 694 {title = 'Clock Rate', affinity = 'info';
693 - desc = lib.math.si('Hz', def.clockRate)};
695 + desc = lib.math.siUI('Hz', def.clockRate)};
694 696 {title = 'RAM', affinity = 'info';
695 - desc = lib.math.si('B', def.ram)};
697 + desc = lib.math.siUI('B', def.ram)};
696 698 }
697 699 if not defOnly then
698 700 table.insert(props, {
699 701 title = 'Free Storage', affinity = 'info';
700 - desc = lib.math.si('B', E.chip.freeSpace(ch, data)) .. ' / '
701 - .. lib.math.si('B', def.flash);
702 + desc = lib.math.siUI('B', E.chip.freeSpace(ch, data)) .. ' / '
703 + .. lib.math.siUI('B', def.flash);
702 704 })
703 705 local swAffMap = {
704 706 schematic = 'schematic';
705 707 suitPower = 'ability';
706 708 driver = 'driver';
707 709 }
708 710 for i, e in ipairs(data.files) do
................................................................................
730 732 affinity = aff;
731 733 desc = name;
732 734 })
733 735 end
734 736 else
735 737 table.insert(props, {
736 738 title = 'Flash Storage', affinity = 'info';
737 - desc = lib.math.si('B', def.flash);
739 + desc = lib.math.siUI('B', def.flash);
738 740 })
739 741 end
740 742 return starlit.ui.tooltip {
741 743 title = data.label and data.label~='' and string.format('<%s>', data.label) or def.name;
742 744 color = lib.color(.6,.6,.6);
743 745 desc = def.desc;
744 746 props = props;
................................................................................
782 784 local circMat = t.circ or 'silicon';
783 785 starlit.item.chip.link(id, {
784 786 name = t.name;
785 787 clockRate = t.clockRate;
786 788 flash = t.flash;
787 789 ram = t.ram;
788 790 powerEfficiency = t.powerEfficiency; -- cycles per joule
789 - fab = {
791 + fab = starlit.type.fab {
790 792 flag = {
791 793 silicompile = true;
792 794 };
793 795 time = {
794 796 silicompile = t.size * 24*60;
795 797 };
796 798 cost = {
................................................................................
866 868 end;
867 869 open = function(self,fn)
868 870 return E.chip.fileOpen(self.chip, self.inode, fn)
869 871 end;
870 872 };
871 873 }
872 874
873 -function E.chip.usableSoftware(chips,pgm)
875 +function E.chip.usableSoftware(chips,pgm,pred)
876 + pred = pred or function() return true end
874 877 local comp = E.chip.sumCompute(chips)
875 878 local r = {}
876 879 local unusable = {}
877 880 local sw if pgm then
878 881 if type(pgm) == 'string' then
879 882 pgm = {starlit.item.sw.db[pgm]}
880 883 end
................................................................................
895 898 end
896 899 end
897 900 end
898 901 end
899 902 end
900 903
901 904 for _, s in pairs(sw) do
902 - if s.sw.cost.ram <= comp.ram then
905 + if s.sw.cost.ram <= comp.ram and pred(s) then
903 906 table.insert(r, {
904 907 sw = s.sw;
905 908 chip = s.chip, chipSlot = s.chipSlot;
906 909 file = s.file;
907 910 fd = E.chip.fileHandle(s.chip, s.inode);
908 911 speed = s.sw.cost.cycles / comp.cycles;
909 912 powerCost = s.sw.cost.cycles / comp.powerEfficiency;