| View previous topic :: View next topic |
| Author |
Message |
joelrodrigues
Joined: 01 May 2006 Posts: 4
|
Posted: Mon May 01, 2006 11:50 pm Post subject: HOW can i TEST my LUA scripts? |
|
|
Hi folks,
I am a LUA newbie and i´d like to test my LUA scripts.
For example: print("Hello World)
How do you make the console or a window appear, using LUAEdit?
When i click in the RUN SCRIPT, i just see a MESSAGE window.and nothing happens, aside from the messages dialog popping up and saying the script has started and ended successfully.
Ok.... If you don´t know how to do this in LuaEDIT, no problem. Do you have any suggestion? I just need something where i could test my LUA SCRIPTS in a friendly way...
Best regards
Joel Rodrigues |
|
| Back to top |
|
 |
buletov
Joined: 26 Oct 2005 Posts: 39 Location: Croatia
|
Posted: Tue May 02, 2006 4:17 am Post subject: |
|
|
If you're interested in creating applications using LUA language,
try the AutoPlay Media Studio Trial, available here: www.indigorose.com _________________ buletov_ |
|
| Back to top |
|
 |
joelrodrigues
Joined: 01 May 2006 Posts: 4
|
Posted: Tue May 02, 2006 11:17 am Post subject: |
|
|
Hi buletov,
Thx. very much for your reply. I download the trial version. With AutoPlay Media Studio Trial i just can create SCRIPTs related to AutoPlay Media Studio and not test my own SCRIPTS (that are not related to the program itself).
I just want to RUN (in a console) my script...
For example:
print("Hello World")
Best regards man.
Joel Rodrigues |
|
| Back to top |
|
 |
Isilion
Joined: 13 Aug 2006 Posts: 5 Location: Spain
|
Posted: Sun Aug 13, 2006 3:43 pm Post subject: |
|
|
Hi
I still havent started using LuaEdit, but you can test your scripts using a IDE like Visual Studio.
There are some free versions of Visual Studio called Visual Studio Express.
If you go to www.microsoft.com you will easily find them. I found them very useful. Once you have got that, I recommend you to follow this tutorial, which I think is very good! http://gamedevgeek.com/tutorials/
Enjoy  |
|
| Back to top |
|
 |
joelrodrigues
Joined: 01 May 2006 Posts: 4
|
Posted: Sun Aug 13, 2006 9:10 pm Post subject: |
|
|
Hey man,
Thanks very much... I didn´t know i could integrate Lua with Visual Studio... Nice tutorials!
Cheers! |
|
| Back to top |
|
 |
Arandmoor
Joined: 04 Sep 2006 Posts: 4
|
Posted: Mon Sep 04, 2006 7:12 pm Post subject: |
|
|
In LuaEdit (I run 2.5) go into the view menu and select the Output window from the Debug submenu. It will bring up a console window that reports any messages your script returns (like from the print() function).
I docked mine below my text window. Works great  |
|
| Back to top |
|
 |
joelrodrigues
Joined: 01 May 2006 Posts: 4
|
Posted: Mon Sep 04, 2006 7:51 pm Post subject: |
|
|
Nice... Thanks for the tip, Arandmoor.
Best regards! |
|
| Back to top |
|
 |
zegarkus
Joined: 17 Feb 2007 Posts: 2
|
Posted: Sat Feb 17, 2007 2:24 am Post subject: |
|
|
Just digging up an old post - thanks Arandmoor for the tip about Lua edit! I was going a bit bonkers about how to run scripts as well.
After a few hours of trying to find how to run Lua scripts, I found the "Caller.lua" in the LuaEdit directory which called the dofile(".\\Function.lua") that can be called up from the command line. Since then I have been using the dofile(".\\filename.lua") to run my scripts.
Question:
I have seen some documentation that seems to call up scripts this way:
lua script.lua
How can I do this using the Lua5.1.exe in Windows XP? I had no luck. Specially 6 - Lua Stand-alone in the Lua documentation describes calling up scripts this way:
$ lua -e'a=1' -e 'print(a)' script.lua
I haven't had any luck so far, can someone point me in the right direction here?
| Code: | > lua test.lua
stdin:1: `=' expected near `-'
> |
|
|
| Back to top |
|
 |
zet
Joined: 12 Nov 2004 Posts: 289 Location: Germany
|
Posted: Sat Feb 17, 2007 6:50 am Post subject: |
|
|
you can exec your lua code if you open the commandline (cmd.com) and execute
lua myluafile.lua
Then the file is executed.
If you are running the lua interpreter (your errormessage is saying so), you have to write lua code:
dofile "myluafile.lua" _________________ Luxinia Engine |
|
| Back to top |
|
 |
zegarkus
Joined: 17 Feb 2007 Posts: 2
|
Posted: Sun Feb 18, 2007 12:57 am Post subject: |
|
|
| sweet - thanks for that zet. It works like a charm now. My confusion was getting the cmd.exe and lua interpreter mixed up. |
|
| Back to top |
|
 |
dfdub
Joined: 27 Nov 2007 Posts: 5
|
Posted: Tue Nov 27, 2007 5:32 pm Post subject: All I want is a "Hello World!" |
|
|
I feel that I am a fairly seasoned coder. I have written extensive java programs with JBuilder and have built rather complex web services with .NET / C#... but...
I can not get one damn LUA script to complile and run successfully. I have looked over the tutorials discussed above and followed all steps very closely and yet I STILL can not compile one script.
Here are my errors when following the tutorial to a T.
| Code: | 1>Compiling...
1>luatest.cpp
1>..\..\..\..\..\Program Files\lua5.1\luatest\luatest.cpp(4) : error C2006: '#include' : expected a filename, found 'identifier'
1>..\..\..\..\..\Program Files\lua5.1\luatest\luatest.cpp(5) : error C2006: '#include' : expected a filename, found 'identifier'
1>..\..\..\..\..\Program Files\lua5.1\luatest\luatest.cpp(6) : error C2006: '#include' : expected a filename, found 'identifier'
1>..\..\..\..\..\Program Files\lua5.1\luatest\luatest.cpp(32) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? |
I am using visual C++ 2005 and have tried several different things with several different errors. Much frustration today so any help is greatly appreciated. |
|
| Back to top |
|
 |
zet
Joined: 12 Nov 2004 Posts: 289 Location: Germany
|
Posted: Wed Nov 28, 2007 9:40 am Post subject: |
|
|
It would help to see the lines of code that the compiler refers to.
don't forget
| Code: |
extern "C" {
#include "lua.h"
// etc.
}
|
if you are using C++. _________________ Luxinia Engine |
|
| Back to top |
|
 |
dfdub
Joined: 27 Nov 2007 Posts: 5
|
Posted: Wed Nov 28, 2007 4:34 pm Post subject: |
|
|
Here is the code:
| Code: | #include <stdio.h>
extern “C” {
#include “lua.h”
#include “lualib.h”
#include “lauxlib.h”
}
/* the Lua interpreter */
lua_State* L;
int main ( int argc, char *argv[] )
{
/* initialize Lua */
L = lua_open();
/* load Lua base libraries */
luaL_openlibs(L);
/* run the script */
luaL_dofile(L, “test.lua”);
/* cleanup Lua */
lua_close(L);
/* pause */
printf( “Press enter to exit…” );
getchar();
return 0;
} |
And test.lua is simply:
print “Hello, World!” |
|
| Back to top |
|
 |
dfdub
Joined: 27 Nov 2007 Posts: 5
|
Posted: Wed Nov 28, 2007 5:53 pm Post subject: |
|
|
And just so everyone knows... I followed the steps here word-for-word:
http://gamedevgeek.com/tutorials/getting-started-with-lua/
All the needed libs, dll's, etc are properly placed. Can someone else follow this tutorial and let me know if it works correctly?
If you follow this tutorial from start to finish, it leaves you with two .cpp files and each with a main(). I thought these would conflict so I got rid of the original but received other errors. I have tried several different configurations today with no avail. |
|
| Back to top |
|
 |
|