Lua "tutorial" guide..blob thing? - Page 2

Lua "tutorial" guide..blob thing?

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Lua "tutorial" guide..blob thing?

Post by gajop »

In Lua, you don't need to use () in if/for statements, example:

Code: Select all

if (f%10 == 0) then
can be written as

Code: Select all

if f%10 == 0 then
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Lua "tutorial" guide..blob thing?

Post by zwzsg »

FLOZi wrote:Maps should exclusively use LuaGaia

Of course you do, LuaGaia is a separate lua environment - which is why maps should use it exclusively. Just because other maps / older maps don;t doesn't mean people should continue to.
The problem is that, last time I checked, LuaGaia was severly limited compared to LuaRules. Has it been changed?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Lua "tutorial" guide..blob thing?

Post by knorke »

gajop: I know. ;)
Imo it is personal preference and not so important.
Often I do the if ( ) because imo it helps recognizes conditions faster when scrolling.
When it is just check for nil or similiar,

Code: Select all

if isReady then
or

Code: Select all

if label ~= "" then
then I tend to leave the ( ) out.

:arrow: Imo focus is not on Lua but on "Spring Lua".
Teaching Lua itself is out of scope for such texts and such stylistic details even more so. ;) I will try to maintain some constant style but imo just not so important here.
Except I will try to write in "easy and elaborate" so no "tricks" like

Code: Select all

bla = blub or blop
Imo the f%10 is already bit "tricky" for such basic level tutorial but it is some commonly used in spring...
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Lua "tutorial" guide..blob thing?

Post by PicassoCT »

knorke wrote: Imo the f%10 is already bit "tricky" for such basic level tutorial but it is some commonly used in spring...

some use speakingNamed functions for tutorials even though they are not as effective

Code: Select all

function everyTenthFrame(frames)
if f%10==0 then return true else return false end

end

...
if everyTenthFrame(frames)== true then
--do stuff
end
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Lua "tutorial" guide..blob thing?

Post by FLOZi »

Modulo is quite a common enough concept early on in basic programming imo
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Lua "tutorial" guide..blob thing?

Post by PicassoCT »

and the percentage of humanity on the internet who has a clue of basic programming and remember that after all those years is exactly one FLOZillionst part of humanity...
MetalSucker
Posts: 98
Joined: 22 Sep 2014, 20:29

Re: Lua "tutorial" guide..blob thing?

Post by MetalSucker »

FLOZi wrote:Modulo is quite a common enough concept early on in basic programming imo
+1

I also want to add .. it could be better without that gradient on the code snippets and maybe syntax highlighting. (don't hit me).
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Lua "tutorial" guide..blob thing?

Post by knorke »

gradient in color or difficulty? about look of wiki can not do much. syntax highlighting might come if wiki gets updated , would be nice. Think for oneliners/short pieces one can do without and ideally the reader has whole script in own editor anyway...
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Lua "tutorial" guide..blob thing?

Post by FLOZi »

I'll keep asking abma to update the wiki software, maybe now after the server switch it is more likely.
Post Reply

Return to “Lua Scripts”