Skip to content

Math circuits, read/write circuits, more assembly stuff

Rob Nelson requested to merge pull/7172/holey_moley into Bleeding-Edge

Created by: unid15

  • Added math circuits. They perform a variety of math functions, like addition, subtraction, multiplication, division, and even some trigonometry
  • Mostly intended to be used in assembly frames. They can also work as handheld calculators for all spessmen who don't have one in their PDA
  • Result of their calculations may be accessed with comparison circuits
  • Math circuits can only perform one function at a time, however they can have any amount of constant (= number, like 5) or variable (= assembly, like an addition circuit) values. So you can have 5 + 123 + 6203 + 3.14 + 509280, but you can't have 1 - 5 * 6
  • Available functions: addition, subtraction, multiplication, division, power, average value, min, max, cos, sin, acos, asin, tg, cotg
  • It's impossible to create an infinite loop with these things (like C1 = C2 + 1, C2 = C1 - 1)
  • Division by 0 and imaginary numbers cause the circuit to return 0 (so tg90 = 0, instead of a NaN)
  • Refactored comparison circuits to allow both values to be either constant or variable. Also, order in which assemblies are connected to them is no longer important
  • This is how the new comparison circuits look:
  • Now it's possible to make equations like "234 is equal to timer's remaining time", "1 is more than 4", "timer 1's remaining time is less than timer 2's remaining time"
  • **Added read/write circuits. These handy little things can read, store and modify data of other assemblies. When pulsed, they read data of one linked assembly, and write it to another linked assembly.
  • All assemblies have a list of "values" that can be accessed - read or written to. For example, the signalers have: "Code", "Frequency". This means read/write circuits can read and modify signalers' code and frequency. Don't worry, the values are checked and sanitized so it's impossible to do any supernatural things with read/write circuits
  • Assemblies may be pulsed straight from assembly frame's interface (clicking on a P next to the assembly will pulse it)

Other changes:

  • Added get_value() and write_to_value() procs for assemblies that's very cool
  • Added connected() and disconnected() procs for assemblies that are called whenever two assemblies are connected together (be it in an assembly frame, or the old fashioned way)
  • Separated assembly/logic.dm into assembly/logic/addition.dm, assembly/logic/comparison.dm, assembly/logic/math.dm, assembly/logic/randomizer.dm
  • Randomizer circuits can be created at the autolathe (they weren't previously due to an oversight)
  • Voice analyzers can be muted by hitting them with a multitool

Merge request reports