Codea 2.3: Lua 5.3

Oh my gosh, you have no idea how excited I am! YES! :smiley:

@TheSolderKing Codea 2.3 includes two “private” libraries. Private in the sense that they will not be documented as an official feature of Codea. Not because they aren’t allowed to be put in — they are — but because I don’t see them as a basic part of the Codea API.

To use socket you will need to use require, i.e.

local socket = require("socket")

Codea 2.3 also includes LPEG as a private library, which is an incredibly powerful parsing expression grammar (http://www.inf.puc-rio.br/~roberto/lpeg/). It’s a native library with a good Lua API for composing complex grammars. The reason it is included is so that the JSON library can make use of it for speed reasons.

The plan for these private libraries is to build future public Codea features on top of them, but you can use them directly if you want to.

I’ve been trying to figure out LPeg, but it seems really confusing. I can’t wait for @Ignatz to do a tutorial on it.

I’d better update to 2.3 and see what all this is about! :slight_smile:

@Ignatz Just go to this link for LPeg.

http://www.inf.puc-rio.br/~roberto/lpeg/

I thought quaternions were hard, until I started reading the paper describing LPEG :-S

A good starting point is Lpeg recipes, it shows how to build simple parsers for common use cases:

http://lua-users.org/wiki/LpegRecipes (the final ones are an entire Lua lexer and parser in Lpeg)

Edit: There’s also a regular expression library written in lpeg. It’s basically Lua code that compiles a regular expression to an lpeg expression using lpeg. I haven’t tested but you should be able to get it as follows:

local re = require("re")

If someone can help build a PTP socket program, I will write it up, because I’m certain it will be an extremely popular feature for game development.

Ill try and help build it @Ignatz though I don’t know how good at it I will be. I guess Ill try my hand at it when the next release version comes out :smiley:

Did I miss something or can the sound function no longer work with *floats for volume?

@Simeon Maybe I’m just stupid, but can what code did work in 2.2 but won’t work in 2.3? I don’t know anything more than basic programming vocabulary.

@Luatee I think it needs to be a float within 1.0 -0.0. 1.0 being max system volume and 0.0 being no sound at all. Could be wrong tho.

@Goatboy76 Oops, I meant floats. I have sound(soundname,0.25) and it doesn’t seem to want to work.

@Luatee Have you tried it in Scratchpad.

Yes, sound has a problem. It is supposed to take a fraction 0-1, but throws an error if it’s not an integer.

@Luatee I had a problem with sound for a few files. It turned out to be that somehow the files werent the file type they said they were.

I tried a built in sound and fractions didn’t work

@dave1707 I didn’t get the chance by the time I saw your post but I haven’t updated scratchpad for a while anyway. There’s no error with the way I use sound() as it’s the same functions that worked 2 months ago, it’s just now they’re saying sound requires an ‘integer representation’.

@Luatee, does music work properly?

he said it didn’t, and it didnt for me either

just run “sound(PICK ANY SOUND FILE,0.5)”

Here’s what I get.

function setup()
    sound("Game Sounds One:Alien 2",0.5)
end

error: [string “-- 00…”]:4: bad argument #2 to ‘sound’ (number has no integer representation)