Talk:Lua Programming
| A Wikibookian has nominated Lua Programming as a featured book candidate and the community is currently discussing it. |
Contents
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 (discuss • contribs) 13:05, 12 October 2013 (UTC)
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 (discuss • contribs) 21:12, 25 February 2011 (UTC)
Merger with Lua programming[edit source]
The voting is happening here: Wikibooks:Requests_for_deletion#Lua_Programming Hackbinary (discuss • contribs) 13:12, 12 October 2013 (UTC)
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)
Translate to Chinese[edit source]
I want to make a Chinese translation. Can I? ShadowYC (discuss • contribs) 01:41, 16 February 2017 (UTC)
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 (discuss • contribs) 06:41, 4 April 2021 (UTC)

