Lua Language Tutorial

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
jussij
Site Admin
Posts: 2483
Joined: Fri Aug 13, 2004 5:10 pm

Lua Language Tutorial

Post by jussij » Wed May 02, 2012 7:45 am

Writing and Running Lua Code

You can use the Zeus IDE to write and execute Lua code.

Here is a simple example:

1) Create a c:\temp\test.lua file using the Lua code shown below:

Code: Select all

printf = function(s,...)
           return io.write(s:format(...))
         end

printf("Hello from %s on %s\n", _VERSION, os.date())
2) Use the Compiler, Compile menu to syntax check the Lua code.

3) To run the code use the Macros, Execute 'test.lua' menu and the following output will be captured inside Zeus:

Code: Select all

---------------------------------------------------------------------------
      Zeus for Windows Programmers Editor - Version 3.97k
      Copyright (c) Xidicone P/L 1993-2012.  All rights reserved.
---------------------------------------------------------------------------

Hello from Lua 5.2 on 05/02/12 18:06:17
Checking Lua Code for Errors

As mention earlier the IDE can be used to check the Lua code for syntax errors.

For example consider this piece of code which contains a Lua syntax error:

Code: Select all

function Test(value)
    if (value == 0)
        return
    end
end
This code can be syntax checked using the Zeus Compiler, Compile menu which when run reports the following error:

Code: Select all

Lua 5.2.0  Copyright (C) 1994-2011 Lua.org, PUC-Rio
luac52.exe: D:\Temp\test.lua:3: 'then' expected near 'return'
Cheers Jussi

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 1 guest