Search found 234 matches

by KayleMaster
Fri Sep 02, 2016 7:28 am
Forum: Support and Development
Topic: Local variables and global variables
Replies: 40
Views: 22891

Re: Local variables and global variables

After the fourth page I think I already got it :D thanks anyways
Btw, someone mentioned that functions are kept in the global environment as well. Could one do this:

Code: Select all

local function thisFunctionIsOnlyForThisFile()
--stuff
end
by KayleMaster
Thu Sep 01, 2016 9:05 am
Forum: Support and Development
Topic: Local variables and global variables
Replies: 40
Views: 22891

Re: Local variables and global variables

Dots? You do realize underscores won't function as table accessors though, right? lowercase, pascalCase, CamelCase, under_scores are formatting choices, but table access can only happen with either [brackets] or .dots (for literal strings, that is) I didn't know that, but what's the difference betw...
by KayleMaster
Thu Sep 01, 2016 7:07 am
Forum: Support and Development
Topic: Limit framerate to exactly 60
Replies: 12
Views: 17893

Re: Limit framerate to exactly 60

zorg wrote:@KayleMaster: That caps frames per second, it does not give you a constant rate for logic, or anything Nilxoc wanted to do.
Ugh, here I am again, with my "GML" knowledge where fps and game logic is the same thing. (well at least you could uncouple them tho)
by KayleMaster
Thu Sep 01, 2016 7:03 am
Forum: Support and Development
Topic: Local variables and global variables
Replies: 40
Views: 22891

Re: Local variables and global variables

raidho36 wrote:
Yes your GameMaker background is apparent from the way you code.

That's why I prefer using underscores rather than dots. I just think it's way more readable, just my opinion tho.
by KayleMaster
Wed Aug 31, 2016 7:42 pm
Forum: Support and Development
Topic: Limit framerate to exactly 60
Replies: 12
Views: 17893

Re: Limit framerate to exactly 60

What about LOVE's tutorial on capping fps? function love.load() min_dt = 1/30 --fps next_time = love.timer.getTime() end function love.update(dt) next_time = next_time + min_dt --rest of function here end function love.draw() --rest of function here local cur_time = love.timer.getTime() if next_time...
by KayleMaster
Wed Aug 31, 2016 9:13 am
Forum: Support and Development
Topic: Multidimensional array returns nil.
Replies: 8
Views: 4330

Re: Multidimensional array returns nil.

Yeah, It was somewhere else in the code.
by KayleMaster
Wed Aug 31, 2016 8:02 am
Forum: Support and Development
Topic: Local variables and global variables
Replies: 40
Views: 22891

Re: Local variables and global variables

What if I did this in my second file?

Code: Select all

local chunk_width = 15

function get_chunk_width()
    return chunk_width
end

And I could just do get_chunk_width in main.lua
Is this slow? Is this preferred over using the global environment ?
by KayleMaster
Tue Aug 30, 2016 6:41 pm
Forum: Support and Development
Topic: Local variables and global variables
Replies: 40
Views: 22891

Re: Local variables and global variables

Well, I'm not really a beginner, I came from GM:S so I know my way around.
The problem is I'm working on a large-scale game (huh, I've wondered if this is the hundredth time you heard this) so I'd really prefer the multiple files convenience. I'd guess I would use globals after all. (for some stuff)
by KayleMaster
Tue Aug 30, 2016 3:48 pm
Forum: Support and Development
Topic: Local variables and global variables
Replies: 40
Views: 22891

Re: Local variables and global variables

Maybe it's better to keep my game in one file mostly then :/
by KayleMaster
Tue Aug 30, 2016 11:29 am
Forum: Support and Development
Topic: Local variables and global variables
Replies: 40
Views: 22891

Re: Local variables and global variables

So If I put return varname in my second file, it's scope will also be extended to the file that called that file? (in this case main.lua) Why are we initializing variables just there and not in love.load() as it is said in love2d beginner tutorial? If I do local varname in love.load, does it mean I ...