Lua problems... Don't bother to read.

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Lua problems...

Post by MarauderIIC »

Use the debugger to step through?
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: Lua problems...

Post by PixelP »

MarauderIIC wrote:Use the debugger to step through?
The main loop in the engine?
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Lua problems...

Post by MarauderIIC »

Yeah, since you said it's not working in the engine either.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Lua problems...

Post by Falco Girgis »

I'm curious as to how exactly your map system works. Are you not actually reading in your maps and storing them in some sort of array? Are you actually parsing through the map file in-game?
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: Lua problems...

Post by PixelP »

MarauderIIC wrote:Yeah, since you said it's not working in the engine either.

Code: Select all

void ToFile(char msg[40]) {
    Debug << msg << std::endl;
    Debug.flush();
}

if(y > 1) {
            Log("start");
            Map.close();
            Log("end");   
        }
I got alot of start/end in my debug.txt.

GyroVorbis wrote:I'm curious as to how exactly your map system works. Are you not actually reading in your maps and storing them in some sort of array? Are you actually parsing through the map file in-game?

Code: Select all

//globals.h
std::fstream Map;
char map_name[40];

//lua.h
int KillMap(lua_State* L) {
	Map.close();
	return 1;
}

int SetMap(lua_State* L) {
	strcpy(map_name, lua_tostring(L, -1));
	Map.open(map_name, std::fstream::in);
	return 1;
}

//level.h
void LevelClass::MapTiles() {
	//layer 1
	for(int j=0;j<18;j++) {
		for(int i=0;i<18;i++) {
			Map >> LevelMap1[j][i];                  
		}
	}
	
	//layer 2
	for(int j=0;j<18;j++) {
		for(int i=0;i<18;i++) {
			Map >> LevelMap2[j][i];
		}
	}
	
	//layer 3
	for(int j=0;j<18;j++) {
		for(int i=0;i<18;i++) {
			Map >> LevelMap3[j][i];
		}
	}
}
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Lua problems...

Post by MarauderIIC »

Reading all this again, it looks like perhaps your coordinates aren't updating properly.

Evidenced by ytile == 1 working and player starts at 1, 1. But doesn't work when you change == to >. And the condition is hit, every frame, judging by "before/after includes" output.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: Lua problems...

Post by PixelP »

MarauderIIC wrote:Reading all this again, it looks like perhaps your coordinates aren't updating properly.
The coordinates do update properly.
I can do like:

Code: Select all

if(ytile > 1) {
    SetPlayerYX(5, 5);
}
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: Lua problems...

Post by PixelP »

I won't need any more help with this... coz I'm going to lay my game structure in another way... thanks for all replys anyway.
Post Reply