In our first example the error is on line 45 but you've indicated the code is on line 43 What does line 45 look like?
The line you show is simply making local variables and setting them from the global versions, if you are going to use those values a lot in your script then that is a good idea, if you only use them once then it's a bit pointless.
Each script will be executed every frame with the only difference being the value of 'e' passed into it so if you need to store extra values on a per entity basis then you have to use a list.
g_Entity is a global list which contains some useful values related to entities which are updated by the engine every frame, so for example g_Entity[ e ].x contains that entities current x position value when the script is called.
If you want to store your own per-entity values you can simply do the same in your script, for example:
local myEntityList = {}
myEntityList[ e ] = { state = 'idle', colour = 'blue', smell = 'fragrant' }
......
if myEntityList[ e ].state == 'idle' then myEntityList[ e ].state = 'active' end
... etc
Been there, done that, got all the T-Shirts!