Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Question about parameters
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#10
RE: Question about parameters

(12-26-2013, 05:22 PM)Zokrar Wrote: ... I still don't understand why I must have parameters in the callback function, even if they're not used within the brackets ...

The short answer is:
Because that's how Frictional Games have set it up. You don't have to use the parameters in the function, but they have to be there


The long answer is:
When the callback that you set up is activated, the engine looks for a function with the name you set the callback with (in your case, "EventDoor"), the word "void" at the beginning (which is whats called the 'return type' of the function), and the whole list of parameters.

The reason you can change the name of the parameter ('asEntity', 'alState', etc), but not the type ('string &in', 'int' etc) is because the engine is actually just looking for the list of parameter types, it doesn't care about the name.

The details it is looking for are...
PHP Code: (Select All)
void YourFunctionName(string &in namestring &in nameint name
Those details that the callback is looking for, have already been set up in the engine, so we can't change them. That means that although you don't need use the parameters, they need to be there or else the engine won't be able to find what code to run (the function you write)


Quote:One more thing, what does "&in" mean? Is that a C memory thing?
It's related to it, yeh
The '&' means it takes the address to the bit of memory that the variable is in (meaning the actual value of the variable doesn't have to get copied into new memory, just an address), and 'in' means it can only take that data 'in', it can't pass it 'out' (which means that the value cannot be changed).
So, 'string &in' basically means its a string that function receives that cannot be changed, but its the original string, not a copy

Obviously there's loads more detail to all this, if you interested there's a manual on 'AngelScript', this language, heres a good place to start, but it assumes quite a bit of knowledge.

12-28-2013, 01:05 AM
Find


Messages In This Thread
Question about parameters - by Zokrar - 12-26-2013, 04:58 AM
RE: Question about parameters - by Romulator - 12-26-2013, 05:56 AM
RE: Question about parameters - by Zokrar - 12-26-2013, 04:52 PM
RE: Question about parameters - by WALP - 12-26-2013, 05:17 PM
RE: Question about parameters - by Zokrar - 12-26-2013, 05:22 PM
RE: Question about parameters - by Zokrar - 12-27-2013, 01:59 AM
RE: Question about parameters - by Adrianis - 12-28-2013, 01:05 AM
RE: Question about parameters - by Romulator - 12-27-2013, 02:07 AM



Users browsing this thread: 1 Guest(s)