Logic World Wednesdays: Labels & Grids

by @MouseHatGames 2019-07-18
Label UI - Jimmy

Labels are blocks with editable text on them. I added them to Logic World a while ago, but there hasn’t been an in-game way of editing them. This week I finally added that menu, as well as the ability to change the labels’ color!

Grid Placing - Jimmy

Grid Placing is a new feature that lets you quickly place many components in a grid.

One of my goals with Logic World is to make the building mechanics fast and easy to use, and Grid Placing is a big part of that!

C# to JS - Felipe

I’m finally back from vacation! Unfortunately I’m going to have less time for LW stuff as I’ll be busy with school, however this week I did have time to add something to my vue-aspvalidate library: as you may remember from my last LWW section in order to, say, validate an email there has to be a snippet of C# code that validates it in the back-end and a snippet of JS that validates it on the front end, which meant writing duplicate code for each kind of validation. This is obviously less than ideal as you’re writing everything twice, so I set on to find a way to take C# code and translate and send it to the client.

I arrived at a solution using the wonderful LINQ Expressions API in C# that lets you pass a method a lambda (i.e. value => value.Length > 10) and then go through it using an ExpressionVisitor, which lets you see the lambda as a regular C# object of a type derived from Expression. For example, the previous example would call the VisitBinary method on your visitor, which in turn lets you visit the left and right sides of the > operator and so on.

This means that a single-line validator like value => value[2] == ‘@’ && value.StartsWith(“lol”) || Regex.IsMatch(value, “.*?%$”) gets translated to the JS code value => value[2] == “@” && value.startsWith(“lol”) || new RegExp(“.*?%$”).test(value). As you can see, some BCL methods get translated to their JS counterparts, allowing me to write complex validators without worrying about writing any JS code!


If you’d like to receive an email each time we post one of these blogs, you can sign up for our newsletter. Be sure also to wishlist Logic World on Steam and join the official Discord.

See you next Wednesday!


8 comments
@shamus030 2019-07-18

Awesome! Grid placement looks really useful, and converting C# to JS is a crazy idea! I would love to be able to fully translate C# into JavaScript for most of the things I make (for similar reasons - run the logic on the UI so it’s fast, but still redo the work in the controlled backend), but I’m sure it will never be 100% capable.

Any thoughts on adding programmable labels? For example changing a label’s text from “add” to “subtract” when on/off? Maybe something similar as tooltip/hover text for a switch?

@Jimmy 2019-07-18

My concern with programmable labels is that it would make any player-made displays totally obsolete. It would make a great mod, but for vanilla any circuit’s text output will need to be done manually.

@woox2k 2019-07-22

But what about making just toggleable labels? I have always wondered why do we need separate displays and label blocks to describe what the lights mean. Why not allow us to make a labeldisplay that has low contrast text when turned off and high contrast when turned on… Like real life indicator panels…

@Jimmy 2019-07-25

This would be a super cool mod but for vanilla I think I want to keep labels and displays as separate components. You can stick a display next to a label, and light up that display when you want to draw attention to the label’s text.

@shamus030 2019-07-20

Thanks for the reply! I agree.

Also, having used some other non-game-related circuit simulation programs (LogicCircuit is my favorite, but I’ve used LogiSim and a couple of others), multi-bit cables (essentially ribbon cables) are a pretty popular and useful feature I’ve seen. I’m interested to hear your opinion on that too. My hope is that grid placement will render that totally unnecessary, although it would definitely be useful to reduce the number of wires whenever a signal has to travel a significant distance between components.

@Jimmy 2019-07-21

Yeah, my hope is that the tools for mass-placing pegs and wires will make multi-bit cables unnecessary. I’m not yet confident that’s the case, though. It’ll be one of the pieces of feedback I ask for once we begin beta testing.

I really like the aesthetics of multi-bit busses as they are now, and I’d be a bit sad to obsolete them with a multi-bit cable.

@ForLoveOfCats 2019-07-18

Perhaps rather than set sizes of labels as separate items, they could instead have a resizing feature similar to board resizing?

@Jimmy 2019-07-18

Interesting idea. Such a system would work well with other components like buttons and displays. I will look into this!