Scripting, Code & Interaction: Difference between revisions

m
no edit summary
*>Dasjoe
mNo edit summary
mNo edit summary
Line 2: Line 2:
''I need help with variables. What I am doing doesn't seem to be working. What do I do?''
''I need help with variables. What I am doing doesn't seem to be working. What do I do?''


One of AGS's main advantages is its ability to use variables. A variale is an area of memory storage that contains a value, which you can check and change with scripting. Variables are very powerful and useful things in programming languages. If you have an RPG-style stat system in place, you can use variables to store information such as health, magic, strength, etc. You can name variables anything you'd like, as long as they're not names of functions, AGS commands, or already-declared variables, like EGO or a GUI name.
One of AGS's main advantages is its ability to use variables. A variable is an area of memory storage that contains a value, which you can check and change with scripting. Variables are very powerful and useful things in programming languages. If you have an RPG-style stat system in place, you can use variables to store information such as health, magic, strength, etc. You can name variables anything you'd like, as long as they're not names of functions, AGS commands, or already-declared variables, like EGO or a GUI name.


Due to AGS's emulation of the 'C' language, variable scope must also be considered. If a variable will be used throughout the entire game, it will have 'global' scope. If it to be used only in a single room, its scope will be limited to that room.
Due to AGS's emulation of the 'C' language, variable scope must also be considered. If a variable will be used throughout the entire game, it will have 'global' scope. If it is to be used only in a single room, its scope will be limited to that room.


There are three major steps to using custom variables.
There are three major steps to using custom variables.
Line 56: Line 56:
If you want your variables to be available in ALL rooms, import them into the Global Header (Ctrl-H).
If you want your variables to be available in ALL rooms, import them into the Global Header (Ctrl-H).


The last two steps are necessary with global variables. Remember! ''ONLY'' the '''import''' command requires the data type as well as the variable name. The '''export''' command ''ONLY'' needs the variable name.
The last two steps are necessary with global variables. Remember: ''ONLY'' the '''import''' command requires the data type as well as the variable name; the '''export''' command ''ONLY'' needs the variable name.


==Running regular code inside dialog==
==Running regular code inside dialog==
Line 249: Line 249:
Ooooh, sorry, that wasn't in the form of a question! ;)
Ooooh, sorry, that wasn't in the form of a question! ;)


Heh just kidding. You can use the character's idle animation to do this. Simply set up his/her idle animation ('''SetCharacterIdle()''', or '''cEgo.SetIdleView()''' for AGS V2.7 and above) with the idle delay to "0" so that it plays constantly. Voila! You now have a repeatedly animating background character with only one line of script. If you wanted, for example, a character in the background to do a one-time animation randomly with pauses between, set the idle delay to a higher number. The higher the idle delay, the longer between idle animations AGS will wait.
Heh, just kidding. You can use the character's idle animation to do this. Simply set up his/her idle animation ('''SetCharacterIdle()''', or '''cEgo.SetIdleView()''' for AGS V2.7 and above) with the idle delay to "0" so that it plays constantly. Voila! You now have a repeatedly animating background character with only one line of script. If you wanted, for example, a character in the background to do a one-time animation randomly with pauses between, set the idle delay to a higher number. The higher the idle delay, the longer between idle animations AGS will wait.


As an alternative to this method (which destroys the idle view delay) you can do this instead:
As an alternative to this method (which destroys the idle view delay) you can do this instead:
0

edits