value of circuit inputs and outputs as well as settings

Post Reply
GopherAtl
Fast Inserter
Fast Inserter
Posts: 177
Joined: Sat Jan 31, 2015 7:54 pm
Contact:

value of circuit inputs and outputs as well as settings

Post by GopherAtl »

:edit: Sorry, turns out this is a duplicate after all, did a search but somehow missed this thread, which is asking for the same thing just in different words.

currently, with the exception of a "fulfilled" boolean on lamps and smart inserters that tells if the condition is true, we have no ability to access information on the circuit network.

A method that could be called from lua on circuit-enabled objects to get the value of a given signal - specified as, ex, {type="item",name="iron-plate"} or {type="virtual", name="signal-0"} - on a given circuit network connection would be very convenient. Something like:

entity.get_circuit_signal_value(circuit_num, color, signal)

where circuit_num would usually be 1, but could be 1 or 2 for input or output in the case of decider and arithmetic combinators, color is "red" or "green," and signal is a table defining a signal, as I defined earlier, with type and name fields.

Much would become possible even with just this limited read access to the connected circuit networks.

:edit: Just discovered a somewhat hacky work-around to let you read from, or at least, perform arbitrary conditional tests against, the network, by using a lamp or smart inserter, calling set_circuit_condition to change the condition to the desired test, and then calling get_circuit_condition and using the "fulfilled" field, which seems to be re-calculated when get_circuit_condition is called (calling set_circuit_condition and then printing get_circuit_condition(1).fulfilled in a single line in the console gives the fulfilled value for the new condition, at least). This is something, but it is not always a suitable substitute when you actually need the value rather than just to know something about the value. For a mod I want to make I'm tempted to implement a binary search to find the exact value of any 32-bit value in 32 tests, but doing so in on_tick seems ... sub-optimal XD
My Mods:
Nixie Tubes - numeric displays for your circuit networks!
Logistic Combinators - use logistics values in circuit logic! -
Autowire - automate red/green wire connections

Post Reply

Return to “Implemented mod requests”