Euflorium: The Eufloria Community

Eufloria => Eufloria Classic => Eufloria Classic Mods => Topic started by: Pilchard123 on June 12, 2011, 12:33:31 AM

Title: Tricks and tips for Lua scripting
Post by: Pilchard123 on June 12, 2011, 12:33:31 AM
I've been poking around the net recently, and I found some interesting stuff about Lua. A fair bit of it seemed fairly obscure, at least to me, so I thought I'd share it with you guys.



Post any other things you know below. You will be credited.
Title: Re: Tricks and tips for Lua scripting
Post by: Pilchard123 on August 17, 2011, 09:07:08 PM
Block comments are written...

--[[
commented stuff here
]]

If you add an extra - at the start of the block...

---[[
uncommented stuff here
]]

Thanks to Aino and Orion 63 for clarification.
Title: Re: Tricks and tips for Lua scripting
Post by: Aino on August 17, 2011, 11:06:49 PM
Heh, though you don't need the '--' at the end of the '--]]--' :P
Title: Re: Tricks and tips for Lua scripting
Post by: Pilchard123 on August 17, 2011, 11:18:57 PM
At the end? I though you didn't need it at the start...
Title: Re: Tricks and tips for Lua scripting
Post by: Orion63 on August 17, 2011, 11:28:22 PM
conditional1 and a or b
It will return a if conditional is true, else it will return b.

i.e.
5 == 5 and 1 or 2 -> returns 1
5 == 12 and 1 or 2 -> returns 2

Also I recommend not using the or trick that often, since Eufloria itself(if not restarted) doesn't reset values, and if you're using the trick just to do something if the variable is not initialized, it will create some weird bugs(since the values will actually be initialized from the previous game).

Also, you don't need both '--' at the end, nor at the front.
Title: Re: Tricks and tips for Lua scripting
Post by: Aino on August 17, 2011, 11:31:47 PM
You need the double at the start of both of them, but not at the end.
Title: Re: Tricks and tips for Lua scripting
Post by: Orion63 on August 17, 2011, 11:42:46 PM
(http://img402.imageshack.us/img402/566/abdef.png)

Hum...not in my editor...
Title: Re: Tricks and tips for Lua scripting
Post by: Aino on August 17, 2011, 11:52:09 PM
Lol, thats right xD

I face that problem when doing array inside of an arraybox, and I say wrong about it! I mean you need the double ONLY at the first!
Title: Re: Tricks and tips for Lua scripting
Post by: Pilchard123 on August 18, 2011, 12:05:25 AM
Just OT a sec, is your avatar a glider from Game of Life, Orion?
Title: Re: Tricks and tips for Lua scripting
Post by: Orion63 on August 18, 2011, 12:16:41 AM
Yap ^^. Good days when I spent entire days, shooting gliders against each other to see if I could make an awesome pattern :-P(Actually, it was last year, but still ^^)
Title: Re: Tricks and tips for Lua scripting
Post by: Bonobo on August 18, 2011, 09:51:09 AM
Amazing, the story of Conways Game of Life. I am 54 now, and I remember being 11 or 12 years old (1968 or ’69), and I got a “boys’ book” with an article about this “new” game and how scientists “wasted” thousands of $$ “playing” Life on computers the size of houses, and how I played this with checkers stones  … and how exciting this was.

BTW am I the oldest here? Could it be? *1957

Greetz, Tom
Title: Re: Tricks and tips for Lua scripting
Post by: Orion63 on August 18, 2011, 10:06:05 AM
I am way younger(16), so... Game of Life it's pretty much exclusive to the computer ^^, but it's still pretty damn fascinating. Good to know, that there are still enthusiastics out there and that I am not the only one being fascinated by a zero-player game ^^
Title: Re: Tricks and tips for Lua scripting
Post by: Aino on August 18, 2011, 11:57:28 PM
16? Nice, I'm 15, but you might have recognized from the signature I had :P
Title: Re: Tricks and tips for Lua scripting
Post by: Bonobo on August 19, 2011, 04:23:08 AM
hahaha, and sorry for the OT, but I must let you know that I remember the time very well when 15 was SOOOO much younger than 16 :D
Title: Re: Tricks and tips for Lua scripting
Post by: Aino on August 19, 2011, 04:33:11 AM
"sorry for the ot"? We were way off topic anyways :P
Title: Re: Tricks and tips for Lua scripting
Post by: Bonobo on August 19, 2011, 08:34:09 AM
Yeah, meant “sorry for carrying the OT even further” ;)