Thread: [Tutorial] Flags, Vars, & Script Tiles View Single Post
#24
November 8th, 2013 (4:50 PM).
 karatekid552 What happens if I push it?.... Join Date: Nov 2012 Location: Do you really want to know? Really? Gender: Male Nature: Bold Posts: 1,766
Quote:
 Originally Posted by mf91 Hi Im browsing around, trying to learn about vars, flags and all this stuff. I totally get the whole idea behind your tutorial, but I have some tiny questions about how it works. setvar 0x4050 0x1 <-- What happens with the var here?? Does the 0x1 change the var number, or is it like a "toggle" inside the variable? The var value you set, is that what you set the variable to, or is it what you set the game to check the variable for? Or rather, with 0000 in this box, and you play the game - is the variable now set to 0x0, or does it compare the variable to 0x0 (because you entered 0000)? And is it a default value for this? I hope what Im asking is not too confusing :P its just the basic functionality that Im missing.
A var always starts at 0x0000. If you have ever programmed, you have used vars. If you have ever done algebra, you have used vars. Vars are variables. They can be anything. In high-level programming, they have names like "place_to_store_stuff" and you can set it to whatever you want. In math, it is almost always X.

Now, a variable is a memory location that you use to store data in. Here, these are two byte data locations accessed by their number, which in this case is 0x4050. So, by doing setvar 0x4050 0x1, you are storing 01 at the location of var 0x4050 for later access. Think of the var number like a book cover on an encyclopedia. Most of the time with encyclopedia volumes, all there is, is a name and a number on the cover. inside is what counts. So here, setvar 0x4050 0x1, is essentially changing the pages of that book.

Understand?
__________________

Paired with Simba