Talk:What is a variable?

From OHRRPGCE-Wiki
Jump to navigation Jump to search

Bob: Clarification; Yes, this is moslty-plotscripting-specific. I took the question from a e-mail I received from a confused beginner plotscripter.

Mike: Erm, isn't variable assignment written as var:= 5 or whatever?

Bob: Right. Fixed. The current article is good, but I hope for more. The concept of variables is easy for programmers, but it is really non-intuitive to anyone without programming experience. I am trying to think of a way to explain variables in Sesame-street terms, so that anybody can understand them.

TMC: The original article confused me in places :( I've taken what Neo wrote and added to it, but now theres that section about constants in an article about variables.

I think its important to note the difference between local and global variables. Maybe it could be moved onto a separate page though, linked to at the bottom. I wouldn't know, but it seems like something novice users would be even more confused by.

Bob: I have this image in my head of a cartoon. A blobby amorphous personification of a variable hovers in the air over a graphical representation of global memory buffer (a row of numbered rectangles)

v: Hello! I am a variable! My name is v!
(a plotscripting fragment, "global variable(3,v)" appears in the background behind v. the name "v" is highlighhted)
v: Yep, v is my name, and 3 is where I live.
(the box labelled "3" in the global memory buffer is highlighted, and so is the "3" in "global variable(3,v)")
v: So now you know my name, and where I live... but what do I do? My job is storing numbers. I am really good at it. Watch me catch this number!
(the global declaration fades, and is replaced by the fragment "v := 42". A big cartoony "42" flies through the air, and v catches it, and drops it into the slot labelled "3" in the global buffer)
v: Wasn't that great? I can store the results of math too! Watch.
(the code fragment "v := 2 + 2" appears, and a big "2+2" flies up and spits out a "4" which v catches and throws into the buffer, replacing the "42")
v: As you can see, I can only hold one number at a time. Now watch me store the result of a function!
(the code fragment "v := current map" appears. A map screenshot of a well-known game arrives, and the map number (say, "5") jumps out of it, and is stored by v)
v: Storing numbers is fun, but there is more to life than that. A number doesn't mean anything unless you can use it for something.
(code fragment "teleport to map (v, 0, 0)" appears)
v: See? That is my name, right there!
(v points to the "v" in the function)
v: When that command runs, I get to use my number.
(v looks at the number in box 3 in the buffer, and then then a "5" appears in a thought bubble over v's head, and floats over and replaces the "v" in the teleport to map command)
(a screenshot of the map with the hero in the top left corner appears.)

Bob: this could go on forevever. He could introduce his little cousin "lv", he could demonstrate incrementing himself, he could bring in his siblings X and Y and demonstrate some multi-variable stuff. Then there would be a theme song at the end where they all dance... yeah :)

Mike: Ha ha ha, dude, I'm so making that into a Flash movie...

Mike: Ok, it's up: Variables and You

Bob: *laugh* that is 14 kinds of delightful, including nine previously undescribed by science! You rock! The Cowboy hat and lasso are a really nice touch.

Mike: Ah would've added voice ovahs, but ah couldn't get mah gosh-durn microphone to work. Ah guess it'll half to wait 'till Part 2...

Bob the Hamster: http://www.finalfantasyq.com/variable1.html is a dead link now. I loved that thing. Mike, do you still have a copy of that somewhere that we can put back up in a permanent location?

Mike C. Uh, it's probably still online. Or... no, it's not. But, when I backed up my site to completely reformat it, I downloaded it all. Lemme take a look. (also, maybe I'll write the second part this weekend)

Edit: Got it: Variables and You