Using an older love version gives out a black screen

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
DerpChest
Prole
Posts: 27
Joined: Tue Oct 06, 2020 1:11 pm

Using an older love version gives out a black screen

Post by DerpChest »

I am using supertoast to test detecting love versions, but it gives out a black screen.
DerpChest
Prole
Posts: 27
Joined: Tue Oct 06, 2020 1:11 pm

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

Post by DerpChest »

DerpChest wrote: Fri Feb 26, 2021 3:10 pm I am using supertoast to test detecting love versions, but it gives out a black screen.
and yes, I did add the main.lua in the zip and turned it into a .love
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

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

Post by darkfrei »

Old colors was 255 times bigger before.

Old white: 255,255,255, new white: 1,1,1.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
MrFariator
Party member
Posts: 559
Joined: Wed Oct 05, 2016 11:53 am

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

Post by MrFariator »

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:

Code: Select all

local originalSetColor = love.graphics.setColor
love.graphics.setColor = function ( r, g, b, a )
  r = r or 1
  g = g or 1
  b = b or 1
  a = a or 1
  originalSetColor ( r * 255, g * 255, b * 255, a * 255 )
end
There is also Polyamory, but I don't think it's quite intended for backporting a löve application made in a newer version to an older version.
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

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

Post by darkfrei »

Actually the color can be defined as table, with or without indexing.

Code: Select all

love.graphics.setColor = function ( r, g, b, a )
	if type(r) == "table" then
		local t = r
		r=t[1] or r[r] or 1
		g=t[2] or r[g] or 1
		b=t[3] or r[b] or 1
		a=t[4] or r[a] or 1
	else -- 
		r = r or 1
		g = g or 1
		b = b or 1
		a = a or 1
	end
	originalSetColor ( r * 255, g * 255, b * 255, a * 255 ) -- old Löve version
end
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
pgimeno
Party member
Posts: 3673
Joined: Sun Oct 18, 2015 2:58 pm

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

Post by pgimeno »

There's cindy too, but it works the other way around. You can use colours in the range 0-255 and include the library only if you're in Löve 11.
DerpChest
Prole
Posts: 27
Joined: Tue Oct 06, 2020 1:11 pm

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

Post by DerpChest »

MrFariator wrote: Sat Feb 27, 2021 9:20 am 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:

Code: Select all

local originalSetColor = love.graphics.setColor
love.graphics.setColor = function ( r, g, b, a )
  r = r or 1
  g = g or 1
  b = b or 1
  a = a or 1
  originalSetColor ( r * 255, g * 255, b * 255, a * 255 )
end
There is also Polyamory, but I don't think it's quite intended for backporting a löve application made in a newer version to an older version.
thanks! that worked!
Post Reply

Who is online

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