Search found 3550 matches

by pgimeno
Sun Jul 14, 2019 6:59 pm
Forum: Support and Development
Topic: What is setUserData and why do I need it?
Replies: 24
Views: 9480

Re: What is setUserData and why do I need it?

This example adds setUserData/getUserData capabilities to an Image object and demonstrates them. It also shows the count of elements in the objectData table. When pressing the space bar, the image is deleted and garbage collection is run immediately to show how the weak element is deleted. For some ...
by pgimeno
Sun Jul 14, 2019 12:49 pm
Forum: Support and Development
Topic: What is setUserData and why do I need it?
Replies: 24
Views: 9480

Re: What is setUserData and why do I need it?

If you have a strong reference somewhere else in the code - the weak ref will never be collected. That's the point. With this method, the user data will be associated to the object for as long as the object is alive. If you destroy the object, the associated data will be automatically destroyed as ...
by pgimeno
Sun Jul 14, 2019 11:50 am
Forum: Support and Development
Topic: What is setUserData and why do I need it?
Replies: 24
Views: 9480

Re: What is setUserData and why do I need it?

You will have a strong reference to the body somewhere, and you can access the associated data using the body as the key to the weak table. The weak key means that the element will be automatically removed from the table when the body disappears. What raidho and I are trying to say is that setUserDa...
by pgimeno
Sun Jul 14, 2019 11:32 am
Forum: Support and Development
Topic: Object inheritance
Replies: 26
Views: 12089

Re: Object inheritance

That's indeed the approach that 4vZEROv posted in the previous page (except 'inherit()' is called 'extend()' in 4vZEROv's version).
by pgimeno
Sat Jul 13, 2019 4:44 pm
Forum: Support and Development
Topic: [SOLVED] Using Push scaling library with SUIT GUI, can't align Mouse position
Replies: 4
Views: 3301

Re: Using Push scaling library with SUIT GUI, can't align Mouse position

I don't use PUSH or SUIT either, but I think this function may help: https://suit.readthedocs.io/en/latest/core.html#mouse-input No idea how it's used, though. The docs are quite terse on that. If it doesn't help, maybe overriding getMousePosition works (https://suit.readthedocs.io/en/latest/core.ht...
by pgimeno
Sat Jul 13, 2019 9:41 am
Forum: Support and Development
Topic: What is setUserData and why do I need it?
Replies: 24
Views: 9480

Re: What is setUserData and why do I need it?

But then you have to modify the table every time a body is created or destroyed. As for creation, in the other method you have to setUserData anyway, so there's no significant advantage - both methods require an action at creation time. As for destruction, weak tables take care of that automaticall...
by pgimeno
Thu Jul 11, 2019 2:15 am
Forum: Libraries and Tools
Topic: Gspöt - retained GUI lib
Replies: 169
Views: 168366

Re: Gspöt - retained GUI lib

Thanks for the quick replies using npcbutton[i][o].click = function(self, x, y) (wasnt using self before,oversight) returns the same error: Gspot.lua:380: attempt to index local 'element' (a nil value) --with a traceback to this line: gui:rem(npcbutton[playertargetid][playertargetnpc]) Line 380 jus...
by pgimeno
Thu Jul 11, 2019 2:00 am
Forum: Support and Development
Topic: problem with player colliding with objects (for loop)
Replies: 2
Views: 2054

Re: problem with player colliding with objects (for loop)

Something very similar happened to someone very recently. What happens is that when checking the collision with the first object, 'hero.observes' is made true, but the loop continues and when checking the collision with the second object, 'hero.observes' is overwritten and set to false. You need to ...
by pgimeno
Thu Jul 11, 2019 1:47 am
Forum: Support and Development
Topic: [SOLVED] Math + Spread bullets
Replies: 10
Views: 5986

Re: Math + Spread bullets

I create my projectile like this: ... local bulletDx = visor.speed*2 * math.cos(angle) -- destination X local bulletDy = visor.speed*2 * math.sin(angle) -- destination Y ... Wouldn't it suffice to randomize the angle a bit? Something like this: angle = angle + love.math.random() * bulletSpreadAngle...
by pgimeno
Thu Jul 11, 2019 1:38 am
Forum: Libraries and Tools
Topic: Gspöt - retained GUI lib
Replies: 169
Views: 168366

Re: Gspöt - retained GUI lib

Is there another way to set functions for each instance of button other than using a colon ? For normal functions you use dots, not colons. You use a colon just before the last element when you want to call a method in an instance of an object, because that passes the instance as an implicit parame...