![]() keycode: the integer keycode of the last key pressed.keydown: is True when a key is being pressed, False otherwise.mousedown: is True when the mouse button is pressed, False otherwise.MOUSEY: the vertical location of the mouse cursor.MOUSEX: the horizontal location of the mouse cursor.Some variables can be used to create interactive animations: FRAME: the current frame in an animation.PAGENUM: the current page being exported in a multi-page export.These variables can only be looked at, not modified. NodeBox has a set of predefined variables that contain information about the state of your script. The specific value of a variable is therefore only known inside the script where it is used, not in other scripts. Quote = "Nicely below each other" text (quote, x, y )Įach script has its own memory storage, it's own warehouse of boxes and sticky notes. Quote = "Nicely on the left" text (quote, x, y ) Thus, the paragraph's vertical position should be dependant on the title's vertical position. Rather, paragraph text should go neatly below the title - and when the title font size changes, the paragraph text should move along by itself. This is essential when positioning text for example: you don't want to calculate the position of each piece of text by yourself. When you store numbers in variables, you can perform math operations on them, multiply them, increase them, and so on. The first rectangle's width is 100, then the value of the variable changes to 20, so the two following rectangles use that new value and have width 20. When this happens, the old value is thrown away, and from now on the variable contains the new value. You can change the value of a variable during the course of a script. In this example, a rectangle is drawn at (10,10), with width of 100 and height of 30. width = 100 rect ( 10, 10, width, 30 ) Variables can be used as parameters. NodeBox keeps a small sticky note reminder for itself to know what value is inside the variable. ![]() It's as easy as this: we think of a good name for a variable, and assign any value to it we like. No one likes to type theWidthOfAllRectangles an dozen times, width says enough. Usually, you pick a name that tells something about what kind of information the variable is storing. ![]() ![]() You can declare a variable at any point in your script, and give it any name you like, except for names that NodeBox has already claimed (like rect, or for). This way, when you change your mind about the rectangle's width, you only need to change the contents of the width variable, since each rectangle is looking over there for it's width.ĭon't worry, things will clear up once we try some examples! Declaring variables If each of ten rectangles you're going to draw is a hundred pixels wide, it's a good idea to declare a width variable that stores the number 100, and tell each rectangle to go look what's inside this width variable. You store things in variables when you plan to reuse them. ![]() Just like boxes, variables can hold all sorts of stuff useful in a NodeBox script: pieces of text, an important number, the name of a font, a list of colors, and so on.Īnother way to look at variables is to think of them as a sticky note. The name is like the label on a box: it's a quick reminder of what item, or value, is inside the variable. Usually, people put labels or some kind of code on boxes to remember what is inside. You can put something inside the box, put it away for storage, and later on retrieve the item from the box. You could think of a variable as a cardboard box. A variable is a place to store a value in computer memory. ![]()
0 Comments
Leave a Reply. |