Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 1, 2009, 11:01 PM   #1
NSDuo
macrumors newbie
 
Join Date: Jan 2008
lunar and lua

I managed to get lua embedded into my app, now I want to make it compatible with C++. After trying many different libraries I decided on using Lunar because it's lightweight being made of a single header file (that, and all the other libraries didn't work).

I got the header and followed the example from here.

I took one of my pre-existing classes and added some lua friendly functions so now it looks like this:
Code:
#include "lunar.h"

class game
{
	
	private:
	
	// the window resolution
	int resWidth, resHeight;
	
	// fullscreen or not? 0 for windowed, 1 for full
	bool fullscreen;
	
	// 2D or 3D? 0 for 2D, 1 for 3D
	bool perspective;
	
	public:
	
	// register lua functions
	static const char className[];
	static Lunar<game>::RegType methods[];
	
	SDL_Surface *gScreen;
	
	game(lua_State *L) {resWidth = 1280; resHeight = 800; fullscreen = 0; perspective = 0;}
	
	void createSurface();
	
	void Init();
	void Reshape();
	void Cleanup();
	
	int changeRes(lua_State *L);
	int changeFull(lua_State *L);
	int changePers(lua_State *L);
	
	~game();
};
When I declare this class in main.cpp, I get an error that says "error: no matching function for call to 'game::game()' ". Now I know that I'm getting it because the class is trying to call it's constructor, but something is going wrong. In my example I declared the constructor as "game(lua_State *L)" and the error says it's looking for "game()", but if I declare it as "game()" then the error is "error: no matching function for call to 'game::game(lua_State*&)' ". What I'm getting from this is that I need to declare "game()" and "game(lua_State*L)", but that would create a new error due to declaring the same function twice, and that is why I'm stuck.

I have been following the example on the page I linked above, unfortunately there is no documentation for Lunar besides this one page and google is giving me flikr pictures for some reason. Does anyone have experience with Lunar or using C++ and lua together? I would really like to know what I'm doing wrong.
NSDuo is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Total Lunar Eclipse ucfgrad93 Current Events 12 Jun 4, 2014 06:45 AM
Should I learn any other language before learning LUA? quantic iPhone/iPad Programming 6 Jun 27, 2013 01:09 AM
[App] Game: Lunar Commander is available now! wagdog iPad Apps 0 Jul 30, 2012 08:43 PM
[App] Game: Lunar Commander! wagdog iPhone and iPod touch Apps 17 Jul 28, 2012 11:52 PM
[App] Game: Lunar Commander Lite is available now! wagdog iPhone and iPod touch Apps 0 Jul 16, 2012 12:35 PM

Forum Jump

All times are GMT -5. The time now is 01:11 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC