Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


c_fried_rice

Member Since 07 Oct 2013
Offline Last Active Private

Posts I've Made

In Topic: Finding Files in a Directory on Windows, with Lua Scripts : Issue I Can't...

07 February 2014 - 03:21 AM

void SongSelect::initSongs(lua_State* L)
{
	// code based off of code found on Google, with modifications to create the track objects
	WIN32_FIND_DATA file_search;

	HANDLE handle = FindFirstFile("Assets/Scripts/Songs/*.lua", &file_search);

	do
	{
		Track track;
		std::string song_file;
		std::stringstream song_file_stream;
		std::stringstream song_name;
		song_file_stream << "Assets/Scripts/Songs/" << file_search.cFileName;
		song_name << file_search.cFileName;
		std::string name = song_name.str();
		song_file = song_file_stream.str();

		//song_files.push_back(song_file);

		std::string sub_song = name.substr(0, name.size() - 4);

		int error = luaL_loadfile(L, song_file.c_str());

		if (error)
		{
			std::cout << lua_tostring(L, -1) << std::endl;
		}

		if (lua_pcall(L, 0 , 0, 0) != 0)
		{
			std::cout<<"Error (Song Init): "<<lua_tostring(L, -1)<<std::endl;
		}	
		else 
		{
			track = luabind::object_cast<Track>(luabind::globals(L)[sub_song.c_str()]);
			Track* p_track = track.clone();
			songs.push_back(p_track);
		}
	} while (FindNextFile(handle, &file_search));

	FindClose(handle);
}

So I'm going to bump this thread. This is my new code, using Luabind instead of Luabridge. I still encounter the same issue, however I've found that it happens when I hit the lua_pcall() line for the third time. This corrupts the first two objects in the vector called songs.

 

Anyone have any tips on what I could do to fix the corruption issue?


In Topic: "Use of Unregistered Class" + Luabind

02 February 2014 - 06:27 PM

Apologies for the double post, but it appears the problem lies in the use of std::vector<Track>. However I can't seem to properly register a std::vector<Track> in Luabind. 

 

I tried following the example in the luabind documentation (which admittedly is prettttty old at this stage) located here.

 

Anyone got any suggestions?


In Topic: Finding Files in a Directory on Windows, with Lua Scripts : Issue I Can't...

30 January 2014 - 03:21 PM

Hrm, I did that but it just printed out each individual character. =S

 

Anyone have any suggestions for trying to bind my initSongs() function to Lua so I can call it in my lua script and return a std::vector?

 

Or does anyone have any suggestions on another way to do this with Lua and luaBridge?

 

Thanks!


In Topic: Finding Files in a Directory on Windows, with Lua Scripts : Issue I Can't...

29 January 2014 - 02:41 PM

The hex values look like pointers (I actually meant the content of the string as hex dump), what kind of type are the strings you use? std::string or char* ?

 

Can you show the definition of your Track class?

class Track
{
public:

	Track();

	void init();

	~Track();

	std::string music;
	std::string midi;
	std::string title;
	std::string artist;
	std::string genre;
	std::string album;
	int starting_track;
	std::string year;
	int bpm;
	std::string left_track;
	std::string right_track;
	StaticUI* album_art;

	unsigned int elapsedTimeMS;
};

That's the Track class, it's basically just a container for the necessary variables. Now for a stupid question, how can I easily get a Hex Dump of my output? >.>


In Topic: Finding Files in a Directory on Windows, with Lua Scripts : Issue I Can't...

28 January 2014 - 06:04 PM

So I printed out some of the values and have copied them below. The first batch is when the songs are being gathered in the initSongs() function. The second batch is after it's called in init().


N/A
Kevin Macleod
Blown Away
Electro Rock
2012
Assets/Audio/Songs/Playable/kevin_macleod_blown_away/kevin_macleod_blown_away.mid
Assets/Audio/Songs/Playable/kevin_macleod_blown_away/kevin_macleod_blown_away.ogg
00AEAC14
00AEAC0C
00AEAC08
00AEAC10
00AEAC1C
00AEAC04
00AEAC00

The Hunter
Mastodon
Dry Bone Valley
Metal
2011
Assets/Audio/Songs/Playable/mastodon_dry_bone_valley/mastodon_dry_bone_valley.mid
Assets/Audio/Songs/Playable/mastodon_dry_bone_valley/mastodon_dry_bone_valley.ogg
00AE8624
00AE861C
00AE8618
00AE8620
00AE862C
00AE8614
00AE8610

Origin of Symmetry
Muse
Plug In Baby
Alternative
2001
Assets/Audio/Songs/Playable/muse_plug_in_baby/muse_plug_in_baby.mid
Assets/Audio/Songs/Playable/muse_plug_in_baby/muse_plug_in_baby.ogg
00AE881C
00AE8814
00AE8810
00AE8818
00AE8824
00AE880C
00AE8808

The Slip
Nine Inch Nails
1,000,000
Industrial
2008
Assets/Audio/Songs/Playable/nin_1000000/nin_1000000.mid
Assets/Audio/Songs/Playable/nin_1000000/nin_1000000.ogg
00AD6CB4
00AD6CAC
00AD6CA8
00AD6CB0
00AD6CBC
00AD6CA4
00AD6CA0

Hesitation Marks
Nine Inch Nails
Came Back Haunted
Industrial
2013
Assets/Audio/Songs/Playable/nin_came_back_haunted/came_back_haunted_nin.mid
Assets/Audio/Songs/Playable/nin_came_back_haunted/Came Back Haunted.ogg
00AE58D4
00AE58CC
00AE58C8
00AE58D0
00AE58DC
00AE58C4
00AE58C0

Psybrid Theory
Rosalina Sama & Triple Q
One Style Closer
Mash Up
2013
Assets/Audio/Songs/Playable/rosalinasama_one_style_closer/rosalinasama_one_style_closer.mid
Assets/Audio/Songs/Playable/rosalinasama_one_style_closer/rosalinasama_one_style_closer.ogg
00AEB614
00AEB60C
00AEB608
00AEB610
00AEB61C
00AEB604
00AEB600


xQ±



2012
<
Assets/Audio/Songs/Playable/kevin_macleod_blown_away/kevin_macleod_blown_away.ogg
00AEAC14
00AEAC0C
00AEAC08
00AEAC10
00AEAC1C
00AEAC04
00AEAC00


Mastodon
Dry Bone Valley
Metal
2011
Assets/Audio/Songs/Playable/mastodon_dry_bone_valley/mastodon_dry_bone_valley.mid
Assets/Audio/Songs/Playable/mastodon_dry_bone_valley/mastodon_dry_bone_valley.ogg
00AE8624
00AE861C
00AE8618
00AE8620
00AE862C
00AE8614
00AE8610

Origin of Symmetry
Muse
Plug In Baby

2001
Assets/Audio/Songs/Playable/muse_plug_in_baby/muse_plug_in_baby.mid
Assets/Audio/Songs/Playable/muse_plug_in_baby/muse_plug_in_baby.ogg
00AE881C
00AE8814
00AE8810
00AE8818
00AE8824
00AE880C
00AE8808


Nine Inch Nails

Industrial
2008
Assets/Audio/Songs/Playable/nin_1000000/nin_1000000.mid
Assets/Audio/Songs/Playable/nin_1000000/nin_1000000.ogg
00AD6CB4
00AD6CAC
00AD6CA8
00AD6CB0
00AD6CBC
00AD6CA4
00AD6CA0

Hesitation Marks
Nine Inch Nails
Came Back Haunted
Industrial
2013
Assets/Audio/Songs/Playable/nin_came_back_haunted/came_back_haunted_nin.mid
Assets/Audio/Songs/Playable/nin_came_back_haunted/Came Back Haunted.ogg
00AE58D4
00AE58CC
00AE58C8
00AE58D0
00AE58DC
00AE58C4
00AE58C0

Psybrid Theory
Rosalina Sama & Triple Q
One Style Closer
Mash Up
2013
Assets/Audio/Songs/Playable/rosalinasama_one_style_closer/rosalinasama_one_style_closer.mid
Assets/Audio/Songs/Playable/rosalinasama_one_style_closer/rosalinasama_one_style_closer.ogg
00AEB614
00AEB60C
00AEB608
00AEB610
00AEB61C
00AEB604
00AEB600


PARTNERS