Page 3 of 3

Re: Questions about platformer game

Posted: Mon Sep 10, 2012 2:46 pm
by Nixola
What is it?

Re: Questions about platformer game

Posted: Mon Sep 10, 2012 2:51 pm
by gregkwaste
Nixola wrote:What is it?
player.box=collider:addRectangle(blahblhablha)

In order to assign a player.box.player value, player.box must be a table, and it is not a table... I can't index it this way :/

Re: Questions about platformer game

Posted: Mon Sep 10, 2012 3:00 pm
by Nixola
print(type(player.box)) afret player.box=collider:etc

Re: Questions about platformer game

Posted: Mon Sep 10, 2012 3:18 pm
by gregkwaste
Nixola wrote:print(type(player.box)) afret player.box=collider:etc

it prints out table :S:S:S i thought that it would print out shape..

But anyways its working now ^^. Although i didn't fully get what is going on here :S:S:S

i assigned a shape type (collider:addRectangle(etc)) in player.box

then i assigned player.box.player=player which means that i actually indexed a shape type :S:S:S:S

Except if collider:addRectangle produces tables and not shapes :? :? :?

Re: Questions about platformer game

Posted: Mon Sep 10, 2012 3:27 pm
by Robin
In Lua, basically everything is a table. HardonCollider (which I assume you're using) is written in Lua. Tables are really flexible.

Re: Questions about platformer game

Posted: Mon Sep 10, 2012 3:31 pm
by gregkwaste
Robin wrote:In Lua, basically everything is a table. HardonCollider (which I assume you're using) is written in Lua. Tables are really flexible.
Didn't know that to be honest ^^. I just read the hardoncollider documentation concerning the shapes module, and thats why i discovered too, its indeed a table... And i do agree that they are flexible ^^.

Re: Questions about platformer game

Posted: Tue Sep 11, 2012 3:08 am
by coffee
gregkwaste wrote:
Robin wrote:In Lua, basically everything is a table. HardonCollider (which I assume you're using) is written in Lua. Tables are really flexible.
Didn't know that to be honest ^^. I just read the hardoncollider documentation concerning the shapes module, and thats why i discovered too, its indeed a table... And i do agree that they are flexible ^^.
Tables are essentially the core thing around all Lua is built. For successfully code in Lua you should start asap read and do even some Lua tutorials about tables. Unless you do that Lua/LOVE world and potentialities will stay "locked" for you.

Re: Questions about platformer game

Posted: Tue Sep 11, 2012 9:15 pm
by tv_user
This book is all you need to know/learn about Lua programming. It was written by one of the founders of the language, and it is pretty easy and enjoyable to read. Buy it, borrow it, download it, steal it...heck, do what you want, but get a copy of it! :ultraglee:
Lua is built around the concept of flexibility, and that comes from the fact that it has only one data structure (yes, you guessed it...) - tables. variables are tables, arrays are tables, functions can be thought of as a cell in a table, even the entire program you write is a table.

Re: Questions about platformer game

Posted: Tue Sep 11, 2012 10:41 pm
by gregkwaste
Thanks a lot for all the input, its an absolute relief for me that everything is a table just because i am very comfortable with using them and basicaly it was easy for me to understand everything as tables as well, and to be honest i definetely did not expect that EVERYTHING would be like that in lua ^^.

I'll try to get somehow this book and find out every detail i am missing ^^.

Re: Questions about platformer game

Posted: Wed Sep 12, 2012 10:05 am
by Roland_Yonaba
gregkwaste wrote:Thanks a lot for all the input, its an absolute relief for me that everything is a table just because i am very comfortable with using them and basicaly it was easy for me to understand everything as tables as well, and to be honest i definetely did not expect that EVERYTHING would be like that in lua ^^.

I'll try to get somehow this book and find out every detail i am missing ^^.
Or eventually, read the free online version.