Scripts / What is e?

Author
Message
mnemonic
17
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden
Posted: 3rd Mar 2014 13:08
Hi! I have not yet dived into LUA, but I have been looking at the scripts in the scriptbank folder where I notice that every starting function takes an argument 'e' example: function MyFunc(e). What variable is that? Is it the entity itself? Somewhat like the this pointer in c++?



BEST!

www.memblockgames.com
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 3rd Mar 2014 13:14 Edited at: 3rd Mar 2014 13:17
It's numeric index of the current entity (the entity your script is assigned to).



g_Entity is global array of entities. g_Entity[e] returns current entity, or in other words, another array of entity properties. For example, g_Entity[e]['x'] will return current entity's X coordinate.



Your scripts are always defined as "function script_main(e)", or whatever_main(e). "e" is provided by FPSC:R engine when it calls your "script_main" function.

mnemonic
17
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden
Posted: 3rd Mar 2014 14:26
Thanks!

www.memblockgames.com

Login to post a reply

Server time is: 2024-04-20 11:52:43
Your offset time is: 2024-04-20 11:52:43