Page 2 of 2

Re: Help with game lag

Posted: Sat Nov 22, 2014 3:05 pm
by SpotlightKid
Muris wrote:I honestly think the worst thing about LUA is the fact that instead of crashing, it actually makes global variables by default unless especially told not to aka local. [...] I have a gut feeling that if the project size grows, the probability of me not being able to track bugs that comes from having accidentally created globals, and not being able to find a bug in my program.
Maybe these can help:

http://www.luafaq.org/index.html#T1.6
http://lua-users.org/wiki/DetectingUndefinedVariables
http://www.lua.org/extras/5.1/strict.lua
http://thomaslauer.com/comp/LuaStrict

Re: Help with game lag

Posted: Sat Nov 22, 2014 5:26 pm
by kikito
Lafolie wrote: From what I've read there is actually little impact using globals over locals[...] They're mostly recommended because it helps to 'keep the scope clean' and makes your code somewhat easier to maintain
@Muris: I strongly suspect that Lafolie is referring to locals in that last phrase("locals are recommended because they keep the scope clean), but he ended up saying the opposite of what he meant.
The reason why I decided to go with libgdx on my project is mostly because I have a gut feeling that if the project size grows, the probability of me not being able to track bugs that comes from having accidentally created globals, and not being able to find a bug in my program.
I have used luacheck to detect unused/global variables in my code with good success recently. It does static analysis of your code, so it can warn you about these issues before run-time.

Re: Help with game lag

Posted: Sat Nov 22, 2014 7:27 pm
by bartbes
kikito wrote:but he ended up saying the opposite of what he meant.
Not even that, he was already talking about locals, all the way through.

Re: Help with game lag

Posted: Mon Nov 24, 2014 7:28 am
by s-ol
Muris wrote:
Lafolie wrote:
jjmafiae wrote: tip 4: use locals and remove any unused globals
makes your code somewhat easier to maintain.
Globals and easier to maintain code doesn't really sound like something I would put together in most cases, unless you are 100% sure that you know exactly what you are doing. I honestly think the worst thing about LUA is the fact that instead of crashing, it actually makes global variables by default unless especially told not to aka local.

The reason why I decided to go with libgdx on my project is mostly because I have a gut feeling that if the project size grows, the probability of me not being able to track bugs that comes from having accidentally created globals, and not being able to find a bug in my program. The other reason is that I feel that debugging in java is easier, but there could be good tools for lua too.

Still I honestly think that Love2D is probably the best 2d engine I have seen so far, and most productive thing I've found.
You should try zerobrane studio, it has full in-code stepping, breakpoints, a REPL and can do livecoding!

Re: Help with game lag

Posted: Mon Nov 24, 2014 6:32 pm
by jjmafiae
Guys I found this a while ago: http://www.lua.org/gems/sample.pdf