"Questions that don't deserve their own thread" thread

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Locked
XxHAMADEHxX
Prole
Posts: 19
Joined: Sun Mar 13, 2016 3:23 am

Re: "Questions that don't deserve their own thread" thread

Post by XxHAMADEHxX »

Wait how does seeding work? I never had to do that in python so it is kind of new to me. I tried the love.math.randomseed(os.time()) but it is giving me a nill value error. What else can I seed with?

Thank you friends
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by zorg »

Since most random functions return pseudorandom values, that means that they use some kind of formula internally; the better that formula (meaning more complex, but that's not enough) the better the "randomness" quality of the generator.

A seed is a value that if you give to a pseudo-random generator, and call it n times, with the same seed it will give the same number.
In other words, a pseudo-random sequence is reproducible in this manner, which is a nice thing to have.

Also, you don't need to seed a prng, since in löve (and in python too, i presume, at some point early in the execution, the default prng function's state will be seeded with a number. Whether it's a constant 0 by default, or something random, like os.clock() in lua (that löve uses in it's love.run game loop), it will work and give back values; the same ones always for the former case, and different values for the latter.

Also, i think i kind of answered your question too. :3 (Also, it errors because love.math.randomseed does not exist, that's the name of the lua math function, you want [wiki]love.math.setRandomSeed[/wiki]
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
XxHAMADEHxX
Prole
Posts: 19
Joined: Sun Mar 13, 2016 3:23 am

Re: "Questions that don't deserve their own thread" thread

Post by XxHAMADEHxX »

zorg wrote:Since most random functions return pseudorandom values, that means that they use some kind of formula internally; the better that formula (meaning more complex, but that's not enough) the better the "randomness" quality of the generator.

A seed is a value that if you give to a pseudo-random generator, and call it n times, with the same seed it will give the same number.
In other words, a pseudo-random sequence is reproducible in this manner, which is a nice thing to have.


Awesome thank you friend
zorg wrote: Also, you don't need to seed a prng, since in löve (and in python too, i presume, at some point early in the execution, the default prng function's state will be seeded with a number. Whether it's a constant 0 by default, or something random, like os.clock() in lua (that löve uses in it's love.run game loop), it will work and give back values; the same ones always for the former case, and different values for the latter.
I see. I think I have to seed for my case because I'm not using love.run

zorg wrote: Also, i think i kind of answered your question too. :3 (Also, it errors because love.math.randomseed does not exist, that's the name of the lua math function, you want [wiki]love.math.setRandomSeed[/wiki]
Oops XD didn't pay attention to that. Thank you friend


Thank you for helping me friends.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: "Questions that don't deserve their own thread" thread

Post by Nixola »

You can't be "not using" love.run, it's run by default. It does seed the pRNG, but you have to wait until love.load before using love.math.random if you want it to be automatically seeded.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
XxHAMADEHxX
Prole
Posts: 19
Joined: Sun Mar 13, 2016 3:23 am

Re: "Questions that don't deserve their own thread" thread

Post by XxHAMADEHxX »

Code: Select all


require'math'
require'os'



WHITE = {255,255,255}
RED = {255,0,0}
YELLOW = {255,255,0}

function love.load()



end

 



function Block()
  local self = {}
  self.color = RED
  self.x_pos = 20
  self.y_pos = 20
  
  function self:drawBlock()
    self.image_color = love.graphics.setColor(self.color)
    self.image = love.graphics.rectangle('fill', self.x_pos, self.y_pos, 20, 20)
  end
  return self
end

function MovingBlock()
  local self = Block() or {}
  local go_right = true
  local go_left = false
  
  function self:movement()
    
    if self.x_pos < 0 then
      
      go_right = true
      go_left = false
    end
    
    if go_right == true then
      self.x_pos = self.x_pos + 5
    end
    
    if self.x_pos > 500 then
      go_left = true
      go_right = false
    end
    
    if go_left == true then
      self.x_pos = self.x_pos - 5
    end
 
  end
  

  

  return self
end




function Player()
  local self = Block() or {}

  function self:movement()
    if love.keyboard.isDown('left') then
      self.x_pos = self.x_pos + -5
    end
    
    if love.keyboard.isDown('right') then
      self.x_pos = self.x_pos + 5
    end
    
    if love.keyboard.isDown('up') then
      self.y_pos = self.y_pos + -5
    end
    
    if love.keyboard.isDown('down') then
      self.y_pos = self.y_pos + 5
    end
  end
  return self
end
x = Player()


x.x_pos = love.math.setRandomSeed(os.time()) --WILL NOT WORK WITHOUT THIS CODE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
x.x_pos = love.math.random(0,500)


function love.update(dt)

 x.color = x.color == RED and YELLOW or RED

x:movement()
end

function love.draw()
--x.color = YELLOW
x:drawBlock()  
end

You can't be "not using" love.run, it's run by default.
My ignorance is strong


It does seed the pRNG, but you have to wait until love.load before using love.math.random if you want it to be automatically seeded.
Strange I did put love.math.random after love.load() and I still have to set a seed. Sorry for the caps I just put it so that it is easier to see.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by s-ol »

XxHAMADEHxX wrote: Strange I did put love.math.random after love.load() and I still have to set a seed. Sorry for the caps I just put it so that it is easier to see.
it needs to run after love.run is run, NOT after it is defined. (Actually, seeding happens just before love.run, so what you want to be doing is put the random number inside love.run.)

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
Kibita
Prole
Posts: 31
Joined: Tue Dec 29, 2015 7:46 pm

Re: "Questions that don't deserve their own thread" thread

Post by Kibita »

I didn't get the part where I must update my android project for add ad support:
Adding google-play-services_lib without an IDE
For adding google-play-services_lib to your project you will first need to download it from the android-sdk by going to the "Android Sdk Manager" on "extras" and checking on "Google Play Services" then you can find the library folder on android_sdk/extras/google/google_play_services/libproject/google-play-services_lib. Now you have to paste it next to the project folder and execute "android update project -p 'dir/to/google-play-services_lib' " and you're done!
What I did was copy the google-play-services_lib folder into the love_android folder and use the command line, it worked, but when I do a ant debug it shows BUILD FAILED "/../google-play-services_lib resolve to path with no project file for project directory to my love_android project"

What should I do?
User avatar
bobismijnnaam
Prole
Posts: 18
Joined: Thu Mar 17, 2016 5:18 pm
Location: Netherlands
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by bobismijnnaam »

Hey everyone, a quick question about forum guidelines. I posted a topic in this subforum (maybe you saw it a minute ago), but I accidentally submitted it twice. Now the second submission one was rejected, so all should be fine (I got a notification). My first submission however also disappeared (deleted?) while I was editing it (wanted to add a download link for a working example of the problem I was asking about). Is this an error related to my double posting? Or was my post in error somehow? I would post the post contents here but if my post was deleted for a specific reason I'd like to make sure it doesn happen again :s I didn't get any private messages about my posts so I'm quite confused.

EDIT:
The post is back, with edit and all! Sorry for the confusion :D
taart
lc = love.timer -- love.chrono :-)
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: "Questions that don't deserve their own thread" thread

Post by Nixola »

Hi! Sorry, I'm the one who handled your first topics, I was in a hurry and had no time to properly explain things ^^'
I disapproved one of your posts because, as you said, you posted it twice and could not see it because it needed to be approved. When you edited the approved one the edit needed approval as well, and I approved it. I should have written something before and avoided this situation ^^'
Welcome here anyway! Image
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
bobismijnnaam
Prole
Posts: 18
Joined: Thu Mar 17, 2016 5:18 pm
Location: Netherlands
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by bobismijnnaam »

Haha wow, that's quite elaborate. Thanks! It seems like a nice place here :D
taart
lc = love.timer -- love.chrono :-)
Locked

Who is online

Users browsing this forum: Bing [Bot] and 5 guests