Euflorium: The Eufloria Community
Eufloria => Eufloria Classic => Eufloria Classic Mods => Topic started 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.
- Lua is case sensitive. This isn't particulary obscure, and I'm sure you all knew it anyway, but some things that are posted my require this knowledge. FOO =/= foo =/= Foo
- For the purposes of logic false = nil and nil = false. Also, if I use either nil or false below, assume the other could be used.
- a, b = b, a will swap the values of the variable a and b. Presumably, though I haven't tested it, a, b, c = b, c, a will transpose all three one space to the left.
- a = a or b will make a = b, but only if a is nil or false (see above). c = a or b will do the same, but c will be given the value. If a is NOT nil, c =a.
- There is a very short method of writing simple if...else statements: condition and do if true or do if false . This is very similar to the previous line, no?
- conditional1 and a or b will return a if conditional is true, else it will return b. --Orion63
Post any other things you know below. You will be credited.
-
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.
-
Heh, though you don't need the '--' at the end of the '--]]--' :P
-
At the end? I though you didn't need it at the start...
-
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.
-
You need the double at the start of both of them, but not at the end.
-
(http://img402.imageshack.us/img402/566/abdef.png)
Hum...not in my editor...
-
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!
-
Just OT a sec, is your avatar a glider from Game of Life, Orion?
-
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 ^^)
-
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
-
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 ^^
-
16? Nice, I'm 15, but you might have recognized from the signature I had :P
-
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
-
"sorry for the ot"? We were way off topic anyways :P
-
Yeah, meant “sorry for carrying the OT even further” ;)