Lua book

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Lua book

D Burgess-2
Having stayed up most of the night reading Robertos book
( http://www.inf.puc-rio.br/~roberto/book/ ), I would like
to congratulate Roberto on a great job. 
Thank you Roberto!

D Burgess



Reply | Threaded
Open this post in threaded view
|

Re: Lua book

Steve Elkins
On Tue, 23 Dec 2003 9:4:17 +1000
"D Burgess" <[hidden email]> wrote:

> Having stayed up most of the night reading Robertos book
> ( http://www.inf.puc-rio.br/~roberto/book/ ), I would like
> to congratulate Roberto on a great job. 

I'm jealous.  Had this from Amazon this morning:

  "Due to an unexpected delay from our supplier, it appears that 
   the following item(s) will not be delivered by December 24."

Maybe it'll show up the next day.  ;-)


Reply | Threaded
Open this post in threaded view
|

Re: Lua book

José dos Santos Machado
In reply to this post by D Burgess-2
Having stayed up most of the night reading Robertos book
( http://www.inf.puc-rio.br/~roberto/book/ ), I would like
to congratulate Roberto on a great job. Thank you Roberto!

Do we already have a "Rio de Janeiro" version available ? I wouldn't like to wait 3 or 4 weeks for it to come from US... Thank's !
-- J. Machado
-- [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Lua book

Enrico Colombini
In reply to this post by Steve Elkins
On Tuesday 23 December 2003 12:45, Steve Elkins wrote:
>   "Due to an unexpected delay from our supplier, it appears that
>    the following item(s) will not be delivered by December 24."

By the time it gets to Amazon France, looks like I'll get it in January... but 
I'm sure it's well worth the wait.

A Merry Christmas and Happy New Year to all Lua users!

  Enrico

Reply | Threaded
Open this post in threaded view
|

Re: Re: Lua book

D Burgess-2
In reply to this post by D Burgess-2
I ordered from B & N
+++++++++++++++++++++++++++++++++
>On Tue, 23 Dec 2003 9:4:17 +1000
>"D Burgess" <[hidden email]> wrote:
>
>> Having stayed up most of the night reading Robertos book
>> ( http://www.inf.puc-rio.br/~roberto/book/ ), I would like
>> to congratulate Roberto on a great job. 
>
>I'm jealous.  Had this from Amazon this morning:
>
>  "Due to an unexpected delay from our supplier, it appears that 
>   the following item(s) will not be delivered by December 24."
>
>Maybe it'll show up the next day.  ;-)
			





Reply | Threaded
Open this post in threaded view
|

Re: Lua book

Roberto Ierusalimschy
>  "Due to an unexpected delay from our supplier, it appears that 
>   the following item(s) will not be delivered by December 24."

>  I ordered from B & N

Actually, B & N currently says "A new copy is not available from Barnes
& Noble.com at this time." I contacted my distributor, and they said
that this is probably related to Christmas. One problem is that the book
is non-returnable, so that both Amazon and B & N do not keep copies of
the book. (The book is non-returnable because it is too expensive to
send returned books to Brazil...)  I hope after Christmas things will
get back to normal.


> Having stayed up most of the night reading Robertos book
> ( http://www.inf.puc-rio.br/~roberto/book/ ), I would like
> to congratulate Roberto on a great job. 
> Thank you Roberto!

Thank you!!! Wouldn't you like to write a short review at Amazon?
We need all kind of help we can get to promote the book.


> Do we already have a "Rio de Janeiro" version available ? I wouldn't  
> like to wait 3 or 4 weeks for it to come from US...                   

The prospects of the "Rio" version are not very clear yet. I contacted
some printers, but it is too expensive to print a short run. (Anyway,
they won't be available in the next 3 weeks...)

-- Roberto

Reply | Threaded
Open this post in threaded view
|

Re: Lua book

D Burgess-2
In reply to this post by D Burgess-2
>Thank you!!! Wouldn't you like to write a short review at Amazon?
>We need all kind of help we can get to promote the book.
I see what I can do.





Reply | Threaded
Open this post in threaded view
|

Re: Lua book

David Anderson
In reply to this post by Enrico Colombini
Enrico Colombini wrote:

By the time it gets to Amazon France, looks like I'll get it in January... but I'm sure it's well worth the wait.


Any info about when it'll be available in France? Or even in the UK, my problem with ordering from amazon.com is having it shipped from outside the EU, with all the import taxes involved...

Pity, I am integrating Lua into a game engine at this time, and it gets tiring having to cope with the "Okay, let's look it up in the book... Oh, haven't got it yet." ;)

Hope it'll reach us soon, so we can also say how great a book it is :)

David Anderson

Attachment: pgprXIzVYuENG.pgp
Description: PGP signature

Reply | Threaded
Open this post in threaded view
|

Re: Lua book

Roberto Ierusalimschy
> Any info about when it'll be available in France? Or even in the UK, my 
> problem with ordering from amazon.com is having it shipped from outside 
> the EU, with all the import taxes involved...

I am not sure whether the book will be directly available in France (or
UK) :( You see, we do not have an "official" publisher. Our printer
and distributor (Lightning Source) only distributes the book in the US
(through Ingram). They do have a subsidiary in the UK, but to offer the
book there we would have to go through the whole process again (and pay
setup costs again, this time in pounds!! :)

Is it really difficult (or expensive) to order it from amazon.com?
(By the current exchange rate, the book costs less than EUR 20,00 ;)
I know it is not as easy as a local buy, but I thought that, putting
it at Amazon, it would be available to most people with an Internet
connection.

-- Roberto

Reply | Threaded
Open this post in threaded view
|

Re: Lua book

Remo Dentato
> Is it really difficult (or expensive) to order it from amazon.com?
> (By the current exchange rate, the book costs less than EUR 20,00 ;)
> I know it is not as easy as a local buy, but I thought that, putting
> it at Amazon, it would be available to most people with an Internet
> connection.

This is (part of) the answer of Amazon to my order (I'm in Italy). I could
have a lower shipping price (something more than 8$) waiting some days more.
As you can see, shipping is around 1/3rd of the total amount I'll pay the
book but I'm sure the book will worth any cent of it.

Shipping Method:     Expedited International Shipping (averages 5-10
business days)
Shipping Preference: Group my items into as few shipments as possible
Subtotal of Items:   $24.47
Shipping & Handling: $12.98
  ------ 
Total for this Order:   $37.45

Shipping estimate for these items: January 5, 2004
Delivery estimate: January 12, 2004 - January 20, 2004
  1 "Programming in Lua" Roberto Ierusalimschy;Paperback; $24.47




Reply | Threaded
Open this post in threaded view
|

Re: Lua book

David Anderson
In reply to this post by Roberto Ierusalimschy
Roberto Ierusalimschy wrote:

Is it really difficult (or expensive) to order it from amazon.com?
It is neither one or the other. However, I find that each time I buy stuff from Amazon USA and get it shipped to france, I receive the package opened, with a small note inviting me to pay for additionnal import taxes and customs handling fees. FYI, the last book I bought international (Schneier's Applied Cryptography,excellent book) cost me about 40 euros plus shipping, and I had to pay another 20 euros of various import taxes and fees on reception.

That is why I now try to get stuff from within the EU, to avoid a repeat of the same scenario :)

I know it is not as easy as a local buy, but I thought that, putting
it at Amazon, it would be available to most people with an Internet
connection.
Indeed, that was a good choice. I was just sort of vaguely hoping that Amazon would make it available through its other distributors (like Applied Cryptography, which was made available from Amazon France about two weeks after I received mine... :/ ), so I can avoid the few weeks waiting time and the additionnal taxes.

I looked on amazon UK, and they have your book in the listings, marked "This product is unavailable at this time", so I was hoping that it would be because Amazon US didn't get round to sending them copies yet ;)

David Anderson

Attachment: pgp3D0q0Wd6J4.pgp
Description: PGP signature

Reply | Threaded
Open this post in threaded view
|

Re: Lua book

Roberto Ierusalimschy
> I looked on amazon UK, and they have your book in the listings, marked 
> "This product is unavailable at this time", so I was hoping that it 
> would be because Amazon US didn't get round to sending them copies yet ;)

I don't know how Amazon works, so maybe the book will be available at
Amazon.co.uk after all. (Barnes & Nobles also shows the book as not
available at this time; but it mysteriously presents an "used copy
available", shipping in 1-2 days, by US$57.75!! So it seems there
is already a black market for the book ;) I will have to wait past
Christmas season to see how things evolve.

-- Roberto

Reply | Threaded
Open this post in threaded view
|

Re: Lua book

Enrico Colombini
In reply to this post by David Anderson
On Friday 26 December 2003 13:33, David Anderson wrote:
> It is neither one or the other. However, I find that each time I buy
> stuff from Amazon USA and get it shipped to france, I receive the
> package opened, with a small note inviting me to pay for additionnal
> import taxes and customs handling fees.

When this happens here in Italy, the package could also be held in a (randomly 
chosen) custom house, waiting for an exchange of paperwork. It happened to me 
once (it wasn't a package from Amazon).

Anyway, both amazon.fr and amazon.co.uk accept orders for the book, so I 
compared the prices and ordered from amazon.fr. The confirmation message 
said:
 Date de livraison estimee: 2 janv. 2004 - 6 janv. 2004
[i.e. estimated delivery time]

  Enrico

Reply | Threaded
Open this post in threaded view
|

Re: Lua book in the UK

Roberto Ierusalimschy
> Anyway, both amazon.fr and amazon.co.uk accept orders for the book, [...]

When was that? The whole discussion is around amazon.co.uk and amazon.fr
not accepting orders! I have just visited both sites and both say
"Actuellement indisponible" (currently not available). But both sites
have a sales rank for the book, meaning that they have sold some
titles. (And amazon.fr explicitly asks the user to return later to check
whether the book is available again...)


> in light of all the comments on the difficulties to get the book in
> the UK/EU for a price that does not include handling fees, inport
> taxes etc, would it be an idea to re-publish it here?

This is an option, but I still think those difficulties may be due
to Christmas season, so I should wait until mid-january to make
a decision.

-- Roberto

Reply | Threaded
Open this post in threaded view
|

Re: Lua book in the UK

Enrico Colombini
On Monday 29 December 2003 12:37, Roberto Ierusalimschy wrote:
> When was that? The whole discussion is around amazon.co.uk 
> and amazon.fr not accepting orders! 

Sorry for having been too concise. The day after you announced it I ordered it 
from amazon.fr and got a confirmation message with the delivery date I 
reported.

  Enrico

Reply | Threaded
Open this post in threaded view
|

Fastest way of mapping a C++ object (or C struct) to Lua

jose marin2
In reply to this post by José dos Santos Machado
Hi.

What´s the fastest way of mapping a C++ object (or C
struct) to Lua?


In C++ 

class NPC{
 int health;
 vector3 position;
 // other attributes

 void Move();
 // other methods
};


In LUA

 enemy1.health = 100
 enemy1.Move()



If is there some way of map fast a C struct to a LUA
variable, this will be enough.

Note:
 I wont use tolua, great tool, but I want to learn how
to do this myself


______________________________________________________________________

Conheça a nova central de informações anti-spam do Yahoo! Mail:
http://www.yahoo.com.br/antispam

Reply | Threaded
Open this post in threaded view
|

Re: Fastest way of mapping a C++ object (or C struct) to Lua

Jarrod Roberson
Jose Marin wrote:

Hi.

What´s the fastest way of mapping a C++ object (or C
struct) to Lua?


In C++
class NPC{
int health;
vector3 position;
// other attributes

void Move();
// other methods
};


In LUA

enemy1.health = 100
enemy1.Move()



If is there some way of map fast a C struct to a LUA
variable, this will be enough.

Note:
I wont use tolua, great tool, but I want to learn how
to do this myself
the fastest way is to use toLua or someother code generator or template such as Luna if you are doing C++.

Now if you want to do it by hand that is not the fastest way by a long shot. I did one by hand just to know how it works. Then I use the Luna template or something else automated, doing it by hand is tedious at best and error prone at worst.

There is pleny of documentation on the wiki on how to do this by hand.



Reply | Threaded
Open this post in threaded view
|

RE: Fastest way of mapping a C++ object (or C struct) to Lua

Virgil Smith
In reply to this post by jose marin2
Check out the "Simple C++ Binding" on the wiki.
http://lua-users.org/wiki/SimpleCppBinding


Also, in short plain English... (well almost plain)

Make a Lua table, add your C++ functions to it as methods, (include a __gc
method etc.), set it's __index method to the table itself.  When creating
userdata's for your object instances set this table as their metatable.  The
C++ functions you use will need to be static, from in these functions
themselves use lua_userdata_cast (or similar) to get the userdata instance
(to map to your C++ object instance via contained pointer or directly as the
address depending on your preference.  Use that pointer to call a non-static
member function.  Its very simple to write a macro that generates the static
version of the member function to call a particular non-static version.

Properties (such as your "enemy1.health = 100") can also be accomplished
with just a little more work.  For this you will probably want to write up a
pair of functions to act as the userdata's __index and __newindex methods.
I recommend keeping a pair of tables within the metatable for use with this.
One to hold a set of "set" functions and one to hold a set of "get"
functions.  From __index check the table of "get" functions, if you find one
then the requested member is a property so call the "get" function, if it is
not found then look it up in the main metatable as a "normal" method.
Similar for __newindex.  Again you can make macros to aide in this (though
its a bit less obvious and is definitely more time consuming).

For expediency you could make your own function that takes an array of
structs and generates a metatable along with its associated property set/get
tables.
Once you get into the "properties" rather than just methods this gets a bit
involved and its not terribly time efficient to do yourself, but it is a
good exercise for working with Lua and you can write up and maintain as much
or as little as you need for repeated use in your projects.  I have to admit
that I've experimented along these lines, but have never thoroughly tested
my work or compared it to what is done by tolua or other bindings.





-----Original Message-----
From: [hidden email]
[[hidden email] Behalf Of Jose Marin
Sent: Wednesday, December 31, 2003 8:39 AM
To: [hidden email]
Subject: Fastest way of mapping a C++ object (or C struct) to Lua


Hi.

What´s the fastest way of mapping a C++ object (or C
struct) to Lua?


In C++

class NPC{
 int health;
 vector3 position;
 // other attributes

 void Move();
 // other methods
};


In LUA

 enemy1.health = 100
 enemy1.Move()



If is there some way of map fast a C struct to a LUA
variable, this will be enough.

Note:
 I wont use tolua, great tool, but I want to learn how
to do this myself


______________________________________________________________________

Conheça a nova central de informações anti-spam do Yahoo! Mail:
http://www.yahoo.com.br/antispam



Reply | Threaded
Open this post in threaded view
|

RE: Fastest way of mapping a C++ object (or C struct) to Lua

Evan Wies-2-2
In reply to this post by jose marin2
I really like luabind (http://luabind.sourceforge.net).  It basically does
what tolua does, but uses template metaprogramming and some binding
functions, rather than parsing a "cleaned header" which generates code.  You
could do it yourself (as the other posts describe), but (for my purposes at
least) why bother if a compiler can make the same thing for you via
templates.

You would simply do this:

void register_objects( lua_State* L )
{
	using namespace luabind;
	module( L )
	[
		class<vector3>("vector3")
			// bind vector3 properties / methods for use in lua
		,
		class_<NPC>( "NPC" )
			.def( constructor<>() )
			.property( "health",   &NPC::Health )
			.property( "position", &NPC::position )
			.def( "Move",          &NPC::Move )
	];
}

Now you can simply use it in Lua:

npc = NPC();
npc.health = 1;
npc.position = vector3(0,0,0);
Npc:Move();

-Evan


-----Original Message-----
From: Jose Marin [[hidden email]] 
Sent: Wednesday, December 31, 2003 9:39 AM
To: [hidden email]
Subject: Fastest way of mapping a C++ object (or C struct) to Lua


Hi.

What´s the fastest way of mapping a C++ object (or C
struct) to Lua?


In C++ 

class NPC{
 int health;
 vector3 position;
 // other attributes

 void Move();
 // other methods
};


In LUA

 enemy1.health = 100
 enemy1.Move()



If is there some way of map fast a C struct to a LUA
variable, this will be enough.

Note:
 I wont use tolua, great tool, but I want to learn how
to do this myself


______________________________________________________________________

Conheça a nova central de informações anti-spam do Yahoo! Mail:
http://www.yahoo.com.br/antispam


Reply | Threaded
Open this post in threaded view
|

Thanks

jose marin2
Thank you all for your tips!

Happy new year!



______________________________________________________________________

Conheça a nova central de informações anti-spam do Yahoo! Mail:
http://www.yahoo.com.br/antispam