Setting up Lua on Windows using Visual C++

Setting up Lua on Windows using Visual C++

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

Moderator: Moderators

Post Reply
discodowney
Posts: 47
Joined: 19 Apr 2010, 15:31

Setting up Lua on Windows using Visual C++

Post by discodowney »

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?
User avatar
quantum
Posts: 590
Joined: 19 Sep 2006, 22:48

Re: Setting up Lua on Windows using Visual C++

Post by quantum »

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/
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Setting up Lua on Windows using Visual C++

Post by zwzsg »

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\
discodowney
Posts: 47
Joined: 19 Apr 2010, 15:31

Re: Setting up Lua on Windows using Visual C++

Post by discodowney »

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.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Setting up Lua on Windows using Visual C++

Post by zwzsg »

What about hello world as a SpringRTS widget?

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
Save as YourSpringInstallFolder\LuaUI\Widgets\HelloWorld.lua
discodowney
Posts: 47
Joined: 19 Apr 2010, 15:31

Re: Setting up Lua on Windows using Visual C++

Post by discodowney »

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
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: Setting up Lua on Windows using Visual C++

Post by slogic »

Here is working console interpreter.
Attachments
lua-5.1.rar
(94.01 KiB) Downloaded 56 times
Post Reply

Return to “Lua Scripts”