tModLoader MechScope - Wiring visualized

Discussion in 'Released' started by DRKV, Jul 2, 2018.

  1. DRKV

    DRKV Spazmatism

    In my opinion, there is one big issue with wiring. You can’t really SEE what is actually going on. Everything happens instantly once you flip the switch. This isn’t a big deal if you just want to build simpler door mechanisms or traps, but when you have a huge chain of logic gates, things will quickly become rather confusing… To resolve this problem, I have created MechScope, a TModLoader mod that can pause and visualize the wiring execution process.

    How does it work?
    There are 4 hotkeys you can use to control MechScope. They can be remapped in the vanilla controls menu.

    [​IMG]

    Toggle (NumPad1)
    Activates or deactivates MechScope. While active, any wire trigger will be intercepted and paused. The state of the wiring system will be displayed based on the visual settings.​

    Step (NumPad2)
    Advances the wiring system by one step. The granularity of the steps depends the mode setting.​

    Auto-step (NumPad3)
    Activates or deactivates the automatic step timer. When active, a step will happen once the number of frames indicated by the auto step rate have passed.​

    Settings (NumPad5)
    Opens the settings menu.​

    Mouse indicator
    The small squares next to your cursor indicate the state of the mod.
    • Yellow square: MechScope is active
    • Red square: MechScope is active, and wiring is currently paused
    • Green square: auto-step is active.
    [​IMG] [​IMG]

    While the wiring system is paused, additional wire triggers will be queued up, and will only run once the current wire iteration has finished. Timers will also be paused.

    [​IMG]

    [​IMG]

    Mode
    The mode setting determines when the wring gets paused during the execution process.

    Single
    The wiring system will be paused after examining every individual block.
    [​IMG]

    Wire
    The wiring will pause after processing a whole run of wires. Red, blue, green and yellow wires will all appear separately.
    [​IMG]

    Source
    Wiring will be paused after handling all wires connected to a trigger source.
    [​IMG]

    Stage
    Wiring will only be paused before processing logic gates, that had their lamps toggled. This mode lets you find logic gate “delay” based issues easily.
    [​IMG]

    Visuals
    The source of the wire signal that is currently being processed is marked with a red border. In single mode, the tile that is currently being examined will also have a similar border. Triggered wires will be marked with a square with the same color as the wire.

    Wire skip
    Marks tiles, that have been explicitly flagged to skip wire activations on, with a red ‘X’. This usually happens when multi tile objects are triggered, such as statues. (There is currently a bug in the game, that causes certain objects to not skip wires, if a previous wire color has already executed.) Wire skip marks will only work in Single mode.​

    Gates done
    Marks gates with a white ‘X’ if they have already triggered during the current wire iteration. If triggered again, these gates won't emit a signal, they will only make a puff of smoke.​

    Upcoming gates
    These are the gates that had their state changed, and are currently waiting for their turn to output a signal. They are marked by a red ‘O’.​

    Triggered lamps
    These lamps, marked by an orange ‘?’, were triggered, but the state of their gate has not been evaluated yet. This will not display in Stage mode.​

    Triggered teleporters
    A white number will show next to activated teleporters, indicating which wire they were triggered by.​
    • 1 = red
    • 2 = blue
    • 3 = green
    • 4 = yellow
    These numbers also tell you what order the teleportations will happen in. This only works in Source or Stage mode.​

    Triggered pumps
    Numbers pumps based on the order they were activated in. Red is input, green is output.​

    I listed these markers in the order in which they are drawn. If a tile has two different markers on it, only the one further down the list will be shown.

    Auto-step rate
    This number indicates how many frames have to pass before an automatic step happens. A setting of 30 means one step will happen once every half a second.

    Compatibility
    This mod does not affect the way wiring actually works, so all wiring devices should function as normal, unless they rely on other game aspect, such as HOIK actors. This mod should also be compatible with other wring related mods. MechScope currently does not work in multiplayer. I don't really see many people interested in this feature, but if there's a demand for it, I can probably make it work.

    Technical details
    So, you might be asking, how is this even possible in TModLoader? To make this mod, I used a library know as Harmony. Harmony can apply patches to managed code at any point during runtime. It can even interoperate with other instances of itself, allowing multiple mods to patch the same methods. Harmony is commonly used to mod various games based on the Unity engine.

    Download
    As usual, the mod can be downloaded from the TModLoader Mod Browser or from GitHub, where you'll also find the source code.
    https://github.com/DRKV333/MechScope/
     
    Last edited: Oct 19, 2018
  2. temery2383

    temery2383 Skeletron Prime

    This is so cool! Is this the thing you had mentioned on the Mechmod thread?
     
  3. Lord Peredur S.Taralian I

    Lord Peredur S.Taralian I Eye of Cthulhu

    Am I the only one who has read this entire topic three times and understood nothing? :(
    I'll try one more time haha, sounds interesting!
     
  4. DRKV

    DRKV Spazmatism

    Indeed. :)
    Just play around with it bit, it will make a lot more sense. I described things very technically, you'd probably need to look at the actual wiring code, to understand most of it. You can check out this guide on to T-MEC to learn more about wiring and the order in which things happen. https://forums.terraria.org/index.p...operations-smoke-and-how-to-prevent-it.44020/
     
  5. DRKV

    DRKV Spazmatism

    I've fixed a few issues, and the mod is now officially available on the Mod Browse. :happy:
    Also, something I should have probably mentioned in the OP:
     
  6. SovereignVis

    SovereignVis Terrarian

    This is very interesting. When ever I'm doing wiring I always picture in my mind a pulse of energy flowing through the wires to trigger things. But this mod shows you what is happening and in the order they happen. I think this would be a good tool for teaching a lot of people who don't understand wiring how to wire.
     
    temery2383 and DRKV like this.
  7. putianyi888

    putianyi888 Terrarian

    Incredible work. I have some ideas that you may add to this mod.
    • Logic Lamp Rod: functions like actuator rod, but affects logic lamps. It can switch logic lamps' states without activating any wire. It would be very useful if some logic lamps have wrong states and one have to change their states with no need to replace all logic lamps stacked above it. Its upgraded version is Activating Rod, which can activate any tile that can be activated except actuator.
    • I don't know how to name this item. it works like Grand Design, but places logic gates and logic lamps instead of wires and actuators. It works when a variety of logic gates and logic lamps take too much space of the hotbar, while there are many other items to be used often.
    • A hammer that can hammer hoiks while cannot hammer background walls.
    • I wonder if you can coop with MechMod developers and bring some features from MechMod. It is a pity that MechMod is not compatible with TModLoader.
    • A sponge that can absorb all kinds of liquids.
    • Move a tile with wires connecting to it. Many restrictions on moving are needed to avoid bugs.
    • Paint Gun: functions like clentaminator, but uses paints as ammo.
     
  8. SovereignVis

    SovereignVis Terrarian

    Before 1.3.1 came out I had already made many suggestions for stuff in 1.3.1 and one was a "Chisel" which would basically do what you said about the hammer for hoiks.
    But maybe right-click could effect the background walls.

    SovereignVis's Many Suggestions for 1.3.1
     
  9. putianyi888

    putianyi888 Terrarian

    That's amazing. Many suggestions have come true.
    It is annoying when hammers break walls while making hoiks, because I have to replace the walls or even repaint the walls. That's why I want this hammer.
     
  10. DRKV

    DRKV Spazmatism

    Yay, thank you! :happy: I worked quite hard on this one, but it looks like not very many people are interested. Thought I am glad at least some people care.

    Yes, I was thinking about something like this too. It would be incredibly useful.

    Hmm... I guess it could work, but I would probably have to rethink the radial ui a bit. I find the grand design is a bit clunky with it's toggles.

    Vipix' toolbox has a thing like that, though is doesn't work too great with hoiks.

    Possibly. MechMod is now open source, so they would probably be okay with that. I'd have to find a smarter way to apply different pathches to terraria's code, because right now it is kinda manual, and not very maintainable.
    This might be problematic as I currently really don't have the time to work on a bigger project like this...

    Should be simple.

    Do you mean like a copy/paste thing? Cause cheat sheat has that and it works pretty well. Or do you mean like a smart wire router sort of thing? That would be interesting...

    Vipix' toolbox does have a paint pallet. There is also Better Paint, but I believe that one uses a custom way to tint blocks instead of the vanilla paint.
     
    Last edited: Oct 19, 2018
  11. putianyi888

    putianyi888 Terrarian

    Thanks for introducing the toolbox to me!
    Yep. I hope that wires connected to the tile can be stretched to wherever the tile goes.
    That does not matter. I would appreciate MechScope even if it would not be updated anymore. It helps a lot when I have to explain to others how my mechanisms work.