Does anyone know a more optimized way of generating spark? I've been using the method below and it's so laggy.
I don't know why you're putting that in your update function. Just set PROP_CONDUCTS and PROP_LIFE_DEC to make the game automatically conduct sparks for you. It will also be much faster than implementing spark conduction logic in Lua.
Anyway, Lua elements tend to be laggy when you're looping over neighbors like this, especially if you're looking for neighbors more than 1 pixel away. I've been able to use the surround_space and not_type arguments to the update function to my advantage to make less laggy Lua elements, but I don't think that would work here.
Doesn't that just make an element conductive..? I'm trying to generate electricity like sensors or batteries.
When you say laggy, how laggy is it? My for loops run very fast.
I'm also very sorry for necroposting, I did not see the date.