Assistance with Lua functions
Posted
by Josh
on Stack Overflow
See other posts from Stack Overflow
or by Josh
Published on 2010-04-08T00:53:04Z
Indexed on
2010/04/08
2:23 UTC
Read the original article
Hit count: 288
As noted before, I'm relatively new to lua, but again, I learn quick. The last time I got help here, it helped me immensely, and I was able to write a better script. Now I've come to another question that I think will make my life a bit easier. I have no clue what I'm doing with functions, but I'm hoping there is a way to do what I want to do here. Below, you'll see an example of code I have to do to strip down some unneeded elements. Yeah, I realize it's not efficient in the least, so if anyone else has a better idea of how to make it much more efficient, I'm all ears. What I would like to do is create a function with it so that I can strip down whatever variable with a simple call of it (like stripdown(winds)). I appreciate any help that is offered, and any lessons given. Thanks!
winds = string.gsub(winds,"%b<>","")
winds = string.gsub(winds,"%c"," ")
winds = string.gsub(winds," "," ")
winds = string.gsub(winds," "," ")
winds = string.gsub(winds,"^%s*(.-)%s*$", "%1)")
winds = string.gsub(winds," ","")
winds = string.gsub(winds,"/ ", "(")
Josh
© Stack Overflow or respective owner