That's out of my league, I'll just wait for the Devs to implement some kind of SSL API. Thanks for all the helpbobbyjones wrote:Here is an example of an ffi binding. It will result in a faster binding and should be easier because libcrypto is part of openssl so it should be available everywhere. And if it's not it will have binaries for everywhere.
https://github.com/LPGhatguy/luajit-request
Edit: just in case it was unclear (I usually do make unclear posts) the example was not an example of libcrypto but just of ffi bindings in general.
"Questions that don't deserve their own thread" thread
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: "Questions that don't deserve their own thread" thread
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: "Questions that don't deserve their own thread" thread
You could try out luasec. I know people had some success with that. Iirc luasec is what will be added to 0.11.0 so you wouldn't have any migration issues if you use luasec.
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: "Questions that don't deserve their own thread" thread
I'll look into luasec, maybe I'll be able to find the binaries somewhere.bobbyjones wrote:You could try out luasec. I know people had some success with that. Iirc luasec is what will be added to 0.11.0 so you wouldn't have any migration issues if you use luasec.
Re: "Questions that don't deserve their own thread" thread
Thanks so much! It works perfectly now.Evine wrote:Ah now I see the mistake you made. When you're using shaders the color that is set with love.graphics.setColor() and the pixel color of an image is two different arguments passed into the shader. "vec4 color" being the love.graphics.setColor() color and "Image texture" being the image pixels.
Re: "Questions that don't deserve their own thread" thread
Simple question. I've tried a few things, but unaware how to solve it;
I have some pickups dropped by enemies as they die, and want them to float in a random direction. So i have these added as part of a table entry.
The problem is, i don't want the pickups to move at (for example); xvel = 1, yvel = -1. I don't want the smaller values.
Ideally i want to only get the values between, -70 to -20 and 20 to 70.
I tried looking at math.max and math.min, but can't seem to find a way.
I could always use a function like
Although i'm wondering if there is a shorthand way to do this using math.random itself?
I have some pickups dropped by enemies as they die, and want them to float in a random direction. So i have these added as part of a table entry.
Code: Select all
xvel = math.random(-70,70),
yvel = math.random(-70,70),
Ideally i want to only get the values between, -70 to -20 and 20 to 70.
I tried looking at math.max and math.min, but can't seem to find a way.
I could always use a function like
Code: Select all
function getrandom()
local rand = math.random(-70,70)
if rand > -20 and rand < 20 then
getrandom()
end
return rand
end
Re: "Questions that don't deserve their own thread" thread
I'm afraid not. Another thing you could do is call math.random(20,70) then make a condition based on another math.random() where you multiply the result by -1.unixfreak wrote:Simple question. I've tried a few things, but unaware how to solve it;
I have some pickups dropped by enemies as they die, and want them to float in a random direction. So i have these added as part of a table entry.
The problem is, i don't want the pickups to move at (for example); xvel = 1, yvel = -1. I don't want the smaller values.Code: Select all
xvel = math.random(-70,70), yvel = math.random(-70,70),
Ideally i want to only get the values between, -70 to -20 and 20 to 70.
I tried looking at math.max and math.min, but can't seem to find a way.
I could always use a function like
Although i'm wondering if there is a shorthand way to do this using math.random itself?Code: Select all
function getrandom() local rand = math.random(-70,70) if rand > -20 and rand < 20 then getrandom() end return rand end
Re: "Questions that don't deserve their own thread" thread
I had tried something similar to that. I guess just using a function to call itself again is probably the simplest way though. Thanks though.I'm afraid not. Another thing you could do is call math.random(20,70) then make a condition based on another math.random() where you multiply the result by -1.
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: "Questions that don't deserve their own thread" thread
It is the simpler way but also potentially slow way. There is a great potential for that function to call itself recursively more than 3 to 5 times. And if you use it often(I assume you do not) then it could be a real performance hit. The solution offered by tuupaku won't impact your performance as much. If you do decide to continue to use your function at least use love.math.random() love.math.random is more random which should result in less "looping".unixfreak wrote:I had tried something similar to that. I guess just using a function to call itself again is probably the simplest way though. Thanks though.I'm afraid not. Another thing you could do is call math.random(20,70) then make a condition based on another math.random() where you multiply the result by -1.
Re: "Questions that don't deserve their own thread" thread
untested:
clampabs should take a number val and a minimum value min and push everything between ]-min, min[ out to the closer one of those two.
Code: Select all
function clampabs(val, min)
if val == 0 then val = min end
local abs = math.abs(val)
local s = val/abs
return math.max(min, abs) * s
end
xvel = clampabs(math.random(-70, 70), 20)
Re: "Questions that don't deserve their own thread" thread
That would give an uneven distribution where 20 and -20 are much more likely than any other number. There are many possible solutions. Apart from the ones already given, it's possible to do it in just one draw with something like this:
That will return a number between -max and -min or between min and max. For example:
Code: Select all
function rand_abs(min, max)
local rnd = love.math.random(min + min - max - 1, max)
return rnd >= min and rnd or rnd - min - min + 1
end
Code: Select all
xvel = rand_abs(20, 70)
yvel = rand_abs(20, 70)
Who is online
Users browsing this forum: Google [Bot] and 6 guests