Search found 216 matches

by MrFariator
Thu Mar 04, 2021 12:22 am
Forum: Support and Development
Topic: Collision just doesn't work.
Replies: 1
Views: 59

Re: Collision just doesn't work.

I think the forums don't let new users to attach files to posts right away, so you'll have to make a few more posts first, or link to some filehosting site. Maybe even copy-pasting your code to pastebin, and linking that here. In the mean time, you could also share your code in your forum posts (rem...
by MrFariator
Wed Mar 03, 2021 6:46 pm
Forum: General
Topic: Why not update LOVE?
Replies: 1
Views: 108

Re: Why not update LOVE?

Generally in software development, developers might version lock themselves into specific versions or releases of their engine or choice, or the libraries they are using. This is so to guarantee that the code will build and run correctly, because any changes in those engines or libraries could break...
by MrFariator
Wed Mar 03, 2021 6:19 pm
Forum: General
Topic: That facepalm moment when ...
Replies: 11
Views: 1054

Re: That facepalm moment when ...

hey, why is it printing 1 1? Tables are passed by reference in lua. As such, if you pass in a table and do some modifications on it, then those changes will persist even after the function finishes. However, in the posted code, when the reset_vector is any non-falsey value, the table the variable "...
by MrFariator
Tue Mar 02, 2021 5:36 pm
Forum: Support and Development
Topic: while and repeat loops still cause errors
Replies: 10
Views: 308

Re: while and repeat loops still cause errors

I don't think that's exactly a good use case for repeat-until loops. You'd rather just have some basic control flow (or callbacks, whatever suits the situation) so the entire game doesn't come to a screeching halt just to process a key stroke. Remember, if you have an infinite loop in love.update, y...
by MrFariator
Tue Mar 02, 2021 6:53 am
Forum: Support and Development
Topic: Noob at classes: how to instantiate?
Replies: 3
Views: 140

Re: Noob at classes: how to instantiate?

This is a simple mishap with the 'self' keyword. inputperceptron = {} inputperceptron.__index = inputperceptron function inputperceptron:new(o) o = o or {} setmetatable(o,self) o.weight = {} -- set weight[1] and [2] and [3] to random values for this perceptron o.weight[1] = math.random(1,10) o.weigh...
by MrFariator
Sun Feb 28, 2021 7:19 pm
Forum: Support and Development
Topic: game: crashes; I: need answers
Replies: 7
Views: 241

Re: game: crashes; I: need answers

In main.lua, you have the following code: function ccol(a) if a.y + a.height == 600 then return true else return false end end function love.update(dt) while not ccol(q,c) do yspeed = yspeed + a * dt a = a^10 * dt end end This code assumes that the object a received by ccol() has fields a.y and a.he...
by MrFariator
Sun Feb 28, 2021 4:21 pm
Forum: Support and Development
Topic: game: crashes; I: need answers
Replies: 7
Views: 241

Re: game: crashes; I: need answers

To add to darkfrei's answer, there's two main "falsy" values in lua: false, and nil (the absence of a value). So long the condition (in your case, simply the variable x) evaluates to anything that is non-false or non-nil, the while loop will continuously run forever (because the variable x having a ...
by MrFariator
Sat Feb 27, 2021 9:20 am
Forum: Support and Development
Topic: Using an older love version gives out a black screen
Replies: 6
Views: 237

Re: Using an older love version gives out a black screen

As darkfrei said, the range love.graphics.setColor uses was changed from 0-255 to 0-1 in version 11.0 of löve . In order to run your code in an older version, you could add this code snippet, in main.lua or elsewhere: local originalSetColor = love.graphics.setColor love.graphics.setColor = function ...
by MrFariator
Thu Feb 25, 2021 2:58 am
Forum: Support and Development
Topic: Attempt to index local 'self' (a number value)
Replies: 10
Views: 417

Re: Attempt to index local 'self' (a number value)

Yeah, that's what the error traceback is good for. It will give you the chain of function calls that led to the error, and often in errors like this it's simply the previous step. Like the error you posted signals that line 21 in your state/level.lua might be the source, because it's the last place ...
by MrFariator
Wed Feb 24, 2021 9:27 pm
Forum: Support and Development
Topic: Attempt to index local 'self' (a number value)
Replies: 10
Views: 417

Re: Attempt to index local 'self' (a number value)

You can access the score with self.score, that's perfectly fine. But you need to be mindful of how you invoke the function. To further drill the point, consider the following: function Score.update(self, amount) self.score = self.score + amount -- the 'self' is explicitly passed as the first paramet...