Search found 3548 matches

by pgimeno
Sun Mar 08, 2020 2:10 am
Forum: Support and Development
Topic: Passing key in function
Replies: 8
Views: 7721

Re: Passing key in function

Perfect, thanks so much for your help! One more question, if ... is more than one variable, then is it stored as a table? like to reference the second variable in the passed arguments, would it be like this function something(...) x = ... print(x[2]) end No, it's a tuple, not a table. However, you ...
by pgimeno
Sat Mar 07, 2020 3:45 pm
Forum: Support and Development
Topic: Passing key in function
Replies: 8
Views: 7721

Re: Passing key in function

Adding the ... in function() and ui:input() seems to have fixed the issue. What exactly does this do? Is this just a placeholder letting lua know it should have an argument or do the 3 dots actually mean something? Thanks! When used in a function declaration, it indicates that it accepts a variable...
by pgimeno
Sat Mar 07, 2020 11:32 am
Forum: Support and Development
Topic: Passing key in function
Replies: 8
Views: 7721

Re: Passing key in function

function stack:push() table.insert(stack.input, function() ui:input() end) end Now the problem I am running into is this code below function love.keypressed(key) stack.input[#stack.input](key) end If it doesn't specify any arguments, every argument you pass will be ignored. Maybe you want this inst...
by pgimeno
Tue Mar 03, 2020 2:41 am
Forum: Support and Development
Topic: [SOLVED] Lua math.cos issue
Replies: 8
Views: 13600

Re: [SOLVED] Lua math.cos issue

This is exactly the reason. The value returned is the cosine of that approximation. Something similar happens with math.sin(math.pi). Nevermind that math.cos function itself only returns approximate cosine values (and of not particularly great accuracy, FYI). Apparently that happens on LuaJIT only....
by pgimeno
Mon Mar 02, 2020 11:40 pm
Forum: Support and Development
Topic: [SOLVED] Lua math.cos issue
Replies: 8
Views: 13600

Re: [SOLVED] Lua math.cos issue

ingsoc451 wrote: Mon Mar 02, 2020 7:05 pm Also don't forget that math.pi is just an approximation of the number pi
This is exactly the reason. The value returned is the cosine of that approximation. Something similar happens with math.sin(math.pi).
by pgimeno
Mon Mar 02, 2020 10:44 am
Forum: General
Topic: Mini Functions Repository
Replies: 48
Views: 41320

Re: Mini Functions Repository

Here's a pair of functions that allow storing tuples into tables and then retrieving back these tables as tuples: local function pack_n(...) return {select('#', ...), ...} end local unpack_n do local function unpack_count(x, n) if n == x[1] + 1 then return end n = n + 1 return x[n], unpack_count(x, ...
by pgimeno
Sun Mar 01, 2020 2:11 pm
Forum: General
Topic: Can you give me advice?
Replies: 3
Views: 7320

Re: Can you give me advice?

Very wise advice by akciom. I have just one thing to add: If you're unhappy with the quality of the code, don't start rewriting your program unless either: you're in the very early stages of development and you realize that you made some very wrong design choices, it's so unmaintainable that it's im...
by pgimeno
Sat Feb 29, 2020 2:45 pm
Forum: Support and Development
Topic: Severe memory leak upon rendering player
Replies: 3
Views: 4654

Re: Severe memory leak upon rendering player

In line 381 you're calling love.draw, which is the same event you're in. That should be love.graphics.draw.
by pgimeno
Sat Feb 29, 2020 2:57 am
Forum: Support and Development
Topic: How do I efficiently update an image?
Replies: 16
Views: 18498

Re: How do I efficiently update an image?

I think you may be looking for (Image):replacePixels.
by pgimeno
Mon Feb 24, 2020 11:25 am
Forum: Support and Development
Topic: Infinite vertical platform generation
Replies: 2
Views: 3731

Re: Infinite vertical platform generation

Welcome to the forum :)

The fastest way is probably going to be to assemble them from a set of pre-built templates. I think I've seen such a game here in past, but I can't remember the details.