Scripting, Code & Interaction: Difference between revisions

Jump to navigation Jump to search
Line 95: Line 95:


==Fatal error when running "function DoSomething(1,2,3);"==
==Fatal error when running "function DoSomething(1,2,3);"==
''When I write "function DoSomething(1,2,3);", it gives me a fatal error! What am I doing wrong now?''
If you intended to use an already-existing function in AGS, then you need only write "'''FunctionName(1,2,3);'''". Don't forget the semi-colon!
The '''function''' keyword is used only while ''defining'' functions, i.e., creating your own. In this case, you would type
  function FunctionName ('''type''' varname, '''type''' varname2, ...) {
followed by your code and an ending brace ( ''}'' ), into the global script, outside of any other functions. The word '''type''' refers to the variable type, such as '''int''', '''string''', or even '''char''' (not supported by AGS, but used in the C++ coding language, so look it up there), while varname, varname2, etc., refer to the names of the variables you want to have passed to your function. Then, go to the '''script header''' (under the '''Game''' menu), and add "'''import FunctionName (type,type,...);'''". You need only list the types of variables used, separated by commas, such as '''(int,string)'''.
==Using "FaceLocation" doesn't work==
==Using "FaceLocation" doesn't work==
==Using "GetMP3posMillis()" always returns "0"==
==Using "GetMP3posMillis()" always returns "0"==

Navigation menu