starlit  Diff

Differences From Artifact [b2e1bf9d1b]:

To Artifact [1c1e9dd876]:


   163    163   
   164    164   			::notfound:: do
   165    165   				return
   166    166   			end
   167    167   
   168    168   			::found::
   169    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)
          170  +			local stages = {
          171  +				{id = 'cyclesLeft', decr=ctx.comp.cycles};
          172  +				{id = 'powerLeft', decr=function(current)
          173  +					return ctx.drawCurrent(current, interval, 'compile')
          174  +				end};
          175  +				{id = 'timeLeft', decr=interval};
          176  +				{id = 'numinaLeft', decr=0}; -- FIXME
          177  +			}
          178  +
          179  +			for i,v in ipairs(stages) do
          180  +				if job[v.id] > 0 then
          181  +					local decr
          182  +					if type(v.decr) == 'function'
          183  +						then decr = v.decr(job[v.id])
          184  +						else decr = v.decr
          185  +					end
          186  +					job[v.id] = math.max(0, job[v.id] - decr)
          187  +					goto incomplete
          188  +				end
   173    189   			end
   174         -			if job.timeLeft == 0 and job.cyclesLeft == 0 then
          190  +
          191  +			::complete:: do
   175    192   				table.remove(conf, jobSlot)
   176    193   				user:give(scm.output)
   177    194   				user:alarm(-2, 'item')
   178         -			else
          195  +				goto done
          196  +			end
          197  +
          198  +			::incomplete:: do
   179    199   				conf[jobSlot].value = job_t.enc(job)
   180    200   			end
   181    201   
          202  +			::done::
   182    203   			ctx.saveConf()
   183    204   		end;
   184    205   	}
   185    206   end
   186    207   
   187    208   starlit.item.sw.link('starlit_electronics:compile_commune', matterCompiler {
   188    209   	name = 'Compile Matter';