Behavioral Location Math

From Desynced Wiki
Revision as of 01:23, 4 September 2023 by Nycidian (talk | contribs)

Location Data Type Composition

As with other (link) Data Types the location data type is a composite of itself and a number component you can test this your self by manual assigning an input a location value under the world tab and using the number slider or input box at the bottom to set a number value after clicking the check box to enter the data if you hover over the input box you just modified you will see a col um of number 3 high like below.

1
6
9

This would be the x, y and number parts of the data type. However in most cases the number component will not do anything useful if you are trying to work with a location.

Relative Location Meaning on the World

As a X location value increases in value the location moves to the right by one grid unit. Decreases move the location to the left.

As a Y location value increases in value the location moves down by one grid unit. Decreases move the location Up.

Location Math

To do math on location data and get usable location results both inputs need to be location data. Add and Subtract work as you would think but multiplication and possibly division (untested by author) are special cases.

Addition

if you have the location coordinates 14,20 and you want to add 5 to the x value you would not pass 5 into the Add instruction but the location data of 5,0

Subtraction

if you have the location coordinates 14,20 and you want to remove 5 from the x value you would not pass 5 into the Subtract instruction but the location data of 5,0

Multiplication

if you have the location coordinates 14,20 and you want to double the x value you would not pass 2 into the Multiply instruction but the location data of 2,1

The reason it's 1 for the y value is just like normal multiplying by zero turn any number to zero.

If you multiply a location value by a positive number it will increase the scale of the value away from the point 0,0 by the scale of the number multiplied.

If you wanted to go 4 times further from 0,0 in the X direction you would multiply your location by 4,1.

Special Property: Reflection

The most useful aspect of multiplication on locations is that it allows you to manipulate x,y values in relation to the 0,0 point on the x,y plane.


If you were at some location and wanted to go the opposite direction by the same amount from the location 0,0 you can use the Instruction



if you were only using multiplication this would have very limited use as it would always be relative to the location 0,0