Stack overflow error

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Stack overflow error

Post by Lmaoboat »

I keep getting "stack overflow underlining "for i=1,25 do", and I don't know why. It was working earlier, so I don't think it's related to what I'm doing with the code, so I think I must have put something a tab too far missed an end somewhere.

Code: Select all

function spawn()
	for i=1,25 do
		spawn("fx", 1, 5, 11, 3, "lcd"..i)
		local lcd = findEntity("lcd"..i)
		lcd:setLight(255,0,0,5,0.25, 360000, true)
	end
	
	
	lcd1:translate(-1,2.5,1.3)
	lcd2:translate(-0.5,2.5,1.3)
	lcd3:translate(0,2.5,1.3)
	lcd4:translate(0.5,2.5,1.3)
	lcd5:translate(1,2.5,1.3)
	lcd6:translate(-1,2,1.3)
	lcd7:translate(-0.5,2,1.3)
	lcd8:translate(0,2,1.3)
	lcd9:translate(0.5,2,1.3)
	lcd10:translate(1,2,1.3)
	lcd11:translate(-1,1.5,1.3)
	lcd12:translate(-0.5,1.5,1.3)
	lcd13:translate(0,1.5,1.3)
	lcd14:translate(0.5,1.5,1.3)
	lcd15:translate(1,1.5,1.3)
	lcd16:translate(-1,1,1.3)
	lcd17:translate(-0.5,1,1.3)
	lcd18:translate(0,1,1.3)
	lcd19:translate(0.5,1,1.3)
	lcd20:translate(1,1,1.3)
	lcd21:translate(-1,0.5,1.3)
	lcd22:translate(-0.5,0.5,1.3)
	lcd23:translate(0,0.5,1.3)
	lcd24:translate(0.5,0.5,1.3)
	lcd25:translate(1,0.5,1.3)
	
end


User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Stack overflow error

Post by petri »

You have an infinite recursion there (your are overriding the spawn function with your own).

Note that spawn() returns the created entity so you don't need to use findEntity() at all.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Stack overflow error

Post by petri »

Also please note that 25 dynamic light sources with shadow casting enabled will hurt the frame rate a lot on slower PCs.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Stack overflow error

Post by petri »

One more thing: r,g,b values are floats so they should be in range 0-1.

I'll shut up now :)
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Stack overflow error

Post by Komag »

This LCD thing is shaping up to be pretty interesting!
Finished Dungeons - complete mods to play
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Re: Stack overflow error

Post by Lmaoboat »

Doh, seems so obvious now. I'l make sure to turn shadows off since they're not needed anyway.
Komag wrote:This LCD thing is shaping up to be pretty interesting!
Thanks. I can get the grid of dots working but setLight functions seem to add on top of themselves, so I make inverse of whatever was there before to turn them off instead of just setting everything to zero. Using timers and short durations is also tricky, because they gradually fade instead of just turning off after the duration is over.
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Re: Stack overflow error

Post by Lmaoboat »

Okay, now it's just crashing to desktop. I tried adjust how many tabs in some of the lines were, but that didn't seem to do anything.

Code: Select all

function light()
	for i=1,25 do
		spawn("fx", 1, 5, 11, 3, "lcd"..i)
			local lcd = findEntity("lcd"..i)
			lcd:setLight(1,0,0,5,0.25, 360000, true)
	end
	
	
	lcd1:translate(-1,2.5,1.3)
	lcd2:translate(-0.5,2.5,1.3)
	lcd3:translate(0,2.5,1.3)
	lcd4:translate(0.5,2.5,1.3)
	lcd5:translate(1,2.5,1.3)
	lcd6:translate(-1,2,1.3)
	lcd7:translate(-0.5,2,1.3)
	lcd8:translate(0,2,1.3)
	lcd9:translate(0.5,2,1.3)
	lcd10:translate(1,2,1.3)
	lcd11:translate(-1,1.5,1.3)
	lcd12:translate(-0.5,1.5,1.3)
	lcd13:translate(0,1.5,1.3)
	lcd14:translate(0.5,1.5,1.3)
	lcd15:translate(1,1.5,1.3)
	lcd16:translate(-1,1,1.3)
	lcd17:translate(-0.5,1,1.3)
	lcd18:translate(0,1,1.3)
	lcd19:translate(0.5,1,1.3)
	lcd20:translate(1,1,1.3)
	lcd21:translate(-1,0.5,1.3)
	lcd22:translate(-0.5,0.5,1.3)
	lcd23:translate(0,0.5,1.3)
	lcd24:translate(0.5,0.5,1.3)
	lcd25:translate(1,0.5,1.3)
	
end
EDIT:
Seem to have fixed it when I moved the translate entities around. Still not sure what it was though
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: Stack overflow error

Post by antti »

Lmaoboat wrote:I tried adjust how many tabs in some of the lines were, but that didn't seem to do anything.
Just for future reference, the tabs only serve to improve the readability of the code. The functionality is just the same with and without the indentation. It's definitely a good habit though.

Offtopic: writing about this reminded me of the only programming language that I know of which gives a damn about whitespaces: the aptly named whitespace. :D
Steven Seagal of gaming industry
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: Stack overflow error

Post by Shroom »

antti wrote: Offtopic: writing about this reminded me of the only programming language that I know of which gives a damn about whitespaces: the aptly named whitespace. :D
further off topic - python requires identation to work properly - god that bugs me :p
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Re: Stack overflow error

Post by Lmaoboat »

Finally figured out how to remove the lights to make place for a different number without having to have a specific one for each number. Changing the brightness or color would just add onto the current lights, but changing the duration doesn't.
Post Reply