The Wayback Machine - https://web.archive.org/web/20220129132342/https://en.wikibooks.org/wiki/Talk:Lua_Programming

Talk:Lua Programming

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Merge with Lua Programming / Embedding Lua / Lua components written in C&C++[edit source]

I support the merge of Lua programming and Lua Programming, with Lua programming's content largely superseding Lua Programming's. Lua Programming does have a section called 'solutions' which suggests there should be pages about writing Lua components in C and C++ and embedding and embedding Lua in C and C++. Hackbinary (discusscontribs) 13:05, 12 October 2013 (UTC)[reply]

Programming Solutions[edit source]

I notice that you have removed the "programming solutions" section. This has left a hidden section "solution"s, which is no longer accessible via the book indexes. I'll put this back for now, until the indexes are fixed.

Markhobley (discusscontribs) 21:12, 25 February 2011 (UTC)[reply]

Merger with Lua programming[edit source]

The voting is happening here: Wikibooks:Requests_for_deletion#Lua_Programming Hackbinary (discusscontribs) 13:12, 12 October 2013 (UTC)[reply]

Consensus was to merge the books. Please see Category:Book:Lua Programming for a complete list of pages, many of which are not linked to from anywhere within this book right now. --darklama 19:05, 23 May 2014 (UTC)[reply]

Translate to Chinese[edit source]

I want to make a Chinese translation. Can I? ShadowYC (discusscontribs) 01:41, 16 February 2017 (UTC)[reply]

Yes you can. Ftiercel (discusscontribs) 19:53, 16 March 2017 (UTC)[reply]

Should we have a section on object oriented programming[edit source]

Should we have a section on object oriented programming?

While Lua doesn’t have native objects, a combination of metatables (i.e. the __index property of metatables) and Lua’s “:” syntactic sugar gives us real classes with inheritance. For example:

 -- Public domain example of Objects in Lua using metatables
 -- Let’s create a class
 Add1Obj = {} -- Initialize a new class
 Add1Obj.__index = Add1Obj -- Allow class to be a metatable
 
 -- Method: Initialize class
 function Add1Obj:new(start)
   if start == nil then
     start = 1
   end
   return setmetatable({v = start},self)
 end
 
 -- Method: Add one to the class’s “v” element
 function Add1Obj:add1()
   self.v = self.v + 1
   return self.v
 end
 
 -- Example of class usage
 foo = Add1Obj:new(1)
 print(foo:add1())
 print(foo:add1())
 
 -- Now, let’s create a derived class
 Add2Obj = {} -- Initialize a new class
 Add2Obj.__index = Add2Obj -- Allow this class to be a metatable
 setmetatable(Add2Obj, Add1Obj) -- Inherit the Add1Obj class
 
 -- Derived class has a new method
 function Add2Obj:add2()
   self.v = self.v + 2
   return self.v
 end
 
 -- Example using derived class
 foo = Add2Obj:new(20)
 print(foo:add1())
 print(foo:add2())
 -- END public domain code

Thoughts? Samboy (discusscontribs) 06:41, 4 April 2021 (UTC)[reply]

Navigation menu

Morty Proxy This is a proxified and sanitized view of the page, visit original site.