Como usar o Vizzy para criar variáveis ​​dinâmicas no Juno: Novas Origens

Describes how to (abuse) Vizzy to create dynamic variables and fakestructvariables within Vizzy.

Isenção de responsabilidade

This guide uses an undocumented feature of Vizzy and may therefore break in future Juno releases without warning. This is verified to work on version 1.1.109.0 (the current PC version as of 9/9/23).

Introdução

Vizzy supports three data types:

  • Floating point numbers,
  • Vectors, which are three floating point numbers,
  • Strings

Além disso, Vizzy supports a list data type, and each entry on a list can be any of the three above types (there is no requirement for all items in the list to be of the same type).

For most purposes this is sufficient, mas… For some applications, it would be helpful to store a list of values sem using the list data type.

Why avoid the list data type?

  1. The main reason is that it is very, very slow. I’m aware that 1.1.109 claims to have improved the performance of lists — Contudo, by the time that this version was released I had discovered and fully committed to this implementation, assim…
  2. Adicionalmente, the Vizzy blocks for working with lists are awkwardly large. They may be easy to understand, especially for users without a programming background, but if you are planning on writing complex applications in Vizzy the large size becomes an issue.
  3. Lists can not be accessed via FUNK expressions. For more complex mathematical expressions, it is advantageous to place the math in a FUNK expression rather than constructing it with Vizzy blocks. If your equation uses lists, Contudo, this option will be far, far less attractive.
  4. In complex applications, the explicitly declared variable list (the green blocks) will become awkwardly large. Or even absurdly large. Anything that can remove items from this list is highly desirable in complex applications.
  5. It is possible to create a complex data structure that contains another complex structure. UMA “List of Lists”, as it were. This is the only thing that this technique can do that lists cannot do.

Como

Esperançosamente, you are very familiar with theset variable [] para []” Vizzy block. The logic is simpleyou define a variable (via theCreate Variable” botão) which creates a green block, which you then drag to first blank in theset variable [] para []” bloquear, then put whatever you want on the right hand side to tell Vizzy what value to set the variable to.

Mas…

What if you didn’t define and place a green block in the first blankwhat if you did esse em vez de:

The answer isThe value of ‘1is assigned to the variable ‘Active_Craft_ID’.” — put another way, it does the exact same thing as the first example.

What if you have not defined (via theCreate Variable” botão) a variable ‘Active_Craft_ID”? Nós iremos, the value still gets assigned to a variable named ‘Active_Craft_IDbut you obviously cannot retrieve the value via a green block. More on this in a bit.

What about this:

This also works as you would hopeat the end, voce terá 10 variables, namedTesting1” – “Testing10”, all assigned a value of 1.

The next question isHow do I access a variable that was created this way?” This will not work, obviamente:

This assigns the stringTesting1to the variableActive_Craft_IDwhen we were hoping to assign the value of the variableTesting1” para “Active_Craft_ID.

No entanto, FUNK can solve the problem — por padrão, if you specify a variable name in a FUNK string, it is interpreted as a variable name. Por isso, esse does trabalhar:

There are two significant caveats to this, Contudo:

  1. FUNK expressions have não support for strings. This even applies to variables. If you specify the name of a variable that contains a string and then try to access it via a FUNK expression, the result will be the number 0. Por isso, while you can assign strings to dynamic variables (as described above) but unless you use theCreate Variablebutton to create a green block for the variable you will not be able to access the value.
  2. FUNK expressions assume variables are floating point numbers unless told otherwise. If you have stored a vector in a dynamic variable, you will need to prefix the variable name withv:” to tell FUNK that the variable contains a vector.

This is the correct way to access a vector stored in a dynamic variable:

This code will assign vectors to 10 variables, then output the 10 vectors to the local log:

Finalmente, I have verified that dynamic variables

fazerget serialized when a craft is saved (via examining the XML file). I have not yet verified that the values are restored properly, although I’m 99.9 % certain that they are.

More advanced topics

It is highly useful to definehelper functionsthat make it easier to extract specific values from a group of similar values. Isso se parece com isso:

All of these functions accept a single parameter, which is a string that represents a group of related variables, then returns one specific variable from the collection.

If you want to do math with dynamic variables, I recommend using FUNK expressions (rather than the helper expressions) when feasible. Isso se parece com isso:

It is also possible to achieve the same result via the “formatar” bloquear (rather than the “Juntar” bloquear), although I believe the join block is faster. Isso se parece com isso:

Conclusão

That’s all folksnow you too can dynamically define your Vizzy variables, freeing you from the need to add tons and tons of variables to your variable list.

Este guia sobre Juno: Novas Origens Foi escrito por mreed2. Você pode visitar a publicação original neste link. Se você tiver alguma dúvida sobre este guia, por favor, não hesite em contactar-nos aqui.

Sobre o autor