starlit  Diff

Differences From Artifact [b2e1bf9d1b]:

To Artifact [1c1e9dd876]:


163
164
165
166
167
168
169
170
171














172

173
174



175
176
177
178




179
180
181

182
183
184
185
186
187
188

			::notfound:: do
				return
			end

			::found::
			local scm = starlit.item.sw.db[job.schematic]
			job.cyclesLeft = math.max(0, job.cyclesLeft - ctx.comp.cycles)
			if job.cyclesLeft == 0 then














				job.timeLeft = math.max(0, job.timeLeft - interval)

			end
			if job.timeLeft == 0 and job.cyclesLeft == 0 then



				table.remove(conf, jobSlot)
				user:give(scm.output)
				user:alarm(-2, 'item')
			else




				conf[jobSlot].value = job_t.enc(job)
			end


			ctx.saveConf()
		end;
	}
end

starlit.item.sw.link('starlit_electronics:compile_commune', matterCompiler {
	name = 'Compile Matter';







|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
<
>
>
>



<
>
>
>
>



>







163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188

189
190
191
192
193
194

195
196
197
198
199
200
201
202
203
204
205
206
207
208
209

			::notfound:: do
				return
			end

			::found::
			local scm = starlit.item.sw.db[job.schematic]
			local stages = {
				{id = 'cyclesLeft', decr=ctx.comp.cycles};
				{id = 'powerLeft', decr=function(current)
					return ctx.drawCurrent(current, interval, 'compile')
				end};
				{id = 'timeLeft', decr=interval};
				{id = 'numinaLeft', decr=0}; -- FIXME
			}

			for i,v in ipairs(stages) do
				if job[v.id] > 0 then
					local decr
					if type(v.decr) == 'function'
						then decr = v.decr(job[v.id])
						else decr = v.decr
					end
					job[v.id] = math.max(0, job[v.id] - decr)
					goto incomplete
				end

			end

			::complete:: do
				table.remove(conf, jobSlot)
				user:give(scm.output)
				user:alarm(-2, 'item')

				goto done
			end

			::incomplete:: do
				conf[jobSlot].value = job_t.enc(job)
			end

			::done::
			ctx.saveConf()
		end;
	}
end

starlit.item.sw.link('starlit_electronics:compile_commune', matterCompiler {
	name = 'Compile Matter';