Page 2 of 2

Re: Lua problems...

Posted: Thu Nov 20, 2008 6:49 pm
by MarauderIIC
Use the debugger to step through?

Re: Lua problems...

Posted: Fri Nov 21, 2008 8:28 am
by PixelP
MarauderIIC wrote:Use the debugger to step through?
The main loop in the engine?

Re: Lua problems...

Posted: Fri Nov 21, 2008 11:07 am
by MarauderIIC
Yeah, since you said it's not working in the engine either.

Re: Lua problems...

Posted: Fri Nov 21, 2008 11:24 am
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?

Re: Lua problems...

Posted: Fri Nov 21, 2008 11:51 am
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];
		}
	}
}

Re: Lua problems...

Posted: Thu Nov 27, 2008 11:55 pm
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.

Re: Lua problems...

Posted: Sat Nov 29, 2008 6:51 am
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);
}

Re: Lua problems...

Posted: Fri Dec 05, 2008 1:02 pm
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.