Log In  


I understand Pico-8 has a subset of the full Lua language. However, I wonder is there enough of it there to make the following book useful: https://www.amazon.com/Programming-Lua-Fourth-Roberto-Ierusalimschy/dp/8590379868/ref=pd_lpo_sbs_14_t_0?_encoding=UTF8&psc=1&refRID=JKY5ABS0S7DB70RF732Z

Does anyone have this and did it help you?

I've been able to get by picking up a smattering of lua syntax just online, but I enjoy the idea of getting a deeper look at the language. However since Pico-8 is the only platform on which I'm extensively using Lua, I want to make sure the investment would be worth it.



I'm not sure how useful it would be...Lua is a pretty simple language to begin with, compared to a lot of others...and the PICO-8 subset makes it even simpler.

I guess I'm just not sure what a book could tell you that you couldn't easily find online (e.g. lua.org, lua-users.org)...I've never had to look at any books personally; I've found the web to be a sufficient source of Lua information. But you may be more book-oriented in your learning style, so I guess only you would know if it would be more helpful :)


@gradualgames

How experienced are you with other languages? That might be useful in deciding whether or not you could use extra learning materials.

These days, I've been exposed to so many languages that I can mostly just poke around and figure out what the language's version of functionality X looks like and I'm good to go. Sure, there are a few weird ones where the whole paradigm is different, but mostly if you're already familiar with programming and with fundamental algorithms, it's usually just a matter of spotting an unfamiliar form of an otherwise-familiar function.


Programming Lua is 1/2 about the language features, 1/4 about the Lua standard library, and 1/4 about embedding the Lua interpreter in a C application. Only the first half is relevant to Pico-8, and there are minor differences to watch out for. Also, the 4th edition covers Lua 5.3, and Pico-8 uses Lua 5.2, so there'd be some minor pitfalls in that regard as well.

The first edition of Programming Lua is free online, covering up to Lua 5.0: https://www.lua.org/pil/contents.html

I'd say it's mostly not worth it for most Pico-8 devs. You'll get more from online materials and Pico-8 specific examples. If you like languages in general (like I do :) ), downloading the Lua interpreter and playing with the book is a good time, and you'll learn stuff for Pico-8 if you're willing to do some minor translation and experimentation.

It's hardly a complete language guide, but you might enjoy a quick read through the Lua page of the Pico-8 wiki. Bouncing around the API reference might also be of interest. I tried to make sure every function has code examples.


I probably don't need the book. I've picked up everything I think I need to know for Pico-8, even going so far as using coroutines. I guess I just liked the idea of learning some Lua idioms that I might not pick up until later or something. But given that Pico-8 does not have the full language maybe I wouldn't be able to employ everything I learn anyway.

I mainly just liked the idea of having a yummy smelling new book for my shelf and support the guys who created Lua. Though I wonder if Lexaloffle has supported Lua at all, so I'd be supporting it indirectly by having purchased Pico-8 to begin with.


Well, PICO-8 has the full language, it just doesn't have the full support library. If you're familiar with C++, it's a lot like having a C++ compiler, but no STL. Or C# without the .NET libraries.

Ideally, I think a PICO-8 programmer would probably learn the most by reading material by/for people who write Lua modules/libraries. By that, I mean people who have to write things in Lua from scratch, building things other people build on top of. Those are the people who are going to know the best tricks.


I fully endorse buying the book for the sweet paper smell and supporting the Lua project. :)

The Pico-8 pitfalls with Lua docs are minor and are mostly about various built-ins being missing with no equivalent. I'm not complaining, just saying it might be confusing for people new to the language. Examples in early chapters in Programming Lua require a bit of mindful translation.

I learned about Lua iterators going through the book just now looking for things that might break. And they work in Pico-8! So there's another endorsement for the book.

function list_iter(t)
 local i = 0
 local n = #t
 return function()
  i += 1
  if (i <= n) then
   return tostr(i)..": "..t[i]
  end
 end
end

x = {"alpha", "beta", "gamma"}
for element in list_iter(x) do
 print(element)
end

Yeah, iterators are cool. Sadly, they can be pretty expensive if you don't use the default pairs() iterator. But still, it's really nice to have the flexibility to write your own, and the work required to do it isn't onerous like it is in C++. Writing a full, robust iterator in C++ can be paaaiiiinful.


I wound up getting the book. I already learned a couple of surprising things, such as the a ? b : c idiom:

(a and b or c)

and that

if 0 then print "hi" end

will actually print "hi." That threw me for a loop :D

Glad I got the book. And after it warmed up from being out in the cold, it DOES smell yummy.


I definitely recommend reading the book. It might not be the most succinct book in terms of explanation, but it does provide some very useful idioms and notes. I tried reading through the latter half of the book but they just don't seem to be practical for pico-8 game dev... I would recommend reading up to object-oriented lua though, as I haven't found a better tutorial on the internet regarding Lua's OO features yet.


I learnt lua when I was making a porklike clone



[Please log in to post a comment]