Im starting Lua. Right now im just trying to get some simple scripts going, the hello worlds and basic functionality i can get through fairly quickly. But i cant find anywhere that really explains how to set up lua.
I was given this:
http://lua-users.org/wiki/TutorialDirectory
But they done explain how to set up for the Tutorials.
Also here:
http://lua-users.org/wiki/BuildingLua
But im having problems. Ive set up a simple C++ program that executes a lua script. It compiles but I get the following link errors:
1>main.obj : error LNK2019: unresolved external symbol _lua_close referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _lua_pcall referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _luaL_loadfile referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _luaL_openlibs referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _luaL_newstate referenced in function _main
Im assuming its some sort of library problem. I have a book that explains how to set up. But it uses lua 5.1.3. This has .lib files that are added. 5.1.4 doesnt appear to have these .lib files. I cant find how to fix this problem. Can anyone help me out here?
Setting up Lua on Windows using Visual C++
Moderator: Moderators
Re: Setting up Lua on Windows using Visual C++
A standalone Lua interpreter is not needed for Spring scripting. Check the LuaGadgets/Gadgets, LuaRules/Gadgets or LuaUI/Widgets inside mods for examples. Here is a guide.
If you still want a standalone interpreter, you can get a precompiled one here: http://code.google.com/p/luaforwindows/
If you still want a standalone interpreter, you can get a precompiled one here: http://code.google.com/p/luaforwindows/
Re: Setting up Lua on Windows using Visual C++
What are you "starting Lua" for?
If you need Lua for Spring, to write a Spring AI for instance, then forget about Visual C++ or setting up an environnement, just type your Lua code in notepad, rename .txt to .lua and dump it in \mods\your_mod.sdd\LuaRules\Gadgets\
If you need Lua for Spring, to write a Spring AI for instance, then forget about Visual C++ or setting up an environnement, just type your Lua code in notepad, rename .txt to .lua and dump it in \mods\your_mod.sdd\LuaRules\Gadgets\
-
- Posts: 47
- Joined: 19 Apr 2010, 15:31
Re: Setting up Lua on Windows using Visual C++
Well i want to do some test programs. Just the standard Hello Worlds, and basic functions etc, that you do when learning any new language.
Re: Setting up Lua on Windows using Visual C++
What about hello world as a SpringRTS widget?
Save as YourSpringInstallFolder\LuaUI\Widgets\HelloWorld.lua
Code: Select all
function widget:GetInfo()
return {
name = "Hello word widget",
desc = "Says \"Hello World\" every 30s",
author = "zwzsg",
date = "17th October, 2010",
license = "Public Domain",
layer = 0,
version = "1.0",
enabled = true,
handler = false,
}
end
function widget:GameFrame(f)
if f%900==5 then
Spring.Echo("Hello World!")
end
end
-
- Posts: 47
- Joined: 19 Apr 2010, 15:31
Re: Setting up Lua on Windows using Visual C++
Ive got a C++ program that runs lua scripts, so im grand for now just getting used to lua basics with this. Ill have a look at widgets after. Cheers
Re: Setting up Lua on Windows using Visual C++
Here is working console interpreter.
- Attachments
-
- lua-5.1.rar
- (94.01 KiB) Downloaded 56 times