If-clauses in JSON

Hey fellas,

for my Fortify-Mod I have recently been working on a working drawbridge. The main feature should be, that if the opened animation is triggered, the bridge should add a temporary collision-Box in front of it.
The wanted result is, that one can build this door in front of a river and enable hearthlings to cross that river without actually building a bridge (with a max river width of 4 blocks).

My first attempt is an if-claus like this:

{"if" : [{"==" : [{"var":"state"}, "opened"]}, "bridge", "no bridge" ]}

“bridge” and “no bridge” are placeholders for the whole collision-box thing. The “state” var should be filled with the active animation.

Now my questions:

  • Is this even possible in json? Or is this a task for a lua file?
  • Where to add the lines of code above? I guess in the “components” section, but I’m not quite sure.

Thank you for your attention.

Json is not code, it is just a list of values. Those are read by some code elsewhere, in Lua.

Yes, a component would be necessary. I think you could maybe just invert the door behavior. Instead of being solid when closed, be solid when opened.

1 Like

And steal the lockable code from the lockable door so you can lock it closed, which means it’s non traversal? Clever

True, Json is not code, but json can work with logic operators. So I thought of giving it a try. I’m not good with lua (at the moment).

Fantastic idea! The more I think of my previous idea, the more stupid it gets.
My attempt would probably mess with the whole pathfinding-thing.

Cherry on top.