math.random as a variable?

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.
Post Reply
Fatmat927
Prole
Posts: 42
Joined: Wed Sep 18, 2013 1:15 am

math.random as a variable?

Post by Fatmat927 »

hello me again i tried using math.random to make the color of my text change but it says something like trying to index field "math" (a nil value)

so here is my code thx if u can help :D

Code: Select all

function love.load()
	love.graphics.setBackgroundColor(255, 255, 255)
	WindowWidth = love.graphics.getWidth()
	WindowHeight = love.graphics.getHeight()
end

function love.update()
	r = love.math.random()
	b = love.math.random()
	g = love.math.random()
end

function love.draw()
	love.graphics.setNewFont(40)
	love.graphics.setColor(r, b, g)
	love.graphics.print("why dis wont work??", WindowWidth / 2 - 220, WindowHeight / 2 - 70, 0, 1, 1, 0, 0)
end
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: math.random as a variable?

Post by Plu »

love.math won't be used until love 0.9.0

You have to use the regular math library until then.

So do math.random instead of love.math.random.
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: math.random as a variable?

Post by jjmafiae »

people should read the box that says what the versions the things are for before asking for help :ehem:
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: math.random as a variable?

Post by raidho36 »

Attitude is contagious.
:rofl:
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest