Lua 5.3. What do you need to do to update code?

I just upgraded to the latest codea update, and with lua 5.3, most of my code spits out errors. What exactly are the things you need to change to update your code? Thanks!

Depends what sort of errors are being thrown out, check the Lua 5.3 thread for more info.

@Mr_Ninja See the start of page 1 of the link below.

One thing that was never answered is if I don’t update so I don’t have to fix the code in a game I’m working on, will the new update be used on export and mess up my code anyway?

@Simeon ?

@Crumble when you export from a particular version it will only download libraries for that version

Can someone give me an example of integers that worked in lua 5.1 but now don’t work in lua 5.3?

@Goatboy76 See my response above. The first page of that link explains things.

EDIT: For the integer error, it’s just a matter of making any floating point numbers integers. That can be done using math.floor or by using the double / for integer division ( // ).

@dave1707 I’ve read that whole thread and am still confused. So you cant have any floats? That cant be true. I need a very simple example of something that did work, and then would would be changed to make it work.

@Goatboy76 You can still have floats, that hasn’t changed. What has changed is some math functions require an integer as a parameter. One of those is math.random . It now requires integers as parameters, for instance math.random(int) or math.random(int,int) where int is an integer. Once you run your code using 5.3, you’ll get error messages where you need to change something.

@dave1707 That makes sense. Is tween also effected by this? It says “error in tween.lua, must be positive number, was 0.0”.

@Goatboy76 That sound like just a tween error. Apparently tween needs a number greater than 0.

I was adding a value into a table and all I needed to do was math.floor it, that may solve some of the problems, and I think that with tables the position you are entering into you are inserting into it can’t be higher by more than one from the length of the table but that might have just been me and not the update.

@Nathan In an older version of Lua, you could insert a value at any position in a table, even if that position was well beyond the end of the table. In version 5.3, you can’t insert a value into a table unless it’s less than the end, or 1 greater than the end of the table.

@dave1707 Yeah, do you know any way to insert into any position other than adding a lot of numbers I don’t use into the table as filler?

@Nathan As far as I know, if you’re going to insert values at random positions in a table, then you need to fill the table with something up to the size you’re going to use.

Alright, that’s been working well enough

@dave1707 - this code works fine for me

    for i,j in pairs(t) do

@dave1707 I’m 99% sure its related to the update to 2.3. The same error is in all of my backups for the last couple months. I’m investigating further.

Can you post some code that breaks?

@Ignatz Sorry if I wasn’t very clear, but table.insert doesn’t allow you to insert a value well beyond the end of a table. You can still insert using a direct entry like you show.