Page 1 of 1

Dumber downed variable types.

PostPosted: Sat Oct 29, 2016 2:46 pm
by +++CAZZY
I have been reading Morrowind Scripting for Dummies but I don't understand page 27. On page 27 of the 9th edition it talks about variable types, long, short and float. I don't get it I don't understand what is meant by these variables and the integers. Could someone dumb this down for me and give me some simple examples of how each of these are used and what makes them different.

Dumber downed variable types.

PostPosted: Sat Oct 29, 2016 7:58 am
by Bird

They are the minimum / maximum values that can be stored in variables of the respective type.



Short: -32768 to 32767
Long: -2147483648 to 2147483647
Float: -3.4*10**38 to 3.4*10**38

If in either direction you exceed the listed values, the variable will "wrap" around to the other end.



set var to 32767
MessageBox "var = %g" var
; shows "var = 32767"

set var to ( var + 1 )
MessageBox "var = %g" var
; shows "var = -32768"


Note: If you want fractions then you must use floats. Storing "1.5" into a long or short would just result in "1" (everything after the decimal is truncated).


Dumber downed variable types.

PostPosted: Sat Oct 29, 2016 2:57 am
by LADONA

Basically to store an integer like 1 in a computer, you need all bunch of ram. Think of it like this:



long x = 1


"0000000001"



But if you know the limits of your variable, that it will only track to max 30 for example then you can optimize it like this:



short x = 1


"00001"



Then there is floats, when you know you will need fractions.



So select the best fit for each variable.


Dumber downed variable types.

PostPosted: Sat Oct 29, 2016 10:12 am
by QuinDINGDONGcey
Okay. I think I have a better understanding of variable types. Floats are for fractions. And long and short are for long number values and shorter number values.


What are some examples of these variable types in a script and in the game world?

Dumber downed variable types.

PostPosted: Sat Oct 29, 2016 12:31 am
by phillip crookes

Try studying some https://www.scribd.com/doc/7007668/Morrowind-Scripting-for-Dummies-9 script examples/explanation. If you still can't understand variables, scripting is not for you


[EDIT]You can still try to copy/paste/assemble already existing/working script snippets from here and there, but this will not work much if you don't really understand the logic


[EDIT2]to ease studying scripts in Morrowind.esm, you could try right click Morrowind.esm in Mash, export\scripts so you have a unique .txt file with all the scripts and see how variables are used everywhere at a glance