starlit  Diff

Differences From Artifact [da2672ba3c]:

To Artifact [1f9bdf2a9e]:


   133    133   	cost = {
   134    134   		cycles = 100e6;
   135    135   		ram = 500e6;
   136    136   	};
   137    137   	run = shredder{range=3, powerDraw=200};
   138    138   })
   139    139   
   140         -starlit.item.sw.link('starlit_electronics:compile_commune', {
          140  +local function matterCompiler(desc)
          141  +	return {
          142  +		name = desc.name;
          143  +		kind = 'suitPower', powerKind = 'direct';
          144  +		desc = desc.desc;
          145  +		size = desc.size;
          146  +		cost = desc.cost;
          147  +		ui = 'starlit:compile-matter-component';
          148  +		bgProc = function(user, ctx, interval, runState)
          149  +			if runState.flags.compiled == true then return false end
          150  +			-- only so many nanides to go around
          151  +			runState.flags.compiled = true
          152  +
          153  +			local conf = ctx.file.body.conf
          154  +			local job_t = starlit.store.compilerJob
          155  +			local job, jobSlot
          156  +			for i, v in ipairs(conf) do
          157  +				if v.key == 'job' then
          158  +					job = job_t.dec(v.value)
          159  +					jobSlot = i
          160  +					goto found
          161  +				end
          162  +			end
          163  +
          164  +			::notfound:: do
          165  +				return
          166  +			end
          167  +
          168  +			::found::
          169  +			local scm = starlit.item.sw.db[job.schematic]
          170  +			job.cyclesLeft = math.max(0, job.cyclesLeft - ctx.comp.cycles)
          171  +			if job.cyclesLeft == 0 then
          172  +				job.timeLeft = math.max(0, job.timeLeft - interval)
          173  +			end
          174  +			if job.timeLeft == 0 and job.cyclesLeft == 0 then
          175  +				table.remove(conf, jobSlot)
          176  +				user:give(scm.output)
          177  +			else
          178  +				conf[jobSlot].value = job_t.enc(job)
          179  +			end
          180  +
          181  +			ctx.saveConf()
          182  +		end;
          183  +	}
          184  +end
          185  +
          186  +starlit.item.sw.link('starlit_electronics:compile_commune', matterCompiler {
   141    187   	name = 'Compile Matter';
   142         -	kind = 'suitPower', powerKind = 'direct';
   143    188   	desc = "A basic suit matter compiler program. It's rather slow, but it's been ruthlessly optimized for size- and memory-efficiency by some of the Commune's most fanatic coders, to the point where every Commune nanosuit can come with the program preinstalled.";
   144    189   	size = 700e3;
   145    190   	cost = {
   146    191   		cycles = 4e9;
   147    192   		ram = .3e9;
   148    193   	};
   149         -	ui = 'starlit:compile-matter-component';
   150         -	run = function(user, ctx)
   151         -	end;
   152    194   })
   153    195   
   154    196   starlit.item.sw.link('starlit_electronics:compile_block_commune', {
   155    197   	name = 'Compile Block';
   156    198   	kind = 'suitPower', powerKind = 'active';
   157    199   	desc = "An advanced suit matter compiler program, capable of printing complete devices and structure parts directly into the world.";
   158    200   	size = 5e6;
................................................................................
   161    203   		ram = 1e9;
   162    204   	};
   163    205   	ui = 'starlit:compile-matter-block';
   164    206   	run = function(user, ctx)
   165    207   	end;
   166    208   })
   167    209   
   168         -starlit.item.sw.link('starlit_electronics:compile_imperial', {
          210  +starlit.item.sw.link('starlit_electronics:compile_imperial', matterCompiler {
   169    211   	name = 'Genesis Deluxe';
   170         -	kind = 'suitPower', powerKind = 'direct';
   171    212   	desc = "House Bascundir has long dominated the matter compiler market in the Crystal Sea. Their firmware is excessively complex due to mountains of specialized edge-case handling, but the end result is certainly speedier than the competitors'.";
   172    213   	size = 2e4;
   173    214   	cost = {
   174    215   		cycles = 100e6;
   175    216   		ram = 1.5e9;
   176    217   	};
   177         -	ui = 'starlit:compile-matter-component';
   178         -	run = function(user, ctx)
   179         -	end;
   180    218   })
   181    219   
   182    220   do local J = starlit.store.compilerJob
   183    221   	starlit.item.sw.link('starlit_electronics:driver_compiler_commune', {
   184    222   		name = 'Matter Compiler';
   185    223   		kind = 'driver';
   186    224   		desc = "A driver for a standalone matter compiler, suitable for building larger components than your suit alone can handle.";
................................................................................
   188    226   		cost = {
   189    227   			cycles = 400e6;
   190    228   			ram = .2e9;
   191    229   		};
   192    230   		ui = 'starlit:device-compile-matter-component';
   193    231   		run = function(user, ctx)
   194    232   		end;
          233  +		--[[
   195    234   		bgProc = function(user, ctx, interval, runState)
   196    235   			if runState.flags.compiled == true then return false end
   197    236   			-- only so many nanides to go around
   198    237   			runState.flags.compiled = true
   199    238   			local time = minetest.get_gametime()
   200    239   			local cyclesLeft = ctx.comp.cycles * interval
   201    240   
................................................................................
   232    271   					else
   233    272   						e.value = J.enc(t)
   234    273   					end
   235    274   					if not cyclesLeft > 0 then break end
   236    275   				end
   237    276   			end
   238    277   			ctx.saveConf()
   239         -		end;
          278  +		end;]]
   240    279   	})
   241    280   end
   242    281   
   243    282   local function pasv_heal(effect, energy, lvl, pgmId)
   244    283   	return function(user, ctx, interval, runState)
   245    284   		if runState.flags.healed == true then return false end
   246    285   		-- competing nanosurgical programs?? VERY bad idea