Skip to main content
gamedev.net
🔒 Locked

LuaPlus Testing

Started by blanky Oct 24, 2005 at 2:25 PM 1 replies 950+ views
Original Post
blanky
blanky
Hey guys, as most of you know, I've chosen Squirrel as my scripting language. However, I'm trying to learn luaplus and squirrel around the same time so I get a good feeling of both, currently I've installed everything and everything seems fine, here's my code:

#pragma comment (lib, "LuaPlus_1081.lib")
#include <LuaPlus/LuaPlus.h>
#include <iostream>
using namespace std;
using namespace LuaPlus;
/* Lua test code

*/

static int LS_PrintNumber(LuaState* state)
{
	LuaStack args(state);

	// Verify it is a number and print it.
	if (args[1].IsNumber())
		cout << args[1].GetNumber();
	printf("%f\n", args[1].GetNumber());

	// No return values.
	return 0;
}

void test() 
{
	//Create state
	LuaStateOwner state;

	//With this the script can access our own C++ functions:
	state->GetGlobals().Register("PrintNumber", LS_PrintNumber);
	
	//Open test file:
	int iret = state->DoFile("test.lua");

	//Get a global variable:
	LuaObject sObj = state->GetGlobal("health");
	int mytest = sObj.GetInteger();

	//Update the value:
	sObj.AssignInteger(state, 30);
	//Get value again:
	mytest = sObj.GetInteger();

	//Call a function in lua:
	LuaFunction<float> Add =  state->GetGlobal("Add");
	float myret = Add(3.14f,0.0f);

	state->Destroy(state);
}

int main()
{
	test();
	system("PAUSE");
	return 0;
}

What happens is, it compiles and all, but when I go to run it it asks for the dynamic link library, be it the debug or release (depending on the type of project). I added the static link library in hope of not requiring this library, so I'd like to know what's wrong with this if anyone could please help out. I have the DLL's, I just want to not require them, thanks guys. Squirrel is going great :D
Kylotan
Kylotan
You may have to rebuild the Luaplus lib. Generally I think that all the libraries in your project have to be of the same type (when it comes to static/dynamic and threaded/not).
John Schultz
John Schultz
Here's the code from my last LuaPlus test. It uses the static libs:

#include "../../../build/3rdparty/LuaPlus_1084/Src/LuaPlus/LuaPlus.h"using namespace LuaPlus;#ifndef _DEBUG#pragma comment(lib,"../../../../build/3rdparty/LuaPlus_1084/lib/win32/LuaPlusLib_1084.lib")#else#pragma comment(lib,"../../../../build/3rdparty/LuaPlus_1084/lib/win32/LuaPlusLibD_1084.lib")#endif


Also be sure to get the latest version from SVN (email Joshua if it's not up). I believe the latest is 1084 (though if you are just testing/comparing, 1081 should be fine).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.