Skip to content

Conditional nodes with .mcdoc #672

Closed Answered by misode
blockninja124 asked this question in Q&A
Discussion options

You must be logged in to vote

It depends on what exactly you need when you say "conditional nodes". There is no generic "if predicate, then use this schema" concept, but almost everything can be represented either by using union types or dispatchers:

type Example = (
	struct {
		present: string,
	} |
	struct {
		width: int,
		height: int,
	} |
)

Or:

struct Example {
	preset?: string,
	...myproject:example[[preset]],
}

dispatch myproject:example[%none] to struct {}

dispatch myproject:example[%unknown] to struct {
	width: int,
	height: int,
}

The above two examples describe the same schema in practice. The second case is more meant when you actually want to dispatch something based on the value of preset, but that's n…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@blockninja124
Comment options

Answer selected by blockninja124
Comment options

You must be logged in to vote
2 replies
@blockninja124
Comment options

@misode
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants