Tilt - physics puzzler (r11)

Show off your games, demos and other (playable) creations.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Tilt - physics puzzler

Post by Robin »

Tesselode wrote:the link will break in a day or two.
No it won't. The only broken links are from before the Attack of the Aliens, which started out as the web site being split and later being down completely, after which most posts were recovered, but attachments were not.
Help us help you: attach a .love.
User avatar
Xkeeper
Prole
Posts: 40
Joined: Wed Aug 04, 2010 2:49 am
Location: Henderson, Nevada, US
Contact:

Re: Tilt - physics puzzler

Post by Xkeeper »

I hope you don't mind if I play a bit with it -- it will be kind of fun to see what else I can do (and maybe help you out, who knows).

I'll also see if I can figure out what went wrong. :P
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Tilt - physics puzzler

Post by Robin »

:shock:

That code... hurts.

The real problem lies in the loop which starts on line 15 (“for line in file:lines() do ...”). You see, objectnum is always incremented (I'd rather you'd do away with it completely), even if the object_type is not "platform". Hilarity does not ensue.

Especially since (rolling drums) object_type is NEVER "platform". Because it's a table.

Code: Select all

		object_type[objectnum]=string.sub(currentline,1,string.find(currentline,",")-1)
		if object_type=="platform" then
Replace that if with

Code: Select all

if object_type[objectnum] == "platform" then
helps.
Help us help you: attach a .love.
giniu
Party member
Posts: 221
Joined: Mon Nov 30, 2009 4:44 pm

Re: Tilt - physics puzzler

Post by giniu »

Robin wrote:Especially since (rolling drums) object_type is NEVER "platform". Because it's a table.
hehe, look at last post on previous page :P :P But anyway, it confirms it - but anyway fixing it leads to next problem we will leave you chance to deal with ;)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Tilt - physics puzzler

Post by Robin »

giniu wrote:hehe, look at last post on previous page :P :P
Oh, sorry, I didn't see that. :oops:
Help us help you: attach a .love.
User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Re: Tilt - physics puzzler

Post by Tesselode »

Thanks guys. Anyway, errors ahoy. It would be great if you could fix this new error, and if you find any other ones, feel free to fix them too if it doesn't hurt you too much.

Seriously, what does indexing a field mean?

P.S. - The code is now commented for both my sake and everyone else's sake. Hopefully this will make it easier to tell what's supposed to be going on.

(It should also make it easier for XKeeper to play around with it.)
Attachments
tilt-r3.love
(1.73 KiB) Downloaded 79 times
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Tilt - physics puzzler

Post by kikito »

Tesselode wrote: Seriously, what does indexing a field mean?
It means doing field.something or field[something_else].

EDIT: also field:something_completely_different()
When I write def I mean function.
User avatar
Xkeeper
Prole
Posts: 40
Joined: Wed Aug 04, 2010 2:49 am
Location: Henderson, Nevada, US
Contact:

Re: Tilt - physics puzzler

Post by Xkeeper »

Looking through this, I'm going to try to work on it a bit and do some stuff.

My thoughts so far, though:

Code: Select all

	object_x={}
	object_y={}
	object_type={}
You're using arrays backwards. It would be wiser to do this:

Code: Select all

objects[1]['x'] = (object x)
objects[1]['y'] = (object y)
objects[1]['type'] = (etc)
objects[2]['type'] = ....
This way, you can create a new object easily by manipulating only one array, and to destroy it is easily similar (objects[id] = nil).

I'm going to clean it up a bit for you, hopefully simplifying the LoadLevel routine too for you. Stay tuned :)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Tilt - physics puzzler

Post by Robin »

Something that's better to avoid is using global variables as loop counters.
Xkeeper wrote:You're using arrays backwards. It would be wiser to do this:

Code: Select all

objects[1]['x'] = (object x)
objects[1]['y'] = (object y)
objects[1]['type'] = (etc)
objects[2]['type'] = ....
Almost. It's easier to type objects[1].x than objects[1]['x'], while they mean exactly the same thing.
Help us help you: attach a .love.
User avatar
Xkeeper
Prole
Posts: 40
Joined: Wed Aug 04, 2010 2:49 am
Location: Henderson, Nevada, US
Contact:

Re: Tilt - physics puzzler

Post by Xkeeper »

Robin wrote:Something that's better to avoid is using global variables as loop counters.
I agree. Though I'm curious, and this has always bugged me about Lua; if you manage your global variables carefully (to only things that really need to be global), is there a downside to omitting local within functions/loops? Especially for temporary values that are set and only used after that point.
Almost. It's easier to type objects[1].x than objects[1]['x'], while they mean exactly the same thing.
D'oh, true. I come from PHP-land so ... yeah.
Post Reply

Who is online

Users browsing this forum: No registered users and 67 guests